Skip to content

Commit

Permalink
makefiles: fix Windows unresolved symbol link errs.
Browse files Browse the repository at this point in the history
Previously, building the tip of `main` in CI for Windows, Windows CMake
(Debug), and Windows CMake (Release) was failing with link-time errors
of the form:

```
rustls_ffi.lib(std-391022a4250a8b9a.std.feb3b897-cgu.0.rcgu.o) : error
LNK2019: unresolved external symbol __imp_NtWriteFile referenced in
function
_ZN3std3sys7windows6handle6Handle17synchronous_write17h5e143db420a86fa8E
[D:\a\rustls-ffi\rustls-ffi\build\tests\server.vcxproj]
```

The fix is to explicitly include `ntdll.lib` in the native static libs
that we link on Windows. Doing this fixes the builds once we also update
the `verify-static-libraries.py` script to expect this additional lib.

This may be related to an upstream `rust-lang/rust` change[0] but I'm
not 100% sure.

[0]: rust-lang/rust#108262
  • Loading branch information
cpu committed Jun 29, 2023
1 parent 32a8c30 commit 132cabb
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Makefile.Windows
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ $(RUSTLS_LIB): src/lib.rs Cargo.toml
@echo

target/%.exe: common.obj %.obj $(RUSTLS_LIB)
$(call link_EXE, $@, $^ advapi32.lib credui.lib kernel32.lib secur32.lib legacy_stdio_definitions.lib kernel32.lib advapi32.lib userenv.lib kernel32.lib kernel32.lib ws2_32.lib bcrypt.lib msvcrt.lib legacy_stdio_definitions.lib userenv.lib kernel32.lib msvcrt.lib)
$(call link_EXE, $@, $^ advapi32.lib credui.lib kernel32.lib secur32.lib legacy_stdio_definitions.lib kernel32.lib advapi32.lib userenv.lib kernel32.lib kernel32.lib ws2_32.lib bcrypt.lib msvcrt.lib legacy_stdio_definitions.lib userenv.lib kernel32.lib msvcrt.lib ntdll.lib)

clean:
rm -f *.obj target/.rustc_info.json $(RUSTLS_LIB) vc1*.pdb
Expand Down
4 changes: 2 additions & 2 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ IF(WIN32)
client
debug "${CMAKE_SOURCE_DIR}/target/debug/rustls_ffi.lib"
optimized "${CMAKE_SOURCE_DIR}/target/release/rustls_ffi.lib"
advapi32.lib credui.lib kernel32.lib secur32.lib legacy_stdio_definitions.lib kernel32.lib advapi32.lib userenv.lib kernel32.lib kernel32.lib ws2_32.lib bcrypt.lib msvcrt.lib legacy_stdio_definitions.lib userenv.lib kernel32.lib msvcrt.lib
advapi32.lib credui.lib kernel32.lib secur32.lib legacy_stdio_definitions.lib kernel32.lib advapi32.lib userenv.lib kernel32.lib kernel32.lib ws2_32.lib bcrypt.lib msvcrt.lib legacy_stdio_definitions.lib userenv.lib kernel32.lib msvcrt.lib ntdll.lib
)
set_property(TARGET client PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreadedDLL")
ENDIF(WIN32)
Expand All @@ -34,7 +34,7 @@ IF(WIN32)
server
debug "${CMAKE_SOURCE_DIR}/target/debug/rustls_ffi.lib"
optimized "${CMAKE_SOURCE_DIR}/target/release/rustls_ffi.lib"
advapi32.lib credui.lib kernel32.lib secur32.lib legacy_stdio_definitions.lib kernel32.lib advapi32.lib userenv.lib kernel32.lib kernel32.lib ws2_32.lib bcrypt.lib msvcrt.lib legacy_stdio_definitions.lib userenv.lib kernel32.lib msvcrt.lib
advapi32.lib credui.lib kernel32.lib secur32.lib legacy_stdio_definitions.lib kernel32.lib advapi32.lib userenv.lib kernel32.lib kernel32.lib ws2_32.lib bcrypt.lib msvcrt.lib legacy_stdio_definitions.lib userenv.lib kernel32.lib msvcrt.lib ntdll.lib
)
set_property(TARGET server PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreadedDLL")
ENDIF(WIN32)
Expand Down
2 changes: 1 addition & 1 deletion tests/verify-static-libraries.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def main():
"advapi32.lib credui.lib kernel32.lib secur32.lib "
"legacy_stdio_definitions.lib "
"kernel32.lib advapi32.lib userenv.lib "
"kernel32.lib kernel32.lib ws2_32.lib bcrypt.lib msvcrt.lib "
"kernel32.lib kernel32.lib ws2_32.lib bcrypt.lib ntdll.lib msvcrt.lib "
"legacy_stdio_definitions.lib"
)
else:
Expand Down

0 comments on commit 132cabb

Please sign in to comment.