Skip to content

Platform-specific linker option ignored when specified using cfg syntax #12472

@tgnottingham

Description

@tgnottingham

Problem

When the following is placed in .cargo/config.toml, the linker option is respected (on an x86_64 Linux system):

[target.x86_64-unknown-linux-gnu]
linker = "clang"
rustflags = ["-C", "link-arg=-fuse-ld=lld"]

However, when the cfg syntax is used, as in the following, the linker option seems to be ignored (-C linker=clang isn't visible in cargo -vv output):

[target.'cfg(unix)']
linker = "clang"
rustflags = ["-C", "link-arg=-fuse-ld=lld"]

In either case, the rustflags option is respected.

Is the linker option being ignored here a bug?

Steps

No response

Possible Solution(s)

No response

Notes

No response

Version

cargo 1.71.1 (7f1d04c00 2023-07-29)
release: 1.71.1
commit-hash: 7f1d04c0053083b98fa50b69b6f56e339b0556a8
commit-date: 2023-07-29
host: x86_64-unknown-linux-gnu
libgit2: 1.6.4 (sys:0.17.1 vendored)
libcurl: 8.0.1-DEV (sys:0.4.61+curl-8.0.1 vendored ssl:OpenSSL/1.1.1t)
ssl: OpenSSL 1.1.1t  7 Feb 2023
os: Ubuntu 22.04 (jammy) [64-bit]

Metadata

Metadata

Assignees

Labels

A-configurationArea: cargo config files and env varsA-linkageArea: linker issues, dylib, cdylib, shared libraries, soC-bugCategory: bugE-easyExperience: EasyS-acceptedStatus: Issue or feature is accepted, and has a team member available to help mentor or review

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions