changeset 367:8c3b3f637811

dev/llvm: add more options to improve bootstrapping
author David Demelier <markand@malikania.fr>
date Sat, 30 Mar 2019 14:20:51 +0100
parents 17a538fc8c8a
children f25628c80479
files dev/clang/clang.sh dev/lld/lld.sh dev/llvm/llvm.sh lib/libc++/libc++.sh lib/libc++abi/libc++abi.sh lib/libunwind/libunwind.sh lib/openmp/openmp.sh
diffstat 7 files changed, 105 insertions(+), 35 deletions(-) [+]
line wrap: on
line diff
--- a/dev/clang/clang.sh	Sat Mar 30 13:12:34 2019 +0100
+++ b/dev/clang/clang.sh	Sat Mar 30 14:20:51 2019 +0100
@@ -21,11 +21,30 @@
 PKGLICENSE="MIT CUSTOM"
 PKGSUMMARY="C language family frontend for LLVM"
 PKGDOWNLOAD="http://releases.llvm.org/$PKGVERSION/cfe-$PKGVERSION.src.tar.xz"
+PKGDEPENDS="dev/ninja:build"
+PKGOPTIONS="COMPILER_RT LIBCXX LLD"
 
 : ${CC:=clang}
 : ${CFLAGS:=-O2}
 : ${CXX:=clang++}
 : ${CXXFLAGS:=-O2}
