[llvm-dev] Using LLD to link against third-party libraries? How?
Zachary Turner via llvm-dev
llvm-dev at lists.llvm.org
Wed Dec 12 08:33:11 PST 2018
You don’t need clang’s standard libraries in order to not get linker errors
with lld-link. In fact, I would strongly suggest not trying to use them,
at least until you get a working build. Once you get a working build, then
if you realllly want to you can try to complicate it by using libcxx.
Until then, keep it simple and use Microsoft standard library (which
happens automatically and “just works”
So for now, I suggest removing libcxx and libcxxabi from your cmake
configurations
On Wed, Dec 12, 2018 at 8:16 AM Osman Zakir via llvm-dev <
llvm-dev at lists.llvm.org> wrote:
> 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>
> 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>
> *Sent:* Wednesday, December 12, 2018 8:40 PM
> *To:* Osman Zakir
> *Cc:* 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> 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> wrote:
>
> How can I tell CMake during the configuration step where to find my zlib
> installation?
> ------------------------------
> *From:* blubee blubeeme <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>
> 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>
> *Sent:* Wednesday, December 12, 2018 11:10 AM
> *To:* blubee blubeeme
> *Cc:* Osman Zakir; David Greene; 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> 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> 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>
> *Sent:* Wednesday, December 12, 2018 3:30 AM
> *To:* Osman Zakir
> *Cc:* blubee blubeeme; 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> writes:
>
> > @blubee blubeeme So what do you think? Got any ideas?
> > ----------------------------------------------------------------------
> > From: Osman Zakir <osmanzakir90 at hotmail.com>
> > Sent: Wednesday, December 12, 2018 1:43 AM
> > To: 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/currency_converter , I
> > used C++17 and managed to get it to work (though I'm only using
> > std::map::insert_or_assign() 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:/boost_1_68_0/stage/lib/libboost_system-vc141-mt-x64-1_68.lib and
> > C:/Jinja2Cpp/install_x64/lib/static/jinja2cpp.lib.
> >
> > I tried to build it with this flag:
> > "
> > clang++ -std=c++17 -Wall -pedantic -
> > D_SILENCE_CXX17_ADAPTOR_TYPEDEFS_DEPRECATION_WARNING -
> > Dvariant_CONFIG_SELECT_VARIANT=variant_VARIANT_NONSTD -
> > D_SILENCE_CXX17_ALLOCATOR_VOID_DEPRECATION_WARNING -
> > D_CRT_SECURE_NO_WARNINGS -D_WINSOCK_DEPRECATED_NO_WARNINGS -D_WIN32 -
> > D_WIN32_WINDOWS -D_NDEBUG -fexceptions -
> > IC:/Jinja2Cpp/install_x64/include -IC:/json/single_include -
> > IC:/boost_1_68_0 -
> > LC:/boost_1_68_0/stage/lib/libboost_system-vc141-mt-x64-1_68.lib -
> > LC:/Jinja2Cpp/install_x64/lib/static/jinja2cpp.lib
> > currency_converter.cpp -o currency_converter.exe
> > "
> > And I got these warnings and errors from LLD:
> >
> > "
> > lld-link: warning:
> > C:\Users\Osman\AppData\Local\Temp\currency_converter-264ae1.o: locally
> > defined symbol imported: __std_terminate (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\currency_converter-264ae1.o:("void _
> > _cdecl handle_request<struct
> > boost::beast::http::basic_string_body<char, struct
> > std::char_traits<char>, class std::allocator<char>>, class
> > std::allocator<char>, struct server_session::send_lambda &>(class
> > boost::basic_string_view<char, struct std::char_traits<char>>, struct
> > boost::beast::http::message<1, struct
> > boost::beast::http::basic_string_body<char, struct
> > std::char_traits<char>, class std::allocator<char>>, class
> > boost::beast::http::basic_fields<class std::allocator<char>>> &&,
> > struct server_session::send_lambda &, char const *, char const *)"
> > (??$handle_request at U?$basic_string_body at DU?$char_traits at D@std@
> @V?$allocator at D@2@@http at beast@boost@@V?
> > $allocator at D@std@@AEAUsend_lambda at server_session@@@@YAXV?$basic_string_
> > view at DU?$char_traits at D@std@@@boost@@$$QEAU?$message@$00U?$basic_string_
> > body at DU?$char_traits 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 AEAUsend_lambda
> @server_session@@PEBD3 at Z)
> > )
> >
> > lld-link: error: undefined symbol: "public: class
> > nonstd::expected_lite::expected<void, class
> > jinja2::ErrorInfoTpl<char>> __cdecl jinja2::Template::LoadFromFile
> > (class std::basic_string<char, struct std::char_traits<char>, class
> > std::allocator<char>> const &)"
> > (?LoadFromFile at Template@jinja2@@QEAA?AV?$expected at XV?$ErrorInfoTpl at D
> @jinja2@@@expected_
> > lite at nonstd@@AEBV?$basic_string at DU?$char_traits at D@std@@V?$allocator at D@2@
> @std@@@Z)
> >
> >>>> referenced by
> > C:\Users\Osman\AppData\Local\Temp\currency_converter-264ae1.o:("void _
> > _cdecl handle_request<struct
> > boost::beast::http::basic_string_body<char, struct
> > std::char_traits<char>, class std::allocator<char>>, class
> > std::allocator<char>, struct server_session::send_lambda &>(class
> > boost::basic_string_view<char, struct std::char_traits<char>>, struct
> > boost::beast::http::message<1, struct
> > boost::beast::http::basic_string_body<char, struct
> > std::char_traits<char>, class std::allocator<char>>, class
> > boost::beast::http::basic_fields<class std::allocator<char>>> &&,
> > struct server_session::send_lambda &, char const *, char const *)"
> > (??$handle_request at U?$basic_string_body at DU?$char_traits at D@std@
> @V?$allocator at D@2@@http at beast@boost@@V?
> > $allocator at D@std@@AEAUsend_lambda at server_session@@@@YAXV?$basic_string_
> > view at DU?$char_traits at D@std@@@boost@@$$QEAU?$message@$00U?$basic_string_
> > body at DU?$char_traits 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 AEAUsend_lambda
> @server_session@@PEBD3 at Z)
> > )
> >
> > lld-link: error: undefined symbol: "public: class
> > std::basic_string<char, struct std::char_traits<char>, class
> > std::allocator<char>> __cdecl jinja2::Template::RenderAsString(class
> > std::unordered_map<class std::basic_string<char, struct
> > std::char_traits<char>, class std::allocator<char>>, class
> > jinja2::Value, struct std::hash<class std::basic_string<char, struct
> > std::char_traits<char>, class std::allocator<char>>>, struct
> > std::equal_to<class std::basic_string<char, struct
> > std::char_traits<char>, class std::allocator<char>>>, class
> > std::allocator<struct std::pair<class std::basic_string<char, struct
> > std::char_traits<char>, class std::allocator<char>> const, class
> > jinja2::Value>>> const &)"
> > (?RenderAsString at Template@jinja2@@QEAA?AV?$basic_string at DU
> ?$char_traits at D@std@@V?
> > $allocator at D@2@@std@@AEBV?$unordered_map at V?$basic_string at DU
> ?$char_traits at D@std@@V?
> > $allocator at D@2@@std@@VValue at jinja2@@U?$hash at V?$basic_string at DU
> ?$char_traits at D@std@@V?
> > $allocator at D@2@@std@@@2 at U?$equal_to at V?$basic_string at DU?$char_traits at D
> @std@@V?
> > $allocator at D@2@@std@@@2 at V?$allocator at U?$pair@$$CBV?$basic_string 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\currency_converter-264ae1.o:("void _
> > _cdecl handle_request<struct
> > boost::beast::http::basic_string_body<char, struct
> > std::char_traits<char>, class std::allocator<char>>, class
> > std::allocator<char>, struct server_session::send_lambda &>(class
> > boost::basic_string_view<char, struct std::char_traits<char>>, struct
> > boost::beast::http::message<1, struct
> > boost::beast::http::basic_string_body<char, struct
> > std::char_traits<char>, class std::allocator<char>>, class
> > boost::beast::http::basic_fields<class std::allocator<char>>> &&,
> > struct server_session::send_lambda &, char const *, char const *)"
> > (??$handle_request at U?$basic_string_body at DU?$char_traits at D@std@
> @V?$allocator at D@2@@http at beast@boost@@V?
> > $allocator at D@std@@AEAUsend_lambda at server_session@@@@YAXV?$basic_string_
> > view at DU?$char_traits at D@std@@@boost@@$$QEAU?$message@$00U?$basic_string_
> > body at DU?$char_traits 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 AEAUsend_lambda
> @server_session@@PEBD3 at Z)
> > )
> >>>> referenced by
> > C:\Users\Osman\AppData\Local\Temp\currency_converter-264ae1.o:("void _
> > _cdecl handle_request<struct
> > boost::beast::http::basic_string_body<char, struct
> > std::char_traits<char>, class std::allocator<char>>, class
> > std::allocator<char>, struct server_session::send_lambda &>(class
> > boost::basic_string_view<char, struct std::char_traits<char>>, struct
> > boost::beast::http::message<1, struct
> > boost::beast::http::basic_string_body<char, struct
> > std::char_traits<char>, class std::allocator<char>>, class
> > boost::beast::http::basic_fields<class std::allocator<char>>> &&,
> > struct server_session::send_lambda &, char const *, char const *)"
> > (??$handle_request at U?$basic_string_body at DU?$char_traits at D@std@
> @V?$allocator at D@2@@http at beast@boost@@V?
> > $allocator at D@std@@AEAUsend_lambda at server_session@@@@YAXV?$basic_string_
> > view at DU?$char_traits at D@std@@@boost@@$$QEAU?$message@$00U?$basic_string_
> > body at DU?$char_traits 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 AEAUsend_lambda
> @server_session@@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\currency_converter-264ae1.o:("void _
> > _cdecl handle_request<struct
> > boost::beast::http::basic_string_body<char, struct
> > std::char_traits<char>, class std::allocator<char>>, class
> > std::allocator<char>, struct server_session::send_lambda &>(class
> > boost::basic_string_view<char, struct std::char_traits<char>>, struct
> > boost::beast::http::message<1, struct
> > boost::beast::http::basic_string_body<char, struct
> > std::char_traits<char>, class std::allocator<char>>, class
> > boost::beast::http::basic_fields<class std::allocator<char>>> &&,
> > struct server_session::send_lambda &, char const *, char const *)"
> > (??$handle_request at U?$basic_string_body at DU?$char_traits at D@std@
> @V?$allocator at D@2@@http at beast@boost@@V?
> > $allocator at D@std@@AEAUsend_lambda at server_session@@@@YAXV?$basic_string_
> > view at DU?$char_traits at D@std@@@boost@@$$QEAU?$message@$00U?$basic_string_
> > body at DU?$char_traits 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 AEAUsend_lambda
> @server_session@@PEBD3 at Z)
> > )
> >>>> referenced by
> > C:\Users\Osman\AppData\Local\Temp\currency_converter-264ae1.o:("int
> > `void __cdecl handle_request<struct
> > boost::beast::http::basic_string_body<char, struct
> > std::char_traits<char>, class std::allocator<char>>, class
> > std::allocator<char>, struct server_session::send_lambda &>(class
> > boost::basic_string_view<char, struct std::char_traits<char>>, struct
> > basic_string_view<char, struct
> > std::char_traits<char>>::beast::http::message<1, struct
> > boost::beast::http::basic_string_body<char, struct
> > std::char_traits<char>, class std::allocator<char>>, class
> > boost::beast::http::basic_fields<class std::allocator<char>>> &&,
> > struct server_session::send_lambda &, char const *, char const *)'::
> > `1'::dtor$114"
> > (?dtor$114@?0???$handle_request at U?$basic_string_body at DU?$char_traits at D
> @std@@V?
> > $allocator at D@2@@http at beast@boost@@V?$allocator at D@std@
> @AEAUsend_lambda at server_
> > session@@@@YAXV?$basic_string_view at DU?$char_traits at D@std@@@boost@
> @$$QEAU?
> > $message@$00U?$basic_string_body at DU?$char_traits 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 AEAUsend_lambda
> @server_
> > session@@PEBD3 at Z@4HA))
> >
> > lld-link: warning:
> > C:\Users\Osman\AppData\Local\Temp\currency_converter-264ae1.o: locally
> > defined symbol imported: _CxxThrowException (defined in
> > libvcruntime.lib(throw.obj)) [LNK4217]
> > lld-link: error: undefined symbol: "class
> > boost::system::error_category const & __cdecl
> > boost::system::detail::system_category_ncx(void)"
> > (?system_category_ncx at detail@system at boost@@YAAEBVerror_category at 23@XZ)
> >>>> referenced by
> > C:\Users\Osman\AppData\Local\Temp\currency_converter-264ae1.o:("class
> > boost::system::error_category const & __cdecl
> > boost::system::system_category(void)"
> > (?system_category at system@boost@@YAAEBVerror_category at 12@XZ))
> >
> > lld-link: warning:
> > C:\Users\Osman\AppData\Local\Temp\currency_converter-264ae1.o: locally
> > defined symbol imported: __RTDynamicCast (defined in libvcruntime.lib
> > (rtti.obj)) [LNK4217]
> > lld-link: error: undefined symbol: "class
> > boost::system::error_category const & __cdecl
> > boost::system::detail::generic_category_ncx(void)"
> > (?generic_category_ncx at detail@system at boost@@YAAEBVerror_category at 23@XZ)
> >
> >>>> referenced by
> > C:\Users\Osman\AppData\Local\Temp\currency_converter-264ae1.o:("class
> > boost::system::error_category const & __cdecl
> > boost::system::generic_category(void)"
> > (?generic_category at system@boost@@YAAEBVerror_category at 12@XZ))
> > clang++: error: linker command failed with exit code 1 (use -v to see
> > invocation)
> > "
> >
> >
> > * GitHub - DragonOsman/currency_converter: 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
> >
> > *
> >
> >
> > _______________________________________________
> > LLVM Developers mailing list
> > 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
> 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
>
> _______________________________________________
> LLVM Developers mailing list
> 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
> 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/2ef1d0f9/attachment.html>
More information about the llvm-dev
mailing list