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 = ['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 mkspec_clang_ios_configure(conf, major, minor, min_ios_version, cpu, minimum=False): conf.set_mkspec_platform("ios") conf.mkspec_clang_configure(major, minor, minimum=minimum) conf.mkspec_set_ios_options(min_ios_version, cpu)
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_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 mkspec_clang_android_configure(conf, major, minor, prefix, target): conf.set_mkspec_platform('android') conf.mkspec_clang_configure(major, minor, prefix) conf.mkspec_set_android_options() # Specify the target architecture as required by clang target_flags = ['-target', target] conf.env['CFLAGS'] += target_flags conf.env['CXXFLAGS'] += target_flags conf.env['LINKFLAGS'] += target_flags
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_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 mkspec_clang_android_configure(conf, major, minor, prefix, target=None): conf.set_mkspec_platform('android') conf.mkspec_clang_configure(major, minor, prefix) conf.mkspec_set_android_options() # Specify the target architecture if required. Newer Android toolchains # explicitly set the target in the arm-linux-androideabi-clang++ script, # so this is no longer needed. if target: target_flags = ['-target', target] conf.env['CFLAGS'] += target_flags conf.env['CXXFLAGS'] += target_flags conf.env['LINKFLAGS'] += target_flags
def mkspec_setup_clang_address_sanitizer(conf, major, minor, arch): """ 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, 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 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 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_clang_android_configure(conf, major, minor, prefix, target=None): conf.set_mkspec_platform("android") conf.mkspec_clang_configure(major, minor, prefix) conf.mkspec_set_android_options() # Specify the target architecture if required. Newer Android toolchains # explicitly set the target in the arm-linux-androideabi-clang++ script, # so this is no longer needed. if target: target_flags = ["-target", target] conf.env["CFLAGS"] += target_flags conf.env["CXXFLAGS"] += target_flags conf.env["LINKFLAGS"] += target_flags if major == 5 and minor == 0: # This warning is broken in clang 5.0.300080 (Android NDK r16b). # The flag is not needed for newer versions that include this patch: # https://reviews.llvm.org/D33526 conf.env["CXXFLAGS"] += ["-Wno-unused-lambda-capture"]
def mkspec_clang_android_configure(conf, major, minor, prefix, target=None): conf.set_mkspec_platform('android') conf.mkspec_clang_configure(major, minor, prefix) conf.mkspec_set_android_options() # Specify the target architecture if required. Newer Android toolchains # explicitly set the target in the arm-linux-androideabi-clang++ script, # so this is no longer needed. if target: target_flags = ['-target', target] conf.env['CFLAGS'] += target_flags conf.env['CXXFLAGS'] += target_flags conf.env['LINKFLAGS'] += target_flags if major == 5 and minor == 0: # This warning is broken in clang 5.0.300080 (Android NDK r16b). # The flag is not needed for newer versions that include this patch: # https://reviews.llvm.org/D33526 conf.env['CXXFLAGS'] += ['-Wno-unused-lambda-capture']
def cxx_clang34_address_sanitizer_x64(conf): """ Detect and setup the clang 3.4 compiler for 64 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('-m64') 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_memory_sanitizer_x86(conf): """ Detect and setup the clang 3.4 compiler for 32 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('-m32') 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_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_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_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_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_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_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_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_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_clang70_x64(conf): """ Detect and setup the clang 7.0 compiler for 64 bit """ conf.mkspec_clang_configure(7, 0) conf.mkspec_add_common_flag('-m64')
def mkspec_clang_ios_configure(conf, major, minor, min_ios_version, cpu): conf.set_mkspec_platform('ios') conf.mkspec_clang_configure(major, minor) conf.mkspec_set_ios_options(min_ios_version, cpu)