This is an archive of the discontinued LLVM Phabricator instance.

[CompilerRT] Don't pass global compile test flags in non-standalone build
ClosedPublic

Authored by aeubanks on Jul 23 2020, 2:23 PM.

Details

Summary

In a build with -DLLVM_ENABLE_LTO=Thin:

$ ninja TSanitizer-x86_64-Test-Nolibc
[1/1] Generating Sanitizer-x86_64-Test-Nolibc
FAILED: projects/compiler-rt/lib/sanitizer_common/tests/Sanitizer-x86_64-Test-Nolibc
sanitizer_nolibc_test_main.x86_64.o: file not recognized: file format not recognized

because -flto=thin is getting passed to the clang_compile step.

For non-standalone builds, global compilation flags shouldn't be passed to compiler-rt tests, only the flags the test specifies.

Diff Detail

Event Timeline

aeubanks created this revision.Jul 23 2020, 2:23 PM
Herald added a project: Restricted Project. · View Herald TranscriptJul 23 2020, 2:23 PM
Herald added subscribers: Restricted Project, dexonsmith, mgorny. · View Herald Transcript
aeubanks edited the summary of this revision. (Show Details)Jul 23 2020, 3:41 PM
aeubanks added a reviewer: vitalybuka.
vitalybuka accepted this revision.Jul 28 2020, 12:54 AM
vitalybuka added inline comments.
compiler-rt/cmake/Modules/CompilerRTCompile.cmake
75

could you please replace tabs with spaces?

This revision is now accepted and ready to land.Jul 28 2020, 12:54 AM
aeubanks updated this revision to Diff 281254.Jul 28 2020, 9:17 AM

Tabs to spaces?

aeubanks added inline comments.Jul 28 2020, 9:20 AM
compiler-rt/cmake/Modules/CompilerRTCompile.cmake
75

Hmm after messing around a bit, I don't think there are any tabs, it's just Phab is displaying whitespace changes in a weird way.

This revision was landed with ongoing or failed builds.Jul 28 2020, 9:26 AM
This revision was automatically updated to reflect the committed changes.
yln added a subscriber: yln.Jul 31 2020, 2:38 PM

Note this breaks ninja check-asan: linker error when linking ASan unit tests.

FAILED: projects/compiler-rt/lib/asan/tests/default/Asan-x86_64-calls-Test 
cd /Users/yln/work/llvm-upstream/build/projects/compiler-rt/lib/asan/tests && /Users/yln/work/llvm-upstream/build/./bin/clang ASAN_INST_TEST_OBJECTS.gtest-all.cc.x86_64-calls.o ASAN_INST_TEST_OBJECTS.asan_globals_test.cpp.x86_64-calls.o ASAN_INST_TEST_OBJECTS.asan_interface_test.cpp.x86_64-calls.o ASAN_INST_TEST_OBJECTS.asan_internal_interface_test.cpp.x86_64-calls.o ASAN_INST_TEST_OBJECTS.asan_test.cpp.x86_64-calls.o ASAN_INST_TEST_OBJECTS.asan_oob_test.cpp.x86_64-calls.o ASAN_INST_TEST_OBJECTS.asan_mem_test.cpp.x86_64-calls.o ASAN_INST_TEST_OBJECTS.asan_str_test.cpp.x86_64-calls.o ASAN_INST_TEST_OBJECTS.asan_test_main.cpp.x86_64-calls.o ASAN_INST_TEST_OBJECTS.asan_mac_test.cpp.x86_64-calls.o ASAN_INST_TEST_OBJECTS.asan_mac_test_helpers.mm.x86_64-calls.o -o /Users/yln/work/llvm-upstream/build/projects/compiler-rt/lib/asan/tests/default/./Asan-x86_64-calls-Test -g -stdlib=libc++ -lc++ -lc++abi -fapplication-extension -mmacosx-version-min=10.10 -isysroot /Applications/XcodeGlacierPoint.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.0.Internal.sdk -Wl,-U,___asan_default_options -Wl,-U,___asan_default_suppressions -Wl,-U,___asan_on_error -Wl,-U,___asan_set_shadow_00 -Wl,-U,___asan_set_shadow_f1 -Wl,-U,___asan_set_shadow_f2 -Wl,-U,___asan_set_shadow_f3 -Wl,-U,___asan_set_shadow_f4 -Wl,-U,___asan_set_shadow_f5 -Wl,-U,___asan_set_shadow_f6 -Wl,-U,___asan_set_shadow_f7 -Wl,-U,___asan_set_shadow_f8 -Wl,-U,___lsan_default_options -Wl,-U,___lsan_default_suppressions -Wl,-U,___lsan_is_turned_off -Wl,-U,___ubsan_default_options -Wl,-U,___sanitizer_free_hook -Wl,-U,___sanitizer_malloc_hook -Wl,-U,___sanitizer_report_error_summary -Wl,-U,___sanitizer_sandbox_on_notify -Wl,-U,___sanitizer_symbolize_code -Wl,-U,___sanitizer_symbolize_data -Wl,-U,___sanitizer_symbolize_demangle -Wl,-U,___sanitizer_symbolize_flush -Wl,-U,___start_xray_fn_idx -Wl,-U,___start_xray_instr_map -Wl,-U,___stop_xray_fn_idx -Wl,-U,___stop_xray_instr_map -Wl,-U,___asan_default_options -Wl,-U,___asan_default_suppressions -Wl,-U,___asan_on_error -Wl,-U,___asan_set_shadow_00 -Wl,-U,___asan_set_shadow_f1 -Wl,-U,___asan_set_shadow_f2 -Wl,-U,___asan_set_shadow_f3 -Wl,-U,___asan_set_shadow_f4 -Wl,-U,___asan_set_shadow_f5 -Wl,-U,___asan_set_shadow_f6 -Wl,-U,___asan_set_shadow_f7 -Wl,-U,___asan_set_shadow_f8 -Wl,-U,___ubsan_default_options -Wl,-U,___sanitizer_free_hook -Wl,-U,___sanitizer_malloc_hook -Wl,-U,___sanitizer_report_error_summary -Wl,-U,___sanitizer_sandbox_on_notify -Wl,-U,___sanitizer_symbolize_code -Wl,-U,___sanitizer_symbolize_data -Wl,-U,___sanitizer_symbolize_demangle -Wl,-U,___sanitizer_symbolize_flush --driver-mode=g++ -framework Foundation -fsanitize=address -arch x86_64
Undefined symbols for architecture x86_64:
  "_CFAllocatorDefaultDoubleFree", referenced from:
      AddressSanitizerMac_CFAllocatorDefaultDoubleFree_Test::TestBody() in ASAN_INST_TEST_OBJECTS.asan_mac_test.cpp.x86_64-calls.o
      CFAllocator_DoubleFreeOnPthread() in ASAN_INST_TEST_OBJECTS.asan_mac_test.cpp.x86_64-calls.o
     (maybe you meant: vtable for testing::internal::TestFactoryImpl<AddressSanitizerMac_CFAllocatorDefaultDoubleFree_ChildPhread_Test>, AddressSanitizerMac_CFAllocatorDefaultDoubleFree_ChildPhread_Test::test_info_ , vtable for AddressSanitizerMac_CFAllocatorDefaultDoubleFree_ChildPhread_Test , vtable for AddressSanitizerMac_CFAllocatorDefaultDoubleFree_Test , AddressSanitizerMac_CFAllocatorDefaultDoubleFree_ChildPhread_Test::~AddressSanitizerMac_CFAllocatorDefaultDoubleFree_ChildPhread_Test() , AddressSanitizerMac_CFAllocatorDefaultDoubleFree_Test::~AddressSanitizerMac_CFAllocatorDefaultDoubleFree_Test() , AddressSanitizerMac_CFAllocatorDefaultDoubleFree_Test::~AddressSanitizerMac_CFAllocatorDefaultDoubleFree_Test() , AddressSanitizerMac_CFAllocatorDefaultDoubleFree_ChildPhread_Test::TestBody() , testing::internal::TestFactoryImpl<AddressSanitizerMac_CFAllocatorDefaultDoubleFree_ChildPhread_Test>::~TestFactoryImpl() , testing::internal::TestFactoryImpl<AddressSanitizerMac_CFAllocatorDefaultDoubleFree_ChildPhread_Test>::CreateTest() , AddressSanitizerMac_CFAllocatorDefaultDoubleFree_Test::test_info_ , vtable for testing::internal::TestFactoryImpl<AddressSanitizerMac_CFAllocatorDefaultDoubleFree_Test> , testing::internal::TestFactoryImpl<AddressSanitizerMac_CFAllocatorDefaultDoubleFree_Test>::~TestFactoryImpl() , testing::internal::TestFactoryImpl<AddressSanitizerMac_CFAllocatorDefaultDoubleFree_Test>::~TestFactoryImpl() , AddressSanitizerMac_CFAllocatorDefaultDoubleFree_Test::TestBody() , testing::internal::TestFactoryImpl<AddressSanitizerMac_CFAllocatorDefaultDoubleFree_ChildPhread_Test>::~TestFactoryImpl() , testing::internal::TestFactoryImpl<AddressSanitizerMac_CFAllocatorDefaultDoubleFree_Test>::CreateTest() , AddressSanitizerMac_CFAllocatorDefaultDoubleFree_ChildPhread_Test::~AddressSanitizerMac_CFAllocatorDefaultDoubleFree_ChildPhread_Test() )
  "_CFAllocatorMallocDoubleFree", referenced from:
      AddressSanitizerMac_CFAllocatorMallocDoubleFree_Test::TestBody() in ASAN_INST_TEST_OBJECTS.asan_mac_test.cpp.x86_64-calls.o
     (maybe you meant: vtable for testing::internal::TestFactoryImpl<AddressSanitizerMac_CFAllocatorMallocDoubleFree_Test>, AddressSanitizerMac_CFAllocatorMallocDoubleFree_Test::test_info_ , AddressSanitizerMac_CFAllocatorMallocDoubleFree_Test::~AddressSanitizerMac_CFAllocatorMallocDoubleFree_Test() , AddressSanitizerMac_CFAllocatorMallocDoubleFree_Test::TestBody() , testing::internal::TestFactoryImpl<AddressSanitizerMac_CFAllocatorMallocDoubleFree_Test>::~TestFactoryImpl() , testing::internal::TestFactoryImpl<AddressSanitizerMac_CFAllocatorMallocDoubleFree_Test>::~TestFactoryImpl() , testing::internal::TestFactoryImpl<AddressSanitizerMac_CFAllocatorMallocDoubleFree_Test>::CreateTest() , AddressSanitizerMac_CFAllocatorMallocDoubleFree_Test::~AddressSanitizerMac_CFAllocatorMallocDoubleFree_Test() , vtable for AddressSanitizerMac_CFAllocatorMallocDoubleFree_Test )
  "_CFAllocatorMallocZoneDoubleFree", referenced from:
      AddressSanitizerMac_DISABLED_CFAllocatorMallocZoneDoubleFree_Test::TestBody() in ASAN_INST_TEST_OBJECTS.asan_mac_test.cpp.x86_64-calls.o
     (maybe you meant: vtable for AddressSanitizerMac_DISABLED_CFAllocatorMallocZoneDoubleFree_Test, AddressSanitizerMac_DISABLED_CFAllocatorMallocZoneDoubleFree_Test::~AddressSanitizerMac_DISABLED_CFAllocatorMallocZoneDoubleFree_Test() , testing::internal::TestFactoryImpl<AddressSanitizerMac_DISABLED_CFAllocatorMallocZoneDoubleFree_Test>::~TestFactoryImpl() , testing::internal::TestFactoryImpl<AddressSanitizerMac_DISABLED_CFAllocatorMallocZoneDoubleFree_Test>::CreateTest() , vtable for testing::internal::TestFactoryImpl<AddressSanitizerMac_DISABLED_CFAllocatorMallocZoneDoubleFree_Test> , AddressSanitizerMac_DISABLED_CFAllocatorMallocZoneDoubleFree_Test::test_info_ , AddressSanitizerMac_DISABLED_CFAllocatorMallocZoneDoubleFree_Test::TestBody() , AddressSanitizerMac_DISABLED_CFAllocatorMallocZoneDoubleFree_Test::~AddressSanitizerMac_DISABLED_CFAllocatorMallocZoneDoubleFree_Test() , testing::internal::TestFactoryImpl<AddressSanitizerMac_DISABLED_CFAllocatorMallocZoneDoubleFree_Test>::~TestFactoryImpl() )
  "_CFAllocatorSystemDefaultDoubleFree", referenced from:
      AddressSanitizerMac_DISABLED_CFAllocatorSystemDefaultDoubleFree_Test::TestBody() in ASAN_INST_TEST_OBJECTS.asan_mac_test.cpp.x86_64-calls.o
     (maybe you meant: vtable for testing::internal::TestFactoryImpl<AddressSanitizerMac_DISABLED_CFAllocatorSystemDefaultDoubleFree_Test>, AddressSanitizerMac_DISABLED_CFAllocatorSystemDefaultDoubleFree_Test::test_info_ , testing::internal::TestFactoryImpl<AddressSanitizerMac_DISABLED_CFAllocatorSystemDefaultDoubleFree_Test>::CreateTest() , AddressSanitizerMac_DISABLED_CFAllocatorSystemDefaultDoubleFree_Test::~AddressSanitizerMac_DISABLED_CFAllocatorSystemDefaultDoubleFree_Test() , AddressSanitizerMac_DISABLED_CFAllocatorSystemDefaultDoubleFree_Test::~AddressSanitizerMac_DISABLED_CFAllocatorSystemDefaultDoubleFree_Test() , vtable for AddressSanitizerMac_DISABLED_CFAllocatorSystemDefaultDoubleFree_Test , AddressSanitizerMac_DISABLED_CFAllocatorSystemDefaultDoubleFree_Test::TestBody() , testing::internal::TestFactoryImpl<AddressSanitizerMac_DISABLED_CFAllocatorSystemDefaultDoubleFree_Test>::~TestFactoryImpl() , testing::internal::TestFactoryImpl<AddressSanitizerMac_DISABLED_CFAllocatorSystemDefaultDoubleFree_Test>::~TestFactoryImpl() )
  "_CallFreeOnWorkqueue", referenced from:
      AddressSanitizerMac_DISABLED_TSDWorkqueueTest_Test::TestBody() in ASAN_INST_TEST_OBJECTS.asan_mac_test.cpp.x86_64-calls.o
  "_TestGCDDispatchAfter", referenced from:
      AddressSanitizerMac_GCDDispatchAfter_Test::TestBody() in ASAN_INST_TEST_OBJECTS.asan_mac_test.cpp.x86_64-calls.o
  "_TestGCDDispatchAsync", referenced from:
      AddressSanitizerMac_GCDDispatchAsync_Test::TestBody() in ASAN_INST_TEST_OBJECTS.asan_mac_test.cpp.x86_64-calls.o
  "_TestGCDDispatchSync", referenced from:
      AddressSanitizerMac_GCDDispatchSync_Test::TestBody() in ASAN_INST_TEST_OBJECTS.asan_mac_test.cpp.x86_64-calls.o
  "_TestGCDGroupAsync", referenced from:
      AddressSanitizerMac_GCDGroupAsync_Test::TestBody() in ASAN_INST_TEST_OBJECTS.asan_mac_test.cpp.x86_64-calls.o
  "_TestGCDReuseWqthreadsAsync", referenced from:
      AddressSanitizerMac_GCDReuseWqthreadsAsync_Test::TestBody() in ASAN_INST_TEST_OBJECTS.asan_mac_test.cpp.x86_64-calls.o
  "_TestGCDReuseWqthreadsSync", referenced from:
      AddressSanitizerMac_GCDReuseWqthreadsSync_Test::TestBody() in ASAN_INST_TEST_OBJECTS.asan_mac_test.cpp.x86_64-calls.o
  "_TestGCDSourceCancel", referenced from:
      AddressSanitizerMac_GCDSourceCancel_Test::TestBody() in ASAN_INST_TEST_OBJECTS.asan_mac_test.cpp.x86_64-calls.o
  "_TestGCDSourceEvent", referenced from:
      AddressSanitizerMac_GCDSourceEvent_Test::TestBody() in ASAN_INST_TEST_OBJECTS.asan_mac_test.cpp.x86_64-calls.o
  "_TestNSURLDeallocation", referenced from:
      AddressSanitizerMac_NSURLDeallocation_Test::TestBody() in ASAN_INST_TEST_OBJECTS.asan_mac_test.cpp.x86_64-calls.o
  "_TestOOBNSObjects", referenced from:
      AddressSanitizerMac_NSObjectOOB_Test::TestBody() in ASAN_INST_TEST_OBJECTS.asan_mac_test.cpp.x86_64-calls.o
ld: symbol(s) not found for architecture x86_64
clang-11: error: linker command failed with exit code 1 (use -v to see invocation)

I am trying to come up with a minimal fix.