Split the building of the toolchain into individual shellscripts
This simplifies building the toolchain outside of docker.
This commit is contained in:
1 parent
04323b03a5
commit
e56a519fdc
10 files changed
+395
-257
No files matched your search
@@ -0,0 +1,6 @@
|
|||||||
|
llvm
|
||||||
|
mingw-w64
|
||||||
|
compiler-rt
|
||||||
|
libunwind
|
||||||
|
libcxxabi
|
||||||
|
libcxx
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
llvm
|
||||||
|
mingw-w64
|
||||||
|
compiler-rt
|
||||||
|
libunwind
|
||||||
|
libcxxabi
|
||||||
|
libcxx
|
||||||
+21
-220
@@ -8,238 +8,39 @@ RUN apt-get update -qq && apt-get install -qqy \
|
|||||||
RUN git config --global user.name "LLVM MinGW" && \
|
RUN git config --global user.name "LLVM MinGW" && \
|
||||||
git config --global user.email root@localhost
|
git config --global user.email root@localhost
|
||||||
|
|
||||||
WORKDIR /build
|
WORKDIR /build/llvm-mingw
|
||||||
|
|
||||||
# When cloning master and checking out a pinned old hash, we can't use --depth=1.
|
|
||||||
# Do the git-svn rebase to populate git-svn information, to make
|
|
||||||
# "clang --version" produce SVN based version numbers.
|
|
||||||
RUN git clone -b master https://github.com/llvm-mirror/llvm.git && \
|
|
||||||
cd llvm/tools && \
|
|
||||||
git clone -b master https://github.com/llvm-mirror/clang.git && \
|
|
||||||
git clone -b master https://github.com/llvm-mirror/lld.git && \
|
|
||||||
cd .. && \
|
|
||||||
git svn init https://llvm.org/svn/llvm-project/llvm/trunk && \
|
|
||||||
git config svn-remote.svn.fetch :refs/remotes/origin/master && \
|
|
||||||
git svn rebase -l && \
|
|
||||||
git checkout c8f103e52b297f3e3e0ed1756e11373c68af3566 && \
|
|
||||||
cd tools/clang && \
|
|
||||||
git svn init https://llvm.org/svn/llvm-project/cfe/trunk && \
|
|
||||||
git config svn-remote.svn.fetch :refs/remotes/origin/master && \
|
|
||||||
git svn rebase -l && \
|
|
||||||
git checkout fdd60aee9c0ea40fa0423d6e43821f53d07961d5 && \
|
|
||||||
cd ../lld && \
|
|
||||||
git svn init https://llvm.org/svn/llvm-project/lld/trunk && \
|
|
||||||
git config svn-remote.svn.fetch :refs/remotes/origin/master && \
|
|
||||||
git svn rebase -l && \
|
|
||||||
git checkout f4208caae12f685c06657aa6e2b9b1eda4adcdb4
|
|
||||||
|
|
||||||
ARG CORES=4
|
ARG CORES=4
|
||||||
|
|
||||||
# Build LLVM
|
|
||||||
RUN cd llvm && mkdir build && cd build && cmake \
|
|
||||||
-DCMAKE_INSTALL_PREFIX="/build/prefix" \
|
|
||||||
-DCMAKE_BUILD_TYPE=Release \
|
|
||||||
-DLLVM_ENABLE_ASSERTIONS=ON \
|
|
||||||
-DLLVM_TARGETS_TO_BUILD="ARM;AArch64;X86" \
|
|
||||||
../ && \
|
|
||||||
make -j$CORES && \
|
|
||||||
make install
|
|
||||||
|
|
||||||
RUN git clone git://git.code.sf.net/p/mingw-w64/mingw-w64 && \
|
|
||||||
cd mingw-w64 && \
|
|
||||||
git checkout 66fab9591c250ade399e9fe91ceda239a735649c
|
|
||||||
|
|
||||||
|
|
||||||
ENV TOOLCHAIN_PREFIX=/build/prefix
|
ENV TOOLCHAIN_PREFIX=/build/prefix
|
||||||
ENV PATH=$TOOLCHAIN_PREFIX/bin:$PATH
|
|
||||||
|
# Build LLVM
|
||||||
|
COPY build-llvm.sh .
|
||||||
|
RUN ./build-llvm.sh $TOOLCHAIN_PREFIX
|
||||||
|
|
||||||
ENV TOOLCHAIN_ARCHS="i686 x86_64 armv7 aarch64"
|
ENV TOOLCHAIN_ARCHS="i686 x86_64 armv7 aarch64"
|
||||||
|
|
||||||
RUN cd mingw-w64/mingw-w64-headers && \
|
|
||||||
for arch in $TOOLCHAIN_ARCHS; do \
|
|
||||||
mkdir build-$arch && cd build-$arch && \
|
|
||||||
../configure --host=$arch-w64-mingw32 --prefix=$TOOLCHAIN_PREFIX/$arch-w64-mingw32 \
|
|
||||||
--enable-secure-api --enable-idl --with-default-win32-winnt=0x600 && \
|
|
||||||
make install && \
|
|
||||||
cd .. || exit 1; \
|
|
||||||
done
|
|
||||||
|
|
||||||
# Install the usual $TUPLE-clang binaries
|
# Install the usual $TUPLE-clang binaries
|
||||||
COPY wrappers/clang-target-wrapper /build/prefix/bin
|
COPY wrappers/clang-target-wrapper ./wrappers/
|
||||||
RUN cd $TOOLCHAIN_PREFIX/bin && \
|
COPY install-wrappers.sh .
|
||||||
for arch in $TOOLCHAIN_ARCHS; do \
|
RUN ./install-wrappers.sh $TOOLCHAIN_PREFIX
|
||||||
for exec in clang clang++; do \
|
|
||||||
ln -s clang-target-wrapper $arch-w64-mingw32-$exec; \
|
|
||||||
done; \
|
|
||||||
done
|
|
||||||
|
|
||||||
# Build mingw with our freshly built cross compiler
|
# Build MinGW-w64
|
||||||
RUN cd mingw-w64/mingw-w64-crt && \
|
COPY build-mingw-w64.sh .
|
||||||
for arch in $TOOLCHAIN_ARCHS; do \
|
RUN ./build-mingw-w64.sh $TOOLCHAIN_PREFIX
|
||||||
mkdir build-$arch && cd build-$arch && \
|
|
||||||
case $arch in \
|
|
||||||
armv7) \
|
|
||||||
FLAGS="--disable-lib32 --disable-lib64 --enable-libarm32" \
|
|
||||||
;; \
|
|
||||||
aarch64) \
|
|
||||||
FLAGS="--disable-lib32 --disable-lib64 --enable-libarm64" \
|
|
||||||
;; \
|
|
||||||
i686) \
|
|
||||||
FLAGS="--enable-lib32 --disable-lib64" \
|
|
||||||
;; \
|
|
||||||
x86_64) \
|
|
||||||
FLAGS="--disable-lib32 --enable-lib64" \
|
|
||||||
;; \
|
|
||||||
esac && \
|
|
||||||
CC=$arch-w64-mingw32-clang \
|
|
||||||
AR=llvm-ar RANLIB=llvm-ranlib DLLTOOL=llvm-dlltool ../configure --host=$arch-w64-mingw32 --prefix=$TOOLCHAIN_PREFIX/$arch-w64-mingw32 $FLAGS && \
|
|
||||||
make -j$CORES && make install && \
|
|
||||||
cd .. || exit 1; \
|
|
||||||
done
|
|
||||||
|
|
||||||
RUN git clone -b master https://github.com/llvm-mirror/compiler-rt.git && \
|
# Build compiler-rt
|
||||||
cd compiler-rt && \
|
COPY build-compiler-rt.sh .
|
||||||
git checkout 1d871d6cd3fed01cd50dd63e743bd2ea6e65eab6
|
RUN ./build-compiler-rt.sh $TOOLCHAIN_PREFIX 6.0.0
|
||||||
|
|
||||||
# Add a symlink for i386 -> i686; we normally name the toolchain
|
# Build libunwind/libcxxabi/libcxx
|
||||||
# i686-w64-mingw32, but due to the compiler-rt cmake peculiarities, we
|
COPY build-libcxx.sh merge_archives.sh ./
|
||||||
# need to refer to it as i386 at this stage.
|
RUN ./build-libcxx.sh $TOOLCHAIN_PREFIX
|
||||||
RUN cd $TOOLCHAIN_PREFIX && ln -s i686-w64-mingw32 i386-w64-mingw32
|
|
||||||
|
|
||||||
# Manually build compiler-rt as a standalone project
|
WORKDIR /build
|
||||||
RUN cd compiler-rt && \
|
ENV PATH=$TOOLCHAIN_PREFIX/bin:$PATH
|
||||||
for arch in $TOOLCHAIN_ARCHS; do \
|
|
||||||
buildarchname=$arch && \
|
|
||||||
libarchname=$arch && \
|
|
||||||
case $arch in \
|
|
||||||
armv7) \
|
|
||||||
libarchname=arm \
|
|
||||||
;; \
|
|
||||||
i686) \
|
|
||||||
buildarchname=i386 \
|
|
||||||
libarchname=i386 \
|
|
||||||
;; \
|
|
||||||
esac && \
|
|
||||||
mkdir build-$arch && cd build-$arch && cmake \
|
|
||||||
-DCMAKE_C_COMPILER=$arch-w64-mingw32-clang \
|
|
||||||
-DCMAKE_SYSTEM_NAME=Windows \
|
|
||||||
-DCMAKE_AR=$TOOLCHAIN_PREFIX/bin/llvm-ar \
|
|
||||||
-DCMAKE_RANLIB=$TOOLCHAIN_PREFIX/bin/llvm-ranlib \
|
|
||||||
-DCMAKE_C_COMPILER_WORKS=1 \
|
|
||||||
-DCMAKE_C_COMPILER_TARGET=$buildarchname-windows-gnu \
|
|
||||||
-DCOMPILER_RT_DEFAULT_TARGET_ONLY=TRUE \
|
|
||||||
../lib/builtins && \
|
|
||||||
make -j$CORES && \
|
|
||||||
mkdir -p $TOOLCHAIN_PREFIX/lib/clang/6.0.0/lib/windows && \
|
|
||||||
cp lib/windows/libclang_rt.builtins-$buildarchname.a $TOOLCHAIN_PREFIX/lib/clang/6.0.0/lib/windows/libclang_rt.builtins-$libarchname.a && \
|
|
||||||
cd .. || exit 1; \
|
|
||||||
done
|
|
||||||
|
|
||||||
RUN git clone -b master https://github.com/llvm-mirror/libcxx.git && \
|
COPY hello.c hello.cpp hello-exception.cpp hello-tls.c ./hello/
|
||||||
git clone -b master https://github.com/llvm-mirror/libcxxabi.git && \
|
|
||||||
git clone -b master https://github.com/llvm-mirror/libunwind.git && \
|
|
||||||
cd libcxx && \
|
|
||||||
git checkout 16eb426933cdb1c54fd6fbba5fc06cc5a4ca52b3 && \
|
|
||||||
cd ../libcxxabi && \
|
|
||||||
git checkout 05ba3281482304ae8de31123a594972a495da06d && \
|
|
||||||
cd ../libunwind && \
|
|
||||||
git checkout 2ddcf2461daa5d61c543474aed06b12a8b9ad816
|
|
||||||
|
|
||||||
COPY merge_archives.sh /build
|
|
||||||
RUN cd libunwind && \
|
|
||||||
for arch in $TOOLCHAIN_ARCHS; do \
|
|
||||||
mkdir build-$arch && cd build-$arch && cmake \
|
|
||||||
-DCMAKE_BUILD_TYPE=Release \
|
|
||||||
-DCMAKE_INSTALL_PREFIX=$TOOLCHAIN_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=$TOOLCHAIN_PREFIX/bin/llvm-ar \
|
|
||||||
-DCMAKE_RANLIB=$TOOLCHAIN_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="-I/build/libcxx/include" \
|
|
||||||
.. && \
|
|
||||||
make -j$CORES && make install && \
|
|
||||||
/build/merge_archives.sh \
|
|
||||||
$TOOLCHAIN_PREFIX/$arch-w64-mingw32/lib/libunwind.a \
|
|
||||||
$TOOLCHAIN_PREFIX/$arch-w64-mingw32/lib/libpsapi.a && \
|
|
||||||
cd .. || exit 1; \
|
|
||||||
done
|
|
||||||
|
|
||||||
RUN cd libcxxabi && \
|
|
||||||
for arch in $TOOLCHAIN_ARCHS; do \
|
|
||||||
mkdir build-$arch && cd build-$arch && cmake \
|
|
||||||
-DCMAKE_BUILD_TYPE=Release \
|
|
||||||
-DCMAKE_INSTALL_PREFIX=$TOOLCHAIN_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=$TOOLCHAIN_PREFIX/bin/llvm-ar \
|
|
||||||
-DCMAKE_RANLIB=$TOOLCHAIN_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 .. || exit 1; \
|
|
||||||
done
|
|
||||||
|
|
||||||
RUN cd libcxx && \
|
|
||||||
for arch in $TOOLCHAIN_ARCHS; do \
|
|
||||||
mkdir build-$arch && cd build-$arch && cmake \
|
|
||||||
-DCMAKE_BUILD_TYPE=Release \
|
|
||||||
-DCMAKE_INSTALL_PREFIX=$TOOLCHAIN_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=$TOOLCHAIN_PREFIX/bin/llvm-ar \
|
|
||||||
-DCMAKE_RANLIB=$TOOLCHAIN_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 && \
|
|
||||||
/build/merge_archives.sh \
|
|
||||||
$TOOLCHAIN_PREFIX/$arch-w64-mingw32/lib/libc++.a \
|
|
||||||
$TOOLCHAIN_PREFIX/$arch-w64-mingw32/lib/libunwind.a && \
|
|
||||||
cd .. || exit 1; \
|
|
||||||
done
|
|
||||||
|
|
||||||
RUN cd $TOOLCHAIN_PREFIX/include && ln -s ../$(echo $TOOLCHAIN_ARCHS | awk '{print $1}')-w64-mingw32/include/c++ .
|
|
||||||
|
|
||||||
COPY hello.c hello.cpp hello-exception.cpp hello-tls.c /build/hello/
|
|
||||||
RUN cd hello && \
|
RUN cd hello && \
|
||||||
for arch in $TOOLCHAIN_ARCHS; do \
|
for arch in $TOOLCHAIN_ARCHS; do \
|
||||||
$arch-w64-mingw32-clang hello.c -o hello-$arch.exe || exit 1; \
|
$arch-w64-mingw32-clang hello.c -o hello-$arch.exe || exit 1; \
|
||||||
|
|||||||
@@ -21,18 +21,20 @@ the exact same goal but with a slightly different mechanism for
|
|||||||
building it, allowing a full from-scratch build of all components
|
building it, allowing a full from-scratch build of all components
|
||||||
in one command.
|
in one command.
|
||||||
|
|
||||||
The only prerequisite for building is Docker; you can also follow the
|
The toolchain can be reproducibly built into a Docker image, or be
|
||||||
steps of the Dockerfile and build manually within a normal linux
|
built and installed in the host environment (currently only tested
|
||||||
environment, but Docker provides reproducibility by building in a known,
|
on Linux and macOS).
|
||||||
empty environment.
|
|
||||||
|
|
||||||
To build, just do:
|
To build and install all components, just do:
|
||||||
|
|
||||||
|
./build-all.sh <target-dir>
|
||||||
|
|
||||||
|
To build the toolchain in Docker, run:
|
||||||
|
|
||||||
docker build .
|
docker build .
|
||||||
|
|
||||||
This will download and build all parts of the toolchain, and build a few
|
In addition to building the toolchain itself (just like `build-all.sh` does),
|
||||||
demo apps to show and verify that the toolchain works.
|
this also builds a few demo apps to show and verify that the toolchain works.
|
||||||
|
|
||||||
|
|
||||||
Other branches in this repo contain patches that might not have been
|
Other branches in this repo contain patches that might not have been
|
||||||
merged upstream yet, and tests of building third party projects using
|
merged upstream yet, and tests of building third party projects using
|
||||||
@@ -43,6 +45,14 @@ For building projects that need more than just specifying
|
|||||||
setup for providing a larger selection of the tools that GNU binutils
|
setup for providing a larger selection of the tools that GNU binutils
|
||||||
normally provides, in the branch `tools`.
|
normally provides, in the branch `tools`.
|
||||||
|
|
||||||
|
Individual components of the toolchain can be (re)built by running
|
||||||
|
the standalone shellscripts listed within `build-all.sh`. However, if
|
||||||
|
the source already is checked out, no effort is made to check out a
|
||||||
|
different version (if the build scripts have been updated to prefer
|
||||||
|
a different version) - and likewise, if configure flags in the build-*.sh
|
||||||
|
scripts have changed, you might need to wipe the build directory under
|
||||||
|
each project for the new configure options to be taken into use.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Status
|
Status
|
||||||
@@ -69,32 +79,3 @@ normal GCC/binutils based MinGW.
|
|||||||
at the moment.
|
at the moment.
|
||||||
|
|
||||||
Additionally, one may run into other minor differences between GCC and clang.
|
Additionally, one may run into other minor differences between GCC and clang.
|
||||||
|
|
||||||
|
|
||||||
Use outside of Docker
|
|
||||||
---------------------
|
|
||||||
|
|
||||||
To use a similar toolchain outside of Docker, you can run the same build
|
|
||||||
commands as the dockerfile in probably most recent linux distributions.
|
|
||||||
The build procedure is currently only maintained as a Dockerfile, for ease
|
|
||||||
of verification, reproducibility and ease of maintainance though.
|
|
||||||
|
|
||||||
The toolchain that was built within the docker image can also be
|
|
||||||
extracted from the image into the surrounding host environment.
|
|
||||||
The `extract-docker.sh` script can copy out a directory from a
|
|
||||||
built docker image, either for getting the toolchain or built test
|
|
||||||
binaries, when given a docker tag or image id.
|
|
||||||
|
|
||||||
If the `docker build` command ended with e.g.
|
|
||||||
`Successfully built d8b13aad965a`, you can run:
|
|
||||||
|
|
||||||
./extract-docker.sh d8b13aad965a prefix
|
|
||||||
|
|
||||||
This copies the directory `prefix` (which contains the whole toolchain,
|
|
||||||
with headers and link libraries for all four architectures) from the
|
|
||||||
built docker image into the current directory.
|
|
||||||
The Dockerfile currently builds in an Ubuntu 16.04 environment, so the
|
|
||||||
extracted toolchain can at least be used in such an environment.
|
|
||||||
|
|
||||||
The extracted toolchain can be used by adding `prefix/bin` to `$PATH`
|
|
||||||
and calling e.g. `x86_64-w64-ming32-clang`.
|
|
||||||
Executable
+15
@@ -0,0 +1,15 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
if [ $# -lt 1 ]; then
|
||||||
|
echo $0 dest
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
PREFIX="$1"
|
||||||
|
|
||||||
|
./build-llvm.sh $PREFIX
|
||||||
|
./install-wrappers.sh $PREFIX
|
||||||
|
./build-mingw-w64.sh $PREFIX
|
||||||
|
./build-compiler-rt.sh $PREFIX 6.0.0
|
||||||
|
./build-libcxx.sh $PREFIX
|
||||||
Executable
+56
@@ -0,0 +1,56 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
if [ $# -lt 2 ]; then
|
||||||
|
echo $0 dest clang-version
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
PREFIX="$1"
|
||||||
|
CLANG_VERSION="$2"
|
||||||
|
export PATH=$PREFIX/bin:$PATH
|
||||||
|
|
||||||
|
: ${CORES:=4}
|
||||||
|
: ${ARCHS:=${TOOLCHAIN_ARCHS-i686 x86_64 armv7 aarch64}}
|
||||||
|
|
||||||
|
if [ ! -d compiler-rt ]; then
|
||||||
|
git clone -b master https://github.com/llvm-mirror/compiler-rt.git
|
||||||
|
cd compiler-rt
|
||||||
|
git checkout 1d871d6cd3fed01cd50dd63e743bd2ea6e65eab6
|
||||||
|
cd ..
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Add a symlink for i386 -> i686; we normally name the toolchain
|
||||||
|
# i686-w64-mingw32, but due to the compiler-rt cmake peculiarities, we
|
||||||
|
# need to refer to it as i386 at this stage.
|
||||||
|
ln -sf i686-w64-mingw32 $PREFIX/i386-w64-mingw32
|
||||||
|
|
||||||
|
cd compiler-rt
|
||||||
|
for arch in $ARCHS; do
|
||||||
|
buildarchname=$arch
|
||||||
|
libarchname=$arch
|
||||||
|
case $arch in
|
||||||
|
armv7)
|
||||||
|
libarchname=arm
|
||||||
|
;;
|
||||||
|
i686)
|
||||||
|
buildarchname=i386
|
||||||
|
libarchname=i386
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
mkdir -p build-$arch
|
||||||
|
cd build-$arch
|
||||||
|
cmake \
|
||||||
|
-DCMAKE_C_COMPILER=$arch-w64-mingw32-clang \
|
||||||
|
-DCMAKE_SYSTEM_NAME=Windows \
|
||||||
|
-DCMAKE_AR=$PREFIX/bin/llvm-ar \
|
||||||
|
-DCMAKE_RANLIB=$PREFIX/bin/llvm-ranlib \
|
||||||
|
-DCMAKE_C_COMPILER_WORKS=1 \
|
||||||
|
-DCMAKE_C_COMPILER_TARGET=$buildarchname-windows-gnu \
|
||||||
|
-DCOMPILER_RT_DEFAULT_TARGET_ONLY=TRUE \
|
||||||
|
../lib/builtins
|
||||||
|
make -j$CORES
|
||||||
|
mkdir -p $PREFIX/lib/clang/$CLANG_VERSION/lib/windows
|
||||||
|
cp lib/windows/libclang_rt.builtins-$buildarchname.a $PREFIX/lib/clang/$CLANG_VERSION/lib/windows/libclang_rt.builtins-$libarchname.a
|
||||||
|
cd ..
|
||||||
|
done
|
||||||
Executable
+142
@@ -0,0 +1,142 @@
|
|||||||
|
#!/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="-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++
|
||||||
Executable
+48
@@ -0,0 +1,48 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
if [ $# -lt 1 ]; then
|
||||||
|
echo $0 dest
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
PREFIX="$1"
|
||||||
|
|
||||||
|
: ${CORES:=4}
|
||||||
|
|
||||||
|
if [ ! -d llvm ]; then
|
||||||
|
# When cloning master and checking out a pinned old hash, we can't use --depth=1.
|
||||||
|
# Do the git-svn rebase to populate git-svn information, to make
|
||||||
|
# "clang --version" produce SVN based version numbers.
|
||||||
|
git clone -b master https://github.com/llvm-mirror/llvm.git
|
||||||
|
cd llvm/tools
|
||||||
|
git clone -b master https://github.com/llvm-mirror/clang.git
|
||||||
|
git clone -b master https://github.com/llvm-mirror/lld.git
|
||||||
|
cd ..
|
||||||
|
git svn init https://llvm.org/svn/llvm-project/llvm/trunk
|
||||||
|
git config svn-remote.svn.fetch :refs/remotes/origin/master
|
||||||
|
git svn rebase -l
|
||||||
|
git checkout c8f103e52b297f3e3e0ed1756e11373c68af3566
|
||||||
|
cd tools/clang
|
||||||
|
git svn init https://llvm.org/svn/llvm-project/cfe/trunk
|
||||||
|
git config svn-remote.svn.fetch :refs/remotes/origin/master
|
||||||
|
git svn rebase -l
|
||||||
|
git checkout fdd60aee9c0ea40fa0423d6e43821f53d07961d5
|
||||||
|
cd ../lld
|
||||||
|
git svn init https://llvm.org/svn/llvm-project/lld/trunk
|
||||||
|
git config svn-remote.svn.fetch :refs/remotes/origin/master
|
||||||
|
git svn rebase -l
|
||||||
|
git checkout f4208caae12f685c06657aa6e2b9b1eda4adcdb4
|
||||||
|
cd ../../..
|
||||||
|
fi
|
||||||
|
|
||||||
|
cd llvm
|
||||||
|
mkdir -p build
|
||||||
|
cd build
|
||||||
|
cmake \
|
||||||
|
-DCMAKE_INSTALL_PREFIX="$PREFIX" \
|
||||||
|
-DCMAKE_BUILD_TYPE=Release \
|
||||||
|
-DLLVM_ENABLE_ASSERTIONS=ON \
|
||||||
|
-DLLVM_TARGETS_TO_BUILD="ARM;AArch64;X86" \
|
||||||
|
..
|
||||||
|
make -j$CORES install
|
||||||
Executable
+63
@@ -0,0 +1,63 @@
|
|||||||
|
#!/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 mingw-w64 ]; then
|
||||||
|
git clone git://git.code.sf.net/p/mingw-w64/mingw-w64
|
||||||
|
cd mingw-w64
|
||||||
|
git checkout 66fab9591c250ade399e9fe91ceda239a735649c
|
||||||
|
cd ..
|
||||||
|
fi
|
||||||
|
|
||||||
|
cd mingw-w64
|
||||||
|
|
||||||
|
if [ -z "$NOHEADERS" ]; then
|
||||||
|
# TODO: Only install if they have changed? Otherwise this forces the CRT
|
||||||
|
# to be rebuilt even if headers haven't changed. Currently set $NOHEADERS
|
||||||
|
# to skip this part.
|
||||||
|
cd mingw-w64-headers
|
||||||
|
for arch in $ARCHS; do
|
||||||
|
mkdir -p build-$arch
|
||||||
|
cd build-$arch
|
||||||
|
../configure --host=$arch-w64-mingw32 --prefix=$PREFIX/$arch-w64-mingw32 \
|
||||||
|
--enable-secure-api --enable-idl --with-default-win32-winnt=0x600
|
||||||
|
make install
|
||||||
|
cd ..
|
||||||
|
done
|
||||||
|
cd ..
|
||||||
|
fi
|
||||||
|
|
||||||
|
cd mingw-w64-crt
|
||||||
|
for arch in $ARCHS; do
|
||||||
|
mkdir -p build-$arch
|
||||||
|
cd build-$arch
|
||||||
|
case $arch in
|
||||||
|
armv7)
|
||||||
|
FLAGS="--disable-lib32 --disable-lib64 --enable-libarm32"
|
||||||
|
;;
|
||||||
|
aarch64)
|
||||||
|
FLAGS="--disable-lib32 --disable-lib64 --enable-libarm64"
|
||||||
|
;;
|
||||||
|
i686)
|
||||||
|
FLAGS="--enable-lib32 --disable-lib64"
|
||||||
|
;;
|
||||||
|
x86_64)
|
||||||
|
FLAGS="--disable-lib32 --enable-lib64"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
CC=$arch-w64-mingw32-clang AR=llvm-ar RANLIB=llvm-ranlib DLLTOOL=llvm-dlltool \
|
||||||
|
../configure --host=$arch-w64-mingw32 --prefix=$PREFIX/$arch-w64-mingw32 $FLAGS
|
||||||
|
make -j$CORES
|
||||||
|
make install
|
||||||
|
cd ..
|
||||||
|
done
|
||||||
Executable
+20
@@ -0,0 +1,20 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
if [ $# -lt 1 ]; then
|
||||||
|
echo $0 dest
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
PREFIX="$1"
|
||||||
|
|
||||||
|
: ${ARCHS:=${TOOLCHAIN_ARCHS-i686 x86_64 armv7 aarch64}}
|
||||||
|
|
||||||
|
mkdir -p $PREFIX/bin
|
||||||
|
cp wrappers/clang-target-wrapper $PREFIX/bin
|
||||||
|
cd $PREFIX/bin
|
||||||
|
for arch in $ARCHS; do
|
||||||
|
for exec in clang clang++; do
|
||||||
|
ln -sf clang-target-wrapper $arch-w64-mingw32-$exec
|
||||||
|
done
|
||||||
|
done
|
||||||
Reference in new issue
Block a user