[compiler-rt] r233215 - On OS X, explicitly use libc++

Hans Wennborg hans at chromium.org
Wed Apr 15 10:03:31 PDT 2015


On Mon, Apr 13, 2015 at 3:56 PM, Kuba Brecka <kuba.brecka at gmail.com> wrote:
> ASan (and other sanitizers) have dropped support for 10.6 long time ago, the
> intention of the commit (and another one before) in question was to
> explicitly specify that via -mmacosx-version-min, and also explicitly
> require libc++.  Libc++ is available on 10.7+ and ASan contains several
> interceptors that only work in libc++ mode.
>
> Before these commits (or if we revert), the situation is that *it depends on
> your system* what C++ library will ASan link against.  The minimal OS X
> version is also set to your *current OS*.  This makes the resulting
> sanitizer dylibs have subtle differences based on how/where the dylib was
> built.

We do "MACOSX_DEPLOYMENT_TARGET=10.6 cmake" to configure compiler-rt.
Does ASan ignore that and use current OS instead?

> Note that this should only apply to sanitizers - the parts of compiler-rt
> that are used for regular binaries are not dylibs, but .a files, and their
> required OS X version should be much lower.

Do the non-sanitizer binaries not care about MACOSX_DEPLOYMENT_TARGET?
What OS version are they built against? If they are always built
against 10.6 or less, we could just stop setting the target
specifically, and our problems would go away, I think.

> If these .a are also affected
> by that patch, then that was unintentional and a bug.

They're not. The problem is that our build with
MACOSX_DEPLOYMENT_TARGET=10.6 stopped working.


Thanks,
Hans

