[compiler-rt] r313033 - [libFuzzer] Fix lit files to make running tests more straightforward on Mac OS.

Max Moroz via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 12 08:02:10 PDT 2017


Author: dor1s
Date: Tue Sep 12 08:02:10 2017
New Revision: 313033

URL: http://llvm.org/viewvc/llvm-project?rev=313033&view=rev
Log:
[libFuzzer] Fix lit files to make running tests more straightforward on Mac OS.

Summary:
Current implementation does not work if CMAKE_OSX_SYSROOT is not specified.

It silently generates invalid command with the following flags:

`-std=c++11 -lc++ -gline-tables-only -isysroot  -fsanitize=address,fuzzer`

and then fails with the following error:

```
warning: no such sysroot directory: '-fsanitize=address,fuzzer' [-Wmissing-sysroot]"
<...>/RepeatedBytesTest.cpp:5:10: fatal error: 'assert.h' file not found
#include <assert.h>
         ^~~~~~~~~~
1 error generated.
```

However, if you have Command Line Tools installed, you have '/usr/include' dir.
In that case, it is not necessary to specify isysroot path.

Also, with the patch, in case of '/usr/include' does not exist, the '-sysroot'
path would be resolved automatically in compiler-rt/cmake/base-config-ix.cmake.

For more context, see the comment at `compiler-rt/cmake/base-config-ix.cmake#L76`

Reviewers: kcc, george.karpenkov

Reviewed By: kcc, george.karpenkov

Differential Revision: https://reviews.llvm.org/D37721

Modified:
    compiler-rt/trunk/test/fuzzer/lit.cfg
    compiler-rt/trunk/test/fuzzer/lit.site.cfg.in

Modified: compiler-rt/trunk/test/fuzzer/lit.cfg
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/fuzzer/lit.cfg?rev=313033&r1=313032&r2=313033&view=diff
==============================================================================
--- compiler-rt/trunk/test/fuzzer/lit.cfg (original)
+++ compiler-rt/trunk/test/fuzzer/lit.cfg Tue Sep 12 08:02:10 2017
@@ -57,8 +57,7 @@ def generate_compiler_cmd(is_cpp=True, f
   if fuzzer_enabled:
     sanitizers.append('fuzzer')
   sanitizers_cmd = ('-fsanitize=%s' % ','.join(sanitizers))
-  isysroot_cmd = ('-isysroot %s' % config.osx_sysroot
-      ) if 'darwin' in config.target_triple else ''
+  isysroot_cmd = config.osx_sysroot_flag if config.osx_sysroot_flag else ''
   include_cmd = '-I%s' % libfuzzer_src_root
   return '%s %s %s -gline-tables-only %s %s %s' % (
       compiler_cmd, std_cmd, link_cmd, isysroot_cmd, sanitizers_cmd, include_cmd)

Modified: compiler-rt/trunk/test/fuzzer/lit.site.cfg.in
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/fuzzer/lit.site.cfg.in?rev=313033&r1=313032&r2=313033&view=diff
==============================================================================
--- compiler-rt/trunk/test/fuzzer/lit.site.cfg.in (original)
+++ compiler-rt/trunk/test/fuzzer/lit.site.cfg.in Tue Sep 12 08:02:10 2017
@@ -6,7 +6,7 @@ config.cpp_compiler = "@LIBFUZZER_TEST_C
 config.target_flags = "@LIBFUZZER_TEST_FLAGS@"
 config.c_compiler = "@LIBFUZZER_TEST_COMPILER@"
 
-config.osx_sysroot = "@CMAKE_OSX_SYSROOT@"
+config.osx_sysroot_flag = "@OSX_SYSROOT_FLAG@"
 config.cmake_binary_dir = "@CMAKE_BINARY_DIR@"
 config.target_triple = "@TARGET_TRIPLE@"
 




More information about the llvm-commits mailing list