Hi. I'm using LLVM 5.0.1 on macOS 10.12. I have a very simple program (program.c): int main() {} When attempting to compile with LLD, I get this output: $ clang -fuse-ld=lld program.c /opt/llvm/5.0.1/bin/ld.lld: error: unknown argument: -no_deduplicate /opt/llvm/5.0.1/bin/ld.lld: error: unknown argument: -dynamic /opt/llvm/5.0.1/bin/ld.lld: error: unknown argument: -arch /opt/llvm/5.0.1/bin/ld.lld: error: unknown emulation: acosx_version_min /opt/llvm/5.0.1/bin/ld.lld: error: unable to find library -lto_library /opt/llvm/5.0.1/bin/ld.lld: error: /opt/llvm/5.0.1/lib/libLTO.dylib: invalid data encoding clang-5.0: error: linker command failed with exit code 1 (use -v to see invocation) Looks like the flags passed to the linker are just wrong, but can't find any relevant documentation at llvm.org/docs. Please help? -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20180104/c6079b25/attachment-0001.html>
I'm seeing something similar. clang is using HOST_LINK_VERSION, obtained from ld64, as the default for -mlinker-version. This causes Darwin.cpp to add the arguments you are seeing, but not handled by lld. Perhaps -fuse-ld should be considered in addition to -mlinker-version when adding these arguments. As a workaround, you can try passing -mlinker-version. Looks like anything < 133 will work, including 0. hth... don On Thu, Jan 4, 2018 at 1:14 AM, Julio César Rocha via llvm-dev < llvm-dev at lists.llvm.org> wrote:> Hi. I'm using LLVM 5.0.1 on macOS 10.12. > > I have a very simple program (program.c): > int main() {} > > When attempting to compile with LLD, I get this output: > $ clang -fuse-ld=lld program.c > /opt/llvm/5.0.1/bin/ld.lld: error: unknown argument: -no_deduplicate > /opt/llvm/5.0.1/bin/ld.lld: error: unknown argument: -dynamic > /opt/llvm/5.0.1/bin/ld.lld: error: unknown argument: -arch > /opt/llvm/5.0.1/bin/ld.lld: error: unknown emulation: acosx_version_min > /opt/llvm/5.0.1/bin/ld.lld: error: unable to find library -lto_library > /opt/llvm/5.0.1/bin/ld.lld: error: /opt/llvm/5.0.1/lib/libLTO.dylib: > invalid data encoding > clang-5.0: error: linker command failed with exit code 1 (use -v to see > invocation) > > Looks like the flags passed to the linker are just wrong, but can't find > any relevant documentation at llvm.org/docs. > > Please help? > > _______________________________________________ > LLVM Developers mailing list > llvm-dev at lists.llvm.org > http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev > >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20180107/e3ef1d6d/attachment.html>
MachO support in lld is not really ready for real world usage. It was able to bootstrap itself a couple of years ago, but, it has not really been maintained or further developed since. I would recommend that you use ld64 if you are intending to build MachO binaries.> On Jan 7, 2018, at 9:57 AM, Don Hinton via llvm-dev <llvm-dev at lists.llvm.org> wrote: > > I'm seeing something similar. > > clang is using HOST_LINK_VERSION, obtained from ld64, as the default for -mlinker-version. This causes Darwin.cpp to add the arguments you are seeing, but not handled by lld. Perhaps -fuse-ld should be considered in addition to -mlinker-version when adding these arguments. > > As a workaround, you can try passing -mlinker-version. Looks like anything < 133 will work, including 0. > > hth... > don > > > > On Thu, Jan 4, 2018 at 1:14 AM, Julio César Rocha via llvm-dev <llvm-dev at lists.llvm.org <mailto:llvm-dev at lists.llvm.org>> wrote: > Hi. I'm using LLVM 5.0.1 on macOS 10.12. > > I have a very simple program (program.c): > int main() {} > > When attempting to compile with LLD, I get this output: > $ clang -fuse-ld=lld program.c > /opt/llvm/5.0.1/bin/ld.lld: error: unknown argument: -no_deduplicate > /opt/llvm/5.0.1/bin/ld.lld: error: unknown argument: -dynamic > /opt/llvm/5.0.1/bin/ld.lld: error: unknown argument: -arch > /opt/llvm/5.0.1/bin/ld.lld: error: unknown emulation: acosx_version_min > /opt/llvm/5.0.1/bin/ld.lld: error: unable to find library -lto_library > /opt/llvm/5.0.1/bin/ld.lld: error: /opt/llvm/5.0.1/lib/libLTO.dylib: invalid data encoding > clang-5.0: error: linker command failed with exit code 1 (use -v to see invocation) > > Looks like the flags passed to the linker are just wrong, but can't find any relevant documentation at llvm.org/docs <http://llvm.org/docs>. > > Please help? > > _______________________________________________ > LLVM Developers mailing list > llvm-dev at lists.llvm.org <mailto:llvm-dev at lists.llvm.org> > http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev <http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev> > > > _______________________________________________ > LLVM Developers mailing list > llvm-dev at lists.llvm.org > http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20180107/ed59b711/attachment.html>
I believe what's happening here is that clang translates the -fuse-ld=lld into calling the ld.lld executable, which is actually the ELF LLD linker, not the Mach-O one. On 6.0, the Mach-O linker symlink is called ld64.lld instead (and clang has been changed to call out to that name) to disambiguate the two. For 5.0, I'm not sure how best to force the Mach-O linker (I'm not familiar with how the distribution is laid out). As Saleem said though, Mach-O LLD isn't really ready yet, so you're better off using ld64 (the default linker). From: llvm-dev <llvm-dev-bounces at lists.llvm.org> on behalf of Julio César Rocha via llvm-dev <llvm-dev at lists.llvm.org> Reply-To: Julio César Rocha <julioc.rocha at gmail.com> Date: Sunday, January 7, 2018 at 7:17 AM To: "llvm-dev at lists.llvm.org" <llvm-dev at lists.llvm.org> Subject: [llvm-dev] Fwd: LLD (macOS) usage? Hi. I'm using LLVM 5.0.1 on macOS 10.12. I have a very simple program (program.c): int main() {} When attempting to compile with LLD, I get this output: $ clang -fuse-ld=lld program.c /opt/llvm/5.0.1/bin/ld.lld: error: unknown argument: -no_deduplicate /opt/llvm/5.0.1/bin/ld.lld: error: unknown argument: -dynamic /opt/llvm/5.0.1/bin/ld.lld: error: unknown argument: -arch /opt/llvm/5.0.1/bin/ld.lld: error: unknown emulation: acosx_version_min /opt/llvm/5.0.1/bin/ld.lld: error: unable to find library -lto_library /opt/llvm/5.0.1/bin/ld.lld: error: /opt/llvm/5.0.1/lib/libLTO.dylib: invalid data encoding clang-5.0: error: linker command failed with exit code 1 (use -v to see invocation) Looks like the flags passed to the linker are just wrong, but can't find any relevant documentation at llvm.org/docs<https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_docs&d=DwMFaQ&c=5VD0RTtNlTh3ycd41b3MUw&r=o3kDXzdBUE3ljQXKeTWOMw&m=u7AStivTiQUkhMKu66ZUkCBZPZEq4EYZ0fP-0tIofUw&s=KYkQl_-tlad-fETHEsTQO9QhksIQ7vvHuBrL_1DXAQw&e=>. Please help? -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20180108/0967a3e2/attachment.html>
fyi.,.. $ ../llvm_project/build/cross/bin/clang -fuse-ld=lld -v -x c - </dev/null clang version 7.0.0 (trunk 321948) (llvm/trunk 321947) Target: x86_64-apple-darwin17.3.0 Thread model: posix InstalledDir: /Users/dhinton/projects/misc/../llvm_project/build/cross/bin "/Users/dhinton/projects/llvm_project/build/cross/bin/clang-7.0" -cc1 -triple x86_64-apple-macosx10.13.0 -Wdeprecated-objc-isa-usage -Werror=deprecated-objc-isa-usage -emit-obj -mrelax-all -disable-free -main-file-name - -mrelocation-model pic -pic-level 2 -mthread-model posix -mdisable-fp-elim -masm-verbose -munwind-tables -target-cpu penryn -dwarf-column-info -debugger-tuning=lldb -target-linker-version 305 -v -resource-dir /Users/dhinton/projects/llvm_project/build/cross/lib/clang/7.0.0 -fdebug-compilation-dir /Users/dhinton/projects/misc -ferror-limit 19 -fmessage-length 208 -stack-protector 1 -fblocks -fencode-extended-block-signature -fobjc-runtime=macosx-10.13.0 -fmax-type-align=16 -fdiagnostics-show-option -fcolor-diagnostics -o /var/folders/c6/9lj3yxp109s0p6ch4jhcw5h00000gn/T/--1c2f9c.o -x c - clang -cc1 version 7.0.0 based upon LLVM 7.0.0svn default target x86_64-apple-darwin17.3.0 #include "..." search starts here: #include <...> search starts here: /usr/local/include /Users/dhinton/projects/llvm_project/build/cross/lib/clang/7.0.0/include /usr/include /System/Library/Frameworks (framework directory) /Library/Frameworks (framework directory) End of search list. "/Users/dhinton/projects/misc/../llvm_project/build/cross/bin/ld64.lld" -demangle -lto_library /Users/dhinton/projects/llvm_project/build/cross/lib/libLTO.dylib -no_deduplicate -dynamic -arch x86_64 -macosx_version_min 10.13.0 -o a.out /var/folders/c6/9lj3yxp109s0p6ch4jhcw5h00000gn/T/--1c2f9c.o -lSystem warning: ignoring unknown argument: -no_deduplicate warning: -sdk_version is required when emitting min version load command. Setting sdk version to match provided min version Unable to find library for -lto_library clang-7.0: error: linker command failed with exit code 1 (use -v to see invocation) On Sun, Jan 7, 2018 at 10:18 PM, Shoaib Meenai via llvm-dev < llvm-dev at lists.llvm.org> wrote:> I believe what's happening here is that clang translates the -fuse-ld=lld > into calling the ld.lld executable, which is actually the ELF LLD linker, > not the Mach-O one. On 6.0, the Mach-O linker symlink is called ld64.lld > instead (and clang has been changed to call out to that name) to > disambiguate the two. For 5.0, I'm not sure how best to force the Mach-O > linker (I'm not familiar with how the distribution is laid out). > > > > As Saleem said though, Mach-O LLD isn't really ready yet, so you're better > off using ld64 (the default linker). > > > > *From: *llvm-dev <llvm-dev-bounces at lists.llvm.org> on behalf of Julio > César Rocha via llvm-dev <llvm-dev at lists.llvm.org> > *Reply-To: *Julio César Rocha <julioc.rocha at gmail.com> > *Date: *Sunday, January 7, 2018 at 7:17 AM > *To: *"llvm-dev at lists.llvm.org" <llvm-dev at lists.llvm.org> > *Subject: *[llvm-dev] Fwd: LLD (macOS) usage? > > > > Hi. I'm using LLVM 5.0.1 on macOS 10.12. > > > > I have a very simple program (program.c): > > int main() {} > > > > When attempting to compile with LLD, I get this output: > > $ clang -fuse-ld=lld program.c > > /opt/llvm/5.0.1/bin/ld.lld: error: unknown argument: -no_deduplicate > > /opt/llvm/5.0.1/bin/ld.lld: error: unknown argument: -dynamic > > /opt/llvm/5.0.1/bin/ld.lld: error: unknown argument: -arch > > /opt/llvm/5.0.1/bin/ld.lld: error: unknown emulation: acosx_version_min > > /opt/llvm/5.0.1/bin/ld.lld: error: unable to find library -lto_library > > /opt/llvm/5.0.1/bin/ld.lld: error: /opt/llvm/5.0.1/lib/libLTO.dylib: > invalid data encoding > > clang-5.0: error: linker command failed with exit code 1 (use -v to see > invocation) > > > > Looks like the flags passed to the linker are just wrong, but can't find > any relevant documentation at llvm.org/docs > <https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_docs&d=DwMFaQ&c=5VD0RTtNlTh3ycd41b3MUw&r=o3kDXzdBUE3ljQXKeTWOMw&m=u7AStivTiQUkhMKu66ZUkCBZPZEq4EYZ0fP-0tIofUw&s=KYkQl_-tlad-fETHEsTQO9QhksIQ7vvHuBrL_1DXAQw&e=> > . > > > > Please help? > > _______________________________________________ > LLVM Developers mailing list > llvm-dev at lists.llvm.org > http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev > >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20180107/4ac5767e/attachment.html>