@@ -31,40 +31,44 @@ fn main() {
3131 // Set linker options specific to Windows MSVC.
3232 let target_os = env:: var ( "CARGO_CFG_TARGET_OS" ) ;
3333 let target_env = env:: var ( "CARGO_CFG_TARGET_ENV" ) ;
34- if !( target_os. as_deref ( ) == Ok ( "windows" ) && target_env. as_deref ( ) == Ok ( "msvc" ) ) {
35- return ;
36- }
34+ let target_pointer_width = env:: var ( "CARGO_CFG_TARGET_POINTER_WIDTH" ) ;
3735
38- // # Only search system32 for DLLs
39- //
40- // This applies to DLLs loaded at load time. However, this setting is ignored
41- // before Windows 10 RS1 (aka 1601).
42- // https://learn.microsoft.com/en-us/cpp/build/reference/dependentloadflag?view=msvc-170
43- println ! ( "cargo:cargo:rustc-link-arg-bin=rustup-init=/DEPENDENTLOADFLAG:0x800" ) ;
36+ if target_os. as_deref ( ) == Ok ( "android" ) && target_pointer_width. as_deref ( ) == Ok ( "32" ) {
37+ // Disable atomics and use locks instead in OpenSSL v3 on `i686-linux-android`.
38+ // See <https://github.com/sfackler/rust-openssl/issues/2043#issuecomment-1763528874>.
39+ println ! ( "cargo:rustc-link-arg=-DBROKEN_CLANG_ATOMICS" )
40+ } else if target_os. as_deref ( ) == Ok ( "windows" ) && target_env. as_deref ( ) == Ok ( "msvc" ) {
41+ // # Only search system32 for DLLs
42+ //
43+ // This applies to DLLs loaded at load time. However, this setting is ignored
44+ // before Windows 10 RS1 (aka 1601).
45+ // https://learn.microsoft.com/en-us/cpp/build/reference/dependentloadflag?view=msvc-170
46+ println ! ( "cargo:cargo:rustc-link-arg-bin=rustup-init=/DEPENDENTLOADFLAG:0x800" ) ;
4447
45- // # Delay load
46- //
47- // Delay load dlls that are not "known DLLs"[1].
48- // Known DLLs are always loaded from the system directory whereas other DLLs
49- // are loaded from the application directory. By delay loading the latter
50- // we can ensure they are instead loaded from the system directory.
51- // [1]: https://learn.microsoft.com/en-us/windows/win32/dlls/dynamic-link-library-search-order#factors-that-affect-searching
52- //
53- // This will work on all supported Windows versions but it relies on
54- // us using `SetDefaultDllDirectories` before any libraries are loaded.
55- // See also: src/bin/rustup-init.rs
56- let delay_load_dlls = [ "bcrypt" , "powrprof" , "secur32" ] ;
57- for dll in delay_load_dlls {
58- println ! ( "cargo:rustc-link-arg-bin=rustup-init=/delayload:{dll}.dll" ) ;
59- }
60- // When using delayload, it's necessary to also link delayimp.lib
61- // https://learn.microsoft.com/en-us/cpp/build/reference/dependentloadflag?view=msvc-170
62- println ! ( "cargo:rustc-link-arg-bin=rustup-init=delayimp.lib" ) ;
48+ // # Delay load
49+ //
50+ // Delay load dlls that are not "known DLLs"[1].
51+ // Known DLLs are always loaded from the system directory whereas other DLLs
52+ // are loaded from the application directory. By delay loading the latter
53+ // we can ensure they are instead loaded from the system directory.
54+ // [1]: https://learn.microsoft.com/en-us/windows/win32/dlls/dynamic-link-library-search-order#factors-that-affect-searching
55+ //
56+ // This will work on all supported Windows versions but it relies on
57+ // us using `SetDefaultDllDirectories` before any libraries are loaded.
58+ // See also: src/bin/rustup-init.rs
59+ let delay_load_dlls = [ "bcrypt" , "powrprof" , "secur32" ] ;
60+ for dll in delay_load_dlls {
61+ println ! ( "cargo:rustc-link-arg-bin=rustup-init=/delayload:{dll}.dll" ) ;
62+ }
63+ // When using delayload, it's necessary to also link delayimp.lib
64+ // https://learn.microsoft.com/en-us/cpp/build/reference/dependentloadflag?view=msvc-170
65+ println ! ( "cargo:rustc-link-arg-bin=rustup-init=delayimp.lib" ) ;
6366
64- // # Turn linker warnings into errors
65- //
66- // Rust hides linker warnings meaning mistakes may go unnoticed.
67- // Turning them into errors forces them to be displayed (and the build to fail).
68- // If we do want to ignore specific warnings then `/IGNORE:` should be used.
69- println ! ( "cargo:cargo:rustc-link-arg-bin=rustup-init=/WX" ) ;
67+ // # Turn linker warnings into errors
68+ //
69+ // Rust hides linker warnings meaning mistakes may go unnoticed.
70+ // Turning them into errors forces them to be displayed (and the build to fail).
71+ // If we do want to ignore specific warnings then `/IGNORE:` should be used.
72+ println ! ( "cargo:cargo:rustc-link-arg-bin=rustup-init=/WX" ) ;
73+ }
7074}
0 commit comments