-
Notifications
You must be signed in to change notification settings - Fork 48
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
NMake Builds: Fix linking on Rust 1.70.0 or later
Link also to ntdll.lib which became required since Rust 1.70.0 or nightly-2023-03-21 [1] (which was sadly not clearly documented as such) when linking the resulting rsvg DLL. So, we extend the batch script that is used to formerly query the default Rust toolchain to also check whether it requires linking to ntdll.lib by checking against the Rust version. [1]: rust-lang/rust#108262 Fixes issue #968.
- Loading branch information
Showing
6 changed files
with
95 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
@echo off | ||
:: SETLOCAL ENABLEDELAYEDEXPANSION | ||
if not "%1" == "use-rustup" if not "%1" == "set-toolchain" goto :err_badopt | ||
if "%2" == "" goto :err_badopt | ||
|
||
set RUSTUP=%2 | ||
if "%1" == "set-toolchain" goto :parse_toolchain | ||
|
||
FOR /F "tokens=* USEBACKQ" %%F IN (`%RUSTUP% default`) DO ( | ||
SET RUST_DEFAULT_TOOLCHAIN=%%F | ||
) | ||
|
||
:: We want to be very sure that if we are using the default | ||
:: Rust toolchain for the build, we are indeed using an msvc | ||
:: one! | ||
|
||
FOR /F "tokens=1,2,3,4,5* delims=-" %%a IN ("%RUST_DEFAULT_TOOLCHAIN%") do ( | ||
:: <version>-<platform>-pc-windows-msvc (default) or stable-<platform>-pc-windows-msvc (default) | ||
if not "%%a" == "nightly" set CHANNEL=%%a | ||
if not "%%a" == "nightly" set TARGET=%%b | ||
if not "%%a" == "nightly" FOR /F "tokens=1,2 delims= " %%o IN ("%%e") do ( | ||
set TOOLCHAIN_COMPILER=%%c-%%d-%%o | ||
) | ||
|
||
:: nightly-yyyy-mm-dd-<platform>-pc-windows-msvc (default) | ||
if "%%a" == "nightly" set CHANNEL=%%a-%%b-%%c | ||
if "%%a" == "nightly" set TARGET=%%e | ||
if "%%a" == "nightly" FOR /F "tokens=1,2 delims= " %%o IN ("%%f") do ( | ||
set TOOLCHAIN_COMPILER=%%o | ||
) | ||
) | ||
|
||
if "%TARGET%" == "aarch64" set NMAKE_TGT=amd64 | ||
if "%TARGET%" == "x86_64" set NMAKE_TGT=x64 | ||
if "%TARGET%" == "i686" set NMAKE_TGT=Win32 | ||
|
||
if exist rust-cfg.mak goto :EOF | ||
echo RUST_DEFAULT_CHANNEL=%CHANNEL%>>rust-cfg.mak | ||
echo RUST_DEFAULT_TARGET=%NMAKE_TGT%>>rust-cfg.mak | ||
echo RUST_DEFAULT_COMPILER=%TOOLCHAIN_COMPILER%>>rust-cfg.mak | ||
goto :check_link_ntdll | ||
|
||
:parse_toolchain | ||
if "%3" == "" goto :err_badopt | ||
set CHANNEL=%3 | ||
|
||
:check_link_ntdll | ||
FOR /F "tokens=1* delims=-" %%a IN ("%CHANNEL%") do ( | ||
set CHANNEL_TYPE=%%a | ||
set NIGHTLY_DATE=%%b | ||
) | ||
|
||
:: Query the actual Rust version if the "stable" channel is used | ||
if "%CHANNEL_TYPE%" == "stable" FOR /F "tokens=1,2* delims= " %%o in ('%RUSTUP:rustup=rustc% --version') do ( | ||
set CHANNEL_TYPE=%%p | ||
) | ||
|
||
if not "%CHANNEL_TYPE%" == "nightly" ( | ||
if "%CHANNEL_TYPE%" GEQ "1.70.0" echo LIBRSVG_USE_NTDLL=1 >> rust-cfg.mak | ||
if "%CHANNEL_TYPE%" LSS "1.70.0" echo LIBRSVG_USE_NTDLL=0 >> rust-cfg.mak | ||
) | ||
if "%CHANNEL_TYPE%" == "nightly" ( | ||
if "%NIGHTLY_DATE%" GEQ "2023-03-21" echo LIBRSVG_USE_NTDLL=1 >> rust-cfg.mak | ||
if "%NIGHTLY_DATE%" LSS "2023-03-21" echo LIBRSVG_USE_NTDLL=0 >> rust-cfg.mak | ||
) | ||
goto :EOF | ||
|
||
:err_badopt | ||
echo Usage: %0 [use-rustup^|set-toolchain] rustup-executable] ^<toolchain-version-for-set-toolchain^> |