Move link args from .cargo/config to build.rs
Move the linker option from .cargo/config.toml to build.rs using the rustc-link-arg-bins directive.
Then users only needs to specific extra-link-arg to rustc, instead of copying the files from this repo to their project.
Ref: https://github.com/rust-lang/cargo/pull/7811 Ref: https://github.com/crawfxrd/gba-dev-rs/commit/db5d897aa8ec23229db6c933bb16fec221b2d199
iiiinteresting.
Yeah this sounds like it could be good. does it let a lib crate pass a linker script "downstream" to a binary using the lib?
I believe so. I've converted my GBA-specific code to a local crate, and the only change I had to make from the commit I linked was to specific CARGO_MANIFEST_DIR for the full linker file path (build.rs).
How would this work with downstream crates that have their own build requirements? I wouldn't want any of the gba crate's default linker settings, as I'm writing a patch that gets integrated into an existing ROM as part of a ROM hack -- something that obviously requires a very different linker script compared to normal.
This should be doable with a default feature flag you can turn off or something, I suppose?
That's a good point.
It would have to be feature flag controlled or something like that.
Also, I think that I'll wait on this change until after cargo stabilizes it (https://github.com/rust-lang/cargo/issues/9426)
rustc-link-arg was stabilized (rust-lang/cargo#9557).
However, they decided that transitive link arguments are bad and you must always explicitly opt-in for custom link arguments (rust-lang/cargo#9554).
So every binary must still copy the linker script and build.rs/.cargo/config.
"oh good"
Since every binary has to copy the config anyway, i think we will skip this change.