-
Notifications
You must be signed in to change notification settings - Fork 13k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Coverage is not generated when using lld as linker #71233
Comments
The platform support page currently says Linux 2.6.18 -- roughly RHEL5, which shipped gcc 4.1.2. Even RHEL6 only shipped 4.4.7, and then RHEL7 would meet your threshold with gcc 4.8.5. |
I thought the kernel revision was in terms of what system calls we needed, not the user space software. Unfortunately, we don't have access to clang internals directly so we can't just re-use their auto-detection algorithm. Some possible options:
Do you have a preference? |
That kind of goes hand in hand. There's not a unified release for this stuff like in the BSDs, but looking at RHEL5 at least gives a reference of contemporary versions.
Are you sure that version is about support? There are much older references to |
So, the core problem here is mixing If we're only considering Rust code, and not considering the profiler runtime (which gets built by the host toolchain and uses a C++ constructor), this will still work on those old systems. It's when you try to mix C/C++ code built with gcc < 4.7 that you'd encounter surprises. |
Ah, I see. If bfd and gold are able to merge these, but lld can't/won't, then can we change behavior based on the linker flavor? I'm not sure if that choice is visible to all codegen, or just the final link.
I guess this too is a more nuanced statement, about what we're able to support mixed when using lld. Maybe that's OK, but better if there's at least some option for going back to
I think this may be the prudent choice, as long as we're still supporting older platforms. It also looks like some Clang platforms may use |
|
I think that controlling this behavior based on linker-flavor is probably not a great idea because:
|
You may read dlang/dmd#10562 about the support of |
rustllvm: Use .init_array rather than .ctors LLVM TargetMachines default to using the (now-legacy) .ctors representation of init functions. Mixing .ctors and .init_array representations can cause issues when linking with lld. This happens in practice for: * Our profiling runtime which is currently implicitly built with .init_array since it is built by clang, which sets this field. * External C/C++ code that may be linked into the same process. Fixes: rust-lang#71233
Attempting to build a coverage Rust binary with
will not actually generate any
.gcda
files.Both of
will produce appropriate output.
I was able to trace this down to an issue with
.ctors
/.init_array
incompatibility. Specifically,ld.bfd
andld.gold
will munge sections to deal with the presence of both.ctors
and.init_array
in the same binary;lld
will not.Rust is currently implicitly using the deprecated
.ctors
section in its output format, because we don't explicitly setOptions.UseInitArray = true;
. Clang does this via some autodetect logic because it supports legacy platforms for which their other compilers do not have.init_array
support (gcc < 4.7), but looking through Rust's supported platforms it doesn't appear that we have any platforms with compilers that old, so we can likely just set this true.I'll upload a patch shortly which sets us to use
.init_array
unconditionally. If we find any platforms we support that may want to use.ctors
, we can add this as a platform attribute similar to other arguments toLLVMRustCreateTargetMachine
, and possibly pass-fno-use-init-array
if clang is in use toprofile_builtins
'sbuild.rs
for those platforms which don't support.init_array
(this shouldn't be needed if clang's autodetect is working correctly).Linking #39915 to this issue in case someone has been having similar problems.
The text was updated successfully, but these errors were encountered: