Skip to content

A way to configure always using @argfile for linker invocations #138421

Open
@weihanglo

Description

@weihanglo

My scenario is a bit weird.

In my build system, there is a general wrapper that disguises itself as clang. Unfortunately it doesn't really propagate the OS error well, so E2BIG won't be caught by rustc.

If the linker invocation has grown too big (which is not uncommon because Cargo always passes absolute paths for rustflags), with the general wrapper in my build system, rustc didn't know how to recover and then gave up.

error: linking with `x86_64-unknown-linux-gnu-clang` failed: exit status: 255
  |
  = note: PATH="..." "x86_64-unknown-linux-gnu-clang" "<256 object files omitted>" <1024 rlib files omitted> "-Wl,--undefined-version"
  = note: some arguments are omitted. use `--verbose` to show all linker arguments
  = note: my-wrapper: Argument list too long      

Is there a way to tell rustc always use @argfile for linker invocations?

Possible solutions

  • Provide a way to tell rustc always use @argfile for linker invocations.
  • Put my t-cargo hat on. Cargo maybe should stop using absolute paths and switch to relative paths, I know. But that won't fix the root problem if I then have 8192 rlib files…
  • Perhaps I could try find an way to estimate the arglist length also on Unix?
    // We mostly only care about Windows in this method, on Unix the limits
    // can be gargantuan anyway so we're pretty unlikely to hit them
    if cfg!(unix) {
    return false;
    }

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-linkersArea: linkers... you gotta love linkersC-feature-requestCategory: A feature request, i.e: not implemented / a PR.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions