[compiler-rt] r355143 - [CMake][LibFuzzer] Match symbol visibility setting between LibFuzzer object files and unit tests.

Dan Liew via llvm-commits llvm-commits at lists.llvm.org
Thu Feb 28 13:57:58 PST 2019


Author: delcypher
Date: Thu Feb 28 13:57:58 2019
New Revision: 355143

URL: http://llvm.org/viewvc/llvm-project?rev=355143&view=rev
Log:
[CMake][LibFuzzer] Match symbol visibility setting between LibFuzzer object files and unit tests.

Summary:
This fixes inconsistent symbol visibility. This shows up as a linker
warning if r336238 (43f633564e338a6dde83d49a48e5bfcbfdce292c) is
reverted.

```
ld: warning: direct access in function 'fuzzer::CleanseCrashInput(std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, fuzzer::fuzzer_allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > > const&, fuzzer::FuzzingOptions const&)' from file '/Volumes/data/dev/llvm/upstream/master/builds/projects/compiler-rt/lib/fuzzer/tests/libRTFuzzerTest.x86_64.a(FuzzerDriver.cpp.o)' to global weak symbol 'fuzzer::Command::ignoreRemainingArgs()::kIgnoreRemaining' from file 'FuzzerTestObjects.FuzzerUnittest.cpp.x86_64.o' means the weak symbol cannot be overridden
 at runtime. This was likely caused by different translation units being compiled with different visibility settings.
```

r336238 just hid the issue rather than fixing the real issue. On macOS
and other platforms we usually compile with `-fvisibility=hidden` but
the unit tests were compiled without this flag.

Reviewers: george.karpenkov, kubamracek, kcc, yln

Subscribers: mgorny, #sanitizers, llvm-commits

Tags: #llvm, #sanitizers

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

Modified:
    compiler-rt/trunk/lib/fuzzer/tests/CMakeLists.txt

Modified: compiler-rt/trunk/lib/fuzzer/tests/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/fuzzer/tests/CMakeLists.txt?rev=355143&r1=355142&r2=355143&view=diff
==============================================================================
--- compiler-rt/trunk/lib/fuzzer/tests/CMakeLists.txt (original)
+++ compiler-rt/trunk/lib/fuzzer/tests/CMakeLists.txt Thu Feb 28 13:57:58 2019
@@ -27,6 +27,11 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Linux" AN
   list(APPEND LIBFUZZER_UNITTEST_CFLAGS -nostdinc++)
 endif()
 
+if ("-fvisibility=hidden" IN_LIST LIBFUZZER_CFLAGS)
+  # Match visibility settings.
+  list(APPEND LIBFUZZER_UNITTEST_CFLAGS "-fvisibility=hidden")
+endif()
+
 if(COMPILER_RT_DEFAULT_TARGET_ARCH IN_LIST FUZZER_SUPPORTED_ARCH)
   # libFuzzer unit tests are only run on the host machine.
   set(arch ${COMPILER_RT_DEFAULT_TARGET_ARCH})




More information about the llvm-commits mailing list