[compiler-rt] r334545 - [libFuzzer] [NFC] Make compiler command generation more readable.
George Karpenkov via llvm-commits
llvm-commits at lists.llvm.org
Tue Jun 12 14:14:12 PDT 2018
Author: george.karpenkov
Date: Tue Jun 12 14:14:11 2018
New Revision: 334545
URL: http://llvm.org/viewvc/llvm-project?rev=334545&view=rev
Log:
[libFuzzer] [NFC] Make compiler command generation more readable.
Use config.clang as a more general option than config.c_compiler.
Differential Revision: https://reviews.llvm.org/D47295
Modified:
compiler-rt/trunk/test/fuzzer/lit.cfg
Modified: compiler-rt/trunk/test/fuzzer/lit.cfg
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/fuzzer/lit.cfg?rev=334545&r1=334544&r2=334545&view=diff
==============================================================================
--- compiler-rt/trunk/test/fuzzer/lit.cfg (original)
+++ compiler-rt/trunk/test/fuzzer/lit.cfg Tue Jun 12 14:14:11 2018
@@ -50,22 +50,35 @@ libfuzzer_src_root = os.path.join(config
config.substitutions.append(('%libfuzzer_src', libfuzzer_src_root))
def generate_compiler_cmd(is_cpp=True, fuzzer_enabled=True):
- compiler_cmd = config.c_compiler
+ compiler_cmd = config.clang
if config.clang and config.stdlib == 'libc++':
link_cmd = '-stdlib=libc++ -Wl,-rpath=%s' % config.llvm_library_dir
elif config.clang and config.stdlib == 'static-libc++':
- link_cmd = '-stdlib=libc++ -lc++abi -static-libstdc++ -Wl,-rpath=%s' % config.llvm_library_dir
+ link_cmd = '-stdlib=libc++ -lc++abi -static-libstdc++ -Wl,-rpath=%s' % (
+ config.llvm_library_dir)
+ elif any(x in config.target_triple for x in ('darwin', 'freebsd')):
+ link_cmd = '-lc++'
else:
- link_cmd = '-lc++' if any(x in config.target_triple for x in ('darwin', 'freebsd')) else '-lstdc++'
+ link_cmd = '-lstdc++'
+
std_cmd = '--driver-mode=g++ -std=c++11' if is_cpp else ''
sanitizers = ['address']
if fuzzer_enabled:
sanitizers.append('fuzzer')
sanitizers_cmd = ('-fsanitize=%s' % ','.join(sanitizers))
- isysroot_cmd = config.osx_sysroot_flag if config.osx_sysroot_flag else ''
- include_cmd = '-I%s' % libfuzzer_src_root
- return '%s %s %s -O2 -gline-tables-only %s %s %s' % (
- compiler_cmd, std_cmd, link_cmd, isysroot_cmd, sanitizers_cmd, include_cmd)
+ if config.osx_sysroot_flag:
+ isysroot_cmd = config.osx_sysroot_flag
+ else:
+ isysroot_cmd = ''
+ return " ".join([
+ compiler_cmd,
+ std_cmd,
+ link_cmd,
+ "-O2 -gline-tables-only",
+ isysroot_cmd,
+ sanitizers_cmd,
+ "-I%s" % libfuzzer_src_root
+ ])
config.substitutions.append(('%cpp_compiler',
generate_compiler_cmd(is_cpp=True, fuzzer_enabled=True)
More information about the llvm-commits
mailing list