Build libcxx and libcxxabi statically for armv7 and test building a C++ hello world
This commit is contained in:
1 parent
43906e77d6
commit
ed96326423
5 files changed
+194
-60
No files matched your search
+69
-60
@@ -71,6 +71,10 @@ RUN cd llvm && mkdir build && cd build && cmake \
|
||||
RUN git clone --depth=1 git://git.code.sf.net/p/mingw-w64/mingw-w64 && \
|
||||
cd mingw-w64 && \
|
||||
git checkout 1e81200e88f19e440bbe646bfb410159ff8b0d51
|
||||
COPY patches/mingw-*.patch /build/patches/
|
||||
RUN cd mingw-w64 && \
|
||||
git am /build/patches/mingw-*.patch
|
||||
|
||||
|
||||
#FIXME: Move this UP!
|
||||
ENV TOOLCHAIN_PREFIX=/build/prefix
|
||||
@@ -210,13 +214,18 @@ RUN cd compiler-rt && \
|
||||
# make -j4 && \
|
||||
# make install
|
||||
|
||||
#RUN git clone -b release_40 --depth=1 https://github.com/llvm-mirror/libcxx.git && \
|
||||
# git clone -b release_40 --depth=1 https://github.com/llvm-mirror/libcxxabi.git && \
|
||||
RUN git clone -b master https://github.com/llvm-mirror/libcxx.git && \
|
||||
git clone -b master https://github.com/llvm-mirror/libcxxabi.git && \
|
||||
cd libcxx && \
|
||||
git checkout d4c8905691de47a521409a6316c94b0009a91fef && \
|
||||
cd ../libcxxabi && \
|
||||
git checkout b157fdd968a4e1093645ec7c65213736c4bc7ea6
|
||||
|
||||
# git clone -b release_40 --depth=1 https://github.com/llvm-mirror/libunwind.git
|
||||
|
||||
#COPY patches/libcxx-*.patch /build/patches/
|
||||
#RUN cd libcxx && \
|
||||
# git am /build/patches/libcxx-*.patch
|
||||
COPY patches/libcxx-*.patch /build/patches/
|
||||
RUN cd libcxx && \
|
||||
git am /build/patches/libcxx-*.patch
|
||||
|
||||
#COPY patches/libcxxabi-*.patch /build/patches/
|
||||
#RUN cd libcxxabi && \
|
||||
@@ -239,62 +248,62 @@ RUN cd compiler-rt && \
|
||||
#RUN cd libunwind/build && make -j4
|
||||
#RUN cd libunwind/build && make install
|
||||
|
||||
#RUN cd libcxx && mkdir build && cd build && \
|
||||
# cmake \
|
||||
# -DCMAKE_BUILD_TYPE=Release \
|
||||
# -DCMAKE_INSTALL_PREFIX=$TOOLCHAIN_PREFIX/$TARGET_TUPLE \
|
||||
# -DCMAKE_C_COMPILER=$CC \
|
||||
# -DCMAKE_CXX_COMPILER=$CXX \
|
||||
# -DCMAKE_CROSSCOMPILING=TRUE \
|
||||
# -DCMAKE_SYSTEM_NAME=Windows \
|
||||
# -DCMAKE_C_COMPILER_WORKS=TRUE \
|
||||
# -DCMAKE_CXX_COMPILER_WORKS=TRUE \
|
||||
# -DCMAKE_AR=$TOOLCHAIN_PREFIX/bin/$AR \
|
||||
# -DCMAKE_RANLIB=$TOOLCHAIN_PREFIX/bin/$RANLIB \
|
||||
# -DLIBCXX_INSTALL_HEADERS=ON \
|
||||
# -DLIBCXX_ENABLE_EXCEPTIONS=OFF \
|
||||
# -DLIBCXX_ENABLE_THREADS=OFF \
|
||||
# -DLIBCXX_ENABLE_MONOTONIC_CLOCK=OFF \
|
||||
# -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 \
|
||||
# -DCMAKE_CXX_FLAGS="-fno-exceptions" \
|
||||
# .. && \
|
||||
# make -j4 && \
|
||||
# make install
|
||||
RUN cd libcxxabi && mkdir build && cd build && \
|
||||
cmake \
|
||||
-DCMAKE_BUILD_TYPE=Release \
|
||||
-DCMAKE_INSTALL_PREFIX=$TOOLCHAIN_PREFIX/armv7-w64-mingw32 \
|
||||
-DCMAKE_C_COMPILER=armv7-w64-mingw32-clang \
|
||||
-DCMAKE_CXX_COMPILER=armv7-w64-mingw32-clang++ \
|
||||
-DCMAKE_CROSSCOMPILING=TRUE \
|
||||
-DCMAKE_SYSTEM_NAME=Windows \
|
||||
-DCMAKE_C_COMPILER_WORKS=TRUE \
|
||||
-DCMAKE_CXX_COMPILER_WORKS=TRUE \
|
||||
-DCMAKE_AR=$TOOLCHAIN_PREFIX/bin/$AR \
|
||||
-DCMAKE_RANLIB=$TOOLCHAIN_PREFIX/bin/$RANLIB \
|
||||
-DLIBCXXABI_USE_COMPILER_RT=ON \
|
||||
-DLIBCXXABI_ENABLE_EXCEPTIONS=OFF \
|
||||
-DLIBCXXABI_ENABLE_THREADS=OFF \
|
||||
-DLIBCXXABI_TARGET_TRIPLE=armv7-w64-mingw32 \
|
||||
-DLIBCXXABI_SYSROOT=$TOOLCHAIN_PREFIX/armv7-w64-mingw32 \
|
||||
-DLIBCXXABI_ENABLE_SHARED=OFF \
|
||||
-DLIBCXXABI_LIBCXX_INCLUDES=../../libcxx/include \
|
||||
-DLLVM_NO_OLD_LIBSTDCXX=TRUE \
|
||||
-DCXX_SUPPORTS_CXX11=TRUE \
|
||||
-DCMAKE_CXX_FLAGS="-fno-exceptions -D_WIN32_WINNT=0x600 -D_LIBCXXABI_DISABLE_VISIBILITY_ANNOTATIONS -D_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS -Xclang -flto-visibility-public-std" \
|
||||
.. && \
|
||||
make -j4
|
||||
|
||||
#RUN cd libcxxabi && mkdir build && cd build && \
|
||||
# cmake \
|
||||
# -DCMAKE_BUILD_TYPE=Release \
|
||||
# -DCMAKE_INSTALL_PREFIX=$TOOLCHAIN_PREFIX/$TARGET_TUPLE \
|
||||
# -DCMAKE_C_COMPILER=$CC \
|
||||
# -DCMAKE_CXX_COMPILER=$CXX \
|
||||
# -DCMAKE_CROSSCOMPILING=TRUE \
|
||||
# -DCMAKE_SYSTEM_NAME=Windows \
|
||||
# -DCMAKE_C_COMPILER_WORKS=TRUE \
|
||||
# -DCMAKE_CXX_COMPILER_WORKS=TRUE \
|
||||
# -DCMAKE_AR=$TOOLCHAIN_PREFIX/bin/$AR \
|
||||
# -DCMAKE_RANLIB=$TOOLCHAIN_PREFIX/bin/$RANLIB \
|
||||
# -DLIBCXXABI_USE_COMPILER_RT=ON \
|
||||
# -DLIBCXXABI_ENABLE_EXCEPTIONS=OFF \
|
||||
# -DLIBCXXABI_ENABLE_THREADS=OFF \
|
||||
# -DLIBCXXABI_TARGET_TRIPLE=$TARGET_TUPLE \
|
||||
# -DLIBCXXABI_SYSROOT=$TOOLCHAIN_PREFIX/$TARGET_TUPLE \
|
||||
# -DLIBCXXABI_ENABLE_SHARED=OFF \
|
||||
# -DLIBCXXABI_LIBCXX_INCLUDES=$TOOLCHAIN_PREFIX/$TARGET_TUPLE/c++/v1 \
|
||||
# -DLLVM_NO_OLD_LIBSTDCXX=TRUE \
|
||||
# -DCXX_SUPPORTS_CXX11=TRUE \
|
||||
# -DCMAKE_CXX_FLAGS="-fno-exceptions" \
|
||||
# .. && \
|
||||
# make -j4 && \
|
||||
# make install
|
||||
RUN cd libcxx && mkdir build && cd build && \
|
||||
cmake \
|
||||
-DCMAKE_BUILD_TYPE=Release \
|
||||
-DCMAKE_INSTALL_PREFIX=$TOOLCHAIN_PREFIX/armv7-w64-mingw32 \
|
||||
-DCMAKE_C_COMPILER=armv7-w64-mingw32-clang \
|
||||
-DCMAKE_CXX_COMPILER=armv7-w64-mingw32-clang++ \
|
||||
-DCMAKE_CROSSCOMPILING=TRUE \
|
||||
-DCMAKE_SYSTEM_NAME=Windows \
|
||||
-DCMAKE_C_COMPILER_WORKS=TRUE \
|
||||
-DCMAKE_CXX_COMPILER_WORKS=TRUE \
|
||||
-DCMAKE_AR=$TOOLCHAIN_PREFIX/bin/$AR \
|
||||
-DCMAKE_RANLIB=$TOOLCHAIN_PREFIX/bin/$RANLIB \
|
||||
-DLIBCXX_INSTALL_HEADERS=ON \
|
||||
-DLIBCXX_ENABLE_EXCEPTIONS=OFF \
|
||||
-DLIBCXX_ENABLE_THREADS=OFF \
|
||||
-DLIBCXX_ENABLE_MONOTONIC_CLOCK=OFF \
|
||||
-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/lib \
|
||||
-DCMAKE_CXX_FLAGS="-fno-exceptions -D_LIBCXXABI_DISABLE_VISIBILITY_ANNOTATIONS -Xclang -flto-visibility-public-std" \
|
||||
.. && \
|
||||
make -j4 && \
|
||||
make install
|
||||
|
||||
#RUN cd /build/prefix/include && ln -s /build/prefix/$TARGET_TUPLE/include/c++ .
|
||||
RUN cd /build/prefix/include && ln -s /build/prefix/armv7-w64-mingw32/include/c++ .
|
||||
|
||||
# gaspp is no longer required with clang 5.0
|
||||
#RUN mkdir gaspp && cd gaspp && \
|
||||
@@ -316,7 +325,7 @@ RUN cd /build/hello && \
|
||||
x86_64-w64-mingw32-clang hello.c -o hello-x86_64.exe && \
|
||||
i686-w64-mingw32-clang hello.c -o hello-i686.exe
|
||||
|
||||
#RUN cd /build/hello && armv7-w64-mingw32-clang++ hello.cpp -o hello-cpp.exe -fno-exceptions
|
||||
RUN cd /build/hello && armv7-w64-mingw32-clang++ hello.cpp -o hello-cpp.exe -fno-exceptions -D_LIBCXXABI_DISABLE_VISIBILITY_ANNOTATIONS -Xclang -flto-visibility-public-std -D_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS
|
||||
|
||||
RUN git clone --depth=1 git://git.libav.org/libav.git
|
||||
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
From f12a5570d2d24b147122d7b64fc1dadf7226db2c Mon Sep 17 00:00:00 2001
|
||||
From: Martin Storsjo <martin@martin.st>
|
||||
Date: Fri, 25 Aug 2017 11:00:37 +0300
|
||||
Subject: [PATCH 1/2] Handle object files named *.obj in merge_archives.py
|
||||
|
||||
Differential Revision: https://reviews.llvm.org/D37133
|
||||
---
|
||||
utils/merge_archives.py | 2 ++
|
||||
1 file changed, 2 insertions(+)
|
||||
|
||||
diff --git a/utils/merge_archives.py b/utils/merge_archives.py
|
||||
index 856dd3b..b1bd3cb 100755
|
||||
--- a/utils/merge_archives.py
|
||||
+++ b/utils/merge_archives.py
|
||||
@@ -120,6 +120,8 @@ def main():
|
||||
|
||||
files = glob.glob(os.path.join(temp_directory_root, '*.o'))
|
||||
if not files:
|
||||
+ files = glob.glob(os.path.join(temp_directory_root, '*.obj'))
|
||||
+ if not files:
|
||||
print_and_exit('Failed to glob for %s' % glob_path)
|
||||
cmd = [ar_exe, '-qc', args.output] + files
|
||||
execute_command_verbose(cmd, cwd=temp_directory_root, verbose=args.verbose)
|
||||
--
|
||||
2.7.4
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
From 79a72b66ba63b97812b8f0076c032da9a0033e9e Mon Sep 17 00:00:00 2001
|
||||
From: Martin Storsjo <martin@martin.st>
|
||||
Date: Fri, 25 Aug 2017 11:06:31 +0300
|
||||
Subject: [PATCH 2/2] Rerun ranlib manually after merging the static libraries
|
||||
|
||||
In cross build setups, the ar used in merge_archives.py might
|
||||
not be the right one for the target; make sure to rebuild the
|
||||
index for the static library.
|
||||
|
||||
Differential Revision: https://reviews.llvm.org/D37134
|
||||
---
|
||||
lib/CMakeLists.txt | 2 ++
|
||||
1 file changed, 2 insertions(+)
|
||||
|
||||
diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt
|
||||
index 5786514..56b9a22 100644
|
||||
--- a/lib/CMakeLists.txt
|
||||
+++ b/lib/CMakeLists.txt
|
||||
@@ -272,6 +272,8 @@ if (LIBCXX_ENABLE_STATIC)
|
||||
"$<TARGET_LINKER_FILE:cxx_static>"
|
||||
"${MERGE_ARCHIVES_ABI_TARGET}"
|
||||
"${MERGE_ARCHIVES_SEARCH_PATHS}"
|
||||
+ COMMAND
|
||||
+ ${CMAKE_RANLIB} $<TARGET_LINKER_FILE:cxx_static>
|
||||
WORKING_DIRECTORY ${LIBCXX_BUILD_DIR}
|
||||
)
|
||||
endif()
|
||||
--
|
||||
2.7.4
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
From 8dedb3528699061cab1fde4c80847ee492226d42 Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?Martin=20Storsj=C3=B6?= <martin@martin.st>
|
||||
Date: Fri, 25 Aug 2017 10:55:45 +0300
|
||||
Subject: [PATCH 1/2] headers: Add casts in ua_wcs*chr in stralign.h
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
When building libcxx, a version of wcschr that returns const
|
||||
is provided, breaking compilation here since the return from
|
||||
wcschr is returned directly as if it were a const pointer.
|
||||
By adding these casts, compilation succeeds.
|
||||
|
||||
This matches the calls to uaw_wcschr and uaw_wcsrchr directly
|
||||
below, having similar casts.
|
||||
|
||||
Signed-off-by: Martin Storsjö <martin@martin.st>
|
||||
---
|
||||
mingw-w64-headers/include/stralign.h | 4 ++--
|
||||
1 file changed, 2 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/mingw-w64-headers/include/stralign.h b/mingw-w64-headers/include/stralign.h
|
||||
index 9b5637d..f4d9d6d 100644
|
||||
--- a/mingw-w64-headers/include/stralign.h
|
||||
+++ b/mingw-w64-headers/include/stralign.h
|
||||
@@ -118,11 +118,11 @@ extern "C" {
|
||||
|
||||
#ifndef __CRT__NO_INLINE
|
||||
__CRT_INLINE PUWSTR_C ua_wcschr(PCUWSTR String,WCHAR Character) {
|
||||
- if(WSTR_ALIGNED(String)) return wcschr((PCWSTR)String,Character);
|
||||
+ if(WSTR_ALIGNED(String)) return (PUWSTR_C)wcschr((PCWSTR)String,Character);
|
||||
return (PUWSTR_C)uaw_wcschr(String,Character);
|
||||
}
|
||||
__CRT_INLINE PUWSTR_C ua_wcsrchr(PCUWSTR String,WCHAR Character) {
|
||||
- if(WSTR_ALIGNED(String)) return wcsrchr((PCWSTR)String,Character);
|
||||
+ if(WSTR_ALIGNED(String)) return (PUWSTR_C)wcsrchr((PCWSTR)String,Character);
|
||||
return (PUWSTR_C)uaw_wcsrchr(String,Character);
|
||||
}
|
||||
#if defined(__cplusplus) && defined(_WConst_Return)
|
||||
--
|
||||
2.7.4
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
From ac615730861d430aa38435ecb55031316062d6f6 Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?Martin=20Storsj=C3=B6?= <martin@martin.st>
|
||||
Date: Fri, 25 Aug 2017 12:02:02 +0300
|
||||
Subject: [PATCH 2/2] crt: Include _strftime_l in msvcrt.def.in
|
||||
|
||||
This fixes linking of libc++, which uses this function. libc++
|
||||
needs a msvcrt new enough to provide this function (present
|
||||
since msvcr90 in the numbered msvcrt DLLs).
|
||||
---
|
||||
mingw-w64-crt/lib-common/msvcrt.def.in | 1 +
|
||||
1 file changed, 1 insertion(+)
|
||||
|
||||
diff --git a/mingw-w64-crt/lib-common/msvcrt.def.in b/mingw-w64-crt/lib-common/msvcrt.def.in
|
||||
index c63edd2..35c685d 100644
|
||||
--- a/mingw-w64-crt/lib-common/msvcrt.def.in
|
||||
+++ b/mingw-w64-crt/lib-common/msvcrt.def.in
|
||||
@@ -1481,6 +1481,7 @@ strcspn
|
||||
strerror
|
||||
; strerror_s replaced by emu
|
||||
strftime
|
||||
+_strftime_l
|
||||
strlen
|
||||
strncat
|
||||
strncat_s
|
||||
--
|
||||
2.7.4
|
||||
|
||||
Reference in new issue
Block a user