From 2cb6a8d390dde0b55bf0883cef42f7fcbd42326a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Storsj=C3=B6?= Date: Tue, 21 Nov 2017 11:55:26 +0200 Subject: [PATCH] Set the flags for exception handling model in the clang wrapper --- Dockerfile | 12 +++--------- wrappers/clang-target-wrapper | 11 ++++++++++- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/Dockerfile b/Dockerfile index 937bab9..6d5616d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -159,11 +159,9 @@ RUN git clone -b master https://github.com/llvm-mirror/libcxx.git && \ RUN cd libcxxabi && \ for arch in armv7 aarch64 i686 x86_64; do \ - CXX_FLAG="-fsjlj-exceptions" && \ EXCEPTIONS=ON && \ case $arch in \ aarch64) \ - CXX_FLAG="-fno-exceptions" \ EXCEPTIONS=OFF \ ;; \ esac && \ @@ -186,7 +184,7 @@ RUN cd libcxxabi && \ -DLIBCXXABI_LIBCXX_INCLUDES=../../libcxx/include \ -DLLVM_NO_OLD_LIBSTDCXX=TRUE \ -DCXX_SUPPORTS_CXX11=TRUE \ - -DCMAKE_CXX_FLAGS="$CXX_FLAG -D_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS" \ + -DCMAKE_CXX_FLAGS="-D_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS" \ .. && \ make -j4 && \ cd .. || exit 1; \ @@ -194,11 +192,9 @@ RUN cd libcxxabi && \ RUN cd libcxx && \ for arch in armv7 aarch64 i686 x86_64; do \ - CXX_FLAG="-fsjlj-exceptions" && \ EXCEPTIONS=ON && \ case $arch in \ aarch64) \ - CXX_FLAG="-fno-exceptions" \ EXCEPTIONS=OFF \ ;; \ esac && \ @@ -227,7 +223,7 @@ RUN cd libcxx && \ -DLIBCXX_CXX_ABI=libcxxabi \ -DLIBCXX_CXX_ABI_INCLUDE_PATHS=../../libcxxabi/include \ -DLIBCXX_CXX_ABI_LIBRARY_PATH=../../libcxxabi/build-$arch/lib \ - -DCMAKE_CXX_FLAGS="$CXX_FLAG -D_LIBCXXABI_DISABLE_VISIBILITY_ANNOTATIONS" \ + -DCMAKE_CXX_FLAGS="-D_LIBCXXABI_DISABLE_VISIBILITY_ANNOTATIONS" \ .. && \ make -j4 && make install && \ cd .. || exit 1; \ @@ -253,8 +249,6 @@ RUN cd libunwind && \ -DLIBUNWIND_ENABLE_THREADS=TRUE \ -DLIBUNWIND_ENABLE_SHARED=FALSE \ -DLIBUNWIND_ENABLE_CROSS_UNWINDING=FALSE \ - -DCMAKE_CXX_FLAGS="-fsjlj-exceptions -D__USING_SJLJ_EXCEPTIONS__" \ - -DCMAKE_C_FLAGS="-D__USING_SJLJ_EXCEPTIONS__" \ .. && \ make -j4 && make install && \ ../../libcxx/utils/merge_archives.py \ @@ -279,7 +273,7 @@ RUN cd /build/hello && \ RUN cd /build/hello && \ for arch in armv7 x86_64 i686; do \ - $arch-w64-mingw32-clang++ hello-exception.cpp -o hello-exception-$arch.exe -fsjlj-exceptions || exit 1; \ + $arch-w64-mingw32-clang++ hello-exception.cpp -o hello-exception-$arch.exe || exit 1; \ done ENV AR=llvm-ar diff --git a/wrappers/clang-target-wrapper b/wrappers/clang-target-wrapper index 6319b7b..87fbad8 100755 --- a/wrappers/clang-target-wrapper +++ b/wrappers/clang-target-wrapper @@ -3,4 +3,13 @@ DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" TARGET="$(basename $0 | sed 's/-clang.*//')" EXE=$(basename $0 | sed 's/.*-\(clang.*\)/\1/') # We could set these defaults in the clang frontend driver, but that's not yet merged upstream -$DIR/$EXE -target $TARGET -rtlib=compiler-rt -stdlib=libc++ -fuse-ld=lld -Qunused-arguments "$@" +ARCH=$(echo $TARGET | sed 's/-.*//') +case $ARCH in +i686|x86_64|armv7) + EH_FLAG=-fsjlj-exceptions + ;; +aarch64) + EH_FLAG=-fno-exceptions + ;; +esac +$DIR/$EXE -target $TARGET -rtlib=compiler-rt -stdlib=libc++ -fuse-ld=lld $EH_FLAG -Qunused-arguments "$@"