Skip to content

Windows GNU toolchain prevents static linking #10

@GrygrFlzr

Description

@GrygrFlzr

Currently, stdc++ must be linked dynamically for GNU toolchains to build from source:

if target.ends_with("-pc-windows-gnu") {
    println!("cargo:rustc-link-lib=dylib=stdc++");
}

This is solvable by rust-lang/rust#37403 via the use of this unstable feature:

  • Add #![feature(static_nobundle)] to both lib.rs and build.rs of glsl-to-spirv-builder
  • Modify the link to use static-nobundle:
if target.ends_with("-pc-windows-gnu") {
    println!("cargo:rustc-link-lib=static-nobundle=stdc++");
}
$ cargo +nightly-gnu test --release --target x86_64-pc-windows-gnu
   Compiling bevy-glsl-to-spirv-builder v0.1.0 (C:\Users\GrygrFlzr\Documents\projects\glsl-to-spirv\glsl-to-spirv-builder)
   Compiling bevy-glsl-to-spirv v0.2.2 (C:\Users\GrygrFlzr\Documents\projects\glsl-to-spirv)
    Finished release [optimized] target(s) in 1.77s
     Running target\x86_64-pc-windows-gnu\release\deps\bevy_glsl_to_spirv-aeb5d0f8868f37b0.exe

running 0 tests

test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s

     Running target\x86_64-pc-windows-gnu\release\deps\test-fe3b922dfa91430d.exe

running 1 test
test test1 ... ok

test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.03s

   Doc-tests bevy-glsl-to-spirv

running 0 tests

test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s

Of course, this will not build without nightly, so this issue is blocked until the feature is stabilized.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions