Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move link args from .cargo/config to build.rs #138

Closed
crawfxrd opened this issue Apr 30, 2021 · 7 comments
Closed

Move link args from .cargo/config to build.rs #138

crawfxrd opened this issue Apr 30, 2021 · 7 comments

Comments

@crawfxrd
Copy link

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: rust-lang/cargo#7811
Ref: https://github.com/crawfxrd/gba-dev-rs/commit/db5d897aa8ec23229db6c933bb16fec221b2d199

@Lokathor
Copy link
Member

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?

@crawfxrd
Copy link
Author

crawfxrd commented Apr 30, 2021

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).

@Lymia
Copy link
Contributor

Lymia commented May 2, 2021

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?

@Lokathor
Copy link
Member

Lokathor commented May 2, 2021

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 (rust-lang/cargo#9426)

@crawfxrd
Copy link
Author

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.

@Lokathor
Copy link
Member

"oh good"

@Lokathor
Copy link
Member

Lokathor commented Oct 6, 2022

Since every binary has to copy the config anyway, i think we will skip this change.

@Lokathor Lokathor closed this as completed Oct 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants