Commit 6ae94c20 authored by Hugo Beauzée-Luyssen's avatar Hugo Beauzée-Luyssen

vlc-debian-llvm-mingw: Update from upstream

parent 67e3907e
......@@ -2,7 +2,7 @@
#
FROM registry.videolan.org:5000/videolan-base-sid:20180419103824
ENV IMAGE_DATE=20181108230
ENV IMAGE_DATE=201811122123
RUN apt-get update -qq && apt-get install -qqy \
git wget bzip2 file unzip libtool pkg-config cmake build-essential \
......@@ -35,7 +35,7 @@ ENV TOOLCHAIN_PREFIX=/opt/llvm-mingw
COPY build-llvm.sh strip-llvm.sh ./
RUN ./build-llvm.sh $TOOLCHAIN_PREFIX && \
./strip-llvm.sh $TOOLCHAIN_PREFIX && \
rm -rf /build
rm -rf /build/*
ARG TOOLCHAIN_ARCHS="i686 x86_64 armv7 aarch64"
......@@ -43,29 +43,29 @@ ARG TOOLCHAIN_ARCHS="i686 x86_64 armv7 aarch64"
COPY wrappers/*.sh wrappers/*.c ./wrappers/
COPY install-wrappers.sh .
RUN ./install-wrappers.sh $TOOLCHAIN_PREFIX && \
rm -rf /build
rm -rf /build/*
# Build MinGW-w64, compiler-rt and mingw-w64's extra libraries
COPY build-mingw-w64.sh build-mingw-w64-widl.sh build-compiler-rt.sh build-mingw-w64-libraries.sh ./
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
rm -rf /build/*
# Build libunwind/libcxxabi/libcxx
COPY build-libcxx.sh merge-archives.sh ./
RUN ./build-libcxx.sh $TOOLCHAIN_PREFIX && \
rm -rf /build
rm -rf /build/*
# Build sanitizers
COPY build-compiler-rt.sh .
RUN ./build-compiler-rt.sh $TOOLCHAIN_PREFIX --build-sanitizers && \
rm -rf /build
rm -rf /build/*
# Build libssp
COPY build-libssp.sh libssp-Makefile ./
RUN ./build-libssp.sh $TOOLCHAIN_PREFIX && \
rm -rf /build
rm -rf /build/*
# Cheating: Pull strip and objcopy from the normal binutils package.
RUN apt-get update -qq && \
......
......@@ -21,6 +21,8 @@ if [ -z "$PREFIX" ]; then
fi
export PATH=$PREFIX/bin:$PATH
: ${CORES:=$(nproc 2>/dev/null)}
: ${CORES:=$(sysctl -n hw.ncpu 2>/dev/null)}
: ${CORES:=4}
: ${ARCHS:=${TOOLCHAIN_ARCHS-i686 x86_64 armv7 aarch64}}
......@@ -40,7 +42,7 @@ cd compiler-rt
if [ -n "$SYNC" ] || [ -n "$CHECKOUT" ]; then
[ -z "$SYNC" ] || git fetch
git checkout fedf618bc7021e1038855668cf1740966b8a414d
git checkout 0492c25c247e31fe23570fe0cf6e9801301ab069
fi
for arch in $ARCHS; do
......
......@@ -25,6 +25,8 @@ if [ -z "$PREFIX" ]; then
fi
export PATH=$PREFIX/bin:$PATH
: ${CORES:=$(nproc 2>/dev/null)}
: ${CORES:=$(sysctl -n hw.ncpu 2>/dev/null)}
: ${CORES:=4}
: ${ARCHS:=${TOOLCHAIN_ARCHS-i686 x86_64 armv7 aarch64}}
......
......@@ -9,6 +9,8 @@ fi
PREFIX="$1"
export PATH=$PREFIX/bin:$PATH
: ${CORES:=$(nproc 2>/dev/null)}
: ${CORES:=$(sysctl -n hw.ncpu 2>/dev/null)}
: ${CORES:=4}
: ${ARCHS:=${TOOLCHAIN_ARCHS-i686 x86_64 armv7 aarch64}}
......
......@@ -22,6 +22,8 @@ if [ -z "$PREFIX" ]; then
exit 1
fi
: ${CORES:=$(nproc 2>/dev/null)}
: ${CORES:=$(sysctl -n hw.ncpu 2>/dev/null)}
: ${CORES:=4}
if [ ! -d llvm ]; then
......@@ -51,13 +53,13 @@ fi
if [ -n "$SYNC" ] || [ -n "$CHECKOUT" ]; then
cd llvm
[ -z "$SYNC" ] || git fetch
git checkout a978525b6415baf1f6a3f49b2cc8b50167f06e60
git checkout c76c02e1ed1a158628019f61aea45fcf87712d2c
cd tools/clang
[ -z "$SYNC" ] || git fetch
git checkout 122fb01a0d3afdb020866c719896161a1b829e03
git checkout e3de7bb263271008c55cc8bf3186a3a08999fbaa
cd ../lld
[ -z "$SYNC" ] || git fetch
git checkout d0c1d02fc3bb851b22f4e5396c9c5afa91842c7b
git checkout 935d766de8b251de001fed5f44b9567ccf6cadb1
cd ../../..
fi
......@@ -67,20 +69,35 @@ if [ -n "$(which ninja)" ]; then
fi
if [ -n "$HOST" ]; then
find_native_tools() {
if [ -d llvm/build/bin ]; then
echo $(pwd)/llvm/build/bin
elif [ -d llvm/build-asserts/bin ]; then
echo $(pwd)/llvm/build-asserts/bin
elif [ -d llvm/build-noasserts/bin ]; then
echo $(pwd)/llvm/build-noasserts/bin
elif [ -n "$(which llvm-tblgen)" ]; then
echo $(dirname $(which llvm-tblgen))
fi
}
native=$(find_native_tools)
if [ -z "$native" ]; then
# As we don't do any install here, the target prefix shouldn't actually
# be created.
HOST="" BUILDTARGETS="llvm-tblgen clang-tblgen llvm-config" $0 $PREFIX/llvmtools
native=$(find_native_tools)
if [ -z "$native" ]; then
echo Unable to find the newly built llvm-tblgen
exit 1
fi
fi
CMAKEFLAGS="$CMAKEFLAGS -DCMAKE_SYSTEM_NAME=Windows"
CMAKEFLAGS="$CMAKEFLAGS -DCMAKE_CROSSCOMPILE=1"
CMAKEFLAGS="$CMAKEFLAGS -DCMAKE_C_COMPILER=$HOST-gcc"
CMAKEFLAGS="$CMAKEFLAGS -DCMAKE_CXX_COMPILER=$HOST-g++"
CMAKEFLAGS="$CMAKEFLAGS -DCMAKE_RC_COMPILER=$HOST-windres"
if [ -d llvm/build/bin ]; then
native=$(pwd)/llvm/build/bin
elif [ -d llvm/build-asserts/bin ]; then
native=$(pwd)/llvm/build-asserts/bin
elif [ -d llvm/build-noasserts/bin ]; then
native=$(pwd)/llvm/build-noasserts/bin
else
native=$(dirname $(which llvm-tblgen))
fi
CMAKEFLAGS="$CMAKEFLAGS -DLLVM_TABLEGEN=$native/llvm-tblgen"
CMAKEFLAGS="$CMAKEFLAGS -DCLANG_TABLEGEN=$native/clang-tblgen"
CMAKEFLAGS="$CMAKEFLAGS -DLLVM_CONFIG_PATH=$native/llvm-config"
......@@ -112,8 +129,10 @@ cmake \
-DLLVM_TOOLCHAIN_TOOLS="llvm-ar;llvm-ranlib;llvm-objdump;llvm-rc;llvm-cvtres;llvm-nm;llvm-strings;llvm-readobj;llvm-dlltool;llvm-pdbutil" \
$CMAKEFLAGS \
..
: ${BUILDTARGETS:=install/strip}
if [ -n "$NINJA" ]; then
ninja install/strip
ninja $BUILDTARGETS
else
make -j$CORES install/strip
make -j$CORES $BUILDTARGETS
fi
......@@ -9,6 +9,8 @@ fi
PREFIX="$1"
export PATH=$PREFIX/bin:$PATH
: ${CORES:=$(nproc 2>/dev/null)}
: ${CORES:=$(sysctl -n hw.ncpu 2>/dev/null)}
: ${CORES:=4}
: ${ARCHS:=${TOOLCHAIN_ARCHS-i686 x86_64 armv7 aarch64}}
......
#!/bin/sh
set -e
if [ $# -lt 1 ]; then
echo $0 dest
exit 1
fi
PREFIX="$1"
# Not adding $PREFIX/bin to $PATH here, since that is expected to be
# a cross toolchain; the compiler is expected to be in $PATH already here.
: ${CORES:=4}
: ${ARCHS:=${TOOLCHAIN_ARCHS-i686 x86_64 armv7 aarch64}}
if [ -n "$HOST" ]; then
CONFIGFLAGS="--host=$HOST"
CROSS_NAME=$HOST-
fi
cd mingw-w64/mingw-w64-tools/widl
for arch in $ARCHS; do
mkdir -p build-$CROSS_NAME$arch
cd build-$CROSS_NAME$arch
../configure --prefix=$PREFIX --target=$arch-w64-mingw32 $CONFIGFLAGS LDFLAGS="-Wl,-s"
make -j$CORES
make install
cd ..
done
......@@ -2,13 +2,29 @@
set -e
if [ $# -lt 1 ]; then
echo $0 dest
while [ $# -gt 0 ]; do
if [ "$1" = "--skip-include-triplet-prefix" ]; then
SKIP_INCLUDE_TRIPLET_PREFIX=1
else
PREFIX="$1"
fi
shift
done
if [ -z "$PREFIX" ]; then
echo $0 [--skip-include-triplet-prefix] dest
exit 1
fi
PREFIX="$1"
export PATH=$PREFIX/bin:$PATH
if [ -z "$HOST" ]; then
# The newly built toolchain isn't crosscompiled; add it to the path.
export PATH=$PREFIX/bin:$PATH
else
# Crosscompiling the toolchain itself; the cross compiler is
# expected to already be in $PATH.
true
fi
: ${CORES:=$(nproc 2>/dev/null)}
: ${CORES:=$(sysctl -n hw.ncpu 2>/dev/null)}
: ${CORES:=4}
: ${ARCHS:=${TOOLCHAIN_ARCHS-i686 x86_64 armv7 aarch64}}
......@@ -21,47 +37,87 @@ cd mingw-w64
if [ -n "$SYNC" ] || [ -n "$CHECKOUT" ]; then
[ -z "$SYNC" ] || git fetch
git checkout 1b29d1bc58910a4c21ff2c5c804bf06821032348
git checkout c69c7a706d767c5ca3c7d1c70887fcd8e1f940b3
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=ucrt INSTALL="install -C"
make install
cd ../..
for arch in $ARCHS; do
mkdir -p $PREFIX/$arch-w64-mingw32
ln -sfn ../generic-w64-mingw32/include $PREFIX/$arch-w64-mingw32/include
done
# If crosscompiling the toolchain itself, we already have a mingw-w64
# runtime and don't need to rebuild it.
if [ -z "$HOST" ]; then
if [ -z "$SKIP_INCLUDE_TRIPLET_PREFIX" ]; then
HEADER_ROOT=$PREFIX/generic-w64-mingw32
else
HEADER_ROOT=$PREFIX
fi
cd mingw-w64-headers
mkdir -p build
cd build
../configure --prefix=$HEADER_ROOT \
--enable-secure-api --enable-idl --with-default-win32-winnt=0x600 --with-default-msvcrt=ucrt INSTALL="install -C"
make install
cd ../..
if [ -z "$SKIP_INCLUDE_TRIPLET_PREFIX" ]; then
for arch in $ARCHS; do
mkdir -p $PREFIX/$arch-w64-mingw32
ln -sfn ../generic-w64-mingw32/include $PREFIX/$arch-w64-mingw32/include
done
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
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
make install
cd ..
done
cd ..
fi
cd mingw-w64-crt
if [ -n "$HOST" ]; then
CONFIGFLAGS="$CONFIGFLAGS --host=$HOST"
CROSS_NAME=$HOST-
EXEEXT=.exe
fi
if [ -n "$SKIP_INCLUDE_TRIPLET_PREFIX" ]; then
CONFIGFLAGS="$CONFIGFLAGS --with-widl-includedir=$PREFIX/include"
# If using the same includedir for all archs, it's enough to
# build one single binary.
ALL_ARCHS="$ARCHS"
ARCHS=x86_64
fi
cd mingw-w64-tools/widl
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
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
mkdir -p build-$CROSS_NAME$arch
cd build-$CROSS_NAME$arch
../configure --prefix=$PREFIX --target=$arch-w64-mingw32 $CONFIGFLAGS LDFLAGS="-Wl,-s"
make -j$CORES
make install
cd ..
done
cd ..
cd ..
./build-mingw-w64-widl.sh "$PREFIX"
if [ -n "$SKIP_INCLUDE_TRIPLET_PREFIX" ]; then
cd $PREFIX/bin
for arch in $ALL_ARCHS; do
if [ "$arch" != "$ARCHS" ]; then
ln -sf $ARCHS-w64-mingw32-widl$EXEEXT $arch-w64-mingw32-widl$EXEEXT
fi
done
fi
......@@ -11,25 +11,69 @@ PREFIX="$1"
: ${ARCHS:=${TOOLCHAIN_ARCHS-i686 x86_64 armv7 aarch64}}
if [ -n "$HOST" ] && [ -z "$CC" ]; then
CC=${HOST}-gcc
CC=$HOST-gcc
fi
: ${CC:=cc}
case $(uname) in
MINGW*)
EXEEXT=.exe
;;
esac
if [ -n "$EXEEXT" ]; then
CLANG_MAJOR=$(basename $(echo $PREFIX/lib/clang/* | awk '{print $NF}') | cut -f 1 -d .)
WRAPPER_FLAGS="$WRAPPER_FLAGS -municode -DCLANG=\"clang-$CLANG_MAJOR\""
fi
mkdir -p $PREFIX/bin
cp wrappers/*-wrapper.sh $PREFIX/bin
if [ -n "$HOST" ]; then
# TODO: If building natively on msys, pick up the default HOST value from there.
WRAPPER_FLAGS="$WRAPPER_FLAGS -DDEFAULT_TARGET=\"$HOST\""
for i in wrappers/*-wrapper.sh; do
cat $i | sed 's/^DEFAULT_TARGET=.*/DEFAULT_TARGET='$HOST/ > $PREFIX/bin/$(basename $i)
done
fi
$CC wrappers/change-pe-arch.c -o $PREFIX/bin/change-pe-arch$EXEEXT
$CC wrappers/clang-target-wrapper.c -o $PREFIX/bin/clang-target-wrapper$EXEEXT -O2 -Wl,-s $WRAPPER_FLAGS
$CC wrappers/windres-wrapper.c -o $PREFIX/bin/windres-wrapper$EXEEXT -O2 -Wl,-s $WRAPPER_FLAGS
if [ -n "$EXEEXT" ]; then
# For Windows, we should prefer the executable wrapper, which also works
# when invoked from outside of MSYS.
CTW_SUFFIX=$EXEEXT
CTW_LINK_SUFFIX=$EXEEXT
else
CTW_SUFFIX=.sh
fi
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
for exec in clang clang++ gcc g++ cc c99 c11 c++; do
ln -sf clang-target-wrapper$CTW_SUFFIX $arch-w64-mingw32-$exec$CTW_LINK_SUFFIX
done
for exec in ar ranlib nm strings; do
ln -sf llvm-$exec$EXEEXT $arch-w64-mingw32-$exec || true
ln -sf llvm-$exec$EXEEXT $arch-w64-mingw32-$exec$EXEEXT || true
done
for exec in ld objdump windres dlltool; do
for exec in windres; do
ln -sf $exec-wrapper$EXEEXT $arch-w64-mingw32-$exec$EXEEXT
done
for exec in ld objdump 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
if [ -n "$EXEEXT" ]; then
if [ ! -L clang$EXEEXT ]; then
mv clang$EXEEXT clang-$CLANG_MAJOR$EXEEXT
fi
if [ -n "$HOST" ]; then
for exec in clang clang++ gcc g++ cc c99 c11 c++ ar ranlib nm strings widl windres; do
ln -sf $HOST-$exec$EXEEXT $exec$EXEEXT
done
for exec in ld objdump dlltool objcopy strip; do
ln -sf $HOST-$exec $exec
done
fi
fi
This diff is collapsed.
#!/bin/sh
DIR="$(cd "$(dirname "$0")" && pwd)"
TARGET="$(basename $0 | sed 's/-[^-]*$//')"
EXE=$(basename $0 | sed 's/.*-\([^-]*\)/\1/')
BASENAME="$(basename "$0")"
TARGET="${BASENAME%-*}"
EXE="${BASENAME##*-}"
DEFAULT_TARGET=x86_64-w64-mingw32
if [ "$TARGET" = "$BASENAME" ]; then
TARGET=$DEFAULT_TARGET
fi
ARCH="${TARGET%%-*}"
# Check if trying to compile Ada; if we try to do this, invoking clang
# would end up invoking <triplet>-gcc with the same arguments, which ends
# up in an infinite recursion.
case "$*" in
*-x\ ada*)
echo "Ada is not supported" >&2
exit 1
;;
*)
;;
esac
# Allow setting e.g. CCACHE=1 to wrap all building in ccache.
if [ -n "$CCACHE" ]; then
CCACHE=ccache
fi
# If changing this wrapper, change clang-target-wrapper.c accordingly.
CLANG="$DIR/clang"
FLAGS=""
case $EXE in
clang++|g++)
DRIVER_MODE=--driver-mode=g++
clang++|g++|c++)
FLAGS="$FLAGS --driver-mode=g++"
;;
esac
ARCH=$(echo $TARGET | sed 's/-.*//')
case $ARCH in
i686)
# Dwarf is the default for i686, but libunwind sometimes fails to
......@@ -19,23 +45,24 @@ i686)
# some handling relating to this dwarf opcode, which made
# test/hello-exception.cpp work properly, but apparently there are
# still issues with it).
ARCH_FLAGS=-fsjlj-exceptions
FLAGS="$FLAGS -fsjlj-exceptions"
;;
x86_64)
# SEH is the default here.
ARCH_FLAGS=
;;
armv7)
# Dwarf is the default here.
ARCH_FLAGS=
;;
aarch64)
# Dwarf is the default here.
ARCH_FLAGS=
;;
esac
# Allow setting e.g. CCACHE=1 to wrap all building in ccache.
if [ -n "$CCACHE" ]; then
CCACHE=ccache
fi
$CCACHE $DIR/clang $DRIVER_MODE -target $TARGET -rtlib=compiler-rt -stdlib=libc++ -fuse-ld=lld -fuse-cxa-atexit $ARCH_FLAGS -Qunused-arguments "$@"
FLAGS="$FLAGS -target $TARGET"
FLAGS="$FLAGS -rtlib=compiler-rt"
FLAGS="$FLAGS -stdlib=libc++"
FLAGS="$FLAGS -fuse-ld=lld"
FLAGS="$FLAGS -fuse-cxa-atexit"
FLAGS="$FLAGS -Qunused-arguments"
$CCACHE $CLANG $FLAGS "$@"
......@@ -3,8 +3,13 @@
DIR="$(cd "$(dirname "$0")" && pwd)"
export PATH=$DIR:$PATH
TARGET="$(basename $0 | sed 's/-[^-]*$//')"
ARCH=$(echo $TARGET | sed 's/-.*//')
BASENAME="$(basename "$0")"
TARGET="${BASENAME%-*}"
DEFAULT_TARGET=x86_64-w64-mingw32
if [ "$TARGET" = "$BASENAME" ]; then
TARGET=$DEFAULT_TARGET
fi
ARCH="${TARGET%%-*}"
case $ARCH in
i686) M=i386 ;;
x86_64) M=i386:x86-64 ;;
......
......@@ -19,8 +19,13 @@ if [ "$1" = "-v" ]; then
exit 0
fi
TARGET="$(basename $0 | sed 's/-[^-]*$//')"
ARCH=$(echo $TARGET | sed 's/-.*//')
BASENAME="$(basename "$0")"
TARGET="${BASENAME%-*}"
DEFAULT_TARGET=x86_64-w64-mingw32
if [ "$TARGET" = "$BASENAME" ]; then
TARGET=$DEFAULT_TARGET
fi
ARCH="${TARGET%%-*}"
case $ARCH in
i686) M=i386pe ;;
x86_64) M=i386pep ;;
......
......@@ -3,9 +3,14 @@
set -e
DIR="$(cd "$(dirname "$0")" && pwd)"
TARGET="$(basename $0 | sed 's/-[^-]*$//')"
EXE=$(basename $0 | sed 's/.*-\([^-]*\)/\1/')
ARCH=$(echo $TARGET | sed 's/-.*//')
BASENAME="$(basename "$0")"
TARGET="${BASENAME%-*}"
DEFAULT_TARGET=x86_64-w64-mingw32
if [ "$TARGET" = "$BASENAME" ]; then
TARGET=$DEFAULT_TARGET
fi
EXE="${BASENAME##*-}"
ARCH="${TARGET%%-*}"
IN=""
OUT=""
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment