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 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 mkspec_setup_clang_thread_sanitizer(conf, major, minor, arch): """ http://clang.llvm.org/docs/ThreadSanitizer.html """ conf.mkspec_clang_configure(major, minor, force_debug=True) conf.mkspec_add_common_flag(arch) conf.mkspec_add_common_flag('-fsanitize=thread')
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_apple_llvm50_x86(conf): """ Detect and setup the 32-bit Apple llvm 5.0 compiler (clang 3.3) """ if conf.is_mkspec_platform('mac'): conf.mkspec_clang_configure(5, 0) conf.mkspec_add_common_flag('-m32') else: conf.fatal("This mkspec is not supported on {0}.".format( conf.get_mkspec_platform()))
def cxx_apple_llvm130_x64(conf): """ Detect and setup the 64-bit Apple LLVM 13.0 compiler """ if conf.is_mkspec_platform("mac"): conf.mkspec_clang_configure(13, 0) conf.mkspec_add_common_flag("-m64") else: conf.fatal("This mkspec is not supported on {0}.".format( conf.get_mkspec_platform()))
def cxx_apple_llvm42_x64(conf): """ Detect and setup the 64-bit Apple llvm 4.2 compiler (clang 3.2) """ if conf.is_mkspec_platform('mac'): conf.mkspec_clang_configure(4, 2) conf.mkspec_add_common_flag('-m64') else: conf.fatal("This mkspec is not supported on {0}.".format( conf.get_mkspec_platform()))
def cxx_apple_llvm100_x64(conf): """ Detect and setup the 64-bit Apple LLVM 10.0 compiler """ if conf.is_mkspec_platform('mac'): conf.mkspec_clang_configure(10, 0) conf.mkspec_add_common_flag('-m64') else: conf.fatal("This mkspec is not supported on {0}.".format( conf.get_mkspec_platform()))
def cxx_android5_gxx49_x86(conf): """ Detect and setup the Android 5.0+ g++ 4.9 compiler for x86 """ conf.cxx_android_gxx49_x86() # Only position independent executables (PIE) are supported on Android 5 # and above. The oldest version that can run a PIE binary is Android 4.1, # so the binary will segfault on all older platforms. conf.mkspec_add_common_flag('-fPIE') conf.env['LINKFLAGS'] += ['-pie']
def cxx_clang34_thread_sanitizer_x64(conf): """ Detect and setup the clang 3.4 compiler for 64 bit and use thread sanitizer """ """ http://clang.llvm.org/docs/ThreadSanitizer.html """ conf.mkspec_clang_configure(3, 4, force_debug=True) conf.mkspec_add_common_flag('-m64') conf.mkspec_add_common_flag('-fsanitize=thread')
def cxx_android5_gxx49_x64(conf): """ Detect and setup the Android 5.0+ g++ 4.9 compiler for x86_64 """ # Note: The x86_64 platform was introduced in Android 5 (API Level 21). # Therefore the standalone toolchain must be created with the # --api=21 option (or above). conf.mkspec_gxx_android_configure(4, 9, 'x86_64-linux-android') # The PIE binary must be the default in this case conf.mkspec_add_common_flag('-fPIE') conf.env['LINKFLAGS'] += ['-pie']
def cxx_android5_clang38_armv7(conf): """ Detects and setup the Android 5.0+ clang 3.8 compiler for ARMv7 """ conf.cxx_android_clang38_armv7() # Only position independent executables (PIE) are supported on Android 5 # and above. The oldest version that can run a PIE binary is Android 4.1, # so the binary will segfault on all older platforms. conf.mkspec_add_common_flag('-fPIE') # Only add the -pie flag when building programs (otherwise we get # a warning when building libraries) conf.env['LINKFLAGS_cprogram'] = ['-pie'] conf.env['LINKFLAGS_cxxprogram'] = ['-pie']
def mkspec_setup_clang_thread_sanitizer(conf, major, minor, arch, minimum=False): """ http://clang.llvm.org/docs/ThreadSanitizer.html """ conf.mkspec_clang_configure(major, minor, minimum=minimum, force_debug=True) conf.mkspec_add_common_flag(arch) conf.mkspec_add_common_flag("-fsanitize=thread")
def cxx_android5_gxx49_arm64(conf): """ Detects and setup the Android 5.0+ g++ 4.9 compiler for ARM64 """ # Note: The arm64 platform was introduced in Android 5 (API Level 21). # Therefore the standalone toolchain must be created with the # --api=21 option (or above). # Only position independent executables (PIE) are supported on Android 5. conf.mkspec_gxx_android_configure(4, 9, 'aarch64-linux-android') conf.mkspec_add_common_flag('-fPIE') conf.env['LINKFLAGS'] += ['-pie'] # Default "bfd" linker for the arm64 toolchain has an issue with linking # shared libraries: https://github.com/android-ndk/ndk/issues/148 # Force the use of the "gold" linker until it becomes the default conf.env['LINKFLAGS'] += ['-fuse-ld=gold'] conf.env['DEST_CPU'] = 'arm64'
def mkspec_setup_clang_memory_sanitizer(conf, major, minor, arch): """ To get a reasonable performance add -O1 or higher. To get meaningful stack traces in error messages add -fno-omit-frame-pointer. To get perfect stack traces you may need to disable inlining (just use -O1) and tail call elimination (-fno-optimize-sibling-calls). http://clang.llvm.org/docs/MemorySanitizer.html """ conf.mkspec_clang_configure(major, minor, force_debug=True) conf.mkspec_add_common_flag(arch) conf.mkspec_add_common_flag('-fsanitize=memory') conf.mkspec_add_common_flag('-fsanitize-memory-track-origins') conf.mkspec_add_common_flag('-fno-omit-frame-pointer') conf.mkspec_add_common_flag('-fno-optimize-sibling-calls')
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 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_clang34_memory_sanitizer_x64(conf): """ Detect and setup the clang 3.4 compiler for 64 bit and use memory sanitizer """ """ To get a reasonable performance add -O1 or higher. To get meaningful stack traces in error messages add -fno-omit-frame-pointer. To get perfect stack traces you may need to disable inlining (just use -O1) and tail call elimination (-fno-optimize-sibling-calls). http://clang.llvm.org/docs/MemorySanitizer.html """ conf.mkspec_clang_configure(3, 4, force_debug=True) conf.mkspec_add_common_flag('-m64') conf.mkspec_add_common_flag('-fsanitize=memory') conf.mkspec_add_common_flag('-fsanitize-memory-track-origins') conf.mkspec_add_common_flag('-fno-omit-frame-pointer') conf.mkspec_add_common_flag('-fno-optimize-sibling-calls')
def mkspec_setup_clang_memory_sanitizer(conf, major, minor, arch, minimum=False): """ To get a reasonable performance add -O1 or higher. To get meaningful stack traces in error messages add -fno-omit-frame-pointer. To get perfect stack traces you may need to disable inlining (just use -O1) and tail call elimination (-fno-optimize-sibling-calls). http://clang.llvm.org/docs/MemorySanitizer.html """ conf.mkspec_clang_configure(major, minor, minimum=minimum, force_debug=True) conf.mkspec_add_common_flag(arch) conf.mkspec_add_common_flag("-fsanitize=memory") conf.mkspec_add_common_flag("-fsanitize-memory-track-origins") conf.mkspec_add_common_flag("-fno-omit-frame-pointer") conf.mkspec_add_common_flag("-fno-optimize-sibling-calls")
def mkspec_setup_clang_address_sanitizer(conf, major, minor, arch, minimum=False): """ To get a reasonable performance add -O1 or higher. To get nicer stack traces in error messages add -fno-omit-frame-pointer. To get perfect stack traces you may need to disable inlining (just use -O1) and tail call elimination (-fno-optimize-sibling-calls). http://clang.llvm.org/docs/AddressSanitizer.html """ conf.mkspec_clang_configure(major, minor, minimum=minimum, force_debug=True) conf.mkspec_add_common_flag(arch) conf.mkspec_add_common_flag('-fsanitize=address') conf.mkspec_add_common_flag('-fno-omit-frame-pointer') conf.mkspec_add_common_flag('-fno-optimize-sibling-calls')
def cxx_clang34_address_sanitizer_x86(conf): """ Detect and setup the clang 3.4 compiler for 32 bit and use address sanitizer """ """ To get a reasonable performance add -O1 or higher. To get nicer stack traces in error messages add -fno-omit-frame-pointer. To get perfect stack traces you may need to disable inlining (just use -O1) and tail call elimination (-fno-optimize-sibling-calls). http://clang.llvm.org/docs/AddressSanitizer.html """ conf.mkspec_clang_configure(3, 4, force_debug=True) conf.mkspec_add_common_flag('-m32') conf.mkspec_add_common_flag('-fsanitize=address') conf.mkspec_add_common_flag('-fno-omit-frame-pointer') conf.mkspec_add_common_flag('-fno-optimize-sibling-calls')
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_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_clang31_x86(conf): """ Detect and setup the clang 3.1 compiler for 32 bit """ conf.mkspec_clang_configure(3, 1) conf.mkspec_add_common_flag('-m32')
def cxx_clang38_x64(conf): """ Detect and setup the clang 3.8 compiler for 64 bit """ conf.mkspec_clang_configure(3, 8) conf.mkspec_add_common_flag("-m64")
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_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_clang70_x86(conf): """ Detect and setup the clang 7.0 compiler for 32 bit """ conf.mkspec_clang_configure(7, 0) conf.mkspec_add_common_flag('-m32')
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_clang30_x86(conf): """ Detect and setup the clang 3.0 compiler for 32 bit """ conf.mkspec_clang_configure(3, 0) conf.mkspec_add_common_flag('-m32')
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 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_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_gxx54_x64(conf): """ Detect and setup the g++ 5.4 compiler for 64 bit """ conf.mkspec_gxx_configure(5, 4) conf.mkspec_add_common_flag('-m64')
def cxx_clang140_x64(conf): """ Detect and setup the clang 14.0 compiler for 64 bit """ conf.mkspec_clang_configure(14, 0) conf.mkspec_add_common_flag("-m64")
def cxx_clang70_x86(conf): """ Detect and setup the clang 7.0 compiler for 32 bit """ conf.mkspec_clang_configure(7, 0) conf.mkspec_add_common_flag("-m32")
def cxx_clang39_x86(conf): """ Detect and setup the clang 3.9 compiler for 32 bit """ conf.mkspec_clang_configure(3, 9) conf.mkspec_add_common_flag("-m32")
def cxx_gcov_gxx49_x64(conf): """ Configure g++ 4.9 (64 bit) for coverage analysis with gcov """ conf.mkspec_setup_gcov(4, 9) conf.mkspec_add_common_flag('-m64')
def cxx_clang30_x64(conf): """ Detect and setup the clang 3.0 compiler for 64 bit """ conf.mkspec_clang_configure(3, 0) 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_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_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_clang31_x64(conf): """ Detect and setup the clang 3.1 compiler for 64 bit """ conf.mkspec_clang_configure(3, 1) conf.mkspec_add_common_flag('-m64')
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')