Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: Test MinGW and FFmpeg LTO #150

Draft
wants to merge 7 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .github/scripts/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ fi

if [[ "$PLATFORM" =~ (mingw|cygwin) ]]; then
.github/scripts/toolchain/build-mingw-crt.sh
if [[ "$MINGW_LTO" = 1 ]]; then
LTO=1 .github/scripts/toolchain/build-mingw-crt.sh
fi
fi
if [[ "$PLATFORM" =~ mingw ]]; then
.github/scripts/toolchain/build-mingw-winpthreads.sh
Expand All @@ -75,6 +78,9 @@ fi

if [[ "$PLATFORM" =~ (mingw|cygwin) ]]; then
.github/scripts/toolchain/build-mingw.sh
if [[ "$MINGW_LTO" = 1 ]]; then
LTO=1 .github/scripts/toolchain/build-mingw.sh
fi
fi
if [[ "$PLATFORM" =~ cygwin ]]; then
.github/scripts/toolchain/build-cygwin.sh 2
Expand Down
4 changes: 4 additions & 0 deletions .github/scripts/config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ if [[ ("$PLATFORM" =~ (mingw|cygwin) && ! ("$CRT" =~ (msvcrt|ucrt))) ||
exit 1
fi

if [[ "$TOOLCHAIN_NAME" = aarch64-w64-mingw32-msvcrt ]]; then
MINGW_LTO=${MINGW_LTO:-1}
fi

SOURCE_PATH=${SOURCE_PATH:-$PWD/code}
DOWNLOADS_PATH=${DOWNLOADS_PATH:-$PWD/downloads}
PATCHES_PATH=${PATCHES_PATH:-$PWD/patches}
Expand Down
14 changes: 13 additions & 1 deletion .github/scripts/ffmpeg/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,19 @@ if [[ "$RUN_CONFIG" = 1 ]] || [[ ! -f "$FFMPEG_BUILD_PATH/Makefile" ]]; then
--enable-debug=3"
fi

CFLAGS="-Wno-incompatible-pointer-types -fno-builtin-sin -fno-builtin-cos" \
CFLAGS="-Wno-incompatible-pointer-types -fno-builtin-sin -fno-builtin-cos"

if [[ "$LTO" = 1 ]]; then
CFLAGS=" \
$CFLAGS \
-fno-builtin"
HOST_OPTIONS=" \
$HOST_OPTIONS \
--enable-lto"

fi

CFLAGS=$CFLAGS \
$FFMPEG_SOURCE_PATH/configure \
--prefix=$FFMPEG_PATH \
--target-path="." \
Expand Down
9 changes: 8 additions & 1 deletion .github/scripts/toolchain/build-gcc-stage1.sh
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ if [[ "$RUN_CONFIG" = 1 ]] || [[ ! -f "$GCC_BUILD_PATH/Makefile" ]]; then
*mingw*)
TARGET_OPTIONS="$TARGET_OPTIONS \
--enable-languages=c \
--enable-lto \
--disable-isl-version-check \
--disable-rpath \
--disable-win32-registry \
Expand All @@ -64,7 +65,6 @@ if [[ "$RUN_CONFIG" = 1 ]] || [[ ! -f "$GCC_BUILD_PATH/Makefile" ]]; then
--disable-shared \
--disable-bootstrap \
--disable-multilib \
--disable-plugins \
--disable-gcov \
--disable-libatomic \
--disable-libgomp \
Expand All @@ -91,6 +91,13 @@ if [[ "$RUN_INSTALL" = 1 ]]; then
rm -rf $GCC_BUILD_PATH
fi
echo "::endgroup::"

lto_plugin_path=$(find $TOOLCHAIN_PATH/libexec/gcc/$TARGET -type f -name liblto_plugin.so | head -n 1)
if [ -n $lto_plugin_path ]; then
echo "::group::Install LTO plug-in"
ln -sf $lto_plugin_path $TOOLCHAIN_PATH/lib/bfd-plugins/liblto_plugin.so
echo "::endgroup::"
fi
fi

echo 'Success!'
7 changes: 7 additions & 0 deletions .github/scripts/toolchain/build-gcc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,13 @@ if [[ "$RUN_INSTALL" = 1 ]]; then
rm -rf $GCC_BUILD_PATH
fi
echo "::endgroup::"

lto_plugin_path=$(find $TOOLCHAIN_PATH/lib/gcc/$TARGET -type f -name liblto_plugin.so | head -n 1)
if [ -n $lto_plugin_path ]; then
echo "::group::Install LTO plug-in"
ln -sf $lto_plugin_path $TOOLCHAIN_PATH/lib/bfd-plugins/liblto_plugin.so
echo "::endgroup::"
fi
fi

echo 'Success!'
20 changes: 16 additions & 4 deletions .github/scripts/toolchain/build-mingw-crt.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,13 @@

source `dirname ${BASH_SOURCE[0]}`/../config.sh

MINGW_BUILD_PATH=$BUILD_PATH/mingw-crt
if [[ "$LTO" = 1 ]]; then
MINGW_BUILD_PATH=$BUILD_PATH/mingw-crt-lto
INSTALL_PATH=$TOOLCHAIN_PATH/$TARGET/lto
else
MINGW_BUILD_PATH=$BUILD_PATH/mingw-crt
INSTALL_PATH=$TOOLCHAIN_PATH/$TARGET
fi

mkdir -p $MINGW_BUILD_PATH
cd $MINGW_BUILD_PATH
Expand All @@ -16,6 +22,12 @@ if [[ "$RUN_CONFIG" = 1 ]] || [[ ! -f "$MINGW_BUILD_PATH/Makefile" ]]; then
--enable-debug"
fi

if [ "$LTO" = 1 ] ; then
CFLAGS="$CFLAGS \
-flto \
-fno-builtin"
fi

case "$ARCH" in
x86_64)
TARGET_OPTIONS="$TARGET_OPTIONS \
Expand All @@ -39,12 +51,12 @@ if [[ "$RUN_CONFIG" = 1 ]] || [[ ! -f "$MINGW_BUILD_PATH/Makefile" ]]; then
*cygwin*)
TARGET_OPTIONS="$TARGET_OPTIONS \
--enable-w32api"
;;
;;
*mingw*)
TARGET_OPTIONS="$TARGET_OPTIONS \
--enable-wildcard \
--disable-dependency-tracking"
;;
;;
esac

case "$CRT" in
Expand All @@ -59,7 +71,7 @@ if [[ "$RUN_CONFIG" = 1 ]] || [[ ! -f "$MINGW_BUILD_PATH/Makefile" ]]; then
esac

$SOURCE_PATH/$MINGW_VERSION/mingw-w64-crt/configure \
--prefix=$TOOLCHAIN_PATH/$TARGET \
--prefix=$INSTALL_PATH \
--build=$BUILD \
--host=$TARGET \
$HOST_OPTIONS \
Expand Down
20 changes: 16 additions & 4 deletions .github/scripts/toolchain/build-mingw.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,13 @@

source `dirname ${BASH_SOURCE[0]}`/../config.sh

MINGW_BUILD_PATH=$BUILD_PATH/mingw
if [[ "$LTO" = 1 ]]; then
MINGW_BUILD_PATH=$BUILD_PATH/mingw-lto
INSTALL_PATH=$TOOLCHAIN_PATH/$TARGET/lto
else
MINGW_BUILD_PATH=$BUILD_PATH/mingw
INSTALL_PATH=$TOOLCHAIN_PATH/$TARGET
fi

mkdir -p $MINGW_BUILD_PATH
cd $MINGW_BUILD_PATH
Expand All @@ -16,6 +22,12 @@ if [[ "$RUN_CONFIG" = 1 ]] || [[ ! -f "$MINGW_BUILD_PATH/Makefile" ]]; then
--enable-debug"
fi

if [[ "$LTO" = 1 ]]; then
CFLAGS="$CFLAGS \
-flto \
-fno-builtin"
fi

case "$ARCH" in
x86_64)
TARGET_OPTIONS="$TARGET_OPTIONS \
Expand All @@ -39,12 +51,12 @@ if [[ "$RUN_CONFIG" = 1 ]] || [[ ! -f "$MINGW_BUILD_PATH/Makefile" ]]; then
*cygwin*)
TARGET_OPTIONS="$TARGET_OPTIONS \
--enable-w32api"
;;
;;
*mingw*)
TARGET_OPTIONS="$TARGET_OPTIONS \
--enable-wildcard \
--disable-dependency-tracking"
;;
;;
esac

case "$CRT" in
Expand All @@ -59,7 +71,7 @@ if [[ "$RUN_CONFIG" = 1 ]] || [[ ! -f "$MINGW_BUILD_PATH/Makefile" ]]; then
esac

$SOURCE_PATH/$MINGW_VERSION/configure \
--prefix=$TOOLCHAIN_PATH/$TARGET \
--prefix=$INSTALL_PATH \
--build=$BUILD \
--host=$TARGET \
$HOST_OPTIONS \
Expand Down
Loading