(tool)
| 1122 | |
| 1123 | |
| 1124 | def build_llvm(tool): |
| 1125 | debug_print(f'build_llvm({tool})') |
| 1126 | llvm_root = tool.installation_path() |
| 1127 | llvm_src_root = os.path.join(llvm_root, 'src') |
| 1128 | success = git_clone_checkout_and_pull(tool.download_url(), llvm_src_root, tool.git_branch) |
| 1129 | if not success: |
| 1130 | return False |
| 1131 | |
| 1132 | build_dir = llvm_build_dir(tool) |
| 1133 | build_root = os.path.join(llvm_root, build_dir) |
| 1134 | |
| 1135 | build_type = decide_cmake_build_type(tool) |
| 1136 | |
| 1137 | # Configure |
| 1138 | tests_arg = 'ON' if BUILD_FOR_TESTING else 'OFF' |
| 1139 | |
| 1140 | enable_assertions = ENABLE_LLVM_ASSERTIONS.lower() == 'on' or (ENABLE_LLVM_ASSERTIONS == 'auto' and build_type.lower() != 'release' and build_type.lower() != 'minsizerel') |
| 1141 | |
| 1142 | if ARCH in {'x86', 'x86_64'}: |
| 1143 | targets_to_build = 'WebAssembly;X86' |
| 1144 | elif ARCH == 'arm': |
| 1145 | targets_to_build = 'WebAssembly;ARM' |
| 1146 | elif ARCH == 'arm64': |
| 1147 | targets_to_build = 'WebAssembly;AArch64' |
| 1148 | else: |
| 1149 | targets_to_build = 'WebAssembly' |
| 1150 | cmake_generator, args = get_generator_and_config_args(tool) |
| 1151 | args += ['-DLLVM_TARGETS_TO_BUILD=' + targets_to_build, |
| 1152 | '-DLLVM_INCLUDE_EXAMPLES=OFF', |
| 1153 | '-DLLVM_INCLUDE_TESTS=' + tests_arg, |
| 1154 | '-DCLANG_INCLUDE_TESTS=' + tests_arg, |
| 1155 | '-DLLVM_ENABLE_ASSERTIONS=' + ('ON' if enable_assertions else 'OFF'), |
| 1156 | # Disable optional LLVM dependencies, these can cause unwanted .so dependencies |
| 1157 | # that prevent distributing the generated compiler for end users. |
| 1158 | '-DLLVM_ENABLE_LIBXML2=OFF', '-DLLDB_ENABLE_LIBEDIT=OFF', |
| 1159 | '-DLLVM_ENABLE_LIBEDIT=OFF', '-DLLVM_ENABLE_LIBPFM=OFF'] |
| 1160 | # LLVM build system bug: compiler-rt does not build on Windows. It insists on performing a CMake install step that writes to C:\Program Files. Attempting |
| 1161 | # to reroute that to build_root directory then fails on an error |
| 1162 | # file INSTALL cannot find |
| 1163 | # "C:/code/emsdk/llvm/git/build_master_vs2017_64/$(Configuration)/lib/clang/10.0.0/lib/windows/clang_rt.ubsan_standalone-x86_64.lib". |
| 1164 | # (there instead of $(Configuration), one would need ${CMAKE_BUILD_TYPE} ?) |
| 1165 | # It looks like compiler-rt is not compatible to build on Windows? |
| 1166 | args += ['-DLLVM_ENABLE_PROJECTS=clang;lld'] |
| 1167 | # To enable widest possible chance of success for building, let the code |
| 1168 | # compile through with older toolchains that are about to be deprecated by |
| 1169 | # upstream LLVM. |
| 1170 | args += ['-DLLVM_TEMPORARILY_ALLOW_OLD_TOOLCHAIN=ON'] |
| 1171 | |
| 1172 | if os.getenv('LLVM_CMAKE_ARGS'): |
| 1173 | extra_args = os.environ['LLVM_CMAKE_ARGS'].split(',') |
| 1174 | print('Passing the following extra arguments to LLVM CMake configuration: ' + str(extra_args)) |
| 1175 | args += extra_args |
| 1176 | |
| 1177 | cmakelists_dir = os.path.join(llvm_src_root, 'llvm') |
| 1178 | |
| 1179 | success = cmake_configure_and_build(cmake_generator, build_root, cmakelists_dir, build_type, args) |
| 1180 | |
| 1181 | return success |
nothing calls this directly
no test coverage detected