This is an archive of the discontinued LLVM Phabricator instance.

[CMake] Fix PR23539: Don't reference C++ ABI symbols prior to Mac OS 10.9.
ClosedPublic

Authored by samsonov on Jun 22 2015, 5:10 PM.

Details

Summary

This patch implements step 1 from
https://llvm.org/bugs/show_bug.cgi?id=23539#c10

I'd appreciate if you could test it on Mac OS and verify that parts of UBSan
runtime that reference C++ ABI symbols are properly excluded, and fix ASan/UBSan
builds.

Diff Detail

Event Timeline

samsonov updated this revision to Diff 28178.Jun 22 2015, 5:10 PM
samsonov retitled this revision from to [CMake] Fix PR23539: Don't reference C++ ABI symbols prior to Mac OS 10.9..
samsonov updated this object.
samsonov edited the test plan for this revision. (Show Details)
samsonov added reviewers: thakis, hans.
samsonov added subscribers: kubamracek, zaks.anna, Unknown Object (MLST).
hans accepted this revision.Jun 24 2015, 3:58 PM
hans edited edge metadata.

Apologies for the delay. I tried this out on Mac, building like this:

$ cmake -GNinja -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_FLAGS=-stdlib=libc++ -DCMAKE_CXX_FLAGS=-stdlib=libc++ -DCMAKE_OSX_DEPLOYMENT_TARGET=10.8 ..
$ ninja lib/clang/3.7.0/lib/darwin/libclang_rt.asan_osx_dynamic.dylib

The diff of that .dylib before and after your patch looks like this:

$ diff -u <(nm /tmp/before.dylib | sed 's/^[0-9a-f ]*//') <(nm /tmp/after.dylib | sed 's/^[0-9a-f ]*//')
--- /dev/fd/63	2015-06-24 15:54:26.000000000 -0700
+++ /dev/fd/62	2015-06-24 15:54:26.000000000 -0700
@@ -29,10 +29,8 @@
 __ZL15dump_once_guard
 __ZL15suppression_ctx
 t __ZL15unpoison_passwdPvPN11__sanitizer18__sanitizer_passwdE
-t __ZL16HandleCFIBadTypePN7__ubsan14CFIBadTypeDataEmNS_13ReportOptionsE
 __ZL16coverage_counter
 __ZL16coverage_enabled
-t __ZL16findBaseAtOffsetPKN10__cxxabiv117__class_type_infoEl
 t __ZL16handleNonNullArgPN7__ubsan14NonNullArgDataENS_13ReportOptionsE
 __ZL16ioctl_table_size
 t __ZL17StrtolFixAndCheckPvPKcPPcS2_i
@@ -147,7 +145,6 @@
 s __ZL20substitution_waitpid
 s __ZL20substitution_wordexp
 t __ZL21handleOutOfBoundsImplPN7__ubsan15OutOfBoundsDataEmNS_13ReportOptionsE
-t __ZL21isDerivedFromAtOffsetPKN10__cxxabiv117__class_type_infoES2_l
 s __ZL21substitution__longjmp
 s __ZL21substitution_asprintf
 s __ZL21substitution_endgrent
@@ -230,7 +227,6 @@
 t __ZL25handleVLABoundNotPositivePN7__ubsan12VLABoundDataEmNS_13ReportOptionsE
 s __ZL25substitution___cxa_atexit
 s __ZL25substitution_pthread_join
-t __ZL26HandleDynamicTypeCacheMissPN7__ubsan24DynamicTypeCacheMissDataEmmNS_13ReportOptionsE
 t __ZL26handleFunctionTypeMismatchPN7__ubsan24FunctionTypeMismatchDataEmNS_13ReportOptionsE
 t __ZL26handleShiftOutOfBoundsImplPN7__ubsan20ShiftOutOfBoundsDataEmmNS_13ReportOptionsE
 s __ZL26substitution_ether_hostton
@@ -1104,15 +1100,12 @@
 __ZN7__ubsan14TypeCheckKindsE
 t __ZN7__ubsan15InitializeFlagsEv
 t __ZN7__ubsan16InitAsStandaloneEv
