Revert "[UBSan] Use shared library for UBSan on OS X" and its followup

This change caused test failures on darwin, and the followup which was
meant to fix those caused compiler-rt to start failing to link.
Reverting to get the build working again.

This reverts r233071 and r233036.

llvm-svn: 233097
This commit is contained in:
Justin Bogner 2015-03-24 17:43:31 +00:00
parent 7f9f7c8748
commit cc7e7cabd5
3 changed files with 36 additions and 59 deletions

View File

@ -22,19 +22,13 @@ set(UBSAN_CXXFLAGS ${SANITIZER_COMMON_CFLAGS})
add_custom_target(ubsan)
if(APPLE)
foreach(os ${SANITIZER_COMMON_SUPPORTED_DARWIN_OS})
add_compiler_rt_darwin_object_library(RTUbsan ${os}
ARCH ${UBSAN_SUPPORTED_ARCH}
SOURCES ${UBSAN_SOURCES} ${UBSAN_CXX_SOURCES}
CFLAGS ${UBSAN_CXXFLAGS})
add_compiler_rt_darwin_dynamic_runtime(clang_rt.ubsan_${os}_dynamic ${os}
ARCH ${UBSAN_SUPPORTED_ARCH}
SOURCES $<TARGET_OBJECTS:RTUbsan.${os}>
$<TARGET_OBJECTS:RTSanitizerCommon.${os}>)
add_dependencies(ubsan clang_rt.ubsan_${os}_dynamic)
endforeach()
# Build universal binary on APPLE.
add_compiler_rt_osx_static_runtime(clang_rt.ubsan_osx
ARCH ${UBSAN_SUPPORTED_ARCH}
SOURCES ${UBSAN_SOURCES} ${UBSAN_CXX_SOURCES}
$<TARGET_OBJECTS:RTSanitizerCommon.osx>
CFLAGS ${UBSAN_CXXFLAGS})
add_dependencies(ubsan clang_rt.ubsan_osx)
else()
# Build separate libraries for each target.
foreach(arch ${UBSAN_SUPPORTED_ARCH})

View File

