Windows: the nvsdk_ngx_d / nvsdk_ngx_s choice uses the build script's own cfg, not the target's crt-static
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức phù hợp với người mới
- 73/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- rust
- Lĩnh vực
- build-system
Hướng nghiên cứu
Bắt đầu trong build.rs và kiểm tra cách nó chọn nvsdk_ngx_d hoặc nvsdk_ngx_s. Sau đó, kiểm tra cách tập lệnh hiện đọc các thiết lập của mục tiêu để liên kết. Đọc các biến môi trường của tập lệnh build Cargo, đặc biệt là CARGO_CFG_TARGET_FEATURE, và cân nhắc việc chọn target_os tương ứng cho thư mục include của Vulkan SDK. Hoàn thành khi lựa chọn thư viện tuân theo thiết lập crt-static của mục tiêu và đường dẫn include của Windows SDK hoạt động với các bản build chéo Windows chạy trên máy chủ Linux.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
build.rs picks the NGX library like this:
#[cfg(not(target_feature = "crt-static"))]
println!("cargo:rustc-link-lib=static=nvsdk_ngx_d");
#[cfg(target_feature = "crt-static")]
println!("cargo:rustc-link-lib=static=nvsdk_ngx_s");
Inside a build script, #[cfg(target_feature = …)] describes how the build script itself was compiled, not the crate being built. Cargo exposes the target's features to build scripts as CARGO_CFG_TARGET_FEATURE, a comma-separated list (Cargo book: environment variables Cargo sets for build scripts).
The two only agree when the same RUSTFLAGS reach both host and target, as with a plain RUSTFLAGS=-C target-feature=+crt-static cargo build without --target. Whenever crt-static is set for the target only, a static-CRT binary links nvsdk_ngx_d, the dynamic-CRT library. Examples:
cargo build --target x86_64-pc-windows-msvcwithRUSTFLAGSCARGO_TARGET_X86_64_PC_WINDOWS_MSVC_RUSTFLAGS[target.x86_64-pc-windows-msvc] rustflagswith--target
MSVC then rejects the mix:
error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MD_DynamicRelease' doesn't match value 'MT_StaticRelease'
Getting the choice right matters in practice because other common dependencies ship static-CRT libraries. For example, nethost-sys (used by netcorehost) links libnethost.lib, so a dynamic-CRT build with dlss_wgpu fails with LNK2038 too. Such a project has to build with crt-static, and then needs dlss_wgpu to follow the target's setting.
Environment: dlss_wgpu 6.0.0, DLSS SDK 310.9.1, x86_64-pc-windows-msvc.
Suggested fix:
let crt_static = env::var("CARGO_CFG_TARGET_FEATURE")
.map(|features| features.split(',').any(|feature| feature == "crt-static"))
.unwrap_or(false);
println!(
"cargo:rustc-link-lib=static={}",
if crt_static { "nvsdk_ngx_s" } else { "nvsdk_ngx_d" }
);
Related, same pattern: vulkan_sdk_include is chosen with #[cfg(target_os = "windows")] on the build script. A Linux-hosted cross build to Windows therefore looks for include where the Windows Vulkan SDK has Include. Reading CARGO_CFG_TARGET_OS, which build.rs already does for linking, would keep the two consistent.
Workaround: apply -C target-feature=+crt-static through plain RUSTFLAGS without --target, so the build script is compiled with it too.
- Ngôn ngữ chính
- Rust
- Star
- 60
- Fork
- 18
- Merge trung bình
- 1 ngày 4 giờ
- Pull request đã merge (30 ngày)
- 1
Chuẩn bị môi trường
- Có Dockerfile hoặc tệp Docker Compose
- Không có mẫu pull request
- Không có hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của bevyengine/dlss_wgpu
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 88/100
bevyengine/dlss_wgpu#39 ·
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 45/100
bevyengine/dlss_wgpu#25 · 1 bình luận ·
Tất cả issue của bevyengine/dlss_wgpu
Issue tương tự
-
go good first issue test
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
Maintainer thường phản hồi trong vòng 2 ngày
-
bug triaged tui ux wontfix
Độ khó 2/5 Nửa ngày Mức phù hợp với người mới 70/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
bevyengine/bevy#26642 ·
Maintainer thường phản hồi trong vòng 2 ngày