_______________________________________________
LLVM Developers mailing list
llvm...@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
| Teresa Johnson | | Software Engineer | | tejo...@google.com | | 408-460-2413 |
Yes, Teresa is right, this is the correct fix.
I'm not sure what subset of GNU archives Mach-O supports, but the only
way of being safe is using offset in the archive + archive name.
Fun fact, you apparently can have a single GNU archive with two
different members with the same name. Using the offset is the only way
to disambiguate.
I think we should really consider documenting this assumption
somewhere as many people have been bitten in the past and tracking
down is not trivial as it shows up as assertion failures in the mover
or duplicate/undefined symbols reported as linker errors, as the
ThinLTO logic will pick the an archive randomly.
On Tue, Sep 5, 2017 at 2:09 PM, Teresa Johnson <tejo...@google.com> wrote:
>
> Hi Johan,
>
> Right, per the bug this is fixed in lld (and was already handled in gold-plugin), but I guess not in ld64. Note that lld and gold-plugin use the new LTO API, while ld64 (and probably other linkers) are still using the legacy libLTO (which is what ThinLTOCodeGenerator.cpp is part of). Fixing it in the location you propose could work for all legacy libLTO users. But I don't think that adding just the size will (always) be enough to disambiguate (couldn't the 2 same named members have the same size?) - although lld is doing the same thing so this may be as good as what is done there. For gold-plugin we add the byte offset into the archive where the member starts, which will be unique.
> +davide for thoughts since he fixed it on the lld side.
>
Yes, Teresa is right, this is the correct fix.
I'm not sure what subset of GNU archives Mach-O supports, but the only
way of being safe is using offset in the archive + archive name.
See here for the fix.
https://reviews.llvm.org/D25495
You pass the the archive name + offset to `lto::InputFile::create`,
assuming your linker uses the new LTO API (and I'm not sure whether
ld64 already switched).
The linker knows the archive name from which it's fetching the member,
as well as its offset (it asks libArchive about it, for lld).
I'm not sure how it works ld64, but of course, to get this mechanism
working, you need some linker modifications.
CC:ed some Mach-O people, they probably know more about this than I do.
Thanks,
--
Davide
CC:ed some Mach-O people, they probably know more about this than I do.
The linker knows the archive name from which it's fetching the member,
as well as its offset (it asks libArchive about it, for lld).
I'm not sure how it works ld64, but of course, to get this mechanism
working, you need some linker modifications.
CC:ed some Mach-O people, they probably know more about this than I do.
Thanks,
--
Davide
_______________________________________________
LLVM Developers mailing list
llvm...@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
Hi Johan,ld64 only calls functions from llvm/include/llvm-c/lto.h (defined in llvm/tools/lto/lto.cpp)For instance ThinLTOCodeGenerator::addModule is called through thinlto_codegen_add_module().Apple hasn't released the code for ld64 in Xcode 9 yet, did you check if it is fixed in Xcode 9?(I think I remember fixing it in ld64 but I'm not totally sure...).
From what I can see with Xcode 8.2, the linker just passes the file name (prefixed with the archive name): https://github.com/michaelweiser/ld64/blob/master/src/ld/parsers/lto_file.cpp#L546(original here: https://opensource.apple.com/source/ld64/ld64-274.2/src/ld/parsers/lto_file.cpp.auto.html )We could workaround this in ThinLTOCodeGenerator by adding a incremental suffix to every new buffer. Something like this diff:
On Thu, Sep 7, 2017 at 5:44 PM, Mehdi AMINI <joke...@gmail.com> wrote:Hi Johan,ld64 only calls functions from llvm/include/llvm-c/lto.h (defined in llvm/tools/lto/lto.cpp)For instance ThinLTOCodeGenerator::addModule is called through thinlto_codegen_add_module().Apple hasn't released the code for ld64 in Xcode 9 yet, did you check if it is fixed in Xcode 9?(I think I remember fixing it in ld64 but I'm not totally sure...).I haven't tried with Xcode 9.From what I can see with Xcode 8.2, the linker just passes the file name (prefixed with the archive name): https://github.com/michaelweiser/ld64/blob/master/src/ld/parsers/lto_file.cpp#L546(original here: https://opensource.apple.com/source/ld64/ld64-274.2/src/ld/parsers/lto_file.cpp.auto.html )We could workaround this in ThinLTOCodeGenerator by adding a incremental suffix to every new buffer. Something like this diff:I was assuming that we do want to assert/error on calling addModule with the exact same module twice? Otherwise your diff is nice, thanks.
On Fri, Sep 8, 2017 at 9:04 PM, Johan Engelen <jbc.e...@gmail.com> wrote:On Thu, Sep 7, 2017 at 5:44 PM, Mehdi AMINI <joke...@gmail.com> wrote:Hi Johan,ld64 only calls functions from llvm/include/llvm-c/lto.h (defined in llvm/tools/lto/lto.cpp)For instance ThinLTOCodeGenerator::addModule is called through thinlto_codegen_add_module().Apple hasn't released the code for ld64 in Xcode 9 yet, did you check if it is fixed in Xcode 9?(I think I remember fixing it in ld64 but I'm not totally sure...).I haven't tried with Xcode 9.From what I can see with Xcode 8.2, the linker just passes the file name (prefixed with the archive name): https://github.com/michaelweiser/ld64/blob/master/src/ld/parsers/lto_file.cpp#L546(original here: https://opensource.apple.com/source/ld64/ld64-274.2/src/ld/parsers/lto_file.cpp.auto.html )We could workaround this in ThinLTOCodeGenerator by adding a incremental suffix to every new buffer. Something like this diff:I was assuming that we do want to assert/error on calling addModule with the exact same module twice? Otherwise your diff is nice, thanks.Hi Mehdi,Can you advise me?Is it OK to not error upon the exact same module being added twice? (and thus your patch would be good)
llvm-lto: error loading file '/Users/buildslave/jenkins/sharedspace/phase1@2/clang-build/test/ThinLTO/X86/Output/funcimport-tbaa.ll.tmp.bc_0': No such file or directory"