Skip to content

Using a shebang-less script as a linker doesn't work anymore on Linux #101511

Closed
@glandium

Description

@glandium

STR:

  • cargo new foo
  • cd foo
  • echo exit 42 > linker
  • chmod +x linker
  • RUSTFLAGS="-Clinker=$PWD/linker" cargo +nightly build

Actual result:

error: could not exec the linker `/tmp/foo/linker`
  |
  = note: Exec format error (os error 8)

With 1.63:

error: linking with `/tmp/foo/linker` failed: exit status: 42

This is a regression from #95026. What's going on is that before that merge, the linker was executed via posix_spawnp@GLIBC_2.2.5, and after, it's executed via posix_spawnp@GLIBC_2.15. The difference between the two is that the former retries executing through the shell when the execution first failed with ENOEXEC. This applies to anything the compiler or cargo would execute via std::process::Command. The change in posix_spawnp behavior in glibc comes from https://sourceware.org/bugzilla/show_bug.cgi?id=13134. It's probably for the better, but it should probably be highlighted in the release notes.

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.P-lowLow priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.regression-from-stable-to-stablePerformance or correctness regression from one stable version to another.relnotesMarks issues that should be documented in the release notes of the next release.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions