Files
llvm-mingw/build-libcxx.sh
T
Martin Storsjö c1f96ba002 Add -nostdinc++ when building libunwind
If the libcxx headers already have been installed, adding
-I$LIBCXX/include to the include path breaks some C standard
headers. The libcxx installation provides e.g. stdlib.h, which
does an #include_next <stdlib.h>. If the include path includes
both $LIBCXX/include and the libcxx headers installed to the
target sysroot, the #include_next will pick up the same header
from the next include directory. And due to include guards,
the second inclusion of the libcxx version of the header does
nothing at all, instead of doing yet another #include_next for
picking up the real version of the header.

By adding -nostdinc++, we avoid the possibly installed version
of these headers.

This fixes rebuilding libunwind after libcxx has been built
and installed.
2018-01-10 10:50:17 +02:00

143 lines
4.5 KiB
Bash
Executable File

#!/bin/sh
set -e
if [ $# -lt 1 ]; then
echo $0 dest
exit 1
fi
PREFIX="$1"
export PATH=$PREFIX/bin:$PATH
: ${CORES:=4}
: ${ARCHS:=${TOOLCHAIN_ARCHS-i686 x86_64 armv7 aarch64}}
if [ ! -d libunwind ]; then
git clone -b master https://github.com/llvm-mirror/libunwind.git
cd libunwind
git checkout 2ddcf2461daa5d61c543474aed06b12a8b9ad816
cd ..
fi
if [ ! -d libcxxabi ]; then
git clone -b master https://github.com/llvm-mirror/libcxxabi.git
cd libcxxabi
git checkout 05ba3281482304ae8de31123a594972a495da06d
cd ..
fi
if [ ! -d libcxx ]; then
git clone -b master https://github.com/llvm-mirror/libcxx.git
cd libcxx
git checkout 16eb426933cdb1c54fd6fbba5fc06cc5a4ca52b3
cd ..
fi
LIBCXX=$(pwd)/libcxx
MERGE_ARCHIVES=$(pwd)/merge_archives.sh
cd libunwind
for arch in $ARCHS; do
mkdir -p build-$arch
cd build-$arch
cmake \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX=$PREFIX/$arch-w64-mingw32 \
-DCMAKE_C_COMPILER=$arch-w64-mingw32-clang \
-DCMAKE_CXX_COMPILER=$arch-w64-mingw32-clang++ \
-DCMAKE_CROSSCOMPILING=TRUE \
-DCMAKE_SYSTEM_NAME=Windows \
-DCMAKE_C_COMPILER_WORKS=TRUE \
-DCMAKE_CXX_COMPILER_WORKS=TRUE \
-DCMAKE_AR=$PREFIX/bin/llvm-ar \
-DCMAKE_RANLIB=$PREFIX/bin/llvm-ranlib \
-DLLVM_NO_OLD_LIBSTDCXX=TRUE \
-DCXX_SUPPORTS_CXX11=TRUE \
-DLIBUNWIND_USE_COMPILER_RT=TRUE \
-DLIBUNWIND_ENABLE_THREADS=TRUE \
-DLIBUNWIND_ENABLE_SHARED=FALSE \
-DLIBUNWIND_ENABLE_CROSS_UNWINDING=FALSE \
-DCMAKE_CXX_FLAGS="-nostdinc++ -I$LIBCXX/include" \
..
make -j$CORES
make install
# Merge libpsapi.a into the static library libunwind.a, to
# avoid having to specify -lpsapi when linking to it.
$MERGE_ARCHIVES \
$PREFIX/$arch-w64-mingw32/lib/libunwind.a \
$PREFIX/$arch-w64-mingw32/lib/libpsapi.a
cd ..
done
cd ..
cd libcxxabi
for arch in $ARCHS; do
mkdir -p build-$arch
cd build-$arch
cmake \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX=$PREFIX/$arch-w64-mingw32 \
-DCMAKE_C_COMPILER=$arch-w64-mingw32-clang \
-DCMAKE_CXX_COMPILER=$arch-w64-mingw32-clang++ \
-DCMAKE_CROSSCOMPILING=TRUE \
-DCMAKE_SYSTEM_NAME=Windows \
-DCMAKE_C_COMPILER_WORKS=TRUE \
-DCMAKE_CXX_COMPILER_WORKS=TRUE \
-DCMAKE_AR=$PREFIX/bin/llvm-ar \
-DCMAKE_RANLIB=$PREFIX/bin/llvm-ranlib \
-DLIBCXXABI_USE_COMPILER_RT=ON \
-DLIBCXXABI_ENABLE_EXCEPTIONS=ON \
-DLIBCXXABI_ENABLE_THREADS=ON \
-DLIBCXXABI_TARGET_TRIPLE=$arch-w64-mingw32 \
-DLIBCXXABI_ENABLE_SHARED=OFF \
-DLIBCXXABI_LIBCXX_INCLUDES=../../libcxx/include \
-DLLVM_NO_OLD_LIBSTDCXX=TRUE \
-DCXX_SUPPORTS_CXX11=TRUE \
-DCMAKE_CXX_FLAGS="-D_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS" \
..
make -j$CORES
cd ..
done
cd ..
cd libcxx
for arch in $ARCHS; do
mkdir -p build-$arch
cd build-$arch
cmake \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX=$PREFIX/$arch-w64-mingw32 \
-DCMAKE_C_COMPILER=$arch-w64-mingw32-clang \
-DCMAKE_CXX_COMPILER=$arch-w64-mingw32-clang++ \
-DCMAKE_CROSSCOMPILING=TRUE \
-DCMAKE_SYSTEM_NAME=Windows \
-DCMAKE_C_COMPILER_WORKS=TRUE \
-DCMAKE_CXX_COMPILER_WORKS=TRUE \
-DCMAKE_AR=$PREFIX/bin/llvm-ar \
-DCMAKE_RANLIB=$PREFIX/bin/llvm-ranlib \
-DLIBCXX_USE_COMPILER_RT=ON \
-DLIBCXX_INSTALL_HEADERS=ON \
-DLIBCXX_ENABLE_EXCEPTIONS=ON \
-DLIBCXX_ENABLE_THREADS=ON \
-DLIBCXX_HAS_WIN32_THREAD_API=ON \
-DLIBCXX_ENABLE_MONOTONIC_CLOCK=ON \
-DLIBCXX_ENABLE_SHARED=OFF \
-DLIBCXX_SUPPORTS_STD_EQ_CXX11_FLAG=TRUE \
-DLIBCXX_HAVE_CXX_ATOMICS_WITHOUT_LIB=TRUE \
-DLIBCXX_ENABLE_EXPERIMENTAL_LIBRARY=OFF \
-DLIBCXX_ENABLE_FILESYSTEM=OFF \
-DLIBCXX_ENABLE_STATIC_ABI_LIBRARY=TRUE \
-DLIBCXX_CXX_ABI=libcxxabi \
-DLIBCXX_CXX_ABI_INCLUDE_PATHS=../../libcxxabi/include \
-DLIBCXX_CXX_ABI_LIBRARY_PATH=../../libcxxabi/build-$arch/lib \
-DCMAKE_CXX_FLAGS="-D_LIBCXXABI_DISABLE_VISIBILITY_ANNOTATIONS" \
..
make -j$CORES
make install
$MERGE_ARCHIVES \
$PREFIX/$arch-w64-mingw32/lib/libc++.a \
$PREFIX/$arch-w64-mingw32/lib/libunwind.a
cd ..
done
cd ..
ln -sf ../$(echo $ARCHS | awk '{print $1}')-w64-mingw32/include/c++ $PREFIX/include/c++