-t __ZN7__ubsan16checkDynamicTypeEPvS0_m
 t __ZN7__ubsan18RegisterUbsanFlagsEPN11__sanitizer10FlagParserEPNS_5FlagsE
 t __ZN7__ubsan21IsVptrCheckSuppressedEPKc
 t __ZN7__ubsan21getSymbolizedLocationEm
 t __ZN7__ubsan22InitializeSuppressionsEv
 t __ZN7__ubsan27InitAsStandaloneIfNecessaryEv
 t __ZN7__ubsan28MaybeCallUbsanDefaultOptionsEv
-t __ZN7__ubsan28getDynamicTypeInfoFromObjectEPv
-t __ZN7__ubsan28getDynamicTypeInfoFromVtableEPv
 t __ZN7__ubsan4DiagD1Ev
 t __ZN7__ubsan4DiagD2Ev
 t __ZN7__ubsan4DiaglsERKNS_14TypeDescriptorE
@@ -1142,13 +1135,9 @@
 t __ZNK7__ubsan5Value12getUIntValueEv
 t __ZNK7__ubsan5Value13getFloatValueEv
 t __ZNK7__ubsan5Value19getPositiveIntValueEv
-U __ZTIN10__cxxabiv117__class_type_infoE
-U __ZTIN10__cxxabiv120__si_class_type_infoE
-U __ZTIN10__cxxabiv121__vmi_class_type_infoE
 __ZTIN11__sanitizer11FlagHandlerIPKcEE
 __ZTIN11__sanitizer11FlagHandlerIbEE
 __ZTIN11__sanitizer15FlagHandlerBaseE
-U __ZTISt9type_info
 s __ZTSN11__sanitizer11FlagHandlerIPKcEE
 s __ZTSN11__sanitizer11FlagHandlerIbEE
 s __ZTSN11__sanitizer15FlagHandlerBaseE
@@ -1172,9 +1161,7 @@
 s __ZTVN11__sanitizer2DDE
 s __ZTVN6__asan17AsanThreadContextE
 __ZZ23__asan_handle_no_returnE16reported_warning
-s __ZZL16HandleCFIBadTypePN7__ubsan14CFIBadTypeDataEmNS_13ReportOptionsEE14TypeCheckKinds
 __ZZL18MlockIsUnsupportedvE7printed
-__ZZL27getTypeCacheHashTableBucketmE21__ubsan_vptr_hash_set
 __ZZL28InitializeCommonInterceptorsvE12metadata_mem
 __ZZN11__sanitizer17GetPageSizeCachedEvE8PageSize
 __ZZN11__sanitizer9MmapOrDieEmPKcE15recursion_count
@@ -1339,7 +1326,6 @@
 t ___destroy_helper_block_20
 t ___destroy_helper_block_23
 t ___destroy_helper_block_26
-U ___dynamic_cast
 U ___error
 T ___lsan_disable
 T ___lsan_do_leak_check
@@ -1392,12 +1378,8 @@
 T ___ubsan_handle_add_overflow
 T ___ubsan_handle_add_overflow_abort
 T ___ubsan_handle_builtin_unreachable
-T ___ubsan_handle_cfi_bad_type
-T ___ubsan_handle_cfi_bad_type_abort
 T ___ubsan_handle_divrem_overflow
 T ___ubsan_handle_divrem_overflow_abort
-T ___ubsan_handle_dynamic_type_cache_miss
-T ___ubsan_handle_dynamic_type_cache_miss_abort
 T ___ubsan_handle_float_cast_overflow
 T ___ubsan_handle_float_cast_overflow_abort
 T ___ubsan_handle_function_type_mismatch
@@ -1423,7 +1405,6 @@
 T ___ubsan_handle_type_mismatch_abort
 T ___ubsan_handle_vla_bound_not_positive
 T ___ubsan_handle_vla_bound_not_positive_abort
-S ___ubsan_vptr_type_cache
 t ___wrap_dispatch_after_block_invoke
 t ___wrap_dispatch_async_block_invoke
 t ___wrap_dispatch_group_async_block_invoke

From what I can tell, that looks reasonable. In particular, __ZTISt9type_info is gone, which was the symbol causing our original link error.

lgtm

This revision is now accepted and ready to land.Jun 24 2015, 3:58 PM
This revision was automatically updated to reflect the committed changes.