Skip to content
This repository has been archived by the owner on May 21, 2021. It is now read-only.

Commit

Permalink
fix osx compilation, test clang binary
Browse files Browse the repository at this point in the history
Summary:
It turns out that "-s" breaks the osx build. Do not rely on that for stripping
but still pass it when supported as it will be cheaper to copy over
already-stripped libraries and binaries.

Add console messages before long silent steps.

Test the built and the installed clang to make sure we don't proceed
successfully if something went wrong.

Test Plan: `./clang/setup.sh`

Reviewers: ryanrhee, akotulski

Reviewed By: ryanrhee, akotulski

Subscribers: mathieubaudet

Differential Revision: https://phabricator.intern.facebook.com/D4635124

Tasks: 16339929

Signature: t1:4635124:1488381259:c5cfd2e8e358ecf5861ae8ee19a69d572dc7ecb7
  • Loading branch information
jvillard committed Mar 1, 2017
1 parent ea9ad9f commit a340f3d
Showing 1 changed file with 23 additions and 4 deletions.
27 changes: 23 additions & 4 deletions clang/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,6 @@ platform=`uname`
CMAKE_ARGS=(
-DCMAKE_INSTALL_PREFIX="$CLANG_PREFIX"
-DCMAKE_BUILD_TYPE=Release
-DCMAKE_C_FLAGS="$CMAKE_C_FLAGS -s"
-DCMAKE_CXX_FLAGS="$CMAKE_CXX_FLAGS -s"
-DLLVM_ENABLE_ASSERTIONS=Off
-DLLVM_ENABLE_EH=On
-DLLVM_ENABLE_RTTI=On
Expand All @@ -99,15 +97,19 @@ if [ "$platform" = "Darwin" ]; then
CMAKE_ARGS+=(
-DLLVM_ENABLE_LIBCXX=On
-DCMAKE_SHARED_LINKER_FLAGS="$CMAKE_SHARED_LINKER_FLAGS"
# adding -s to the C{,XX} flags breaks the compilation on osx
-DCMAKE_C_FLAGS="$CMAKE_C_FLAGS"
-DCMAKE_CXX_FLAGS="$CMAKE_CXX_FLAGS"
)
else
CMAKE_ARGS+=(
-DCMAKE_SHARED_LINKER_FLAGS="-lstdc++ $CMAKE_SHARED_LINKER_FLAGS"
-DCMAKE_C_FLAGS="-s $CMAKE_C_FLAGS"
-DCMAKE_CXX_FLAGS="-s $CMAKE_CXX_FLAGS"
)
fi

# start the installation
echo "Installing clang..."
if [ -n "$CLANG_TMP_DIR" ]; then
TMP=$CLANG_TMP_DIR
else
Expand All @@ -119,6 +121,7 @@ if tar --version | grep -q 'GNU'; then
# GNU tar is too verbose if the tarball was created on MacOS
QUIET_TAR="--warning=no-unknown-keyword"
fi
echo "unpacking '$CLANG_SRC'..."
tar --extract $QUIET_TAR --file "$CLANG_SRC"

mkdir build
Expand All @@ -131,11 +134,27 @@ cmake -G "Unix Makefiles" ../llvm "${CMAKE_ARGS[@]}" $CLANG_CMAKE_ARGS

JOBS="$(getconf _NPROCESSORS_ONLN 2>/dev/null || echo 1)"

make -j $JOBS && make -j $JOBS install
make -j $JOBS

echo "testing clang build"
./bin/clang --version

make -j $JOBS install

popd # build
popd # $TMP

# brutally strip everything, ignore errors
set +e
find "$CLANG_PREFIX"/{bin,lib} -type f \
\( -name '*.so' -o -name '*.so.*' -o -name '*.a' \) \
-exec strip -x \{\} \+
set -e

echo "testing installed clang"
"$CLANG_PREFIX"/bin/clang --version

echo "deleting temp dir '$CLANG_TMP_DIR'..."
if [ -n "$CLANG_TMP_DIR" ]; then
rm -rf "$TMP/*"
else
Expand Down

0 comments on commit a340f3d

Please sign in to comment.