1 # How to Build Compiler
3 This document is based on the system where Ubuntu Desktop Linux 18.04 LTS is installed with default
4 settings, and can be applied in other environments without much difference. For reference, the
5 development of our project started in the Ubuntu Desktop Linux 16.04 LTS environment.
6 As of now, to build in 16.04, please use gcc 7.x or above.
10 If you are going to build this project, the following modules must be installed on your system:
15 In the Ubuntu, you can easily install it with the following command.
18 $ sudo apt-get install cmake libboost-all-dev
21 If your linux system does not have the basic development configuration, you will need to install
22 more packages. A list of all packages needed to configure the development environment can be found
23 in the https://github.com/Samsung/ONE/blob/master/infra/docker/Dockerfile.1804 file.
25 Here is a summary of it
28 $ sudo apt-get install \
52 software-properties-common \
58 $ cmake /usr/src/gtest
60 $ sudo mv *.a /usr/lib
62 $ pip install yapf==0.22.0 numpy
67 In a typical linux development environment, including Ubuntu, you can build the compiler with a
68 simple command like this:
71 $ git clone https://github.com/Samsung/ONE.git one
76 Build artifacts will be placed in `build` folder.
83 Above steps will build all the modules in the compiler folder. There are modules that are currently
84 not active. To build only as of now active modules of the compiler, we provide a preset of modules
85 to build with below command:
87 $ ./nnas create-package --prefix $HOME/.local
90 With this command, `~/.local` folder will contain all files in release.
91 If you have added `~/.local/bin` in PATH, then you will now have latest compiler binaries.
93 ### Build for debug and release separately
95 Build target folder can be customized by `NNCC_WORKSPACE` environment, as we may want to separate
96 debug and release builds.
99 $ NNCC_WORKSPACE=build/debug ./nncc configure
102 will build debug version in `build/debug` folder, and
105 $ NNCC_WORKSPACE=build/release ./nncc configure -DCMAKE_BUILD_TYPE=Release
108 will build release version in `build/release` folder.
112 If you are using python3.8, as there is no TensorFlow1.13.2 package for python3.8, build may fail.
113 Please install python3.7 or lower versions as default python3.
117 To build for Windows, we use MinGW(Minimalist GNU for Windows). [Here](https://github.com/git-for-windows/build-extra/releases) you can download a tool that includes it.
120 $ git clone https://github.com/Samsung/ONE.git one
122 $ NNAS_BUILD_PREFIX=build ./nnas create-package --preset 20200731_windows --prefix install
125 - `NNAS_BUILD_PREFIX` is the path to directory where compiler-build-artifacts will be stored.
126 - `--preset` is the one that specifies a version you will install. You can see `infra/packaging/preset/` directory for more details and getting latest version.
127 - `--prefix` is the install directory.
129 ## Cross build for Ubuntu/ARM32 (experimental)
131 Some modules are availble to run in Ubuntu/ARM32 through cross building.
133 While configuring the build, some modules need to execute tools for generating
134 test materials and they need to execute in the host(x86-64). So some modules
135 are needed to build the tools for host before cross building.
137 Cross build overall steps are like, (1) configure for host
138 (2) build tools for host (3) configure for ARM32 target (4) and then build
141 Unit tests can also run in target device.
142 But value test needs to run TensorFlow lite to get expected results,
143 and it would be a task to do this so the data files from host execution
146 Thus to run the unit tests in the target, running in host is needed in prior.
148 ### Prepare root file system
150 You should prepare Ubuntu/ARM32 root file system for cross compilation.
152 [how-to-cross-build-runtime-for-arm.md](how-to-cross-build-runtime-for-arm.md)
155 You can set `ROOTFS_ARM` environment variable if you have in alternative
158 ### Clean existing external source for patches
160 Some external projects from source are not "cross compile ready with CMake"
161 projects. This experimental project prepared some patches for this.
162 Just remove the source and stamp file like below and the `make` will prepare
163 patch applied source codes.
165 rm -rf externals/HDF5
166 rm -rf externals/PROTOBUF
167 rm externals/HDF5.stamp
168 rm externals/PROTOBUF.stamp
173 To cross build, `infra/nncc/Makefile.arm32` file is provided as an example to
174 work with `make` command.
176 make -f infra/nncc/Makefile.arm32 cfg
177 make -f infra/nncc/Makefile.arm32 debug
179 First `make` will run above steps (1), (2) and (3). Second `make` will run (4).
183 Preprequisite for testing in ARM32 device.
185 # numpy is required for value match in ARM32 target device
186 sudo apt-get install python3-pip
187 python3 -m pip install numpy
190 You can also run unit tests in ARM32 Ubuntu device with cross build results.
191 First you need to run the test in host to prepare files that are currently
192 complicated in target device.
194 # run this in x86-64 host
195 make -f infra/nncc/Makefile.arm32 test_prep
197 # run this in ARM32 target device
198 make -f infra/nncc/Makefile.arm32 test
202 - host and target have same directoy structure
203 - should copy `build` folder to target or
204 - mounting `ONE` folder with NFS on the target would be simple