> On Apr 13, 2015, at 4:39 PM, Nico Weber <thakis at google.com> wrote:
>
> On Sun, Apr 12, 2015 at 12:22 AM, Hans Wennborg <hans at chromium.org> wrote:
>>
>> +samsonov who did the Clang part in r233860
>>
>> We only do one compiler-rt build, and that is used for both asan and
>> regular builds, so it needs to work with both.
>>
>> Nico: I assume parts of compiler-rt get linked into the target
>> binaries, i.e. it's not just used for asan, right?
>
>
> Yes:
>
> $ clang test.c -v
> # ...
> "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld"
> ...
> /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/clang/6.0/lib/darwin/libclang_rt.osx.a
>
> Since the commit description didn't say anything about intentionally
> dropping support for 10.6, I think it's ok to revert this for now.
>
>>
>> On Fri, Apr 10, 2015 at 10:17 AM, Alexander Potapenko <glider at google.com>
>> wrote:
>> > I don't think we really need to require libc++ for ASan, but note that
>> > ASan itself already requires 10.7.
>> > Perhaps we should bump the target OS version in Chromium for asan==1?
>> > (IIRC we don't have 10.6 machines on CF or bots)
>> >
>> > On Fri, Apr 10, 2015 at 3:07 AM, Hans Wennborg <hans at chromium.org>
>> > wrote:
>> >> This seems to have broken Chromium's ASan build on Darwin, where we
>> >> target Mac OS X 10.6 which IIUC doesn't have libc++.
>> >>
>> >> Is libc++ now a hard requirement of the ASan run-time?
>> >>
>> >> On Wed, Mar 25, 2015 at 2:07 PM, Kuba Brecka <kuba.brecka at gmail.com>
>> >> wrote:
>> >>> Author: kuba.brecka
>> >>> Date: Wed Mar 25 16:07:20 2015
>> >>> New Revision: 233215
>> >>>
>> >>> URL: http://llvm.org/viewvc/llvm-project?rev=233215&view=rev
>> >>> Log:
>> >>> On OS X, explicitly use libc++
>> >>>
>> >>> For OS X builds, both Make and CMake, let's be very explicit about
>> >>> using
>> >>> libc++ and libc++abi with:
>> >>>
>> >>> 1) -stdlib=libc++ in CFLAGS and LDFLAGS for all platforms
>> >>> 2) -lc++ in LDFLAGS for all platforms
>> >>> 3) switch from -undefined dynamic_lookup to -lc++abi for UBSan in
>> >>>    Makefile-based builds
>> >>>
>> >>> Reviewed at http://reviews.llvm.org/D8617
>> >>>
>> >>>
>> >>> Modified:
>> >>>     compiler-rt/trunk/CMakeLists.txt
>> >>>     compiler-rt/trunk/make/platform/clang_darwin.mk
>> >>>
>> >>> Modified: compiler-rt/trunk/CMakeLists.txt
>> >>> URL:
>> >>> http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/CMakeLists.txt?rev=233215&r1=233214&r2=233215&view=diff
>> >>>
>> >>> ==============================================================================
>> >>> --- compiler-rt/trunk/CMakeLists.txt (original)
>> >>> +++ compiler-rt/trunk/CMakeLists.txt Wed Mar 25 16:07:20 2015
>> >>> @@ -302,10 +302,12 @@ if(APPLE)
>> >>>    set(DARWIN_osx_CFLAGS
>> >>> -mmacosx-version-min=${SANITIZER_MIN_OSX_VERSION}
>> >>>      -stdlib=libc++)
>> >>>    set(DARWIN_iossim_CFLAGS
>> >>> +    -stdlib=libc++
>> >>>      -mios-simulator-version-min=7.0 -isysroot ${IOSSIM_SDK_DIR})
>> >>>    set(DARWIN_osx_LINKFLAGS
>> >>> -mmacosx-version-min=${SANITIZER_MIN_OSX_VERSION}
>> >>> -     -stdlib=libc++)
>> >>> +    -stdlib=libc++ -lc++)
>> >>>    set(DARWIN_iossim_LINKFLAGS
>> >>> +    -stdlib=libc++ -lc++
>> >>>      -Wl,-ios_simulator_version_min,7.0.0
>> >>>      -mios-simulator-version-min=7.0
>> >>>      -isysroot ${IOSSIM_SDK_DIR})
>> >>>
>> >>> Modified: compiler-rt/trunk/make/platform/clang_darwin.mk
>> >>> URL:
>> >>> http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/make/platform/clang_darwin.mk?rev=233215&r1=233214&r2=233215&view=diff
>> >>>
>> >>> ==============================================================================
>> >>> --- compiler-rt/trunk/make/platform/clang_darwin.mk (original)
>> >>> +++ compiler-rt/trunk/make/platform/clang_darwin.mk Wed Mar 25
>> >>> 16:07:20 2015
>> >>> @@ -178,29 +178,27 @@ CFLAGS.10.4               := $(CFLAGS)
>> >>> $(OSX_DEPLOYME
>> >>>  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
>> >>> +SANITIZER_CFLAGS := -fno-builtin -gline-tables-only -stdlib=libc++
>> >>>
>> >>>  CFLAGS.asan_osx_dynamic := \
>> >>>         $(CFLAGS) $(SANITIZER_MACOSX_DEPLOYMENT_ARGS) \
>> >>>         $(SANITIZER_CFLAGS) \
>> >>> -       -stdlib=libc++ \
>> >>>         -DMAC_INTERPOSE_FUNCTIONS=1 \
>> >>>         -DASAN_DYNAMIC=1
>> >>>
>> >>>  CFLAGS.asan_iossim_dynamic := \
>> >>>         $(CFLAGS) $(SANITIZER_IOSSIM_DEPLOYMENT_ARGS) \
>> >>> -  $(SANITIZER_CFLAGS) \
>> >>> +       $(SANITIZER_CFLAGS) \
>> >>>         -DMAC_INTERPOSE_FUNCTIONS=1 \
>> >>>         -DASAN_DYNAMIC=1
>> >>>
>> >>>  CFLAGS.ubsan_osx_dynamic := \
>> >>>         $(CFLAGS) $(SANITIZER_MACOSX_DEPLOYMENT_ARGS) \
>> >>> -       $(SANITIZER_CFLAGS) \
>> >>> -       -stdlib=libc++
>> >>> +       $(SANITIZER_CFLAGS)
>> >>>
>> >>>  CFLAGS.ubsan_iossim_dynamic := \
>> >>>         $(CFLAGS) $(SANITIZER_IOSSIM_DEPLOYMENT_ARGS) \
>> >>> -  $(SANITIZER_CFLAGS)
>> >>> +       $(SANITIZER_CFLAGS)
>> >>>
>> >>>
>> >>>  CFLAGS.ios.i386                := $(CFLAGS) $(IOSSIM_DEPLOYMENT_ARGS)
>> >>> @@ -232,10 +230,10 @@ CFLAGS.profile_ios.armv7k := $(CFLAGS) $
>> >>>  CFLAGS.profile_ios.armv7s := $(CFLAGS) $(IOS_DEPLOYMENT_ARGS)
>> >>>  CFLAGS.profile_ios.arm64  := $(CFLAGS) $(IOS6_DEPLOYMENT_ARGS)
>> >>>
>> >>> -SANITIZER_LDFLAGS := -undefined dynamic_lookup
>> >>> +SANITIZER_LDFLAGS := -stdlib=libc++ -lc++
>> >>>
>> >>>  SHARED_LIBRARY.asan_osx_dynamic := 1
>> >>> -LDFLAGS.asan_osx_dynamic := -lc++ $(SANITIZER_LDFLAGS) -install_name
>> >>> @rpath/libclang_rt.asan_osx_dynamic.dylib \
>> >>> +LDFLAGS.asan_osx_dynamic := $(SANITIZER_LDFLAGS) -install_name
>> >>> @rpath/libclang_rt.asan_osx_dynamic.dylib \
>> >>>    $(SANITIZER_MACOSX_DEPLOYMENT_ARGS)
>> >>>
>> >>>  SHARED_LIBRARY.asan_iossim_dynamic := 1
>> >>> @@ -243,11 +241,11 @@ LDFLAGS.asan_iossim_dynamic := $(SANITIZ
>> >>>    -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 \
>> >>> +LDFLAGS.ubsan_osx_dynamic := $(SANITIZER_LDFLAGS) -lc++abi
>> >>> -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 \
>> >>> +LDFLAGS.ubsan_iossim_dynamic := $(SANITIZER_LDFLAGS) -lc++abi
>> >>> -install_name @rpath/libclang_rt.ubsan_iossim_dynamic.dylib \
>> >>>    -Wl,-ios_simulator_version_min,7.0.0
>> >>> $(SANITIZER_IOSSIM_DEPLOYMENT_ARGS)
>> >>>
>> >>>  ifneq ($(OSX_SDK),)
>> >>>
>> >>>
>> >>> _______________________________________________
>> >>> llvm-commits mailing list
>> >>> llvm-commits at cs.uiuc.edu
>> >>> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>> >
>> >
>> >
>> > --
>> > Alexander Potapenko
>> > Software Engineer
>> > Google Moscow
>
>
>



More information about the llvm-commits mailing list