Windows: the nvsdk_ngx_d / nvsdk_ngx_s choice uses the build script's own cfg, not the target's crt-static
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 2/5
- Tiempo estimado
- 1-3 horas
- Aptitud para principiantes
- 73/100
- Tipo de issue
- Error
- Claridad
- Bien especificado
- Estado de actividad
- Activo
- Stack tecnológico
- rust
- Área
- build-system
Línea de trabajo
Empieza en build.rs e inspecciona cómo selecciona nvsdk_ngx_d o nvsdk_ngx_s. Luego comprueba cómo lee el script la configuración del destino para el enlazado. Lee las variables de entorno de los scripts de compilación de Cargo, en especial CARGO_CFG_TARGET_FEATURE, y considera la selección relacionada de target_os para el directorio de inclusión del Vulkan SDK. El trabajo estará terminado cuando la elección de la biblioteca siga la configuración crt-static del destino y la ruta de inclusión del Windows SDK funcione para compilaciones cruzadas de Windows alojadas en Linux.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
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.
- Lenguaje dominante
- Rust
- Estrellas
- 60
- Forks
- 18
- Merge medio
- 1 d 4 h
- PR fusionados (30 d)
- 1
Preparar el entorno
- Incluye un Dockerfile o un archivo de Docker Compose
- Sin plantilla de pull request
- Sin guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de bevyengine/dlss_wgpu
-
Dificultad 1/5 Menos de una hora Aptitud para principiantes 88/100
bevyengine/dlss_wgpu#39 ·
-
Dificultad 4/5 3-5 días Aptitud para principiantes 45/100
bevyengine/dlss_wgpu#25 · 1 comentario ·
Todos los issues de bevyengine/dlss_wgpu
Issues similares
-
go good first issue test
Dificultad 2/5 1-3 horas Aptitud para principiantes 88/100
Los mantenedores suelen responder en 2 días
-
bug triaged tui ux wontfix
Dificultad 2/5 Medio día Aptitud para principiantes 70/100
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 70/100
bevyengine/bevy#26642 ·
Los mantenedores suelen responder en 2 días