Commit 09ea9090 authored by Hugo Beauzée-Luyssen's avatar Hugo Beauzée-Luyssen

vlc-ubuntu-llvm-mingw: Update from upstream

parent 28c8b74f
......@@ -14,14 +14,6 @@ RUN apt-get update -qq && apt-get install -qqy \
apt-get clean -y && \
rm -rf /var/lib/apt/lists/*
# Disable statx for the time being to fix Qt build
# https://bugreports.qt.io/browse/QTBUG-64490
RUN for f in /usr/include/sys/syscall.h /usr/include/$(gcc -print-multiarch)/sys/syscall.h; do \
if [ -f $f ]; then \
echo "#undef SYS_statx" >> $f; \
fi; \
done
RUN git config --global user.name "LLVM MinGW" && \
git config --global user.email root@localhost
......@@ -31,20 +23,46 @@ WORKDIR /build
ARG CORES=4
ENV TOOLCHAIN_PREFIX=/opt/llvm-mingw
# Build and strip the LLVM installation
COPY build-llvm.sh strip-llvm.sh ./
RUN ./build-llvm.sh $TOOLCHAIN_PREFIX && \
./strip-llvm.sh $TOOLCHAIN_PREFIX && \
rm -rf /build
ENV TOOLCHAIN_ARCHS="i686 x86_64 armv7 aarch64"
# Install the usual $TUPLE-clang binaries
COPY wrappers/*.sh wrappers/*.c ./wrappers/
COPY install-wrappers.sh .
RUN ./install-wrappers.sh $TOOLCHAIN_PREFIX && \
rm -rf /build
# Build everything and clean up, in one step
COPY *.sh ./
COPY wrappers/*.sh ./wrappers/
RUN ./build-all.sh $TOOLCHAIN_PREFIX && \
./strip-llvm.sh $TOOLCHAIN_PREFIX && \
apt-get update -qq && \
# Build MinGW-w64, compiler-rt and mingw-w64's extra libraries
COPY build-mingw-w64.sh build-compiler-rt.sh build-mingw-w64-libraries.sh ./
RUN ./build-mingw-w64.sh $TOOLCHAIN_PREFIX && \
./build-compiler-rt.sh $TOOLCHAIN_PREFIX && \
./build-mingw-w64-libraries.sh $TOOLCHAIN_PREFIX && \
rm -rf /build
# Build libunwind/libcxxabi/libcxx
COPY build-libcxx.sh merge-archives.sh ./
RUN ./build-libcxx.sh $TOOLCHAIN_PREFIX && \
rm -rf /build
# Build libssp
RUN apt update && apt install -y subversion
COPY build-libssp.sh libssp-Makefile ./
RUN ./build-libssp.sh $TOOLCHAIN_PREFIX && \
rm -rf /build
# Cheating: Pull strip and objcopy from the normal binutils package.
RUN apt-get update -qq && \
apt-get install -qqy binutils-mingw-w64-x86-64 && \
cp /usr/bin/x86_64-w64-mingw32-windres $TOOLCHAIN_PREFIX/bin/x86_64-w64-mingw32-windresreal && \
cp /usr/bin/x86_64-w64-mingw32-strip $TOOLCHAIN_PREFIX/bin/binutils-strip && \
cp /usr/bin/x86_64-w64-mingw32-objcopy $TOOLCHAIN_PREFIX/bin/binutils-objcopy && \
apt-get remove -qqy binutils-mingw-w64-x86-64 && \
apt-get clean -y && \
rm -rf /var/lib/apt/lists/* && \
rm -rf /build
rm -rf /var/lib/apt/lists/*
ENV PATH=$TOOLCHAIN_PREFIX/bin:$PATH
......@@ -12,4 +12,6 @@ PREFIX="$1"
./install-wrappers.sh $PREFIX
./build-mingw-w64.sh $PREFIX
./build-compiler-rt.sh $PREFIX
./build-mingw-w64-libraries.sh $PREFIX
./build-libcxx.sh $PREFIX
./build-libssp.sh $PREFIX
......@@ -22,13 +22,13 @@ 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
ln -sfn i686-w64-mingw32 $PREFIX/i386-w64-mingw32 || true
cd compiler-rt
if [ -n "$SYNC" ] || [ -n "$CHECKOUT" ]; then
[ -z "$SYNC" ] || git fetch
git checkout 97adb78eaae40595d052cfa76514db8256063bea
git checkout 3a468fa7bb7cc79eca0320230b4201e84a43c1e6
fi
for arch in $ARCHS; do
......
......@@ -2,11 +2,23 @@
set -e
if [ $# -lt 1 ]; then
echo $0 dest
BUILD_STATIC=1
BUILD_SHARED=1
while [ $# -gt 0 ]; do
if [ "$1" = "--disable-shared" ]; then
BUILD_SHARED=
elif [ "$1" = "--disable-static" ]; then
BUILD_STATIC=
else
PREFIX="$1"
fi
shift
done
if [ -z "$PREFIX" ]; then
echo $0 [--disable-shared] [--disable-static] dest
exit 1
fi
PREFIX="$1"
export PATH=$PREFIX/bin:$PATH
: ${CORES:=4}
......@@ -27,128 +39,178 @@ fi
if [ -n "$SYNC" ] || [ -n "$CHECKOUT_LIBUNWIND" ]; then
cd libunwind
[ -z "$SYNC" ] || git fetch
git checkout 86ab23972978242b6f9e27cebc239f3e8428b1af
git checkout 1f89d78bb488bc71cfdee8281fc0834e9fbe5dce
cd ..
fi
if [ -n "$SYNC" ] || [ -n "$CHECKOUT_LIBCXXABI" ]; then
cd libcxxabi
[ -z "$SYNC" ] || git fetch
git checkout 05ba3281482304ae8de31123a594972a495da06d
git checkout 5f7425947f303be5ca9b1a6471471d92d209f498
cd ..
fi
if [ -n "$SYNC" ] || [ -n "$CHECKOUT_LIBCXX" ]; then
cd libcxx
[ -z "$SYNC" ] || git fetch
git checkout a351d793abce1ecaead0fd947fe17f75b0c41ae5
git checkout 8220dac54c22c42a5ec2a32a0ed50343a2ea4775
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
build_all() {
type="$1"
if [ "$type" = "shared" ]; then
SHARED=TRUE
STATIC=FALSE
else
SHARED=FALSE
STATIC=TRUE
fi
cd libunwind
for arch in $ARCHS; do
mkdir -p build-$arch-$type
cd build-$arch-$type
# If llvm-config and the llvm cmake files are available, -w gets added
# to the compiler flags; manually add it here to avoid noisy warnings
# that normally are suppressed.
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=$SHARED \
-DLIBUNWIND_ENABLE_STATIC=$STATIC \
-DLIBUNWIND_ENABLE_CROSS_UNWINDING=FALSE \
-DLIBUNWIND_STANDALONE_BUILD=TRUE \
-DCMAKE_CXX_FLAGS="-nostdinc++ -I$LIBCXX/include -w" \
-DCMAKE_C_FLAGS="-w" \
-DCMAKE_SHARED_LINKER_FLAGS="-lpsapi" \
..
make -j$CORES
make install
if [ "$type" = "shared" ]; then
cp lib/libunwind.dll $PREFIX/$arch-w64-mingw32/bin
else
# 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
fi
cd ..
done
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 libcxxabi
for arch in $ARCHS; do
mkdir -p build-$arch-$type
cd build-$arch-$type
# If llvm-config and the llvm cmake files are available, -w gets added
# to the compiler flags; manually add it here to avoid noisy warnings
# that normally are suppressed.
if [ "$type" = "shared" ]; then
LIBCXXABI_VISIBILITY_FLAGS="-D_LIBCPP_BUILDING_LIBRARY -U_LIBCXXABI_DISABLE_VISIBILITY_ANNOTATIONS"
else
LIBCXXABI_VISIBILITY_FLAGS="-D_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS"
fi
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 \
-DLIBCXXABI_ENABLE_NEW_DELETE_DEFINITIONS=OFF \
-DLLVM_NO_OLD_LIBSTDCXX=TRUE \
-DCXX_SUPPORTS_CXX11=TRUE \
-DCMAKE_CXX_FLAGS="$LIBCXXABI_VISIBILITY_FLAGS -D_LIBCPP_HAS_THREAD_API_WIN32 -w" \
..
make -j$CORES
cd ..
done
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 libcxx
for arch in $ARCHS; do
mkdir -p build-$arch-$type
cd build-$arch-$type
if [ "$type" = "shared" ]; then
LIBCXX_VISIBILITY_FLAGS="-D_LIBCXXABI_BUILDING_LIBRARY"
else
LIBCXX_VISIBILITY_FLAGS="-D_LIBCXXABI_DISABLE_VISIBILITY_ANNOTATIONS"
fi
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=$SHARED \
-DLIBCXX_ENABLE_STATIC=$STATIC \
-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_ABI_UNSTABLE=TRUE \
-DLIBCXX_CXX_ABI=libcxxabi \
-DLIBCXX_CXX_ABI_INCLUDE_PATHS=../../libcxxabi/include \
-DLIBCXX_CXX_ABI_LIBRARY_PATH=../../libcxxabi/build-$arch-$type/lib \
-DCMAKE_CXX_FLAGS="$LIBCXX_VISIBILITY_FLAGS" \
-DCMAKE_SHARED_LINKER_FLAGS="-lunwind -Wl,--export-all-symbols" \
-DLIBCXX_ENABLE_ABI_LINKER_SCRIPT=FALSE \
..
make -j$CORES
make install
if [ "$type" = "shared" ]; then
$MERGE_ARCHIVES \
$PREFIX/$arch-w64-mingw32/lib/libc++.dll.a \
$PREFIX/$arch-w64-mingw32/lib/libunwind.dll.a
cp lib/libc++.dll $PREFIX/$arch-w64-mingw32/bin
else
$MERGE_ARCHIVES \
$PREFIX/$arch-w64-mingw32/lib/libc++.a \
$PREFIX/$arch-w64-mingw32/lib/libunwind.a
fi
cd ..
done
cd ..
done
cd ..
}
ln -sf ../generic-w64-mingw32/include/c++ $PREFIX/include/c++
# Build shared first and static afterwards; the headers for static linking also
# work when linking against the DLL, but not vice versa.
[ -z "$BUILD_SHARED" ] || build_all shared
[ -z "$BUILD_STATIC" ] || build_all static
#!/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 libssp ]; then
svn checkout -q svn://gcc.gnu.org/svn/gcc/tags/gcc_7_3_0_release/libssp
fi
cp libssp-Makefile libssp/Makefile
cd libssp
# gcc/libssp's configure script runs checks for flags that clang doesn't
# implement. We actually just need to set a few HAVE defines and compile
# the .c sources.
cp config.h.in config.h
for i in HAVE_FCNTL_H HAVE_INTTYPES_H HAVE_LIMITS_H HAVE_MALLOC_H \
HAVE_MEMMOVE HAVE_MEMORY_H HAVE_MEMPCPY HAVE_STDINT_H HAVE_STDIO_H \
HAVE_STDLIB_H HAVE_STRINGS_H HAVE_STRING_H HAVE_STRNCAT HAVE_STRNCPY \
HAVE_SYS_STAT_H HAVE_SYS_TYPES_H HAVE_UNISTD_H HAVE_USABLE_VSNPRINTF \
HAVE_HIDDEN_VISIBILITY; do
cat config.h | sed 's/^#undef '$i'$/#define '$i' 1/' > tmp
mv tmp config.h
done
cat ssp/ssp.h.in | sed 's/@ssp_have_usable_vsnprintf@/define/' > ssp/ssp.h
for arch in $ARCHS; do
mkdir -p build-$arch
cd build-$arch
make -f ../Makefile -j$CORES CROSS=$arch-w64-mingw32-
mkdir -p $PREFIX/$arch-w64-mingw32/bin
cp libssp.a $PREFIX/$arch-w64-mingw32/lib
cp libssp_nonshared.a $PREFIX/$arch-w64-mingw32/lib
cp libssp.dll.a $PREFIX/$arch-w64-mingw32/lib
cp libssp-0.dll $PREFIX/$arch-w64-mingw32/bin
cd ..
done
......@@ -2,11 +2,22 @@
set -e
if [ $# -lt 1 ]; then
echo $0 dest
ASSERTS=ON
BUILDDIR=build
while [ $# -gt 0 ]; do
if [ "$1" = "--disable-asserts" ]; then
ASSERTS=OFF
BUILDDIR=build-noasserts
else
PREFIX="$1"
fi
shift
done
if [ -z "$PREFIX" ]; then
echo $0 [--disable-asserts] dest
exit 1
fi
PREFIX="$1"
: ${CORES:=4}
......@@ -37,13 +48,13 @@ fi
if [ -n "$SYNC" ] || [ -n "$CHECKOUT" ]; then
cd llvm
[ -z "$SYNC" ] || git fetch
git checkout 29475f1bf8ec6d0bd19c245fb8679448d513af98
git checkout 3e090e5aa550f55ab68927d18022c4e244733ab8
cd tools/clang
[ -z "$SYNC" ] || git fetch
git checkout 94cbbb825727057c7378c573b4093c58b667da80
git checkout 1bc73590ad1335313e8f262393547b8af67c9167
cd ../lld
[ -z "$SYNC" ] || git fetch
git checkout f3bc2b404cf547c08cc43840efd2373e8a0c7e66
git checkout 4ea826e45cf92d005bf9b1655920897ffc82f366
cd ../../..
fi
......@@ -53,14 +64,16 @@ if [ "$(which ninja)" != "" ]; then
fi
cd llvm
mkdir -p build
cd build
mkdir -p $BUILDDIR
cd $BUILDDIR
cmake \
$CMAKE_GENERATOR \
-DCMAKE_INSTALL_PREFIX="$PREFIX" \
-DCMAKE_BUILD_TYPE=Release \
-DLLVM_ENABLE_ASSERTIONS=ON \
-DLLVM_ENABLE_ASSERTIONS=$ASSERTS \
-DLLVM_TARGETS_TO_BUILD="ARM;AArch64;X86" \
-DLLVM_INSTALL_TOOLCHAIN_ONLY=ON \
-DLLVM_TOOLCHAIN_TOOLS="llvm-ar;llvm-ranlib;llvm-objdump;llvm-rc;llvm-cvtres;llvm-nm;llvm-strings;llvm-readobj;llvm-dlltool;llvm-pdbutil" \
..
if [ -n "$NINJA" ]; then
ninja install/strip
......
#!/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}}
cd mingw-w64/mingw-w64-libraries
for lib in winpthreads winstorecompat; do
cd $lib
for arch in $ARCHS; do
mkdir -p build-$arch
cd build-$arch
../configure --host=$arch-w64-mingw32 --prefix=$PREFIX/$arch-w64-mingw32 \
CC=$arch-w64-mingw32-clang AR=llvm-ar RANLIB=llvm-ranlib
make -j$CORES
make install
cd ..
done
cd ..
done
......@@ -13,7 +13,7 @@ export PATH=$PREFIX/bin:$PATH
: ${ARCHS:=${TOOLCHAIN_ARCHS-i686 x86_64 armv7 aarch64}}
if [ ! -d mingw-w64 ]; then
git clone https://github.com/mirror/mingw-w64
git clone git://git.code.sf.net/p/mingw-w64/mingw-w64
CHECKOUT=1
fi
......@@ -21,19 +21,19 @@ cd mingw-w64
if [ -n "$SYNC" ] || [ -n "$CHECKOUT" ]; then
[ -z "$SYNC" ] || git fetch
git checkout 17826c7e28e645375cbdce7818b5e5d2d7be20a2
git checkout 55e067dc48ad4aededf7a858b15a3039e8088ed4
fi
cd mingw-w64-headers
mkdir -p build
cd build
../configure --prefix=$PREFIX/generic-w64-mingw32 \
--enable-secure-api --enable-idl --with-default-win32-winnt=0x600 --with-default-msvcrt=ucrtbase INSTALL="install -C"
--enable-secure-api --enable-idl --with-default-win32-winnt=0x600 --with-default-msvcrt=ucrt INSTALL="install -C"
make install
cd ../..
for arch in $ARCHS; do
mkdir -p $PREFIX/$arch-w64-mingw32
ln -sf ../generic-w64-mingw32/include $PREFIX/$arch-w64-mingw32/include
ln -sfn ../generic-w64-mingw32/include $PREFIX/$arch-w64-mingw32/include
done
cd mingw-w64-crt
......@@ -54,7 +54,7 @@ for arch in $ARCHS; do
FLAGS="--disable-lib32 --enable-lib64"
;;
esac
FLAGS="$FLAGS --with-default-msvcrt=ucrtbase"
FLAGS="$FLAGS --with-default-msvcrt=ucrt"
../configure --host=$arch-w64-mingw32 --prefix=$PREFIX/$arch-w64-mingw32 $FLAGS \
CC=$arch-w64-mingw32-clang AR=llvm-ar RANLIB=llvm-ranlib DLLTOOL=llvm-dlltool
make -j$CORES
......
......@@ -12,18 +12,19 @@ PREFIX="$1"
mkdir -p $PREFIX/bin
cp wrappers/*-wrapper.sh $PREFIX/bin
cc wrappers/change-pe-arch.c -o $PREFIX/bin/change-pe-arch
cd $PREFIX/bin
for arch in $ARCHS; do
for exec in clang clang++ gcc g++; do
ln -sf clang-target-wrapper.sh $arch-w64-mingw32-$exec
done
for exec in ar ranlib nm strings; do
ln -sf llvm-$exec $arch-w64-mingw32-$exec
done
for exec in strip; do
ln -sf /bin/true $arch-w64-mingw32-$exec
ln -sf llvm-$exec $arch-w64-mingw32-$exec || true
done
for exec in ld objdump windres dlltool; do
ln -sf $exec-wrapper.sh $arch-w64-mingw32-$exec
done
for exec in objcopy strip; do
ln -sf objcopy-wrapper.sh $arch-w64-mingw32-$exec
done
done
SRC_PATH=$(word 1, $(dir $(MAKEFILE_LIST)))
vpath %.c $(SRC_PATH)
CC = $(CROSS)gcc
AR = $(CROSS)ar
CFLAGS = -O2 -Wall -Wundef -I$(SRC_PATH) -D_FORTIFY_SOURCE=0 -D__SSP_FORTIFY_LEVEL=0
SOURCES = $(filter-out ssp-local.c, $(patsubst $(SRC_PATH)%,%,$(wildcard $(SRC_PATH)*.c)))
OBJS = $(SOURCES:%.c=%.o)
all: libssp.a libssp_nonshared.a libssp-0.dll
libssp.a: $(OBJS)
$(AR) rcs $@ $+
libssp-0.dll: $(OBJS)
$(CC) -shared -o $@ $+ -Wl,--out-implib,libssp.dll.a
libssp_nonshared.a: ssp-local.o
$(AR) rcs $@ $+
clean:
rm -f *.a *.o *.dll
......@@ -10,17 +10,29 @@ PREFIX="$1"
cd "$PREFIX"
cd bin
for i in bugpoint c-index-test clang-* dsymutil git-clang-format llc lli llvm-* obj2yaml opt sancov sanstats scan-build scan-view verify-uselistorder yaml2obj; do
for i in bugpoint c-index-test clang-* diagtool dsymutil git-clang-format hmaptool llc lli llvm-* obj2yaml opt sancov sanstats scan-build scan-view verify-uselistorder yaml2obj; do
case $i in
*.sh)
;;
clang++|clang-*.*|clang-cpp)
;;
llvm-ar|llvm-cvtres|llvm-dlltool|llvm-nm|llvm-objdump|llvm-ranlib|llvm-rc|llvm-readobj|llvm-strings)
clang-*)
suffix="${i#*-}"
# Test removing all numbers from the suffix; if it is empty, the suffix
# was a plain number (as if the original name was clang-7); if it wasn't
# empty, remove the tool.
if [ "$(echo $suffix | tr -d '[0-9]')" != "" ]; then
rm $i
fi
;;
llvm-ar|llvm-cvtres|llvm-dlltool|llvm-nm|llvm-objdump|llvm-ranlib|llvm-rc|llvm-readobj|llvm-strings|llvm-pdbutil)
;;
*)
if [ -f $i ]; then
rm $i
elif [ -L $i ] && [ ! -e $(readlink $i) ]; then
# Remove dangling symlinks
rm $i
fi
;;
esac
......
/*
* Copyright (c) 2018 Martin Storsjo
*
* This file is part of llvm-mingw.
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
#include <stdio.h>
#include <stdint.h>
#include <string.h>
#define IMAGE_DOS_SIGNATURE 0x5A4D
#define IMAGE_NT_SIGNATURE 0x00004550
#define IMAGE_FILE_MACHINE_AMD64 0x8664
#define IMAGE_FILE_MACHINE_ARMNT 0x1C4
#define IMAGE_FILE_MACHINE_ARM64 0xAA64
#define IMAGE_FILE_MACHINE_I386 0x14C
static uint16_t readUint16(FILE *f) {
uint8_t buf[2];
if (fread(buf, 1, 2, f) != 2)
return -1;
return buf[0] | (buf[1] << 8);
}
static uint32_t readUint32(FILE *f) {
uint8_t buf[4];
if (fread(buf, 1, 4, f) != 4)
return -1;
return buf[0] | (buf[1] << 8) | (buf[2] << 16) | (buf[3] << 24);
}
static void writeUint16(FILE *f, uint16_t val) {
uint8_t buf[2];
buf[0] = val & 0xff;
buf[1] = (val >> 8) & 0xff;
if (fwrite(buf, 1, 2, f) != 2)
perror("fwrite");
}
static void writeUint32(FILE *f, uint32_t val) {
uint8_t buf[4];
buf[0] = val & 0xff;
buf[1] = (val >> 8) & 0xff;
buf[2] = (val >> 16) & 0xff;
buf[3] = (val >> 24) & 0xff;
if (fwrite(buf, 1, 4, f) != 4)
perror("fwrite");
}