+: ${COMPILER_RT:=yes}
+: ${LIBCXX:=yes}
+: ${LLD:=yes}
+
+if [ "$COMPILER_RT" = "yes" ]; then
+	with_compiler_rt="-DCLANG_DEFAULT_RTLIB=compiler-rt"
+fi
+
+if [ "$LIBCXX" = "yes" ]; then
+	with_libcxx="-DCLANG_DEFAULT_CXX_STDLIB=libc++"
+else
+	with_libcxx="-DCLANG_DEFAULT_CXX_STDLIB=libstdc++"
+fi
+
+if [ "$LLD" = "yes" ]; then
+	with_lld="-DCLANG_DEFAULT_LINKER=lld"
+fi
 
 build()
 {
@@ -35,20 +54,19 @@
 
 	mkdir build && pushd build
 	cmake .. \
-		-DBUILD_SHARED_LIBS=On \
 		-DCMAKE_BUILD_TYPE=Release \
 		-DCMAKE_CXX_COMPILER="$CXX" \
 		-DCMAKE_CXX_FLAGS="$CXXFLAGS" \
 		-DCMAKE_C_COMPILER="$CC" \
 		-DCMAKE_C_FLAGS="$CFLAGS" \
 		-DCMAKE_INSTALL_PREFIX=/usr \
-		-DCLANG_DEFAULT_CXX_STDLIB=libc++ \
-		-DCLANG_DEFAULT_LINKER=lld \
-		-DCLANG_DEFAULT_RTLIB=compiler-rt \
 		-DCLANG_VENDOR="Vanilla Linux" \
-		-DCLANG_VENDOR_UTI="https://redmine.malikania.fr/projects/vanilla"
-	make
-	make install DESTDIR=$DESTDIR
+		$with_compiler_rt \
+		$with_libcxx \
+		$with_lld \
+		-GNinja
+	ninja
+	DESTDIR=$DESTDIR ninja install
 	popd
 
 	popd
--- a/dev/lld/lld.sh	Sat Mar 30 13:12:34 2019 +0100
+++ b/dev/lld/lld.sh	Sat Mar 30 14:20:51 2019 +0100
@@ -21,6 +21,7 @@
 PKGLICENSE="MIT CUSTOM"
 PKGSUMMARY="LLVM's linker"
 PKGDOWNLOAD="http://releases.llvm.org/$PKGVERSION/$PKGNAME-$PKGVERSION.src.tar.xz"
+PKGDEPENDS="dev/ninja:build"
 
 : ${CC:=clang}
 : ${CFLAGS:=-O2}
@@ -34,16 +35,16 @@
 	pushd $PKGNAME-$PKGVERSION.src
 
 	mkdir build && pushd build
-	cmake .. \
-		-DBUILD_SHARED_LIBS=On \
+	cmake .. -Wno-dev \
 		-DCMAKE_BUILD_TYPE=Release \
 		-DCMAKE_CXX_COMPILER="$CXX" \
 		-DCMAKE_CXX_FLAGS="$CXXFLAGS" \
 		-DCMAKE_C_COMPILER="$CC" \
 		-DCMAKE_C_FLAGS="$CFLAGS" \
-		-DCMAKE_INSTALL_PREFIX=/usr
-	make
-	make install DESTDIR=$DESTDIR
+		-DCMAKE_INSTALL_PREFIX=/usr \
+		-GNinja
+	ninja
+	DESTDIR=$DESTDIR ninja install
 	popd
 
 	popd
--- a/dev/llvm/llvm.sh	Sat Mar 30 13:12:34 2019 +0100
+++ b/dev/llvm/llvm.sh	Sat Mar 30 14:20:51 2019 +0100
@@ -21,8 +21,8 @@
 PKGLICENSE="MIT CUSTOM"
 PKGSUMMARY="low level virtual machine compiler infrastructure"
 PKGDOWNLOAD="http://releases.llvm.org/$PKGVERSION/$PKGNAME-$PKGVERSION.src.tar.xz"
-PKGDEPENDS="python/python lib/zlib"
-PKGOPTIONS="DOXYGEN SPHINX"
+PKGDEPENDS="python/python lib/zlib dev/ninja:build"
+PKGOPTIONS="DOXYGEN LIBCXX LLD SPHINX STATIC TARGETS"
 
 : ${CHOST:=$(uname -m)-linux-musl}
 : ${CC:=clang}
@@ -30,20 +30,42 @@
 : ${CXX:=clang++}
 : ${CXXFLAGS:=-O2}
 : ${DOXYGEN:=yes}
+: ${LIBCXX:=yes}
+: ${LLD:=yes}
 : ${SPHINX:=yes}
+: ${STATIC:=no}
+: ${TARGETS:=all}
+
+if [ "$LIBCXX" = "yes" ]; then
+	with_libcxx="-DLLVM_ENABLE_LIBCXX=On"
+else
+	with_libcxx="-DLLVM_ENABLE_LIBCXX=Off"
+fi
+
+if [ "$LLD" = "yes" ]; then
+	with_lld="-DLLVM_ENABLE_LLD=On"
+else
+	with_lld="-DLLVM_ENABLE_LLD=Off"
+fi
 
 if [ "$DOXYGEN" = "yes" ]; then
 	PKGDEPENDS="dev/doxygen $PKGDEPENDS"
-	with_doxygen="On"
+	with_doxygen="-DLLVM_ENABLE_DOXYGEN=On"
 else
-	with_doxygen="Off"
+	with_doxygen="-DLLVM_ENABLE_DOXYGEN=Off"
 fi
 
 if [ "$SPHINX" = "yes" ]; then
 	PKGDEPENDS="dev/sphinx $PKGDEPENDS"
-	with_sphinx="On"
+	with_sphinx="-DLLVM_ENABLE_SPHINX=On"
 else
-	with_sphinx="Off"
+	with_sphinx="-DLLVM_ENABLE_SPHINX=Off"
+fi
+
+if [ "$STATIC" = "yes" ]; then
+	with_static="-DLLVM_BUILD_LLVM_DYLIB=Off"
+else
+	with_static="-DLLVM_BUILD_LLVM_DYLIB=On"
 fi
 
 build()
@@ -55,21 +77,23 @@
 	mkdir build && pushd build
 	cmake .. \
 		-DCMAKE_BUILD_TYPE=Release \
-		-DBUILD_SHARED_LIBS=On \
 		-DCMAKE_INSTALL_PREFIX=/usr \
 		-DCMAKE_C_COMPILER="$CC" \
 		-DCMAKE_C_FLAGS="$CFLAGS" \
 		-DCMAKE_CXX_COMPILER="$CXX" \
 		-DCMAKE_CXX_FLAGS="$CXXFLAGS" \
-		-DLLVM_ENABLE_DOXYGEN=$with_doxygen \
 		-DLLVM_ENABLE_EH=On \
-		-DLLVM_ENABLE_LIBCXX=On \
-		-DLLVM_ENABLE_LLD=On \
 		-DLLVM_ENABLE_RTTI=On \
-		-DLLVM_ENABLE_SPHINX=$with_sphinx \
-		-DLLVM_HOST_TRIPLE=$CHOST
-	make
-	make install DESTDIR=$DESTDIR
+		-DLLVM_HOST_TRIPLE=$CHOST \
+		-DLLVM_TARGETS_TO_BUILD=$TARGETS \
+		$with_static \
+		$with_doxygen \
+		$with_libcxx \
+		$with_lld \
+		$with_sphinx \
+		-GNinja
+	ninja
+	DESTDIR=$DESTDIR ninja install
 	popd
 
 	popd
--- a/lib/libc++/libc++.sh	Sat Mar 30 13:12:34 2019 +0100
+++ b/lib/libc++/libc++.sh	Sat Mar 30 14:20:51 2019 +0100
@@ -21,11 +21,27 @@
 PKGLICENSE="MIT CUSTOM"
 PKGSUMMARY="C++ standard library from LLVM"
 PKGDOWNLOAD="http://releases.llvm.org/$PKGVERSION/libcxx-$PKGVERSION.src.tar.xz"
+PKGOPTIONS="ABI COMPILER_RT LIBUNWIND"
 
 : ${CC:=clang}
 : ${CFLAGS:=-O2}
 : ${CXX:=clang++}
 : ${CXXFLAGS:=-O2}
+: ${ABI:=libcxxabi}
+: ${COMPILER_RT:=yes}
+: ${LIBUNWIND:=yes}
+
+if [ "$COMPILER_RT" = "yes" ]; then
+	with_compiler_rt="-DLIBCXX_USE_COMPILER_RT=On"
+else
+	with_compiler_rt="-DLIBCXX_USE_COMPILER_RT=Off"
+fi
+
+if [ "$LIBUNWIND" = "yes" ]; then
+	with_libunwind="-DLIBCXXABI_USE_LLVM_UNWINDER=On"
+else
+	with_libunwind="-DLIBCXXABI_USE_LLVM_UNWINDER=Off"
+fi
 
 build()
 {
@@ -42,11 +58,10 @@
 		-DCMAKE_C_COMPILER="$CC" \
 		-DCMAKE_C_FLAGS="$CFLAGS" \
 		-DCMAKE_INSTALL_PREFIX=/usr \
-		-DLIBCXX_CXX_ABI=libcxxabi \
-		-DLIBCXX_USE_COMPILER_RT=On \
+		-DLIBCXX_CXX_ABI=$ABI \
 		-DLIBCXX_HAS_MUSL_LIBC=On \
-		-DLIBCXX_ENABLE_STATIC=Off \
-		-DLIBCXXABI_USE_LLVM_UNWINDER=On
+		$with_compiler_rt \
+		$with_libunwind
 	make
 	make install DESTDIR=$DESTDIR
 	popd
--- a/lib/libc++abi/libc++abi.sh	Sat Mar 30 13:12:34 2019 +0100
+++ b/lib/libc++abi/libc++abi.sh	Sat Mar 30 14:20:51 2019 +0100
@@ -21,11 +21,26 @@
 PKGLICENSE="MIT CUSTOM"
 PKGSUMMARY="low level support for the standard C++ library"
 PKGDOWNLOAD="http://releases.llvm.org/$PKGVERSION/libcxxabi-$PKGVERSION.src.tar.xz"
+PKGOPTIONS="COMPILER_RT LIBUNWIND"
 
 : ${CC:=clang}
 : ${CFLAGS:=-O2}
 : ${CXX:=clang++}
 : ${CXXFLAGS:=-O2}
+: ${COMPILER_RT:=yes}
+: ${LIBUNWIND:=yes}
+
+if [ "$COMPILER_RT" = "yes" ]; then
+	with_compiler_rt="-DLIBCXXABI_USE_COMPILER_RT=Off"
+else
+	with_compiler_rt="-DLIBCXXABI_USE_COMPILER_RT=On"
+fi
+
+if [ "$LIBUNWIND" = "yes" ]; then
+	with_libunwind="-DLIBCXXABI_USE_LLVM_UNWINDER=On"
+else
+	with_libunwind="-DLIBCXXABI_USE_LLVM_UNWINDER=Off"
+fi
 
 build()
 {
@@ -43,9 +58,8 @@
 		-DCMAKE_C_FLAGS="$CFLAGS" \
 		-DCMAKE_INSTALL_PREFIX=/usr \
 		-DLIBCXXABI_LIBCXX_INCLUDES=/usr/include/c++/v1 \
-		-DLIBCXXABI_USE_COMPILER_RT=On \
-		-DLIBCXXABI_USE_LLVM_UNWINDER=On \
-		-DLIBCXXABI_ENABLE_STATIC=Off
+		$with_compiler_rt \
+		$with_libunwind
 	make
 	make install DESTDIR=$DESTDIR
 	mkdir -p $DESTDIR/usr/include
--- a/lib/libunwind/libunwind.sh	Sat Mar 30 13:12:34 2019 +0100
+++ b/lib/libunwind/libunwind.sh	Sat Mar 30 14:20:51 2019 +0100
@@ -42,7 +42,6 @@
 		-DCMAKE_C_COMPILER="$CC" \
 		-DCMAKE_C_FLAGS="$CFLAGS" \
 		-DCMAKE_INSTALL_PREFIX=/usr \
-		-DLIBUNWIND_ENABLE_STATIC=Off \
 		-DLIBUNWIND_USE_COMPILER_RT=On
 	make
 	make install DESTDIR=$DESTDIR
--- a/lib/openmp/openmp.sh	Sat Mar 30 13:12:34 2019 +0100
+++ b/lib/openmp/openmp.sh	Sat Mar 30 14:20:51 2019 +0100
@@ -35,7 +35,6 @@
 
 	mkdir build && pushd build
 	cmake .. \
-		-DBUILD_SHARED_LIBS=On \
 		-DCMAKE_BUILD_TYPE=Release \
 		-DCMAKE_CXX_COMPILER="$CXX" \
 		-DCMAKE_CXX_FLAGS="$CXXFLAGS" \