Clang linker script support - incorrect argument
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 119k
- Forks
- 16.1k
- PR merge metrics
- PR metrics pending
Description
Using clang as linker with any custom target (spec in json) that contains linker-script (field link-script) produces invocation like
# clang or cc, or gcc
"clang" "--script" "/path/to/link-script/exported/from/my-target-json"
But clang doesn't support --script and returns error clang: error: unsupported option '--script'.
Instead of that, according documentation, we just need to pass it with -T,
e.g.: -T/path/to/link-script.ld.
How to reproduce:
-
Prepare spec json file for your custom target. It could be anything, just one thing matter - add
link-scriptfield. Something like this:{ "llvm-target": "Your-HOST-target", "link-script": "ENTRY(main)", "linker": "clang" } -
Compile anything targeting to your custom target, e.g.:
--target=./your-target.json
Expected result:
Clang should be invoked with -T<link-script> instead of --script <link-script>.
I can reproduce with target-spec with explicitly set linker as clang, gcc, arm-none-eabi-gcc and cc.
Meta
rustc --version --verbose:
rustc 1.80.0-nightly (72fdf913c 2024-06-05)
binary: rustc
commit-hash: 72fdf913c53dd0e75313ba83e4aa80df3f6e2871
commit-date: 2024-06-05
host: aarch64-apple-darwin
release: 1.80.0-nightly
LLVM version: 18.1.6
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
The payload names no source files or tests; start by locating the target-spec linker argument generation for the link-script field and the handling of clang, gcc, and cc. Reproduce with the custom JSON target described in the issue, then verify that the generated invocation uses the documented -T form and that relevant compiler tests pass.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- build-system, compilers
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 48/100