def invoke_configure(build_folder, install_folder, root_folder, target, host_arch): """ Invokes the configure script to generate a Makefile :param build_folder: Build directory :param install_folder: Directory to install binutils to :param root_folder: Working directory :param target: Target to compile for :param host_arch: Host architecture to optimize for """ configure = [ root_folder.joinpath(utils.current_binutils(), "configure").as_posix(), '--prefix=%s' % install_folder.as_posix(), '--enable-deterministic-archives', '--enable-plugins', '--quiet', 'CFLAGS=-O2 -march=%s -mtune=%s' % (host_arch, host_arch), 'CXXFLAGS=-O2 -march=%s -mtune=%s' % (host_arch, host_arch) ] configure_arch_flags = { "arm-linux-gnueabi": [ '--disable-multilib', '--disable-nls', '--with-gnu-as', '--with-gnu-ld', '--with-sysroot=%s' % install_folder.joinpath(target).as_posix() ], "mipsel-linux-gnu": [ '--disable-compressed-debug-sections', '--enable-new-dtags', '--enable-shared', '--enable-targets=mips64el-linux-gnuabi64,mips64el-linux-gnuabin32', '--enable-threads' ], "powerpc-linux-gnu": [ '--enable-lto', '--enable-relro', '--enable-shared', '--enable-threads', '--disable-gdb', '--disable-sim', '--disable-werror', '--with-pic', '--with-system-zlib' ], "x86_64-linux-gnu": [ '--enable-lto', '--enable-relro', '--enable-shared', '--enable-targets=x86_64-pep', '--enable-threads', '--disable-gdb', '--disable-werror', '--with-pic', '--with-system-zlib' ] } configure_arch_flags['aarch64-linux-gnu'] = configure_arch_flags[ 'arm-linux-gnueabi'] + ['--enable-ld=default', '--enable-gold'] configure_arch_flags['powerpc64-linux-gnu'] = configure_arch_flags[ 'powerpc-linux-gnu'] configure_arch_flags['powerpc64le-linux-gnu'] = configure_arch_flags[ 'powerpc-linux-gnu'] configure += configure_arch_flags.get(target, []) # If the current machine is not the target, add the prefix to indicate # that it is a cross compiler if not host_is_target(target): configure += ['--program-prefix=%s-' % target, '--target=%s' % target] utils.print_header("Building %s binutils" % target) subprocess.run(configure, check=True, cwd=build_folder.as_posix())
def base_cmake_defines(dirs): """ Generate base cmake defines, which will always be present, regardless of user input and stage :param dirs: An instance of the Directories class with the paths to use :return: A set of defines """ # yapf: disable defines = { # Objective-C Automatic Reference Counting (we don't use Objective-C) # https://clang.llvm.org/docs/AutomaticReferenceCounting.html 'CLANG_ENABLE_ARCMT': 'OFF', # We don't (currently) use the static analyzer and it saves cycles # according to Chromium OS: # https://crrev.com/44702077cc9b5185fc21e99485ee4f0507722f82 'CLANG_ENABLE_STATIC_ANALYZER': 'OFF', # We don't use the plugin system and it will remove unused symbols: # https://crbug.com/917404 'CLANG_PLUGIN_SUPPORT': 'OFF', # For LLVMgold.so, which is used for LTO with ld.gold 'LLVM_BINUTILS_INCDIR': dirs.root_folder.joinpath(utils.current_binutils(), "include").as_posix(), # Don't build bindings; they are for other languages that the kernel does not use 'LLVM_ENABLE_BINDINGS': 'OFF', # We need to enable LLVM plugin support so that LLVMgold.so is loadable 'LLVM_ENABLE_PLUGINS': 'ON', # Don't build Ocaml documentation 'LLVM_ENABLE_OCAMLDOC': 'OFF', # Removes system dependency on terminfo and almost every major clang provider turns this off 'LLVM_ENABLE_TERMINFO': 'OFF', # Don't build clang-tools-extras to cut down on build targets (about 400 files or so) 'LLVM_EXTERNAL_CLANG_TOOLS_EXTRA_SOURCE_DIR': '', # Don't include documentation build targets because it is available on the web 'LLVM_INCLUDE_DOCS': 'OFF', # Don't include example build targets to save on cmake cycles 'LLVM_INCLUDE_EXAMPLES': 'OFF', 'LLVM_TABLEGEN': '/home/runner/llvm-tblgen' , 'CLANG_TABLEGEN': '/home/runner/clang-tblgen' , 'CMAKE_C_COMPILER': '/home/runner/clang/bin/aarch64-linux-android-gcc' , 'CMAKE_CXX_COMPILER': '/home/runner/clang/bin/aarch64-linux-android-g++' , 'CMAKE_CROSSCOMPILING': 'True' , 'LLVM_TARGET_ARCH': 'AArch64' , 'LLVM_DEFAULT_TARGET_TRIPLE': 'aarch64-linux-android' , 'LLVM_TARGETS_TO_BUILD': 'AArch64' , } # yapf: enable return defines
def base_cmake_defines(dirs): """ Generate base cmake defines, which will always be present, regardless of user input and stage :param dirs: An instance of the Directories class with the paths to use :return: A set of defines """ # yapf: disable defines = { # Objective-C Automatic Reference Counting (we don't use Objective-C) # https://clang.llvm.org/docs/AutomaticReferenceCounting.html 'CLANG_ENABLE_ARCMT': 'OFF', # We don't (currently) use the static analyzer and it saves cycles # according to Chromium OS: # https://crrev.com/44702077cc9b5185fc21e99485ee4f0507722f82 'CLANG_ENABLE_STATIC_ANALYZER': 'OFF', # We don't use the plugin system and it will remove unused symbols: # https://crbug.com/917404 'CLANG_PLUGIN_SUPPORT': 'OFF', # For LLVMgold.so, which is used for LTO with ld.gold 'LLVM_BINUTILS_INCDIR': dirs.root_folder.joinpath(utils.current_binutils(), "include").as_posix(), # Don't build bindings; they are for other languages that the kernel does not use 'LLVM_ENABLE_BINDINGS': 'OFF', # Don't build Ocaml documentation 'LLVM_ENABLE_OCAMLDOC': 'OFF', # Removes system dependency on terminfo and almost every major clang provider turns this off 'LLVM_ENABLE_TERMINFO': 'OFF', # Don't build clang-tools-extras to cut down on build targets (about 400 files or so) 'LLVM_EXTERNAL_CLANG_TOOLS_EXTRA_SOURCE_DIR': '', # Don't include documentation build targets because it is available on the web 'LLVM_INCLUDE_DOCS': 'OFF', # Don't include example build targets to save on cmake cycles 'LLVM_INCLUDE_EXAMPLES': 'OFF', } # yapf: enable # Use ccache if it is available for faster incremental builds if shutil.which("ccache") is not None: defines['LLVM_CCACHE_BUILD'] = 'ON' return defines