@ -119,11 +119,8 @@ UniversalArchs.asan_osx_dynamic := $(call CheckArches,i386 x86_64 x86_64h,asan_o
Configs += asan_iossim_dynamic
UniversalArchs.asan_iossim_dynamic := $(call CheckArches,i386 x86_64,asan_iossim_dynamic,$(IOSSIM_SDK))
Configs += ubsan_osx_dynamic
UniversalArchs.ubsan_osx_dynamic := $(call CheckArches,i386 x86_64 x86_64h,ubsan_osx_dynamic,$(OSX_SDK))
Configs += ubsan_iossim_dynamic
UniversalArchs.ubsan_iossim_dynamic := $(call CheckArches,i386 x86_64,ubsan_iossim_dynamic,$(IOSSIM_SDK))
Configs += ubsan_osx
UniversalArchs.ubsan_osx := $(call CheckArches,i386 x86_64 x86_64h,ubsan_osx,$(OSX_SDK))
# Darwin 10.6 has a bug in cctools that makes it unable to use ranlib on our ARM
# object files. If we are on that platform, strip out all ARM archs. We still
@ -175,33 +172,24 @@ IOSSIM_DEPLOYMENT_ARGS += -isysroot $(IOSSIM_SDK)
CFLAGS.eprintf := $(CFLAGS) $(OSX_DEPLOYMENT_ARGS)
CFLAGS.10.4 := $(CFLAGS) $(OSX_DEPLOYMENT_ARGS)
SANITIZER_MACOSX_DEPLOYMENT_ARGS := -mmacosx-version-min=10.7
SANITIZER_IOSSIM_DEPLOYMENT_ARGS := -mios-simulator-version-min=7.0 \
-isysroot $(IOSSIM_SDK)
SANITIZER_CFLAGS := -fno-builtin -gline-tables-only
CFLAGS.asan_osx_dynamic := \
$(CFLAGS) $(SANITIZER_MACOSX_DEPLOYMENT_ARGS) \
$(SANITIZER_CFLAGS) \
$(CFLAGS) -mmacosx-version-min=10.7 \
-stdlib=libc++ \
-fno-builtin \
-gline-tables-only \
-DMAC_INTERPOSE_FUNCTIONS=1 \
-DASAN_DYNAMIC=1
CFLAGS.asan_iossim_dynamic := \
$(CFLAGS) $(SANITIZER_IOSSIM_DEPLOYMENT_ARGS) \
$(SANITIZER_CFLAGS) \
$(CFLAGS) -mios-simulator-version-min=7.0 \
-isysroot $(IOSSIM_SDK) \
-fno-builtin \
-gline-tables-only \
-DMAC_INTERPOSE_FUNCTIONS=1 \
-DASAN_DYNAMIC=1
CFLAGS.ubsan_osx_dynamic := \
$(CFLAGS) $(SANITIZER_MACOSX_DEPLOYMENT_ARGS) \
$(SANITIZER_CFLAGS) \
-stdlib=libc++
CFLAGS.ubsan_iossim_dynamic := \
$(CFLAGS) $(SANITIZER_IOSSIM_DEPLOYMENT_ARGS) \
$(SANITIZER_CFLAGS)
CFLAGS.ubsan_osx := $(CFLAGS) -mmacosx-version-min=10.6 \
-fno-builtin
CFLAGS.ios.i386 := $(CFLAGS) $(IOSSIM_DEPLOYMENT_ARGS)
CFLAGS.ios.x86_64 := $(CFLAGS) $(IOSSIM_DEPLOYMENT_ARGS)
@ -232,29 +220,24 @@ CFLAGS.profile_ios.armv7k := $(CFLAGS) $(IOS_DEPLOYMENT_ARGS)
CFLAGS.profile_ios.armv7s := $(CFLAGS) $(IOS_DEPLOYMENT_ARGS)
CFLAGS.profile_ios.arm64 := $(CFLAGS) $(IOS6_DEPLOYMENT_ARGS)
SANITIZER_LDFLAGS := -undefined dynamic_lookup
# Configure the asan_osx_dynamic library to be built shared.
SHARED_LIBRARY.asan_osx_dynamic := 1
LDFLAGS.asan_osx_dynamic := -lc++ $(SANITIZER_LDFLAGS) -install_name @rpath/libclang_rt.asan_osx_dynamic.dylib \
$(SANITIZER_MACOSX_DEPLOYMENT_ARGS)
LDFLAGS.asan_osx_dynamic := -lc++ -undefined dynamic_lookup -install_name @rpath/libclang_rt.asan_osx_dynamic.dylib \
-mmacosx-version-min=10.7
# Configure the asan_iossim_dynamic library to be built shared.
SHARED_LIBRARY.asan_iossim_dynamic := 1
LDFLAGS.asan_iossim_dynamic := $(SANITIZER_LDFLAGS) -install_name @rpath/libclang_rt.asan_iossim_dynamic.dylib \
-Wl,-ios_simulator_version_min,7.0.0 $(SANITIZER_IOSSIM_DEPLOYMENT_ARGS)
SHARED_LIBRARY.ubsan_osx_dynamic := 1
LDFLAGS.ubsan_osx_dynamic := -lc++ $(SANITIZER_LDFLAGS) -install_name @rpath/libclang_rt.ubsan_osx_dynamic.dylib \
$(SANITIZER_MACOSX_DEPLOYMENT_ARGS)
SHARED_LIBRARY.ubsan_iossim_dynamic := 1
LDFLAGS.ubsan_iossim_dynamic := $(SANITIZER_LDFLAGS) -install_name @rpath/libclang_rt.ubsan_iossim_dynamic.dylib \
-Wl,-ios_simulator_version_min,7.0.0 $(SANITIZER_IOSSIM_DEPLOYMENT_ARGS)
# configure+make uses Clang, so we're using isysroot instead of --sysroot
# or -Wl,-syslibroot.
LDFLAGS.asan_iossim_dynamic := -undefined dynamic_lookup -install_name @rpath/libclang_rt.asan_iossim_dynamic.dylib \
-Wl,-ios_simulator_version_min,7.0.0 \
-mios-simulator-version-min=7.0 -isysroot $(IOSSIM_SDK)
ifneq ($(OSX_SDK),)
CFLAGS.asan_osx_dynamic += -isysroot $(OSX_SDK)
LDFLAGS.asan_osx_dynamic += -isysroot $(OSX_SDK)
CFLAGS.ubsan_osx_dynamic += -isysroot $(OSX_SDK)
LDFLAGS.ubsan_osx_dynamic += -isysroot $(OSX_SDK)
CFLAGS.ubsan_osx += -isysroot $(OSX_SDK)
LDFLAGS.ubsan_osx += -isysroot $(OSX_SDK)
endif
FUNCTIONS.eprintf := eprintf
@ -277,18 +260,15 @@ FUNCTIONS.profile_ios := $(FUNCTIONS.profile_osx)
FUNCTIONS.asan_osx_dynamic := $(AsanFunctions) $(AsanCXXFunctions) \
$(InterceptionFunctions) \
$(SanitizerCommonFunctions) \
$(AsanDynamicFunctions)
$(AsanDynamicFunctions)
FUNCTIONS.asan_iossim_dynamic := $(AsanFunctions) $(AsanCXXFunctions) \
$(InterceptionFunctions) \
$(SanitizerCommonFunctions) \
$(AsanDynamicFunctions)
$(AsanDynamicFunctions)
FUNCTIONS.ubsan_osx_dynamic := $(UbsanFunctions) $(UbsanCXXFunctions) \
$(SanitizerCommonFunctions)
FUNCTIONS.ubsan_iossim_dynamic := $(UbsanFunctions) $(UbsanCXXFunctions) \
$(SanitizerCommonFunctions)
FUNCTIONS.ubsan_osx := $(UbsanFunctions) $(UbsanCXXFunctions) \
$(SanitizerCommonFunctions)
CCKEXT_PROFILE_FUNCTIONS := \
InstrProfiling \

View File

@ -1,6 +1,9 @@
// RUN: %clangxx -frtti -fsanitize=vptr -fno-sanitize-recover=vptr -g %s -O3 -o %t
// RUN: not %run %t 2>&1 | FileCheck %s
// FIXME: This test produces linker errors on Darwin.
// XFAIL: darwin
struct S { virtual int f() { return 0; } };
struct T : virtual S {};