Skip to content

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

Closed

Description

@crawfxrd

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

Activity

  1. Lokathor commented on Apr 30, 2021

    @Lokathor
    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?

  2. crawfxrd commented on Apr 30, 2021

    @crawfxrd
    Author

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

  3. Lymia commented on May 2, 2021

    @Lymia
    Contributor

    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?

  4. Lokathor commented on May 2, 2021

    @Lokathor
    Member

    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)

  5. crawfxrd commented on Jul 27, 2021

    @crawfxrd
    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.

  6. Lokathor commented on Jul 28, 2021

    @Lokathor
    Member

    "oh good"

  7. Lokathor commented on Oct 6, 2022

    @Lokathor
    Member

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions