Skip to content

Allow linker override specifically for build scripts and proc macros #14105

Closed as not planned
@AldanTanneo

Description

@AldanTanneo

Problem

When cross compiling for a target that has the same architecture as the host, the build scripts and proc macros are compiled with the target linker. However, those builds are not meant to be run on the target!

In my use case, I was building on an x86_64-unknown-linux-gnu host with glibc 2.31, and the target environment was x86_64-unknown-linux-gnu with glibc 2.38, and a specific linker for this target.

The build scripts and proc macros were failing with dynamic linking errors, saying they couldn't find the correct libc version, because they had been linked with the target linker, not the host linker.

Proposed Solution

Allow the user to specify if they want to build the build scripts / proc macros with a different linker or not.

Notes

As a workaround, I used this rustc wrapper script, that will remove the -C linker=... arguments if the crate name is build_script_build, or the crate type is proc-macro

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-cross-compilingArea: using --target flag for other platformsA-rustflagsArea: rustflagsC-feature-requestCategory: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted`S-needs-infoStatus: Needs more info, such as a reproduction or more background for a feature request.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions