def load_compiler(conf, compiler, arch): # Note clang goes first otherwise 'g++' will be in 'clang++' # ¯¯¯ ¯¯¯ if 'clang' in compiler: conf.mkspec_clang_configure(3, 6, minimum=True) elif 'g++' in compiler: conf.mkspec_gxx_configure(4, 9, minimum=True) elif 'msvc' in compiler or 'CL.exe' in compiler or 'cl.exe' in compiler: if arch == 'x86': conf.env.MSVC_TARGETS = ['x86'] elif arch == 'x64': conf.env.MSVC_TARGETS = ['x86_amd64'] conf.load('msvc') # Note: the waf msvc tool also loads msvc as a C compiler conf.mkspec_check_minimum_msvc_version(14.0) conf.mkspec_set_msvc_flags() else: raise Errors.WafError('Unknown compiler: %s' % compiler) if ('clang' in compiler or 'g++' in compiler) and arch: if arch == 'x86': conf.mkspec_add_common_flag('-m32') elif arch == 'x64': conf.mkspec_add_common_flag('-m64')
def cxx_poky_gxx63_armv7(conf): """ Detect and setup the g++ 6.3 cross compiler for the Yocto based Poky distribution. """ conf.mkspec_gxx_configure(major=6, minor=3, prefix='arm-poky-linux-gnueabi') # Note: A static version of libstdc++ is not available in the # poky SDK so we cannot use -static-libstdc++ for statically # linking. flags = [ '-march=armv7-a', '-marm', '-mfpu=neon', '-mfloat-abi=hard', '-mcpu=cortex-a9' ] if conf.has_tool_option('poky_sdk_path'): sdk_path = conf.get_tool_option('poky_sdk_path') sysroot = os.path.join(sdk_path, 'sysroots', 'cortexa9hf-neon-poky-linux-gnueabi') flags.append('--sysroot=%s' % sysroot) conf.env['LINKFLAGS'] += flags conf.env['CXXFLAGS'] += flags # Set the target CPU conf.env['DEST_CPU'] = 'arm'
def cxx_crosslinux_gxx47_mips(conf): """ Detect and setup the g++ 4.7 cross-compiler for MIPS 32-bit Linux """ conf.mkspec_gxx_configure(4, 7, 'crosslinux-gxx47-mips') # Statically link in the C++ standard library conf.env['LINKFLAGS'] += ['-static-libstdc++']
def cxx_poky_gxx63_armv7(conf): """ Detect and setup the g++ 6.3 cross compiler for the Yocto based Poky distribution. """ conf.mkspec_gxx_configure(major=6, minor=3, prefix="arm-poky-linux-gnueabi") # Note: A static version of libstdc++ is not available in the # poky SDK so we cannot use -static-libstdc++ for statically # linking. flags = [ "-march=armv7-a", "-marm", "-mfpu=neon", "-mfloat-abi=hard", "-mcpu=cortex-a9", ] if conf.has_tool_option("poky_sdk_path"): sdk_path = conf.get_tool_option("poky_sdk_path") sysroot = os.path.join(sdk_path, "sysroots", "cortexa9hf-neon-poky-linux-gnueabi") flags.append("--sysroot=%s" % sysroot) conf.env["LINKFLAGS"] += flags conf.env["CXXFLAGS"] += flags # Set the target CPU conf.env["DEST_CPU"] = "arm"
def load_compiler(conf, compiler, arch): # Note clang goes first otherwise 'g++' will be in 'clang++' # ¯¯¯ ¯¯¯ if "clang" in compiler: conf.mkspec_clang_configure(3, 6, minimum=True) elif "g++" in compiler: conf.mkspec_gxx_configure(4, 9, minimum=True) elif "msvc" in compiler or "CL.exe" in compiler or "cl.exe" in compiler: if arch == "x86": conf.env.MSVC_TARGETS = ["x86"] elif arch == "x64": conf.env.MSVC_TARGETS = ["x64", "x86_amd64"] conf.load("msvc") # Note: the waf msvc tool also loads msvc as a C compiler conf.mkspec_check_minimum_msvc_version(14.0) conf.mkspec_set_msvc_flags() else: raise Errors.WafError("Unknown compiler: %s" % compiler) if ("clang" in compiler or "g++" in compiler) and arch: if arch == "x86": conf.mkspec_add_common_flag("-m32") elif arch == "x64": conf.mkspec_add_common_flag("-m64")
def load_compiler(conf, compiler, arch): # Note clang goes first otherwise 'g++' will be in 'clang++' # ¯¯¯ ¯¯¯ if 'clang' in compiler: conf.mkspec_clang_configure(3, 6, minimum=True) elif 'g++' in compiler: conf.mkspec_gxx_configure(4, 9, minimum=True) elif 'msvc' in compiler or 'CL.exe' in compiler or 'cl.exe' in compiler: if arch == 'x86': conf.env.MSVC_TARGETS = ['x86'] elif arch == 'x64': conf.env.MSVC_TARGETS = ['x64', 'x86_amd64'] conf.load('msvc') # Note: the waf msvc tool also loads msvc as a C compiler conf.mkspec_check_minimum_msvc_version(14.0) conf.mkspec_set_msvc_flags() else: raise Errors.WafError('Unknown compiler: %s' % compiler) if ('clang' in compiler or 'g++' in compiler) and arch: if arch == 'x86': conf.mkspec_add_common_flag('-m32') elif arch == 'x64': conf.mkspec_add_common_flag('-m64')
def cxx_gxx63_armv7_softfp(conf): """ Detect and setup the g++ 6.3 cross-compiler for ARM Linux running on ARMv7 CPU with a hardware FPU, but on a system where a soft-float ABI is required. The 'g++-arm-linux-gnueabi' Debian package should provide a compatible toolchain, or the standalone version can be downloaded from the Linaro releases: https://releases.linaro.org/components/toolchain/binaries/latest/arm-linux-gnueabi/ """ conf.mkspec_gxx_configure(6, 3, 'arm-linux-gnueabi') # Specify the ARMv7 architecture and the 'softfp' float ABI to compile for # hardware FPU, but with software linkage (required for -mfpu=neon flag). # The __ARM_NEON__ macro will be defined only if the -mfloat-abi=softfp and # -mfpu=neon flags are used together. flags = ['-march=armv7-a', '-mfloat-abi=softfp'] conf.env['CFLAGS'] += flags conf.env['CXXFLAGS'] += flags # Specify the ARMv7 architecture in the LINKFLAGS to link with the # atomic support that is required for std::threads (without this flag, # the threading code might call pure virtual methods) conf.env['LINKFLAGS'] += ['-march=armv7-a'] # Note: libstdc++ might not be available on the target platform # Statically link with the C++ standard library conf.env['LINKFLAGS'] += ['-static-libstdc++'] # Set the target CPU conf.env['DEST_CPU'] = 'arm'
def cxx_poky_gxx63_armv7(conf): """ Detect and setup the g++ 6.3 cross compiler for the Yocto based Poky distribution. """ conf.mkspec_gxx_configure( major=6, minor=3, prefix='arm-poky-linux-gnueabi') # Note: A static version of libstdc++ is not available in the # poky SDK so we cannot use -static-libstdc++ for statically # linking. flags = ['-march=armv7-a', '-marm', '-mfpu=neon', '-mfloat-abi=hard', '-mcpu=cortex-a9'] if conf.has_tool_option('poky_sdk_path'): sdk_path = conf.get_tool_option('poky_sdk_path') sysroot = os.path.join( sdk_path, 'sysroots', 'cortexa9hf-neon-poky-linux-gnueabi') flags.append('--sysroot=%s' % sysroot) conf.env['LINKFLAGS'] += flags conf.env['CXXFLAGS'] += flags # Set the target CPU conf.env['DEST_CPU'] = 'arm'
def cxx_openwrt_gxx53_mips(conf): """ Detect and setup the g++ 5.3 cross-compiler for OpenWRT MIPS """ conf.mkspec_gxx_configure(5, 3, 'mips-openwrt-linux') # Note: libstdc++ might not be available on the target platform # Statically link with the C++ standard library conf.env['LINKFLAGS'] += ['-static-libstdc++']
def cxx_openwrt_gxx48_arm(conf): """ Detect and setup the g++ 4.8 cross-compiler for 32-bit ARM OpenWRT """ conf.mkspec_gxx_configure(4, 8, 'arm-openwrt-linux') # Note: libstdc++ might not be available on the target platform # Statically link with the C++ standard library conf.env['LINKFLAGS'] += ['-static-libstdc++']
def cxx_openwrt_gxx53_arm(conf): """ Detect and setup the g++ 5.3 cross-compiler for OpenWRT ARM """ conf.mkspec_gxx_configure(5, 3, "arm-openwrt-linux") # Note: libstdc++ might not be available on the target platform # Statically link with the C++ standard library conf.env["LINKFLAGS"] += ["-static-libstdc++"]
def cxx_crosslinux_gxx46_x86(conf): """ Detect and setup the g++ 4.6 cross-compiler for 32-bit Linux """ conf.mkspec_gxx_configure(4, 6, 'crosslinux-gxx46-x86') conf.mkspec_add_common_flag('-m32') # Note: libstdc++ might not be available on the target platform # Statically link the GCC runtime and the C++ standard library conf.env['LINKFLAGS'] += ['-static-libgcc', '-static-libstdc++']
def cxx_raspberry_gxx49_arm(conf): """ Detect and setup the g++ 4.9 cross-compiler for Raspberry Pi (Linux) """ conf.mkspec_gxx_configure(4, 9, 'raspberry-gxx49-arm') # Note: libstdc++ might not be available on the target platform # Statically link with the C++ standard library conf.env['LINKFLAGS'] += ['-static-libstdc++'] # Set the target CPU conf.env['DEST_CPU'] = 'arm'
def cxx_musl_gxx91_x86_64(conf): """ Detect and setup the g++ 9.1 compiler for MUSL Libc running on x86-64 A toolchain can be downloaded from: https://musl.cc/ """ conf.mkspec_gxx_configure(9, 1, 'x86_64-linux-musl') # Note: libstdc++ might not be available on the target platform # Statically link with the C++ standard library conf.env['LINKFLAGS'] += ['-static-libstdc++']
def cxx_openwrt_gxx73_mips(conf): """ Detect and setup the g++ 7.3 cross-compiler for OpenWRT MIPS """ conf.mkspec_gxx_configure(7, 3, 'mips-openwrt-linux') # Enable atomic support (without these flags, the linker might have # undefined references to atomic functions) conf.env['LINKFLAGS'] += ['-latomic'] # Note: libstdc++ might not be available on the target platform # Statically link with the C++ standard library conf.env['LINKFLAGS'] += ['-static-libstdc++']
def cxx_openwrt_gxx73_armv7(conf): """ Detect and setup the g++ 7.3 cross-compiler for OpenWRT ARM """ conf.mkspec_gxx_configure(7, 3, "arm-openwrt-linux") # Enable atomic support (without these flags, the linker might have # undefined references to atomic functions) conf.env["LINKFLAGS"] += ["-march=armv7-a", "-latomic"] # Note: libstdc++ might not be available on the target platform # Statically link with the C++ standard library conf.env["LINKFLAGS"] += ["-static-libstdc++"]
def cxx_gxx103_aarch64(conf): """ Detect and setup the g++ 10.3 cross-compiler for AAarch64. """ conf.mkspec_gxx_configure(10, 3, "aarch64-linux-gnu") conf.env["LINKFLAGS"] += ["-march=aarch64"] # Note: libstdc++ might not be available on the target platform # Statically link with the C++ standard library conf.env["LINKFLAGS"] += ["-static-libstdc++"] # Set the target CPU conf.env["DEST_CPU"] = "aarch64"
def cxx_crosslinux_gxx47_arm(conf): """ Detect and setup the g++ 4.7 cross-compiler for ARM 32-bit Linux """ conf.mkspec_gxx_configure(4, 7, 'arm-openwrt-linux') # Note: libstdc++ might not be available on the target platform # Statically link the GCC runtime and the C++ standard library conf.env['LINKFLAGS'] += ['-static-libgcc', '-static-libstdc++'] # The GCC runtime does not contain the C++ exception handling functions, # so libgcc_eh.a should also be statically linked conf.env['STLIB'] += ['gcc_eh']
def cxx_gxx75_aarch64(conf): """ Detect and setup the g++ 7.5 cross-compiler for ARM Linux running on AAarch64 CPU with a hardware FPU. """ conf.mkspec_gxx_configure(7, 5, "aarch64-linux-gnu") conf.env["LINKFLAGS"] += ["-march=aarch64"] # Note: libstdc++ might not be available on the target platform # Statically link with the C++ standard library conf.env["LINKFLAGS"] += ["-static-libstdc++"] # Set the target CPU conf.env["DEST_CPU"] = "aarch64"
def cxx_raspberry_gxx49_armv7(conf): """ Detect and setup the g++ 4.9 cross-compiler for Raspberry Pi (Linux) running on ARMv7 compatible hardware (Raspberry Pi 2) """ conf.mkspec_gxx_configure(4, 9, 'raspberry-gxx49-arm') # atomic support that is required for std::threads (without this flag, # the threading code might call pure virtual methods) conf.env['LINKFLAGS'] += ['-march=armv7-a'] # Note: libstdc++ might not be available on the target platform # Statically link with the C++ standard library conf.env['LINKFLAGS'] += ['-static-libstdc++'] # Set the target CPU conf.env['DEST_CPU'] = 'arm'
def cxx_raspberry_gxx83_armv7(conf): """ Detect and setup the g++ 8.3 cross-compiler for Raspberry Pi (Linux) running on ARMv7 compatible hardware (Raspberry Pi 2) """ conf.mkspec_gxx_configure(8, 3, "arm-linux-gnueabihf") # atomic support that is required for std::threads (without this flag, # the threading code might call pure virtual methods) conf.env["LINKFLAGS"] += ["-march=armv7-a"] # Note: libstdc++ might not be available on the target platform # Statically link with the C++ standard library conf.env["LINKFLAGS"] += ["-static-libstdc++"] # Set the target CPU conf.env["DEST_CPU"] = "arm"
def cxx_musl_gxx54_armv5(conf): """ Detect and setup the g++ 5.4 cross-compiler for MUSL Libc running on ARMv7 compatible hardware (Raspberry Pi 3) A toolchain can be downloaded from: https://musl.cc/ """ conf.mkspec_gxx_configure(5, 4, 'arm-linux') # Note: libstdc++ might not be available on the target platform # Statically link with the C++ standard library conf.env['LINKFLAGS'] += ['-static-libstdc++'] conf.env['CXXFLAGS'] += ['-std=c++14'] # Set the target CPU conf.env['DEST_CPU'] = 'arm'
def cxx_gxx103_armv7(conf): """ Detect and setup the g++ 10.3 cross-compiler for ARM Linux running on ARMv7 CPU with a hardware FPU. The 'g++-arm-linux-gnueabihf' Ubuntu/Debian package should provide a compatible toolchain. """ conf.mkspec_gxx_configure(10, 3, "arm-linux-gnueabihf") # Specify the ARMv7 architecture in the LINKFLAGS to link with the # atomic support that is required for std::threads (without this flag, # the threading code might call pure virtual methods) conf.env["LINKFLAGS"] += ["-march=armv7-a"] # Note: libstdc++ might not be available on the target platform # Statically link with the C++ standard library conf.env["LINKFLAGS"] += ["-static-libstdc++"] # Set the target CPU conf.env["DEST_CPU"] = "arm"
def cxx_musl_gxx91_armv7(conf): """ Detect and setup the g++ 9.1 cross-compiler for MUSL Libc running on ARMv7 compatible hardware (Raspberry Pi 3) A toolchain can be downloaded from: https://musl.cc/ """ conf.mkspec_gxx_configure(9, 1, 'armv7l-linux-musleabihf') # atomic support that is required for std::threads (without this flag, # the threading code might call pure virtual methods) conf.env['LINKFLAGS'] += ['-march=armv7-a'] # Note: libstdc++ might not be available on the target platform # Statically link with the C++ standard library conf.env['LINKFLAGS'] += ['-static-libstdc++'] # Set the target CPU conf.env['DEST_CPU'] = 'arm'
def mkspec_setup_gcov(conf, major, minor, minimum=False): """ Setup g++ for coverage analysis with gcov """ # Don't add any optimization flags (these might lead to incorrect results) conf.env['MKSPEC_DISABLE_OPTIMIZATION'] = True conf.mkspec_gxx_configure(major, minor, minimum=minimum) # Set flag to compile and link code instrumented for coverage analysis conf.mkspec_add_common_flag('--coverage') # Add flags to disable optimization and all function inlining flags = ['-O0', '-fPIC', '-fno-inline', '-fno-inline-small-functions', '-fno-default-inline'] conf.env['CFLAGS'] += flags conf.env['CXXFLAGS'] += flags
def cxx_gxx63_armv7(conf): """ Detect and setup the g++ 6.3 cross-compiler for ARM Linux running on ARMv7 CPU with a hardware FPU. The 'g++-arm-linux-gnueabihf' Debian package should provide a compatible toolchain, or the standalone version can be downloaded from the Linaro releases: https://releases.linaro.org/components/toolchain/binaries/latest/arm-linux-gnueabihf/ """ conf.mkspec_gxx_configure(6, 3, 'arm-linux-gnueabihf') # Specify the ARMv7 architecture in the LINKFLAGS to link with the # atomic support that is required for std::threads (without this flag, # the threading code might call pure virtual methods) conf.env['LINKFLAGS'] += ['-march=armv7-a'] # Note: libstdc++ might not be available on the target platform # Statically link with the C++ standard library conf.env['LINKFLAGS'] += ['-static-libstdc++'] # Set the target CPU conf.env['DEST_CPU'] = 'arm'
def mkspec_setup_gcov(conf, major, minor, minimum=False): """ Setup g++ for coverage analysis with gcov """ # Don't add any optimization flags (these might lead to incorrect results) conf.env['MKSPEC_DISABLE_OPTIMIZATION'] = True conf.mkspec_gxx_configure(major, minor, minimum=minimum) # Set flag to compile and link code instrumented for coverage analysis conf.mkspec_add_common_flag('--coverage') # Add flags to disable optimization and all function inlining flags = [ '-O0', '-fPIC', '-fno-inline', '-fno-inline-small-functions', '-fno-default-inline' ] conf.env['CFLAGS'] += flags conf.env['CXXFLAGS'] += flags
def cxx_gxx60_x64(conf): """ Detect and setup the g++ 6.0 compiler for 64 bit """ conf.mkspec_gxx_configure(6, 0) conf.mkspec_add_common_flag('-m64')
def cxx_gxx61_x86(conf): """ Detect and setup the g++ 6.1 compiler for 32 bit """ conf.mkspec_gxx_configure(6, 1) conf.mkspec_add_common_flag('-m32')
def cxx_gxx72_x86(conf): """ Detect and setup the g++ 7.2 compiler for 32 bit """ conf.mkspec_gxx_configure(7, 2) conf.mkspec_add_common_flag('-m32')
def cxx_gxx73_x64(conf): """ Detect and setup the g++ 7.3 compiler for 64 bit """ conf.mkspec_gxx_configure(7, 3) conf.mkspec_add_common_flag('-m64')
def cxx_gxx82_x64(conf): """ Detect and setup the g++ 8.2 compiler for 64 bit """ conf.mkspec_gxx_configure(8, 2) conf.mkspec_add_common_flag('-m64')
def mkspec_gxx_android_configure(conf, major, minor, prefix): conf.set_mkspec_platform('android') conf.mkspec_gxx_configure(major, minor, prefix) conf.mkspec_set_android_options()
def cxx_gxx48_x64(conf): """ Detect and setup the g++ 4.8 compiler for 64 bit """ conf.mkspec_gxx_configure(4, 8) conf.mkspec_add_common_flag('-m64')
def cxx_gxx83_x86(conf): """ Detect and setup the g++ 8.3 compiler for 32 bit """ conf.mkspec_gxx_configure(8, 3) conf.mkspec_add_common_flag('-m32')
def cxx_gxx74_x86(conf): """ Detect and setup the g++ 7.4 compiler for 32 bit """ conf.mkspec_gxx_configure(7, 4) conf.mkspec_add_common_flag('-m32')
def cxx_gxx54_x86(conf): """ Detect and setup the g++ 5.4 compiler for 32 bit """ conf.mkspec_gxx_configure(5, 4) conf.mkspec_add_common_flag('-m32')
def cxx_gxx49_x86(conf): """ Detect and setup the g++ 4.9 compiler for 32 bit """ conf.mkspec_gxx_configure(4, 9) conf.mkspec_add_common_flag('-m32')
def cxx_gxx92_x86(conf): """ Detect and setup the g++ 9.2 compiler for 32 bit """ conf.mkspec_gxx_configure(9, 2) conf.mkspec_add_common_flag('-m32')
def cxx_raspberry_gxx47_arm(conf): """ Detect and setup the g++ 4.7 cross-compiler for Raspberry Pi (Linux) """ conf.mkspec_gxx_configure(4, 7, 'raspberry-gxx47-arm')
def cxx_gxx46_x86(conf): """ Detect and setup the g++ 4.6 compiler for 32 bit linux """ conf.mkspec_gxx_configure(4, 6) conf.mkspec_add_common_flag('-m32')