-
Notifications
You must be signed in to change notification settings - Fork 156
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
write/coff: Merge all .rdata$.refptr. sections #474
Comments
I think the current behaviour is copying what mingw does. Can you give me an example object file generated by the llvm backend? |
I took a random lib (
We print fewer sections 2497 vs llvm which spits out 30376. However, llvm produces them all with the same name, so I wonder if MSVC is able to deal with that better and possibly merge them all before processing somehow. Here's a link to a repo with both libraries, github does not allow me to attach them to this comment. Its worth noting that I only see this behaviour with MSVC's I'm going to try to minimize our section names and see if the issue goes away. |
Yep, that seems to have done the trick! I applied this commit to duplicate our section names and it now links in a reasonable time. Would you like me to open a PR for that, or should we deal with this in a different manner? |
llvm isn't emitting refptr symbols at all in that library. The reason it has a large number of sections is because llvm is using a separate section for each function and data symbol, while cgclif has a single section for each of I don't want to apply a commit without first having a complete understanding:
|
I don't really know how to answer the first two questions, but maybe @bjorn3 can help?
Not really, I just tried with |
AFAIK rustc disables
When is_pic is enabled, Cranelift emits GotRelative relocations when accessing data. Object lowers this to .rdata$.refptr.* for COFF object files. Without is_pic enabled it isn't possible to link the object files into dylibs afaik and we don't know in advance if a crate will end up being linked into an executable or a dylib. |
Why does
|
Just checked the rustc source and it seems it is only disabled on MinGW. Based on some discussion I found elsewhere it seems that MSVC and MinGW both have a trick now to avoid the section limit using COMDAT, but both in incompatible ways. It is still disabled on MinGW due to a binutils bug.
I think there is some difference in how PE and ELF implement dylibs that Cranelift doesn't know about. I'm not familiar enough with PE to tell what though. |
Based on https://learn.microsoft.com/en-us/windows/win32/debug/pe-format#grouped-sections-object-only, I think it is okay to rename the sections to |
It seems that in https://github.com/bjorn3/rustc_codegen_cranelift/issues/1249#issuecomment-1272290580 the windows linker spends most of the time (almost 75%) churning through the names of all these sections.
The text was updated successfully, but these errors were encountered: