forked from OSchip/llvm-project
[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 llvm-svn: 313033
This commit is contained in:
parent
0af5a772e0
commit
1a33da2401
|
@ -57,8 +57,7 @@ def generate_compiler_cmd(is_cpp=True, fuzzer_enabled=True):
|
|||
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)
|
||||
|
|
|
@ -6,7 +6,7 @@ config.cpp_compiler = "@LIBFUZZER_TEST_COMPILER@"
|
|||
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@"
|
||||
|
||||
|
|
Loading…
Reference in New Issue