diff options
author | thakis@chromium.org <thakis@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-04-01 18:28:25 +0000 |
---|---|---|
committer | thakis@chromium.org <thakis@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-04-01 18:28:25 +0000 |
commit | b0c0e839cc56e937300bf40b27ccd445cf6e6ba3 (patch) | |
tree | 65fe431f1179e85d0bf75a5f9ce2c02977f4e7b7 /tools/clang | |
parent | 7fa48c73124c31f88129abc88e3fedb5f04cc208 (diff) | |
download | chromium_src-b0c0e839cc56e937300bf40b27ccd445cf6e6ba3.zip chromium_src-b0c0e839cc56e937300bf40b27ccd445cf6e6ba3.tar.gz chromium_src-b0c0e839cc56e937300bf40b27ccd445cf6e6ba3.tar.bz2 |
clang/mac: Bundle libc++.dylib with clang.
clang now uses c++11, which on OS X means it depends on libc++.
OS X 10.6 doesn't have libc++ yet, but some bots still are on 10.6 and
upgrading them will take a bit longer. Bundle libc++ with the clang package,
and set rpaths so that both clang and plugins refer to the bundled libc++
instead of /usr/lib/libc++.1.dylib.
(System libraries will still cause libstdc++ to be loaded as well. Since libc++
keeps its symbols in std::__1:: and aliases everything to that, loading libc++
and libstdc++ in the same process is safe.)
Also don't set MACOSX_DEPLOYMENT_TARGET while building the bootstrap
compiler (Xcode's clang complains when using -stdlib=libc++ when targeting
10.6 or older; open-source luckily doesn't for some reason).
Also pass -isysroot; when building on OS X 10.9, /usr/include doesn't exist
unless the command line tools are installed.
BUG=358500
TEST=Run package.sh (with a tweaked clang revision, to not clobber an
existing package). Upload produced tgz file somewhere, download it on
a 10.6 box. Clang should run.
R=hans@chromium.org
Review URL: https://codereview.chromium.org/218613009
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@260908 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'tools/clang')
-rw-r--r-- | tools/clang/blink_gc_plugin/Makefile | 2 | ||||
-rw-r--r-- | tools/clang/plugins/Makefile | 2 | ||||
-rwxr-xr-x | tools/clang/scripts/package.sh | 4 | ||||
-rwxr-xr-x | tools/clang/scripts/update.sh | 68 |
4 files changed, 63 insertions, 13 deletions
diff --git a/tools/clang/blink_gc_plugin/Makefile b/tools/clang/blink_gc_plugin/Makefile index d6e7da9..29e3834 100644 --- a/tools/clang/blink_gc_plugin/Makefile +++ b/tools/clang/blink_gc_plugin/Makefile @@ -17,5 +17,5 @@ SHARED_LIBRARY = 1 include $(CLANG_LEVEL)/Makefile ifeq ($(OS),Darwin) - LDFLAGS=-Wl,-undefined,dynamic_lookup + LDFLAGS+=-Wl,-undefined,dynamic_lookup endif diff --git a/tools/clang/plugins/Makefile b/tools/clang/plugins/Makefile index 0cfec71..98ce28b 100644 --- a/tools/clang/plugins/Makefile +++ b/tools/clang/plugins/Makefile @@ -15,5 +15,5 @@ SHARED_LIBRARY = 1 include $(CLANG_LEVEL)/Makefile ifeq ($(OS),Darwin) - LDFLAGS=-Wl,-undefined,dynamic_lookup + LDFLAGS+=-Wl,-undefined,dynamic_lookup endif diff --git a/tools/clang/scripts/package.sh b/tools/clang/scripts/package.sh index ba9d744..93d0780 100755 --- a/tools/clang/scripts/package.sh +++ b/tools/clang/scripts/package.sh @@ -100,6 +100,10 @@ cp buildlog.txt $PDIR/ cp "${LLVM_BIN_DIR}/clang" $PDIR/bin/ (cd $PDIR/bin && ln -sf clang clang++ && cd -) cp "${LLVM_BIN_DIR}/llvm-symbolizer" $PDIR/bin/ +if [ "$(uname -s)" = "Darwin" ]; then + cp "${LLVM_BIN_DIR}/libc++.1.${SO_EXT}" $PDIR/bin/ + (cd $PDIR/bin && ln -sf libc++.1.dylib libc++.dylib && cd -) +fi # Copy plugins. Some of the dylibs are pretty big, so copy only the ones we # care about. diff --git a/tools/clang/scripts/update.sh b/tools/clang/scripts/update.sh index 113905c..e730b24 100755 --- a/tools/clang/scripts/update.sh +++ b/tools/clang/scripts/update.sh @@ -19,9 +19,14 @@ CLANG_DIR="${LLVM_DIR}/tools/clang" CLANG_TOOLS_EXTRA_DIR="${CLANG_DIR}/tools/extra" COMPILER_RT_DIR="${LLVM_DIR}/projects/compiler-rt" LIBCXX_DIR="${LLVM_DIR}/projects/libcxx" +LIBCXXABI_DIR="${LLVM_DIR}/projects/libcxxabi" ANDROID_NDK_DIR="${LLVM_DIR}/../android_tools/ndk" STAMP_FILE="${LLVM_BUILD_DIR}/cr_build_revision" +ABS_LIBCXX_DIR="${PWD}/${LIBCXX_DIR}" +ABS_LIBCXXABI_DIR="${PWD}/${LIBCXXABI_DIR}" + + # Use both the clang revision and the plugin revisions to test for updates. BLINKGCPLUGIN_REVISION=\ $(grep LIBRARYNAME "$THIS_DIR"/../blink_gc_plugin/Makefile \ @@ -276,6 +281,14 @@ if [ "${OS}" = "Darwin" ]; then "${LIBCXX_DIR}" fi +# While we're bundling our own libc++ on OS X, we need to compile libc++abi +# into it too (since OS X 10.6 doesn't have libc++abi.dylib either). +if [ "${OS}" = "Darwin" ]; then + echo Getting libc++abi r"${CLANG_REVISION}" in "${LIBCXXABI_DIR}" + svn co --force "${LLVM_REPO_URL}/libcxxabi/trunk@${CLANG_REVISION}" \ + "${LIBCXXABI_DIR}" +fi + # Apply patch for test failing with --disable-pthreads (llvm.org/PR11974) cd "${CLANG_DIR}" svn revert test/Index/crash-recovery-modules.m @@ -957,12 +970,15 @@ export CXXFLAGS="" # needed, on OS X it requires libc++. clang only automatically links to libc++ # when targeting OS X 10.9+, so add stdlib=libc++ explicitly so clang can run on # OS X versions as old as 10.7. -# TODO(thakis): Enable this once all bots are on 10.7, and remove the -# --disable-compiler-version-checks flags below, and change all -# MACOSX_DEPLOYMENT_TARGET values to 10.7. +# TODO(thakis): Some bots are still on 10.6, so for now bundle libc++.dylib. +# Remove this once all bots are on 10.7+, then use --enable-libcpp=yes and +# change all MACOSX_DEPLOYMENT_TARGET values to 10.7. if [ "${OS}" = "Darwin" ]; then - #CXXFLAGS="-stdlib=libc++" - CXXFLAGS="-std=gnu++98" + # When building on 10.9, /usr/include usually doesn't exist, and while + # Xcode's clang automatically sets a sysroot, self-built clangs don't. + export CFLAGS="-isysroot $(xcrun --show-sdk-path)" + export CPPFLAGS="${CFLAGS}" + export CXXFLAGS="-stdlib=libc++ -nostdinc++ -I${ABS_LIBCXX_DIR}/include ${CFLAGS}" fi # Build bootstrap clang if requested. @@ -977,7 +993,6 @@ if [[ -n "${bootstrap}" ]]; then # compiler should be as similar to the final compiler as possible, so do # keep --disable-threads & co. ../llvm/configure \ - --disable-compiler-version-checks \ --enable-optimized \ --enable-targets=host-only \ --enable-libedit=no \ @@ -988,12 +1003,12 @@ if [[ -n "${bootstrap}" ]]; then --prefix="${ABS_INSTALL_DIR}" fi - MACOSX_DEPLOYMENT_TARGET=10.5 ${MAKE} -j"${NUM_JOBS}" + ${MAKE} -j"${NUM_JOBS}" if [[ -n "${run_tests}" ]]; then ${MAKE} check-all fi - MACOSX_DEPLOYMENT_TARGET=10.5 ${MAKE} install + ${MAKE} install if [[ -n "${gcc_toolchain}" ]]; then # Copy that gcc's stdlibc++.so.6 to the build dir, so the bootstrap # compiler can start. @@ -1019,10 +1034,39 @@ fi # The clang bots have this path hardcoded in built/scripts/slave/compile.py, # so if you change it you also need to change these links. mkdir -p "${LLVM_BUILD_DIR}" -cd "${LLVM_BUILD_DIR}" +pushd "${LLVM_BUILD_DIR}" + +# Build libc++.dylib while some bots are still on OS X 10.6. +if [ "${OS}" = "Darwin" ]; then + rm -rf libcxxbuild + LIBCXXFLAGS="-O3 -std=c++11 -fstrict-aliasing" + + # libcxx and libcxxabi both have a file stdexcept.cpp, so put their .o files + # into different subdirectories. + mkdir -p libcxxbuild/libcxx + pushd libcxxbuild/libcxx + c++ -c ${CXXFLAGS} ${LIBCXXFLAGS} "${ABS_LIBCXX_DIR}"/src/*.cpp + popd + + mkdir -p libcxxbuild/libcxxabi + pushd libcxxbuild/libcxxabi + c++ -c ${CXXFLAGS} ${LIBCXXFLAGS} "${ABS_LIBCXXABI_DIR}"/src/*.cpp -I"${ABS_LIBCXXABI_DIR}/include" + popd + + pushd libcxxbuild + cc libcxx/*.o libcxxabi/*.o -o libc++.1.dylib -dynamiclib -nodefaultlibs \ + -current_version 1 -compatibility_version 1 \ + -lSystem -install_name @executable_path/libc++.dylib \ + -Wl,-unexported_symbols_list,${ABS_LIBCXX_DIR}/lib/libc++unexp.exp \ + -Wl,-force_symbols_not_weak_list,${ABS_LIBCXX_DIR}/lib/notweak.exp \ + -Wl,-force_symbols_weak_list,${ABS_LIBCXX_DIR}/lib/weak.exp + ln -sf libc++.1.dylib libc++.dylib + popd + export LDFLAGS+="-stdlib=libc++ -L${PWD}/libcxxbuild" +fi + if [[ ! -f ./config.status ]]; then ../llvm/configure \ - --disable-compiler-version-checks \ --enable-optimized \ --enable-libedit=no \ --disable-threads \ @@ -1042,9 +1086,11 @@ STRIP_FLAGS= if [ "${OS}" = "Darwin" ]; then # See http://crbug.com/256342 STRIP_FLAGS=-x + + cp libcxxbuild/libc++.1.dylib Release+Asserts/bin fi strip ${STRIP_FLAGS} Release+Asserts/bin/clang -cd - +popd if [[ -n "${with_android}" ]]; then # Make a standalone Android toolchain. |