[llvm-dev] Using LLD to link against third-party libraries? How? (original) (raw)
Osman Zakir via llvm-dev llvm-dev at lists.llvm.org
Wed Dec 12 08:16:26 PST 2018
- Previous message: [llvm-dev] Using LLD to link against third-party libraries? How?
- Next message: [llvm-dev] Using LLD to link against third-party libraries? How?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
I need them so I can build stuff using clang or clang-cl with its C++ standard libraries. To make sure that lld-link won't give errors about missing symbols from any standard libraries.
By the way, you wouldn't happen to know how to use link.exe, would you? I might need some help on that to understand how to use lld-link.exe.
From: Zachary Turner <zturner at google.com> Sent: Wednesday, December 12, 2018 9:02 PM To: Osman Zakir; llvm-dev Subject: Re: [llvm-dev] Using LLD to link against third-party libraries? How?
Do you have a specific reason for enabling libcxx and libcxxabi? Because I would strongly suggest disabling them otherwise
On Wed, Dec 12, 2018 at 7:47 AM Osman Zakir <osmanzakir90 at hotmail.com<mailto:osmanzakir90 at hotmail.com>> wrote: I was asking about zlib because CMake couldn't find zlib. There was no error in the configuration, but knowing how to set the path to zlib would still be nice.
I enabled clang, lld, lldb, libcxx and libcxxabi when configuring the build with CMake. What projects should I build aside from ALL_BUILD.vcxproj and INSTALL.vcxproj to make sure I get the libcxx and libcxxabi projects built as well, along with lld, lldb and clang?
I didn't know about the bootstrapping Clang with itself bit, so I didn't do that.
From: Zachary Turner <zturner at google.com<mailto:zturner at google.com>> Sent: Wednesday, December 12, 2018 8:40 PM To: Osman Zakir Cc: llvm-dev at lists.llvm.org<mailto:llvm-dev at lists.llvm.org>
Subject: Re: [llvm-dev] Using LLD to link against third-party libraries? How?
If you want to bootstrap clang and lld using itself, then you should pass -DCMAKE_C_COMPILER=path/to/clang-cl.exe -DCMAKE_CXX_COMPILER=path/to/clang-cl.exe -DCMAKE_LINKER=path/to/lld-link.exe.
Note the clang-cl.exe. Not clang.exe or clang++.exe.
On Wed, Dec 12, 2018 at 7:37 AM Zachary Turner <zturner at google.com<mailto:zturner at google.com>> wrote: You shouldn't need zlib to build. I think we discussed in a previous thread that the only components you should need to complete a build are Microsoft Visual Studio, git, and CMake.
On Wed, Dec 12, 2018 at 7:14 AM Osman Zakir via llvm-dev <llvm-dev at lists.llvm.org<mailto:llvm-dev at lists.llvm.org>> wrote: How can I tell CMake during the configuration step where to find my zlib installation?
From: blubee blubeeme <gurenchan at gmail.com<mailto:gurenchan at gmail.com>> Sent: Wednesday, December 12, 2018 7:31 PM
To: Osman Zakir Cc: llvm-dev Subject: Re: [llvm-dev] Using LLD to link against third-party libraries? How? I would agree with the next email from Brian Cain
If you do not have specific reason to want to use llvm lld try to use your system provided c++ linker.
Bootstrapping the llvm c++ c++abi can be troublesome on Unix like platforms and I have no experience doing anything like that on windows.
If you already have a c++ toochain and still want to attempt this then you'll need to svn checkout or git clone a version of the llvm toolchain and build it with your native toolchain then switch to using clang and lld.
if you do not have a native c++ toolchain; let's cross that bridge only if you need to.
A complete LLVM toolchain includes llvm clang clang-extra-tools lld lldb polly compiler-rt openmp libcxx libcxx-abi testsuite There's "Getting Started Quickly (A Summary" : https://llvm.org/docs/GettingStarted.html
With steps to build a complete toolchain. Compilation could take a long time.
It would be simpler to use your native c++ and linker unless they do not provide c++17 in which case the above link can get you started.
Best
On Wed, Dec 12, 2018 at 8:57 PM Osman Zakir <osmanzakir90 at hotmail.com<mailto:osmanzakir90 at hotmail.com>> wrote: So how do I get it to build libcxx and libcxxabi? I got it from the mono repo and enabled lld, clang, libcxx and libcxxabi. But I built the two main CMake targets only--all_build and install. What else do I have to do? Please let me know.
From: Zachary Turner <zturner at google.com<mailto:zturner at google.com>> Sent: Wednesday, December 12, 2018 11:10 AM To: blubee blubeeme Cc: Osman Zakir; David Greene; llvm-dev at lists.llvm.org<mailto:llvm-dev at lists.llvm.org> Subject: Re: [llvm-dev] Using LLD to link against third-party libraries? How?
I see you’re using lld-link, so we’re talking about Windows here.
Have you gotten it working with the Microsoft linker? Because if so, just replace link.exe with lld-link.exe and it will work.
Btw, it’s a bit odd to use clang++ on Windows. The recommended workflow is to use clang-cl. It’s possible to use clang++, but you’re just setting yourself up for more difficulty On Tue, Dec 11, 2018 at 7:23 PM blubee blubeeme via llvm-dev <llvm-dev at lists.llvm.org<mailto:llvm-dev at lists.llvm.org>> wrote: I couldn't get it to build libcxx... You need c++ and c++abi to compile c++ code.
On Wed, Dec 12, 2018, 07:01 Osman Zakir via llvm-dev <llvm-dev at lists.llvm.org<mailto:llvm-dev at lists.llvm.org>> wrote: LLVM on a Developer Command Prompt. The ones I want to fix first are the ones from Boost and Jinja2Cpp. I saw some from those as well.
If there any standard library ones missing, could it be because I couldn't get it to build libcxx? I did try to include that, but it seems to be missing. What should I do?
From: David Greene <dag at cray.com<mailto:dag at cray.com>> Sent: Wednesday, December 12, 2018 3:30 AM To: Osman Zakir Cc: blubee blubeeme; llvm-dev at lists.llvm.org<mailto:llvm-dev at lists.llvm.org>
Subject: Re: [llvm-dev] Using LLD to link against third-party libraries? How?
Are you linking with a C++ compiler? A lot of those missing symbols look like they come from the C++ standard library.
-David
Osman Zakir via llvm-dev <llvm-dev at lists.llvm.org<mailto:llvm-dev at lists.llvm.org>> writes:
@blubee blubeeme So what do you think? Got any ideas? ---------------------------------------------------------------------- From: Osman Zakir <osmanzakir90 at hotmail.com<mailto:osmanzakir90 at hotmail.com>> Sent: Wednesday, December 12, 2018 1:43 AM To: llvm-dev at lists.llvm.org<mailto:llvm-dev at lists.llvm.org> Subject: Re: [llvm-dev] Using LLD to link against third-party libraries? How? In my code here https://github.com/DragonOsman/currencyconverter , I used C++17 and managed to get it to work (though I'm only using std::map::insertorassign() from C++17). And I'm using Windows, so I shouldn't use LDFLAGS or CXXFLAGS as environment variables. I'll use them directly on the compiler command line instead. The libraries I need to link against are C:/boost1680/stage/lib/libboostsystem-vc141-mt-x64-168.lib and C:/Jinja2Cpp/installx64/lib/static/jinja2cpp.lib.
I tried to build it with this flag: " clang++ -std=c++17 -Wall -pedantic - DSILENCECXX17ADAPTORTYPEDEFSDEPRECATIONWARNING - DvariantCONFIGSELECTVARIANT=variantVARIANTNONSTD - DSILENCECXX17ALLOCATORVOIDDEPRECATIONWARNING - DCRTSECURENOWARNINGS -DWINSOCKDEPRECATEDNOWARNINGS -DWIN32 - DWIN32WINDOWS -DNDEBUG -fexceptions - IC:/Jinja2Cpp/installx64/include -IC:/json/singleinclude - IC:/boost1680 - LC:/boost1680/stage/lib/libboostsystem-vc141-mt-x64-168.lib - LC:/Jinja2Cpp/installx64/lib/static/jinja2cpp.lib currencyconverter.cpp -o currencyconverter.exe " And I got these warnings and errors from LLD: " lld-link: warning: C:\Users\Osman\AppData\Local\Temp\currencyconverter-264ae1.o: locally _defined symbol imported: stdterminate (defined in libvcruntime.lib (ehhelpers.obj)) [LNK4217] _lld-link: error: undefined symbol: "public: cdecl jinja2::Template::Template(class jinja2::TemplateEnv *)" (??0Template at jinja2@@QEAA at PEAVTemplateEnv@1@@Z)
referenced by C:\Users\Osman\AppData\Local\Temp\currencyconverter-264ae1.o:("void cdecl handlerequest<struct_ _boost::beast::http::basicstringbody<char, struct_ _std::chartraits, class std::allocator>, class std::allocator, struct serversession::sendlambda &>(class boost::basicstringview<char, struct std::chartraits>, struct boost::beast::http::message<1, struct_ _boost::beast::http::basicstringbody<char, struct_ _std::chartraits, class std::allocator>, class boost::beast::http::basicfields<class std::allocator>> &&, struct serversession::sendlambda &, char const *, char const *)" (??$handlerequest at U?$basicstringbody at DU?$chartraits at D@std@@V?$allocator at D@2@@http at beast@boost@@V? $allocator at D@std@@AEAUsendlambda at serversession@@@@YAXV?$basicstring view at DU?$chartraits at D@std@@@boost@@$$QEAU?$message@$00U?$basicstring body at DU?$chartraits at D@std@@V?$allocator at D@2@@http at beast@boost@@V?$basic fields at V?$allocator at D@std@@@234@@http at beast@1 at AEAUsendlambda@serversession@@PEBD3 at Z) ) lld-link: error: undefined symbol: "public: class _nonstd::expectedlite::expected<void, class_ _jinja2::ErrorInfoTpl> cdecl jinja2::Template::LoadFromFile (class std::basicstring<char, struct std::chartraits, class std::allocator> const &)" (?LoadFromFile at Template@jinja2@@QEAA?AV?$expected at XV?$ErrorInfoTpl at D@jinja2@@@expected lite at nonstd@@AEBV?$basicstring at DU?$chartraits at D@std@@V?$allocator at D@2@@std@@@Z) referenced by C:\Users\Osman\AppData\Local\Temp\currencyconverter-264ae1.o:("void cdecl handlerequest<struct_ _boost::beast::http::basicstringbody<char, struct_ _std::chartraits, class std::allocator>, class std::allocator, struct serversession::sendlambda &>(class boost::basicstringview<char, struct std::chartraits>, struct boost::beast::http::message<1, struct_ _boost::beast::http::basicstringbody<char, struct_ _std::chartraits, class std::allocator>, class boost::beast::http::basicfields<class std::allocator>> &&, struct serversession::sendlambda &, char const *, char const *)" (??$handlerequest at U?$basicstringbody at DU?$chartraits at D@std@@V?$allocator at D@2@@http at beast@boost@@V? $allocator at D@std@@AEAUsendlambda at serversession@@@@YAXV?$basicstring view at DU?$chartraits at D@std@@@boost@@$$QEAU?$message@$00U?$basicstring body at DU?$chartraits at D@std@@V?$allocator at D@2@@http at beast@boost@@V?$basic fields at V?$allocator at D@std@@@234@@http at beast@1 at AEAUsendlambda@serversession@@PEBD3 at Z) ) lld-link: error: undefined symbol: "public: class std::basicstring<char, struct std::chartraits, class _std::allocator> cdecl jinja2::Template::RenderAsString(class std::unorderedmap<class std::basicstring<char, struct_ _std::chartraits, class std::allocator>, class jinja2::Value, struct std::hash<class std::basicstring<char, struct_ _std::chartraits, class std::allocator>>, struct std::equalto<class std::basicstring<char, struct_ _std::chartraits, class std::allocator>>, class std::allocator<struct std::pair<class std::basicstring<char, struct_ _std::chartraits, class std::allocator> const, class jinja2::Value>>> const &)" (?RenderAsString at Template@jinja2@@QEAA?AV?$basicstring at DU?$chartraits at D@std@@V? $allocator at D@2@@std@@AEBV?$unorderedmap at V?$basicstring at DU?$chartraits at D@std@@V? $allocator at D@2@@std@@VValue at jinja2@@U?$hash at V?$basicstring at DU?$chartraits at D@std@@V? $allocator at D@2@@std@@@2 at U?$equalto at V?$basicstring at DU?$chartraits at D@std@@V? $allocator at D@2@@std@@@2 at V?$allocator at U?$pair@$$CBV?$basicstring at DU?$char traits at D@std@@V?$allocator at D@2@@std@@VValue at jinja2@@@std@@@2@@4@@Z) referenced by C:\Users\Osman\AppData\Local\Temp\currencyconverter-264ae1.o:("void cdecl handlerequest<struct_ _boost::beast::http::basicstringbody<char, struct_ _std::chartraits, class std::allocator>, class std::allocator, struct serversession::sendlambda &>(class boost::basicstringview<char, struct std::chartraits>, struct boost::beast::http::message<1, struct_ _boost::beast::http::basicstringbody<char, struct_ _std::chartraits, class std::allocator>, class boost::beast::http::basicfields<class std::allocator>> &&, struct serversession::sendlambda &, char const *, char const *)" (??$handlerequest at U?$basicstringbody at DU?$chartraits at D@std@@V?$allocator at D@2@@http at beast@boost@@V? $allocator at D@std@@AEAUsendlambda at serversession@@@@YAXV?$basicstring view at DU?$chartraits at D@std@@@boost@@$$QEAU?$message@$00U?$basicstring body at DU?$chartraits at D@std@@V?$allocator at D@2@@http at beast@boost@@V?$basic fields at V?$allocator at D@std@@@234@@http at beast@1 at AEAUsendlambda@serversession@@PEBD3 at Z) ) referenced by C:\Users\Osman\AppData\Local\Temp\currencyconverter-264ae1.o:("void cdecl handlerequest<struct_ _boost::beast::http::basicstringbody<char, struct_ _std::chartraits, class std::allocator>, class std::allocator, struct serversession::sendlambda &>(class boost::basicstringview<char, struct std::chartraits>, struct boost::beast::http::message<1, struct_ _boost::beast::http::basicstringbody<char, struct_ _std::chartraits, class std::allocator>, class boost::beast::http::basicfields<class std::allocator>> &&, struct serversession::sendlambda &, char const *, char const *)" (??$handlerequest at U?$basicstringbody at DU?$chartraits at D@std@@V?$allocator at D@2@@http at beast@boost@@V? $allocator at D@std@@AEAUsendlambda at serversession@@@@YAXV?$basicstring view at DU?$chartraits at D@std@@@boost@@$$QEAU?$message@$00U?$basicstring body at DU?$chartraits at D@std@@V?$allocator at D@2@@http at beast@boost@@V?$basic fields at V?$allocator at D@std@@@234@@http at beast@1 at AEAUsendlambda@serversession@@PEBD3 at Z) ) _lld-link: error: undefined symbol: "public: cdecl jinja2::Template::~Template(void)" (??1Template at jinja2@@QEAA at XZ) referenced by C:\Users\Osman\AppData\Local\Temp\currencyconverter-264ae1.o:("void cdecl handlerequest<struct_ _boost::beast::http::basicstringbody<char, struct_ _std::chartraits, class std::allocator>, class std::allocator, struct serversession::sendlambda &>(class boost::basicstringview<char, struct std::chartraits>, struct boost::beast::http::message<1, struct_ _boost::beast::http::basicstringbody<char, struct_ _std::chartraits, class std::allocator>, class boost::beast::http::basicfields<class std::allocator>> &&, struct serversession::sendlambda &, char const *, char const *)" (??$handlerequest at U?$basicstringbody at DU?$chartraits at D@std@@V?$allocator at D@2@@http at beast@boost@@V? $allocator at D@std@@AEAUsendlambda at serversession@@@@YAXV?$basicstring view at DU?$chartraits at D@std@@@boost@@$$QEAU?$message@$00U?$basicstring body at DU?$chartraits at D@std@@V?$allocator at D@2@@http at beast@boost@@V?$basic fields at V?$allocator at D@std@@@234@@http at beast@1 at AEAUsendlambda@serversession@@PEBD3 at Z) ) referenced by C:\Users\Osman\AppData\Local\Temp\currencyconverter-264ae1.o:("int
void _cdecl handlerequest<struct_ _boost::beast::http::basicstringbody<char, struct_ _std::chartraits<char>, class std::allocator<char>>, class_ _std::allocator<char>, struct serversession::sendlambda &>(class_ _boost::basicstringview<char, struct std::chartraits<char>>, struct_ _basicstringview<char, struct_ _std::chartraits<char>>::beast::http::message<1, struct_ _boost::beast::http::basicstringbody<char, struct_ _std::chartraits<char>, class std::allocator<char>>, class_ _boost::beast::http::basicfields<class std::allocator<char>>> &&,_ _struct serversession::sendlambda &, char const *, char const *)'::_ _
1'::dtor$114" (?dtor$114@?0???$handlerequest at U?$basicstringbody at DU?$chartraits at D@std@@V? $allocator at D@2@@http at beast@boost@@V?$allocator at D@std@@AEAUsendlambda at server session@@@@YAXV?$basicstringview at DU?$chartraits at D@std@@@boost@@$$QEAU? $message@$00U?$basicstringbody at DU?$chartraits at D@std@@V?$allocator at D@2@@http at beast@boost@@V? $basicfields at V?$allocator at D@std@@@234@@http at beast@1 at AEAUsendlambda@server session@@PEBD3 at Z@4HA)) lld-link: warning: C:\Users\Osman\AppData\Local\Temp\currencyconverter-264ae1.o: locally defined symbol imported: CxxThrowException (defined in libvcruntime.lib(throw.obj)) [LNK4217] lld-link: error: undefined symbol: "class _boost::system::errorcategory const & cdecl boost::system::detail::systemcategoryncx(void)" (?systemcategoryncx at detail@system at boost@@YAAEBVerrorcategory at 23@XZ) referenced by C:\Users\Osman\AppData\Local\Temp\currencyconverter-264ae1.o:("class _boost::system::errorcategory const & cdecl boost::system::systemcategory(void)" (?systemcategory at system@boost@@YAAEBVerrorcategory at 12@XZ)) lld-link: warning: C:\Users\Osman\AppData\Local\Temp\currencyconverter-264ae1.o: locally _defined symbol imported: RTDynamicCast (defined in libvcruntime.lib (rtti.obj)) [LNK4217] lld-link: error: undefined symbol: "class _boost::system::errorcategory const & cdecl boost::system::detail::genericcategoryncx(void)" (?genericcategoryncx at detail@system at boost@@YAAEBVerrorcategory at 23@XZ) referenced by C:\Users\Osman\AppData\Local\Temp\currencyconverter-264ae1.o:("class _boost::system::errorcategory const & cdecl boost::system::genericcategory(void)" (?genericcategory at system@boost@@YAAEBVerrorcategory at 12@XZ)) clang++: error: linker command failed with exit code 1 (use -v to see invocation) " * GitHub - DragonOsman/currencyconverter: Application for Computer Science course Google Maps + Currency Converter Web Application. Application for Computer Science course. This is a currency converter web application with the frontend and a backend. github.com<http://github.com> *
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
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
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
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 -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20181212/4c50a13f/attachment-0001.html>
- Previous message: [llvm-dev] Using LLD to link against third-party libraries? How?
- Next message: [llvm-dev] Using LLD to link against third-party libraries? How?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]