Skip to content

Linker argument order sometimes wrong. #12446

Closed
@HildarTheDorf

Description

@HildarTheDorf

extern crates appear in the link arguments after #[link(name="foo")] attributes in the current crate. This can cause undefined symbol issues when an rlib contains an incomplete version of the static library foo (foo.a) because it is later in the linker command line. Forcing it to be last in the commandline with -C link-args="-lfoo" works as a workaround.
`
To be fair, I'm not sure if there is ever a "perfect" ordering for linker arguments that works in every single case (other than doing it manually), but making it extern crates, then #links in the current crate seems to make more sense. Something like #[link_first()] and/or #[link_last()] would work too (forcing it to link before or after external crates respectively).

This was all on Ubuntu 13.10 x86_64, and all the libs in question were static (.rlib or .a).

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