[PATCH] D47295: [libFuzzer] [NFC] Make compiler command generation more readable.

George Karpenkov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jun 12 14:18:40 PDT 2018


This revision was automatically updated to reflect the committed changes.
Closed by commit rCRT334545: [libFuzzer] [NFC] Make compiler command generation more readable. (authored by george.karpenkov, committed by ).
Herald added subscribers: Sanitizers, llvm-commits.

Repository:
  rCRT Compiler Runtime

https://reviews.llvm.org/D47295

Files:
  test/fuzzer/lit.cfg


Index: test/fuzzer/lit.cfg
===================================================================
--- test/fuzzer/lit.cfg
+++ test/fuzzer/lit.cfg
@@ -50,22 +50,35 @@
 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)


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D47295.151028.patch
Type: text/x-patch
Size: 1861 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180612/7c481bf1/attachment.bin>


More information about the llvm-commits mailing list