-
Notifications
You must be signed in to change notification settings - Fork 12k
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
[BOLT] Err when linking objects of different architectures #66770
Conversation
This could happen, for example, when instrumenting an AArch64 binary on an x86 host because the instrumentation library is always built for the host. Note that this check will probably need to be refined in the future as merely having the same architecture does not guarantee objects can be linked. For example, on RISC-V, the float ABI of all objects should match.
Good catch, thanks for the added check. We should err but that doesn't address the rootcause. In principle, we should support something akin to LLVM_RUNTIME_TARGETS. Can you please add a test with x86 host ( |
Indeed, this would be nice. I have been working around this by manually building the runtime library for RISC-V in order to use it on an x86 host. It would be better to integrate this in the build system so I might try this out soon.
Done! It was a bit tricky though to produce an AArch64 binary suitable for instrumentation on x86. I had to:
Please let me know if there's an easier way to accomplish this. |
Yes, these are the minimum requirements. Usually I prefer to use -Wl,-fini flag though, but it doesn't really matter |
Thanks! As a side note: is AArch64 using |
The BOLT uses DT_FINI currently only, the DT_FINI_ARRAY tag is not even read right now. If you mean at runtime - I think as for any other platforms all FINI_ARRAY and FINI is getting called in a sequence |
I was wondering if AArch64 doesn't use |
AFAICT the symbol is came from libc and it does nothing but return. But since BOLT tests doesn't use libc the _fini symbol is absent and that is why we have to create it manually in our tests |
This could happen, for example, when instrumenting an AArch64 binary on an x86 host because the instrumentation library is always built for the host.
Note that this check will probably need to be refined in the future as merely having the same architecture does not guarantee objects can be linked. For example, on RISC-V, the float ABI of all objects should match.