-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix Rust linking on component and debug Windows builds
1. The CRT can be specified from rustc but only static/dynamic, not release/debug. This is tracked upstream in rust-lang/libs-team#211 Because of this, we must not use the CRT command line options from rustc, and instead specify the library directly. This is done at the same location where the CRT is chosen for C++ targets via the "/MD" and friends flags. Then, we must not have rustc try to also link the CRT and we disable that by setting -Zlink-directives=false for the libc crate. 2. After the above, we have two sets of libraries that must be linked when using the rust stdlib. Internal dependencies, which are #[link] directives from the libc crate (other than the CRT), which must be linked any time the rust lib is used. Public dependencies, which are linked automatically by rustc but are not linked by C++ targets that depend on Rust targets. So we split these into two configs, and expose the latter on the BUILD rule for C++ targets that depend on Rust. 3. The local build of stdlib is here to stay and is always used with the Chromium toolchain, so remove a bunch of configuration levers around it and just hardcode the stdlib in when using the Chromium toolchain. And hardcode the prebuilt stdlib path when not using the Chromium toolchain. This removes a bunch of branches elsewhere in our GN rules as we can simply depend on the "rust stdlib target" instead of choosing between them. Then drop the test build target that was opting into the local stdlib as all our Rust build tests do that now. 4. Don't use __attribute__((visibility("default"))) on Windows, use __declspec(dllexport) instead. I don't know that this fixes anything, but that attribute doesn't exist on Windows, so yeah. 5. In the component build, C++ targets are linked with the dynamic CRT. In order to have mixed targets, Rust needs to as well. Then Rust build script exes are linked with the dynamic CRT and they are unable to find the DLL on the bots (which don't have Visual Studio) installed. The CRT DLL is placed in root_out_dir, so we move build script exes to the root_out_dir in order to have them find the DLL and be able to execute. 6. Ensure the CRT DLLs are present on the bots when running the tests by adding a data_deps edge to them for build_rust_tests. Normally this edge comes from a dependency on //base which basically everything has, but our Rust build tests don't. 7. Disable rust_shared_library unit test on Windows component build while we figure out how to get the right `data_deps` edge from the test to the library so that it's included in the isolate. When building a library's tests, the library itself is recompiled under cfg=test as part of the test exe. So the rlib or shared library itself is not used. But we still need to depend on any transitive deps of that library when building the unit tests, so the unit tests add a deps edge onto the library. For shared libraries this deps edge doesn't do anything on Linux, or on Windows non-component builds. But on Windows component builds, the unit test EXE acquires a dependency on the DLL (as shown by dumpbin) and thus the DLL needs to be present when running the test. Bug: 1442273, 1434719 Change-Id: I157a0728ec25f636d0b78973b8ab81205e7b25ef Cq-Include-Trybots: luci.chromium.try:win-rust-x64-rel,win-rust-x64-dbg,linux-rust-x64-rel,linux-rust-x64-dbg,android-rust-arm64-rel,android-rust-arm64-dbg,android-rust-arm32-rel Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4499979 Reviewed-by: Bruce Dawson <brucedawson@chromium.org> Commit-Queue: danakj <danakj@chromium.org> Reviewed-by: Adrian Taylor <adetaylor@chromium.org> Cr-Commit-Position: refs/heads/main@{#1139572} NOKEYCHECK=True GitOrigin-RevId: e917deabc983569acfd001b06fa71ea3471d8ff3
- Loading branch information
1 parent
aa6d19f
commit 5311fc0
Showing
19 changed files
with
273 additions
and
253 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 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
Oops, something went wrong.