Created
May 20, 2019 10:12
-
-
Save retrage/86f78ba107366e5131d8dc4bc6f25dba to your computer and use it in GitHub Desktop.
frankenlibc++
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
From f5a7768da347fed4acbe389ec01817f6a6b7ee2a Mon Sep 17 00:00:00 2001 | |
From: Akira Moroo <retrage01@gmail.com> | |
Date: Mon, 20 May 2019 13:13:27 +0900 | |
Subject: [PATCH 1/4] Add gitignore for src/tools | |
Signed-off-by: Akira Moroo <retrage01@gmail.com> | |
--- | |
.gitignore | 3 +++ | |
src/tools/.gitignore | 12 ++++++++++++ | |
src/tools/awk/.gitignore | 3 +++ | |
src/tools/compat/.gitignore | 7 +++++++ | |
src/tools/config/.gitignore | 4 ++++ | |
src/tools/host-mkdep/.gitignore | 4 ++++ | |
src/tools/lex/.gitignore | 5 +++++ | |
src/tools/m4/.gitignore | 4 ++++ | |
src/tools/mandoc/.gitignore | 3 +++ | |
9 files changed, 45 insertions(+) | |
create mode 100644 src/tools/.gitignore | |
create mode 100644 src/tools/awk/.gitignore | |
create mode 100644 src/tools/compat/.gitignore | |
create mode 100644 src/tools/config/.gitignore | |
create mode 100644 src/tools/host-mkdep/.gitignore | |
create mode 100644 src/tools/lex/.gitignore | |
create mode 100644 src/tools/m4/.gitignore | |
create mode 100644 src/tools/mandoc/.gitignore | |
diff --git a/.gitignore b/.gitignore | |
index 6df5951b..ee25917e 100644 | |
--- a/.gitignore | |
+++ b/.gitignore | |
@@ -2,3 +2,6 @@ | |
/rumpobj/ | |
*.core | |
ktrace.out | |
+.depend | |
+*.d | |
+*.lo | |
diff --git a/src/tools/.gitignore b/src/tools/.gitignore | |
new file mode 100644 | |
index 00000000..4c5bb677 | |
--- /dev/null | |
+++ b/src/tools/.gitignore | |
@@ -0,0 +1,12 @@ | |
+binstall/xinstall | |
+cat/cat | |
+genassym/genassym | |
+join/join | |
+lorder/lorder | |
+mkdep/mkdep | |
+mktemp/mktemp | |
+rpcgen/rpcgen | |
+sed/sed | |
+stat/stat | |
+tsort/tsort | |
+yacc/yacc | |
diff --git a/src/tools/awk/.gitignore b/src/tools/awk/.gitignore | |
new file mode 100644 | |
index 00000000..5388a055 | |
--- /dev/null | |
+++ b/src/tools/awk/.gitignore | |
@@ -0,0 +1,3 @@ | |
+awk | |
+awkgram.c | |
+awkgram.h | |
diff --git a/src/tools/compat/.gitignore b/src/tools/compat/.gitignore | |
new file mode 100644 | |
index 00000000..570cd61a | |
--- /dev/null | |
+++ b/src/tools/compat/.gitignore | |
@@ -0,0 +1,7 @@ | |
+config.cache | |
+config.log | |
+config.status | |
+defs.mk | |
+include/* | |
+libnbcompat.a | |
+nbtool_config.h | |
diff --git a/src/tools/config/.gitignore b/src/tools/config/.gitignore | |
new file mode 100644 | |
index 00000000..5348141b | |
--- /dev/null | |
+++ b/src/tools/config/.gitignore | |
@@ -0,0 +1,4 @@ | |
+config | |
+gram.c | |
+gram.h | |
+scan.c | |
diff --git a/src/tools/host-mkdep/.gitignore b/src/tools/host-mkdep/.gitignore | |
new file mode 100644 | |
index 00000000..a2505d4b | |
--- /dev/null | |
+++ b/src/tools/host-mkdep/.gitignore | |
@@ -0,0 +1,4 @@ | |
+config.cache | |
+config.log | |
+config.status | |
+host-mkdep | |
diff --git a/src/tools/lex/.gitignore b/src/tools/lex/.gitignore | |
new file mode 100644 | |
index 00000000..394bbbe6 | |
--- /dev/null | |
+++ b/src/tools/lex/.gitignore | |
@@ -0,0 +1,5 @@ | |
+parse.c | |
+parse.h | |
+scan.c | |
+skel.c | |
+lex | |
diff --git a/src/tools/m4/.gitignore b/src/tools/m4/.gitignore | |
new file mode 100644 | |
index 00000000..a7c13410 | |
--- /dev/null | |
+++ b/src/tools/m4/.gitignore | |
@@ -0,0 +1,4 @@ | |
+parser.c | |
+parser.h | |
+tokenizer.c | |
+m4 | |
diff --git a/src/tools/mandoc/.gitignore b/src/tools/mandoc/.gitignore | |
new file mode 100644 | |
index 00000000..3b39012d | |
--- /dev/null | |
+++ b/src/tools/mandoc/.gitignore | |
@@ -0,0 +1,3 @@ | |
+config.h | |
+config.log | |
+mandoc | |
-- | |
2.17.2 | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
From 2220954b359909f49779ee769465a15a29855493 Mon Sep 17 00:00:00 2001 | |
From: Akira Moroo <retrage01@gmail.com> | |
Date: Mon, 20 May 2019 13:19:36 +0900 | |
Subject: [PATCH 2/4] Import LLVM source tree as a submodule | |
Signed-off-by: Akira Moroo <retrage01@gmail.com> | |
--- | |
.gitmodules | 3 +++ | |
llvm | 1 + | |
2 files changed, 4 insertions(+) | |
create mode 160000 llvm | |
diff --git a/.gitmodules b/.gitmodules | |
index 84712130..e54b05e1 100644 | |
--- a/.gitmodules | |
+++ b/.gitmodules | |
@@ -4,3 +4,6 @@ | |
[submodule "musl"] | |
path = musl | |
url = git://github.com/libos-nuse/musl.git | |
+[submodule "llvm"] | |
+ path = llvm | |
+ url = git@github.com:llvm/llvm-project.git | |
diff --git a/llvm b/llvm | |
new file mode 160000 | |
index 00000000..d2298e74 | |
--- /dev/null | |
+++ b/llvm | |
@@ -0,0 +1 @@ | |
+Subproject commit d2298e74235598f15594fe2c99bbac870a507c59 | |
-- | |
2.17.2 | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
From a947194fcb3099edba9b23019460676de94fae50 Mon Sep 17 00:00:00 2001 | |
From: Akira Moroo <retrage01@gmail.com> | |
Date: Mon, 20 May 2019 14:20:49 +0900 | |
Subject: [PATCH 3/4] Add libcxx build scripts | |
The libc++ support is for Linux only. | |
It builds libunwind, libc++abi, and libc++. | |
It can build these libraries, but they can not working binaries. | |
Signed-off-by: Akira Moroo <retrage01@gmail.com> | |
--- | |
build.sh | 11 +++++- | |
rumpkernel/linux.sh | 93 +++++++++++++++++++++++++++++++++++++++++++- | |
rumpkernel/netbsd.sh | 5 +++ | |
3 files changed, 106 insertions(+), 3 deletions(-) | |
diff --git a/build.sh b/build.sh | |
index 88f831d6..6b6d711a 100755 | |
--- a/build.sh | |
+++ b/build.sh | |
@@ -555,16 +555,20 @@ then | |
if ${CC-cc} -I${OUTDIR}/include --sysroot=${OUTDIR} -static ${COMPILER_FLAGS} tests/hello.c -o /dev/null 2>/dev/null | |
then | |
# can use sysroot with clang | |
- printf "#!/bin/sh\n\nexec ${CC-cc} --sysroot=${OUTDIR} -static ${COMPILER_FLAGS} \"\$@\"\n" > ${BINDIR}/${TOOL_PREFIX}-clang | |
+ printf "#!/bin/sh\n\nexec clang --sysroot=${OUTDIR} -static ${COMPILER_FLAGS} \"\$@\"\n" > ${BINDIR}/${TOOL_PREFIX}-clang | |
+ printf "#!/bin/sh\n\nexec clang++ --sysroot=${OUTDIR} -static ${COMPILER_FLAGS} \"\$@\"\n" > ${BINDIR}/${TOOL_PREFIX}-clang++ | |
else | |
# sysroot does not work with linker eg NetBSD | |
appendvar COMPILER_FLAGS "-I${OUTDIR}/include -L${OUTDIR}/lib -B${OUTDIR}/lib" | |
- printf "#!/bin/sh\n\nexec ${CC-cc} -static ${COMPILER_FLAGS} \"\$@\"\n" > ${BINDIR}/${TOOL_PREFIX}-clang | |
+ printf "#!/bin/sh\n\nexec clang -static ${COMPILER_FLAGS} \"\$@\"\n" > ${BINDIR}/${TOOL_PREFIX}-clang | |
+ printf "#!/bin/sh\n\nexec clang++ -static ${COMPILER_FLAGS} \"\$@\"\n" > ${BINDIR}/${TOOL_PREFIX}-clang++ | |
fi | |
COMPILER="${TOOL_PREFIX}-clang" | |
( cd ${BINDIR} | |
ln -s ${COMPILER} ${TOOL_PREFIX}-cc | |
ln -s ${COMPILER} rumprun-cc | |
+ ln -s ${TOOL_PREFIX}-clang++ ${TOOL_PREFIX}-c++ | |
+ ln -s ${TOOL_PREFIX}-clang++ rumprun-c++ | |
) | |
else | |
# spec file for gcc | |
@@ -626,6 +630,9 @@ then | |
rumpkernel_maketools | |
fi | |
+write_log " done" | |
+write_log "-n" "building libcxx.." | |
+rumpkernel_install_libcxx | |
write_log " done" | |
write_log "-n" "building tests.." | |
diff --git a/rumpkernel/linux.sh b/rumpkernel/linux.sh | |
index d0f3f2ec..88b6eb07 100644 | |
--- a/rumpkernel/linux.sh | |
+++ b/rumpkernel/linux.sh | |
@@ -62,7 +62,6 @@ rumpkernel_install_header() | |
# install headers | |
cp -a ${RUMP}/include/* ${OUTDIR}/include | |
cp -a ${RUMPOBJ}/musl/include/* ${OUTDIR}/include | |
- | |
} | |
[ ${OS} = "freebsd" ] && appendvar UNDEF "-U__FreeBSD__" | |
@@ -114,3 +113,95 @@ rumpkernel_build_test() | |
${MAKE} -C tests/iputils clean | |
fi | |
} | |
+ | |
+rumpkernel_install_libcxx() | |
+{ | |
+# build libunwind for Linux | |
+( | |
+ if [ -z "${BUILD_QUIET}" ] ; then set -x ; fi | |
+ set -e | |
+ echo "#define __WORDSIZE 64" > "${OUTDIR}/include/bits/wordsize.h" | |
+ sed -i -e "$ s/#endif/#define __GLIBC_PREREQ(maj, min) 0\n#endif/g" ${OUTDIR}/include/features.h | |
+ echo "=== building libunwind ===" | |
+ mkdir -p ${RUMPOBJ}/libunwind | |
+ cd ${RUMPOBJ}/libunwind | |
+ LIBUNWIND_FLAGS="-I${OUTDIR}/include -D_LIBUNWIND_IS_BAREMETAL=1" | |
+ cmake \ | |
+ -DCMAKE_CROSSCOMPILING=True \ | |
+ -DCMAKE_C_COMPILER=x86_64-rumprun-linux-clang \ | |
+ -DCMAKE_C_FLAGS="${LIBUNWIND_FLAGS}" \ | |
+ -DCMAKE_CXX_COMPILER=x86_64-rumprun-linux-clang++ \ | |
+ -DCMAKE_CXX_FLAGS="${LIBUNWIND_FLAGS}" \ | |
+ -DCMAKE_INSTALL_PREFIX="${OUTDIR}" \ | |
+ -DCMAKE_TRY_COMPILE_TARGET_TYPE=STATIC_LIBRARY \ | |
+ -DLIBUNWIND_ENABLE_SHARED=0 \ | |
+ -DLIBUNWIND_ENABLE_STATIC=1 \ | |
+ -DLIBUNWIND_ENABLE_CROSS_UNWINDING=1 \ | |
+ -DLIBUNWIND_TARGET_TRIPLE=x86_64-rumprun-linux \ | |
+ -DLLVM_PATH=../../llvm \ | |
+ ../../llvm/libunwind | |
+ ${MAKE} V=1 | |
+ ${MAKE} install | |
+) | |
+# build libc++abi for Linux | |
+( | |
+ if [ -z "${BUILD_QUIET}" ] ; then set -x ; fi | |
+ set -e | |
+ echo "=== building libc++abi ===" | |
+ mkdir -p ${RUMPOBJ}/libcxxabi | |
+ cd ${RUMPOBJ}/libcxxabi | |
+ LIBCXXABI_FLAGS="-I${OUTDIR}/include" | |
+ cmake \ | |
+ -DCMAKE_CROSSCOMPILING=True \ | |
+ -DCMAKE_C_COMPILER=x86_64-rumprun-linux-clang \ | |
+ -DCMAKE_C_FLAGS="${LIBCXXABI_FLAGS}" \ | |
+ -DCMAKE_CXX_COMPILER=x86_64-rumprun-linux-clang++ \ | |
+ -DCMAKE_CXX_FLAGS="${LIBCXXABI_FLAGS}" \ | |
+ -DCMAKE_INSTALL_PREFIX="${OUTDIR}" \ | |
+ -DCMAKE_TRY_COMPILE_TARGET_TYPE=STATIC_LIBRARY \ | |
+ -DCMAKE_SHARED_LINKER_FLAGS="-L${OUTDIR}/lib" \ | |
+ -DLIBCXXABI_USE_LLVM_UNWINDER=1 \ | |
+ -DLIBCXXABI_LIBUNWIND_PATH=../../llvm/unwind \ | |
+ -DLIBCXXABI_LIBCXX_INCLUDES=../../llvm/libcxx/include \ | |
+ -DLIBCXXABI_ENABLE_SHARED=0 \ | |
+ -DLIBCXXABI_ENABLE_STATIC=1 \ | |
+ -DLIBCXXABI_BAREMETAL=1 \ | |
+ -DLIBCXXABI_TARGET_TRIPLE=x86_64-rumprun-linux \ | |
+ -DLIBCXXABI_SYSROOT=${OUTDIR} \ | |
+ -DLLVM_PATH=../../llvm \ | |
+ ../../llvm/libcxxabi | |
+ ${MAKE} | |
+ ${MAKE} install | |
+) | |
+# build libc++ for Linux | |
+( | |
+ if [ -z "${BUILD_QUIET}" ] ; then set -x ; fi | |
+ set -e | |
+ echo "=== building libc++ ===" | |
+ mkdir -p ${RUMPOBJ}/libcxx | |
+ cd ${RUMPOBJ}/libcxx | |
+ LIBCXX_FLAGS="-I${OUTDIR}/include -D_GNU_SOURCE" | |
+ cmake \ | |
+ -DCMAKE_CROSSCOMPILING=True \ | |
+ -DCMAKE_C_COMPILER=x86_64-rumprun-linux-clang \ | |
+ -DCMAKE_C_FLAGS="${LIBCXX_FLAGS}" \ | |
+ -DCMAKE_CXX_COMPILER=x86_64-rumprun-linux-clang++ \ | |
+ -DCMAKE_CXX_FLAGS="${LIBCXX_FLAGS}" \ | |
+ -DCMAKE_INSTALL_PREFIX="${OUTDIR}" \ | |
+ -DCMAKE_TRY_COMPILE_TARGET_TYPE=STATIC_LIBRARY \ | |
+ -DCMAKE_SHARED_LINKER_FLAGS="${OUTDIR}/lib" \ | |
+ -DLIBCXX_CXX_ABI=libcxxabi \ | |
+ -DLIBCXX_CXX_ABI_LIBRARY_PATH="${OUTDIR}/lib" \ | |
+ -DLIBCXX_CXX_ABI_INCLUDE_PATHS=../../llvm/libcxxabi/include \ | |
+ -DLIBCXX_ENABLE_SHARED=0 \ | |
+ -DLIBCXX_ENABLE_STATIC=1 \ | |
+ -DLIBCXX_HAS_MUSL_LIBC=1 \ | |
+ -DLIBCXX_HAS_GCC_S_LIB=0 \ | |
+ -DLIBCXX_TARGET_TRIPLE=x86_64-rumprun-linux \ | |
+ -DLIBCXX_SYSROOT=${OUTDIR} \ | |
+ -DLLVM_PATH=../../llvm \ | |
+ ../../llvm/libcxx | |
+ ${MAKE} | |
+ ${MAKE} install | |
+) | |
+} | |
diff --git a/rumpkernel/netbsd.sh b/rumpkernel/netbsd.sh | |
index f303c904..ce35eeff 100644 | |
--- a/rumpkernel/netbsd.sh | |
+++ b/rumpkernel/netbsd.sh | |
@@ -89,3 +89,8 @@ rumpkernel_build_test() | |
{ | |
return 0 | |
} | |
+ | |
+rumpkernel_install_libcxx() | |
+{ | |
+ echo "Nothing to be done" | |
+} | |
-- | |
2.17.2 | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
From 0510a7a1f536c2d85a0539f80d42285f889496ba Mon Sep 17 00:00:00 2001 | |
From: Akira Moroo <retrage01@gmail.com> | |
Date: Mon, 20 May 2019 18:35:29 +0900 | |
Subject: [PATCH 4/4] Fix libcxx build scripts to use clang wrapper generated | |
in rump/bin | |
Signed-off-by: Akira Moroo <retrage01@gmail.com> | |
--- | |
rumpkernel/linux.sh | 16 +++++++--------- | |
1 file changed, 7 insertions(+), 9 deletions(-) | |
diff --git a/rumpkernel/linux.sh b/rumpkernel/linux.sh | |
index 88b6eb07..53afdd8c 100644 | |
--- a/rumpkernel/linux.sh | |
+++ b/rumpkernel/linux.sh | |
@@ -128,9 +128,9 @@ rumpkernel_install_libcxx() | |
LIBUNWIND_FLAGS="-I${OUTDIR}/include -D_LIBUNWIND_IS_BAREMETAL=1" | |
cmake \ | |
-DCMAKE_CROSSCOMPILING=True \ | |
- -DCMAKE_C_COMPILER=x86_64-rumprun-linux-clang \ | |
+ -DCMAKE_C_COMPILER=${OUTDIR}/bin/x86_64-rumprun-linux-clang \ | |
-DCMAKE_C_FLAGS="${LIBUNWIND_FLAGS}" \ | |
- -DCMAKE_CXX_COMPILER=x86_64-rumprun-linux-clang++ \ | |
+ -DCMAKE_CXX_COMPILER=${OUTDIR}/bin/x86_64-rumprun-linux-clang++ \ | |
-DCMAKE_CXX_FLAGS="${LIBUNWIND_FLAGS}" \ | |
-DCMAKE_INSTALL_PREFIX="${OUTDIR}" \ | |
-DCMAKE_TRY_COMPILE_TARGET_TYPE=STATIC_LIBRARY \ | |
@@ -140,7 +140,7 @@ rumpkernel_install_libcxx() | |
-DLIBUNWIND_TARGET_TRIPLE=x86_64-rumprun-linux \ | |
-DLLVM_PATH=../../llvm \ | |
../../llvm/libunwind | |
- ${MAKE} V=1 | |
+ ${MAKE} | |
${MAKE} install | |
) | |
# build libc++abi for Linux | |
@@ -153,9 +153,9 @@ rumpkernel_install_libcxx() | |
LIBCXXABI_FLAGS="-I${OUTDIR}/include" | |
cmake \ | |
-DCMAKE_CROSSCOMPILING=True \ | |
- -DCMAKE_C_COMPILER=x86_64-rumprun-linux-clang \ | |
+ -DCMAKE_C_COMPILER=${OUTDIR}/bin/x86_64-rumprun-linux-clang \ | |
-DCMAKE_C_FLAGS="${LIBCXXABI_FLAGS}" \ | |
- -DCMAKE_CXX_COMPILER=x86_64-rumprun-linux-clang++ \ | |
+ -DCMAKE_CXX_COMPILER=${OUTDIR}/bin/x86_64-rumprun-linux-clang++ \ | |
-DCMAKE_CXX_FLAGS="${LIBCXXABI_FLAGS}" \ | |
-DCMAKE_INSTALL_PREFIX="${OUTDIR}" \ | |
-DCMAKE_TRY_COMPILE_TARGET_TYPE=STATIC_LIBRARY \ | |
@@ -167,7 +167,6 @@ rumpkernel_install_libcxx() | |
-DLIBCXXABI_ENABLE_STATIC=1 \ | |
-DLIBCXXABI_BAREMETAL=1 \ | |
-DLIBCXXABI_TARGET_TRIPLE=x86_64-rumprun-linux \ | |
- -DLIBCXXABI_SYSROOT=${OUTDIR} \ | |
-DLLVM_PATH=../../llvm \ | |
../../llvm/libcxxabi | |
${MAKE} | |
@@ -183,9 +182,9 @@ rumpkernel_install_libcxx() | |
LIBCXX_FLAGS="-I${OUTDIR}/include -D_GNU_SOURCE" | |
cmake \ | |
-DCMAKE_CROSSCOMPILING=True \ | |
- -DCMAKE_C_COMPILER=x86_64-rumprun-linux-clang \ | |
+ -DCMAKE_C_COMPILER=${OUTDIR}/bin/x86_64-rumprun-linux-clang \ | |
-DCMAKE_C_FLAGS="${LIBCXX_FLAGS}" \ | |
- -DCMAKE_CXX_COMPILER=x86_64-rumprun-linux-clang++ \ | |
+ -DCMAKE_CXX_COMPILER=${OUTDIR}/bin/x86_64-rumprun-linux-clang++ \ | |
-DCMAKE_CXX_FLAGS="${LIBCXX_FLAGS}" \ | |
-DCMAKE_INSTALL_PREFIX="${OUTDIR}" \ | |
-DCMAKE_TRY_COMPILE_TARGET_TYPE=STATIC_LIBRARY \ | |
@@ -198,7 +197,6 @@ rumpkernel_install_libcxx() | |
-DLIBCXX_HAS_MUSL_LIBC=1 \ | |
-DLIBCXX_HAS_GCC_S_LIB=0 \ | |
-DLIBCXX_TARGET_TRIPLE=x86_64-rumprun-linux \ | |
- -DLIBCXX_SYSROOT=${OUTDIR} \ | |
-DLLVM_PATH=../../llvm \ | |
../../llvm/libcxx | |
${MAKE} | |
-- | |
2.17.2 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment