Enable X-lang LTO for Windows x86-64 builds (or any extra build)
authorMatt Corallo <git@bluematt.me>
Thu, 1 Feb 2024 19:28:31 +0000 (19:28 +0000)
committerMatt Corallo <git@bluematt.me>
Thu, 1 Feb 2024 19:28:31 +0000 (19:28 +0000)
deterministic-build-wrappers/clang-x86_64-windows
genbindings.sh

index 31bb0280b63963656c0ac4065c4b373984a6d867..6c925dd8109a67d12f56a6b2b1509d8c2716632b 100755 (executable)
@@ -1,2 +1,2 @@
 #!/bin/bash
-clang -target x86_64-pc-windows-gnu -L/usr/lib/gcc/x86_64-w64-mingw32/12-win32/ "$@"
+clang -fembed-bitcode -fuse-ld=lld -target x86_64-pc-windows-gnu "$@"
index dd76e3040304b16a1218904a27c520172b5dde17..6007f721f2954e98682d9cc990e85c46d280ed4a 100755 (executable)
@@ -552,6 +552,7 @@ fi
 
 EXTRA_TARGETS=( $LDK_C_BINDINGS_EXTRA_TARGETS )
 EXTRA_CCS=( $LDK_C_BINDINGS_EXTRA_TARGET_CCS )
+EXTRA_LINK_LTO=( $LDK_C_BINDINGS_EXTRA_TARGET_LINK_LTO )
 
 if [ ${#EXTRA_TARGETS[@]} != ${#EXTRA_CCS[@]} ]; then
        echo "LDK_C_BINDINGS_EXTRA_TARGETS and LDK_C_BINDINGS_EXTRA_TARGET_CCS didn't have the same number of elements!"
@@ -569,6 +570,7 @@ for IDX in ${!EXTRA_TARGETS[@]}; do
                        EXTRA_RUSTFLAGS="-C target-cpu=sandybridge"
                        ;;
        esac
+       [ "${EXTRA_LINK_LTO[$IDX]}" != "" ] && EXTRA_RUSTFLAGS="-C linker-plugin-lto"
        RUSTFLAGS="$BASE_RUSTFLAGS -C embed-bitcode=yes -C lto -C linker=${EXTRA_CCS[$IDX]} $EXTRA_RUSTFLAGS" CARGO_PROFILE_RELEASE_LTO=true cargo build $CARGO_BUILD_ARGS -v --release --target "${EXTRA_TARGETS[$IDX]}"
 done