Comments (11)
Looks like it's in rustc_codegen_ssa/src/back/link.rs
in add_link_script
. As far as I can tell (and I'm no expert on this code but got curious) if link_script
is set on the target it'll add a --script <path>
to the linker args before running it. There's no evidence that it currently supports using clang
as a linker and no evidence it can support any other argument for this; the supported variants are listed in rustc_target/src/spec/mod.rs
against the enum LinkerFlavor
, main ones being Gnu/Msvc/Darwin/Wasm (and some other more obscure ones).
One option might be to add a linker flavor Llvm(Cc)
(where Cc is true if clang and false if lld) but it doesn't look like this is currently supported. Suspect this is a bit of work as the gnu one links to GCC libs and the like, guessing you'd need to figure out which equivalent LLVM libs but could be wrong. Probably needs triaging by someone who knows this stuff a bit better than me.
from rust.
As far as I know, clang as linker is supported and used with flavors gnu-cc, darwin-cc, maybe unix-cc and some more.
from rust.
Yeah I think the answer here is to move to a -T
argument as everything I've looked at supports that. It's only a problem if something supports only --script
and I haven't found anything that is like that. Again, someone with more experience may disagree.
I think for the second problem (another issue and maybe needs looking at in another ticket) you might have to add a clang
specific flavor which currently doesn't exist. Then you could do this easily if you wanted to go down that route.
from rust.
@strottos I could do it, but
- we need some research to determine what tools supports separate
-T <script>
and/or merged-T<script>
- as you say above need to know what tools supports only
--script
, if such exist - could be great to have some integration tests with various tools, various versions on various OSs.
Maybe could be good to have something like cc::is_flag_supported()
to get to know in runtime.
For now I see it as following:
- only for all
cc-
flavors : - change this to just
-T
from rust.
Agree with most of that, only bit I'm not sure about is the is_flag_supported()
suggestion, not sure you could do that easily. Don't think it knows what end program you're passing it and it just assumes it matches the GNU system. You could make it spawn it with a --version
and check certain variants but (a) that's messy, (b) adds a not completely trivial performance hit and (c) hard to be exhaustive potentially. I think adding in more flavors is better personally.
I actually really think the "change this to just -T
" is a good one as all the GNU tools seem to support it and they're the only thing that is allowed because of this line.
All this being said, bowing out now in case someone with more expertise here wants to take this.
from rust.
FWIW, I tried changing it to -T
and it worked fine on my machine after breaking in the same way with --script
:)
Had to do a bit of playing around to the targets right, essentially outputting the target specs with this:
rustc +nightly -Z unstable-options --print target-spec-json
removing the is-builtin
option and adding the "link-script": "ENTRY(main)"
option seemed to reproduce for me on a Gentoo Linux machine.
from rust.
I think it's supported in the sense that clang
is largely compatible with gcc
where command line options are concerned so can be used as a drop in linker. What's odd here is that, as you say, it passes a --script <script_file>
with a temporary file it's just created where even gcc
seems to only accept a -T
parameter unless I'm mistaken. The fix could be a very simple --script
-> -T
as it seems to only support the gnu
stuff specifically, e.g: https://github.com/rust-lang/rust/blob/master/compiler/rustc_codegen_ssa/src/back/link.rs#L1900
I wonder if just nobody else has used this and this is just an easily fixable bug, or maybe there's some variants of gcc
or something else that accept --script
(and heaven forbid only --script
and not -T
)?
from rust.
Can't see any evidence gcc
supports --script
in the official GNU docs: https://gcc.gnu.org/onlinedocs/gcc/Link-Options.html#index-T
from rust.
Hmm, lld
has the --script
or -T
option:
--script=<value> Read linker script
-T <value> Alias for --script```
from rust.
As does ld
(all on Linux, not sure about mac/windows):
-T FILE, --script FILE Read linker script```
from rust.
Yup, both -T
and --script
is for both __ GNU-__ linkers - lld
as well as ld
.
But on macOs that is unknown option for ld
from Xcodeutils (1, 2).
Also, I see the option in the code, but not --script
there.
Also there is important difference:
clang
supports-fuse-ld=ld
gcc
supports-fuse-ld=lld
That's should be another issue.
from rust.
Related Issues (20)
- Incorrect code generated from inline assembly with `inout` register on riscv32im-unknown-none-elf HOT 6
- Performance regression with `get_many_mut()` HOT 1
- The compiler does not report errors for recursive calls that can not be ended HOT 2
- x86_64-win7-windows-msvc target cannot run HOT 11
- Permit library-only and binary-only dependencies HOT 3
- mut struct member var(ref) bind to new obj still hint: does not live long enough HOT 2
- Should `Mutex` and `Condvar` respect priorities? HOT 2
- ICE: `unable to construct a valtree for the unevaluated constant` HOT 3
- fs::read_to_string(config.src.join("src/ci/channel")) failed with No such file or directory (os error 2) HOT 4
- Regression in `type annotations needed for` check between 1.79 and 1.80 HOT 2
- Jump threading MIR opt unsoundly uses bitpattern equality for floats HOT 15
- ICE: `trait takes 1 generic argument but 0 generic arguments were supplied` HOT 2
- Bug when using `cargo check` (my program works with `cargo run`) HOT 1
- zero-sized slices are sometimes placed at 0x1 (1.79+) HOT 16
- Documentation of default value for config.toml's `rust.channel` is inaccurate
- Rustdoc: struct fields are spaced too closely HOT 3
- [Enhancement]: `must_use_xor` to Force Using One of the Functions but not all in a Struct HOT 1
- false positive `dead_code` "never constructed" warning on 1.80.0 for a `struct` where the constructor takes `&'static self` HOT 11
- rustc_contracts: differentiate between exhaustive and non-exhaustive contracts
- ICE: The Rust Compiler Panicked After I Removed A Windows SDK HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rust.