From 03f1fd6c6586413c83601ea87b352ad6dce63430 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Storsj=C3=B6?= Date: Mon, 9 Oct 2017 10:54:33 +0300 Subject: [PATCH] Use dwarf exceptions on armv7 and aarch64 Dwarf is also the default in clang on i686, but libunwind currently has an issue relating to unwinding dwarf exceptions on i686 on windows (and less easily reproducible on other platforms), see https://reviews.llvm.org/D38680. This enables exceptions on aarch64, where they previously were avoided/disabled. When linking to a statically linked libunwind with support for dwarf, one (currently) has to link in -lpsapi. --- Dockerfile | 24 ++++++------------------ README.md | 3 --- wrappers/clang-target-wrapper | 6 +++--- 3 files changed, 9 insertions(+), 24 deletions(-) diff --git a/Dockerfile b/Dockerfile index 18c782f..cb5e541 100644 --- a/Dockerfile +++ b/Dockerfile @@ -159,12 +159,6 @@ RUN git clone -b master https://github.com/llvm-mirror/libcxx.git && \ RUN cd libcxxabi && \ for arch in armv7 aarch64 i686 x86_64; do \ - EXCEPTIONS=ON && \ - case $arch in \ - aarch64) \ - EXCEPTIONS=OFF \ - ;; \ - esac && \ mkdir build-$arch && cd build-$arch && cmake \ -DCMAKE_BUILD_TYPE=Release \ -DCMAKE_INSTALL_PREFIX=$TOOLCHAIN_PREFIX/$arch-w64-mingw32 \ @@ -177,7 +171,7 @@ RUN cd libcxxabi && \ -DCMAKE_AR=$TOOLCHAIN_PREFIX/bin/llvm-ar \ -DCMAKE_RANLIB=$TOOLCHAIN_PREFIX/bin/llvm-ranlib \ -DLIBCXXABI_USE_COMPILER_RT=ON \ - -DLIBCXXABI_ENABLE_EXCEPTIONS=$EXCEPTIONS \ + -DLIBCXXABI_ENABLE_EXCEPTIONS=ON \ -DLIBCXXABI_ENABLE_THREADS=ON \ -DLIBCXXABI_TARGET_TRIPLE=$arch-w64-mingw32 \ -DLIBCXXABI_ENABLE_SHARED=OFF \ @@ -192,12 +186,6 @@ RUN cd libcxxabi && \ RUN cd libcxx && \ for arch in armv7 aarch64 i686 x86_64; do \ - EXCEPTIONS=ON && \ - case $arch in \ - aarch64) \ - EXCEPTIONS=OFF \ - ;; \ - esac && \ mkdir build-$arch && cd build-$arch && cmake \ -DCMAKE_BUILD_TYPE=Release \ -DCMAKE_INSTALL_PREFIX=$TOOLCHAIN_PREFIX/$arch-w64-mingw32 \ @@ -211,7 +199,7 @@ RUN cd libcxx && \ -DCMAKE_RANLIB=$TOOLCHAIN_PREFIX/bin/llvm-ranlib \ -DLIBCXX_USE_COMPILER_RT=ON \ -DLIBCXX_INSTALL_HEADERS=ON \ - -DLIBCXX_ENABLE_EXCEPTIONS=$EXCEPTIONS \ + -DLIBCXX_ENABLE_EXCEPTIONS=ON \ -DLIBCXX_ENABLE_THREADS=ON \ -DLIBCXX_ENABLE_MONOTONIC_CLOCK=ON \ -DLIBCXX_ENABLE_SHARED=OFF \ @@ -232,7 +220,7 @@ RUN cd libcxx && \ RUN cd $TOOLCHAIN_PREFIX/include && ln -s ../armv7-w64-mingw32/include/c++ . RUN cd libunwind && \ - for arch in armv7 i686 x86_64; do \ + for arch in armv7 aarch64 i686 x86_64; do \ mkdir build-$arch && cd build-$arch && cmake \ -DCMAKE_BUILD_TYPE=Release \ -DCMAKE_INSTALL_PREFIX=$TOOLCHAIN_PREFIX/$arch-w64-mingw32 \ @@ -268,12 +256,12 @@ RUN cd hello && \ RUN cd hello && \ for arch in armv7 aarch64 x86_64 i686; do \ - $arch-w64-mingw32-clang++ hello.cpp -o hello-cpp-$arch.exe -fno-exceptions || exit 1; \ + $arch-w64-mingw32-clang++ hello.cpp -o hello-cpp-$arch.exe -fno-exceptions -lpsapi || exit 1; \ done RUN cd hello && \ - for arch in armv7 x86_64 i686; do \ - $arch-w64-mingw32-clang++ hello-exception.cpp -o hello-exception-$arch.exe || exit 1; \ + for arch in armv7 aarch64 x86_64 i686; do \ + $arch-w64-mingw32-clang++ hello-exception.cpp -o hello-exception-$arch.exe -lpsapi || exit 1; \ done ENV AR=llvm-ar diff --git a/README.md b/README.md index e2013aa..6ae1687 100644 --- a/README.md +++ b/README.md @@ -68,9 +68,6 @@ normal GCC/binutils based MinGW. the dllimport attributes. - The C++ libraries ([libcxxabi](http://libcxxabi.llvm.org/), [libcxx](http://libcxx.llvm.org/)) can only be linked statically at the moment. -- The C++ libraries and unwinder aren't built with exceptions support for - ARM64 target at the moment. (The toolchain and libraries themselves do - support it though.) - The ARM64 target doesn't support thread local variables. Additionally, one may run into other minor differences between GCC and clang. diff --git a/wrappers/clang-target-wrapper b/wrappers/clang-target-wrapper index 87fbad8..15dc12a 100755 --- a/wrappers/clang-target-wrapper +++ b/wrappers/clang-target-wrapper @@ -5,11 +5,11 @@ EXE=$(basename $0 | sed 's/.*-\(clang.*\)/\1/') # We could set these defaults in the clang frontend driver, but that's not yet merged upstream ARCH=$(echo $TARGET | sed 's/-.*//') case $ARCH in -i686|x86_64|armv7) +i686|x86_64) EH_FLAG=-fsjlj-exceptions ;; -aarch64) - EH_FLAG=-fno-exceptions +armv7|aarch64) + EH_FLAG= ;; esac $DIR/$EXE -target $TARGET -rtlib=compiler-rt -stdlib=libc++ -fuse-ld=lld $EH_FLAG -Qunused-arguments "$@"