LLVM bitcode for Boost libraries?
I want to build a project I have, which has to link against Boost.System, to WebAssembly, and it seems like I have to generate LLVM bitcode for it first. Is it possible to use the bootstrapper that comes with the Boost distribution to do this on Windows 10? The project in question is on GitHub here: https://github.com/DragonOsman/currency_converter . I switched out the Asio in the Boost distribution with the official Emscripten port of Asio, found here: https://github.com/emscripten-ports/asio . But I don't know which version of Boost.Asio it's using so I'd like some clarification on that if possible (I opened this issue there: https://github.com/emscripten-ports/asio/issues/2 and have just now updated the question to ask what version of Asio is being used for the port). [https://avatars0.githubusercontent.com/u/18173932?s=400&v=4]https://github.com/emscripten-ports/asio/issues/2 Update of Asio port? · Issue #2 · emscripten-ports/asiohttps://github.com/emscripten-ports/asio/issues/2 Sorry if this is an unwelcome question, but I want to ask if there'll ever be an update to this port of Asio to Emscripten/WebAssembly. I notice it's from 2015. Which version of Boost is it... github.com [https://avatars1.githubusercontent.com/u/8116924?s=400&v=4]https://github.com/emscripten-ports/asio GitHub - emscripten-ports/asiohttps://github.com/emscripten-ports/asio Join GitHub today. GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together. github.com [https://avatars0.githubusercontent.com/u/18173932?s=400&v=4]https://github.com/DragonOsman/currency_converter GitHub - DragonOsman/currency_converter: Application for Computer Science coursehttps://github.com/DragonOsman/currency_converter 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
On 29/11/2018 09:04, Osman Zakir wrote:
The project in question is on GitHub here: https://github.com/DragonOsman/currency_converter . I switched out the Asio in the Boost distribution with the official Emscripten port of Asio, found here: https://github.com/emscripten-ports/asio . But I don't know which version of Boost.Asio it's using so I'd like some clarification on that if possible (I opened this issue there: https://github.com/emscripten-ports/asio/issues/2 and have just now updated the question to ask what version of Asio is being used for the port). https://github.com/emscripten-ports/asio/issues/2
I would assume it is not Boost.Asio at all, but rather the standalone Asio library (http://think-async.com/Asio), albeit an old version of it. See http://think-async.com/Asio/AsioAndBoostAsio.
Do you know how I could try to port the latest version, then? Or should I consult the Emscripten developers after all?
________________________________
From: Boost-users
The project in question is on GitHub here: https://github.com/DragonOsman/currency_converter . I switched out the Asio in the Boost distribution with the official Emscripten port of Asio, found here: https://github.com/emscripten-ports/asio . But I don't know which version of Boost.Asio it's using so I'd like some clarification on that if possible (I opened this issue there: https://github.com/emscripten-ports/asio/issues/2 and have just now updated the question to ask what version of Asio is being used for the port). https://github.com/emscripten-ports/asio/issues/2
I would assume it is not Boost.Asio at all, but rather the standalone Asio library (http://think-async.com/Asio), albeit an old version of it. See http://think-async.com/Asio/AsioAndBoostAsio. _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org https://lists.boost.org/mailman/listinfo.cgi/boost-users
And what about how to generate LLVM bitcode for Boost libraries? Can I do it with the bootstrapper tool that comes with the Boost distribution when we download Boost source files?
________________________________
From: Osman Zakir
The project in question is on GitHub here: https://github.com/DragonOsman/currency_converter . I switched out the Asio in the Boost distribution with the official Emscripten port of Asio, found here: https://github.com/emscripten-ports/asio . But I don't know which version of Boost.Asio it's using so I'd like some clarification on that if possible (I opened this issue there: https://github.com/emscripten-ports/asio/issues/2 and have just now updated the question to ask what version of Asio is being used for the port). https://github.com/emscripten-ports/asio/issues/2
I would assume it is not Boost.Asio at all, but rather the standalone Asio library (http://think-async.com/Asio), albeit an old version of it. See http://think-async.com/Asio/AsioAndBoostAsio. _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org https://lists.boost.org/mailman/listinfo.cgi/boost-users
On Thu, 29 Nov 2018 at 18:09, Osman Zakir via Boost-users < boost-users@lists.boost.org> wrote:
And what about how to generate LLVM bitcode for Boost libraries? Can I do it with the bootstrapper tool that comes with the Boost distribution when we download Boost source files?
I'm cross-posting this from the cfe-dev list [I know nothing about this,
just that the questions seem to be the same]
Date: Thu, 29 Nov 2018 09:48:58 +0100
From: Alex Denisov via cfe-dev
On 28. Nov 2018, at 23:22, David Greene via cfe-dev < cfe-dev@lists.llvm.org> wrote:
How do I get the LLVM IR produced by clang? I know that -emit-llvm produces IR but it seems to be after processing by LLVM (things are optimized out, for example). Is there an "official" way to get the IR coming right out of clang's codegen? I can do a hack with -mllvm -print-before-all but that's icky.
Thanks!
-David _______________________________________________ cfe-dev mailing list cfe-dev@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
degski -- *“If something cannot go on forever, it will stop" - Herbert Stein*
So can I pass that flag to b2 when building Boost and have it generate bitcode? How do I configure the Boost.Build to use LLVM/Clang as the compiler toolchain, though? On Windows, of course.
________________________________
From: degski
On 28. Nov 2018, at 23:22, David Greene via cfe-dev
mailto:cfe-dev@lists.llvm.org> wrote: How do I get the LLVM IR produced by clang? I know that -emit-llvm produces IR but it seems to be after processing by LLVM (things are optimized out, for example). Is there an "official" way to get the IR coming right out of clang's codegen? I can do a hack with -mllvm -print-before-all but that's icky.
Thanks!
-David _______________________________________________ cfe-dev mailing list cfe-dev@lists.llvm.orgmailto:cfe-dev@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
degski -- “If something cannot go on forever, it will stop" - Herbert Stein
On 11/30/2018 7:47 AM, Osman Zakir via Boost-users wrote:
So can I pass that flag to b2 when building Boost and have it generate bitcode? How do I configure the Boost.Build to use LLVM/Clang as the compiler toolchain, though? On Windows, of course.
You should not top post. On Windows: If LLVM/clang is targeting vc++, use the clang-win toolchain; if LLVM/clang is targeting mingw(-w64)/gcc use the clang toolchain.
------------------------------------------------------------------------ *From:* degski
*Sent:* Friday, November 30, 2018 11:03 AM *To:* boost-users@lists.boost.org *Cc:* osmanzakir90@hotmail.com *Subject:* Re: [Boost-users] LLVM bitcode for Boost libraries? On Thu, 29 Nov 2018 at 18:09, Osman Zakir via Boost-users mailto:boost-users@lists.boost.org> wrote: And what about how to generate LLVM bitcode for Boost libraries? Can I do it with the bootstrapper tool that comes with the Boost distribution when we download Boost source files?
I'm cross-posting this from the cfe-dev list [I know nothing about this, just that the questions seem to be the same]
Date: Thu, 29 Nov 2018 09:48:58 +0100 From: Alex Denisov via cfe-dev
mailto:cfe-dev@lists.llvm.org> To: David Greene mailto:dag@cray.com> Cc: "cfe-dev@lists.llvm.org mailto:cfe-dev@lists.llvm.org" mailto:cfe-dev@lists.llvm.org> Subject: Re: [cfe-dev] Getting LLVM IR from clang Message-ID: <268D2CEC-AFC2-4F32-94FE-E445E882A00D@gmail.com mailto:268D2CEC-AFC2-4F32-94FE-E445E882A00D@gmail.com> Content-Type: text/plain; charset=us-ascii Hi David,
There are at least two robust ways to get the Bitcode/IR:
1. LTO. You can enable link-time optimization by adding -flto compiler flags, in the end all object files (*.o) will in fact be bitcode files. I.e.:
> file gmock.dir/gmock-gtest-all.cc.o gmock.dir/gmock-gtest-all.cc.o: LLVM bitcode, wrapper x86_6
2. Embedded bitcode. Clang 3.9 and higher has an option -fembed-bitcode. When enabled, the resulting executable will contain additional section containing bitcode. You can use this great tool[1] to extract the bitcode from an executable.
Both approaches produce bitcode (binary format), if you need IR (human-readable format), then you can post-process the bitcode by running llvm-dis against each bitcode file.
I hope it helps.
[1] https://github.com/JDevlieghere/LibEBC
On 28. Nov 2018, at 23:22, David Greene via cfe-dev
mailto:cfe-dev@lists.llvm.org> wrote: How do I get the LLVM IR produced by clang? I know that -emit-llvm produces IR but it seems to be after processing by LLVM (things are optimized out, for example). Is there an "official" way to get the IR coming right out of clang's codegen? I can do a hack with -mllvm -print-before-all but that's icky.
Thanks!
-David _______________________________________________ cfe-dev mailing list cfe-dev@lists.llvm.org mailto:cfe-dev@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
degski -- /*/*“*/If something cannot go on forever, it will stop" - Herbert Stein*/
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org https://lists.boost.org/mailman/listinfo.cgi/boost-users
From: Boost-users
So can I pass that flag to b2 when building Boost and have it generate bitcode? How do I configure the Boost.Build to use LLVM/Clang as the compiler toolchain, though? On Windows, of course.
You should not top post.
On Windows: If LLVM/clang is targeting vc++, use the clang-win toolchain; if LLVM/clang is targeting mingw(-w64)/gcc use the clang toolchain.
So you mean I should use Clang-C2/Clang with Microsoft CodeGen, aka the clang-cl compiler? Either way, how do I change the compiler toolchain when building Boost?
------------------------------------------------------------------------ *From:* degski
*Sent:* Friday, November 30, 2018 11:03 AM *To:* boost-users@lists.boost.org *Cc:* osmanzakir90@hotmail.com *Subject:* Re: [Boost-users] LLVM bitcode for Boost libraries? On Thu, 29 Nov 2018 at 18:09, Osman Zakir via Boost-users mailto:boost-users@lists.boost.org> wrote: And what about how to generate LLVM bitcode for Boost libraries? Can I do it with the bootstrapper tool that comes with the Boost distribution when we download Boost source files?
I'm cross-posting this from the cfe-dev list [I know nothing about this, just that the questions seem to be the same]
Date: Thu, 29 Nov 2018 09:48:58 +0100 From: Alex Denisov via cfe-dev
mailto:cfe-dev@lists.llvm.org> To: David Greene mailto:dag@cray.com> Cc: "cfe-dev@lists.llvm.org mailto:cfe-dev@lists.llvm.org" mailto:cfe-dev@lists.llvm.org> Subject: Re: [cfe-dev] Getting LLVM IR from clang Message-ID: <268D2CEC-AFC2-4F32-94FE-E445E882A00D@gmail.com mailto:268D2CEC-AFC2-4F32-94FE-E445E882A00D@gmail.com> Content-Type: text/plain; charset=us-ascii Hi David,
There are at least two robust ways to get the Bitcode/IR:
1. LTO. You can enable link-time optimization by adding -flto compiler flags, in the end all object files (*.o) will in fact be bitcode files. I.e.:
> file gmock.dir/gmock-gtest-all.cc.o gmock.dir/gmock-gtest-all.cc.o: LLVM bitcode, wrapper x86_6
2. Embedded bitcode. Clang 3.9 and higher has an option -fembed-bitcode. When enabled, the resulting executable will contain additional section containing bitcode. You can use this great tool[1] to extract the bitcode from an executable.
Both approaches produce bitcode (binary format), if you need IR (human-readable format), then you can post-process the bitcode by running llvm-dis against each bitcode file.
I hope it helps.
[1] https://github.com/JDevlieghere/LibEBC
On 28. Nov 2018, at 23:22, David Greene via cfe-dev
mailto:cfe-dev@lists.llvm.org> wrote: How do I get the LLVM IR produced by clang? I know that -emit-llvm produces IR but it seems to be after processing by LLVM (things are optimized out, for example). Is there an "official" way to get the IR coming right out of clang's codegen? I can do a hack with -mllvm -print-before-all but that's icky.
Thanks!
-David _______________________________________________ cfe-dev mailing list cfe-dev@lists.llvm.org mailto:cfe-dev@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
degski -- /*/*“*/If something cannot go on forever, it will stop" - Herbert Stein*/
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org https://lists.boost.org/mailman/listinfo.cgi/boost-users
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org https://lists.boost.org/mailman/listinfo.cgi/boost-users
On Fri, 30 Nov 2018 at 16:09, Osman Zakir via Boost-users < boost-users@lists.boost.org> wrote:
So you mean I should use Clang-C2/Clang with Microsoft CodeGen, aka the clang-cl compiler? Either way, how do I change the compiler toolchain when building Boost?
No, that's dead for a [quite] while now, just get and install Clang/LLVM from https://releases.llvm.org/download.html#7.0.0. AFAIK, the final Boost-1.69 release [or current dev branch] will allow for building with clang-cl **and lld-link** [Thanks to Peter Dimov]. You'll need to have a project-jam file something like this: import option ; using clang-win : : "C:\\Program Files\\LLVM\\bin\\clang-cl.exe" -fuse-ld=lld : <compatibility>vc14 <compileflags>-fmsc-version=1915 <compileflags>-fms-compatibility <compileflags>-fno-delayed-template-parsing <compileflags>-flto=thin <cxxflags>"/std:c++17" <cxxflags>"/Zc:forScope" <cxxflags>"/Zc:wchar_t" <cxxflags>"/EHsc" <cxxflags>"/Zc:inline" <cxxflags>"/Gd" <cxxflags>"/diagnostics:classic" <cxxflags>-Wno-unknown-argument <cxxflags>-Wno-unknown-pragmas <cxxflags>-Wno-macro-redefined <cxxflags>-Wno-unused-variable <cxxflags>-Wno-mismatched-tags <cxxflags>-Wno-deprecated-declarations <cxxflags>-D_UNICODE <cxxflags>-DUNICODE <cxxflags>-DBOOST_USE_WINDOWS_H <cxxflags>-DBOOST_NO_ANSI_APIS <cxxflags>-DBOOST_USE_WINAPI_VERSION=0x1000 <cxxflags>-DBOOST_USE_WINDOWS_H=1 <cxxflags>-DNOMINMAX <cxxflags>-DWIN32_LEAN_AND_MEAN <cxxflags>-D_CRT_SECURE_NO_WARNINGS ; But you'll have to adjust that to your needs. degski -- *“If something cannot go on forever, it will stop" - Herbert Stein*
From: Boost-users [mailto:boost-users-bounces@lists.boost.org] On Behalf Of degski via Boost-users
Sent: 30 November 2018 20:40
To: boost-users@lists.boost.org
Cc: degski
Subject: Re: [Boost-users] LLVM bitcode for Boost libraries?
On Fri, 30 Nov 2018 at 16:09, Osman Zakir via Boost-users
On Tue, 4 Dec 2018 at 13:08, Paul A. Bristow via Boost-users < boost-users@lists.boost.org> wrote:
*From:* Boost-users [mailto:boost-users-bounces@lists.boost.org] *On Behalf Of *degski via Boost-users *Sent:* 30 November 2018 20:40 *To:* boost-users@lists.boost.org *Cc:* degski *Subject:* Re: [Boost-users] LLVM bitcode for Boost libraries?
On Fri, 30 Nov 2018 at 16:09, Osman Zakir via Boost-users < boost-users@lists.boost.org> wrote:
So you mean I should use Clang-C2/Clang with Microsoft CodeGen, aka the clang-cl compiler? Either way, how do I change the compiler toolchain when building Boost?
No, that's dead for a [quite] while now, just get and install Clang/LLVM from https://releases.llvm.org/download.html#7.0.0.
AFAIK, the final Boost-1.69 release [or current dev branch] will allow for building with clang-cl **and lld-link** [Thanks to Peter Dimov]. You'll need to have a project-jam file something like this:
import option ; using clang-win : : "C:\\Program Files\\LLVM\\bin\\clang-cl.exe" -fuse-ld=lld : <compatibility>vc14 <compileflags>-fmsc-version=1915 <compileflags>-fms-compatibility <compileflags>-fno-delayed-template-parsing <compileflags>-flto=thin <cxxflags>"/std:c++17" <cxxflags>"/Zc:forScope" <cxxflags>"/Zc:wchar_t" <cxxflags>"/EHsc" <cxxflags>"/Zc:inline" <cxxflags>"/Gd" <cxxflags>"/diagnostics:classic" <cxxflags>-Wno-unknown-argument <cxxflags>-Wno-unknown-pragmas <cxxflags>-Wno-macro-redefined <cxxflags>-Wno-unused-variable <cxxflags>-Wno-mismatched-tags <cxxflags>-Wno-deprecated-declarations <cxxflags>-D_UNICODE <cxxflags>-DUNICODE <cxxflags>-DBOOST_USE_WINDOWS_H <cxxflags>-DBOOST_NO_ANSI_APIS <cxxflags>-DBOOST_USE_WINAPI_VERSION=0x1000 <cxxflags>-DBOOST_USE_WINDOWS_H=1 <cxxflags>-DNOMINMAX <cxxflags>-DWIN32_LEAN_AND_MEAN <cxxflags>-D_CRT_SECURE_NO_WARNINGS ;
But you'll have to adjust that to your needs.
Before I bash my head against this configuration again, please can you confirm that this does this work for you to build the Boost libraries **on Windows** so that one can use the Boost.Test library (not header-only)?
Am I right on thinking that
All the / items are to allow compilation of MSVC stuff.
Is it essential to use <cxxflags>"/EHsc" ? when
test suite using Boost. emits a warning that EHa should be enabled:
*warning C4535: calling _set_se_translator() requires /EHa*
All the –Wno- items are to deal with a blizzard of warnings from MSVC stuff?
<cxxflags>-D_CRT_SECURE_NO_WARNINGS is need to avoid C runtime warnings.
And all the other –D items are only needed if you want to use more than empty project console applications?
You can probably forget everything after the line <cxxflags>"/std:c++17", the rest is indeed mostly to have a build log with as little nonsense as possible and I picked /EHsc, because this seems to be the default in the IDE. I don't build the test suite, but the libs build quite nicely. degski PS: @Paul, was not clear to me who wrote what [who was abusing his head], so maybe I missed something. -- *“If something cannot go on forever, it will stop" - Herbert Stein*
On 5/12/2018 05:27, degski wrote:
PS: @Paul, was not clear to me who wrote what [who was abusing his head], so maybe I missed something.
Pro-tip (@Osman): don't use Outlook for any mailing list (except the few where top-posting is tolerated) because Outlook cannot cope with anything except top-posting, especially in HTML formatted email. And they steadfastly refuse to provide a way to "split" a quote block, which is all it would take to make this scenario actually work. (In a pinch you can convert the email to text-only in Outlook first and then you can successfully reply to it, but that loses the quote markers so you'll have to add those in manually.)
On 5/12/2018 12:39, Osman Zakir wrote:
Or I can just delete all of the quotes from below, like here. Isn't this okay too?
For people using a threaded mail client, it's ok (though not preferred). But it may confuse people using unthreaded clients or digests, especially in a thread with several branches. Proper style is to quote just the part you're actually directly replying to, in order to provide context without duplicating the whole chain.
-----Original Message----- From: Boost-users [mailto:boost-users-bounces@lists.boost.org] On Behalf Of Gavin Lambert via Boost-users Sent: 04 December 2018 22:22 To: boost-users@lists.boost.org Cc: Gavin Lambert Subject: Re: [Boost-users] LLVM bitcode for Boost libraries?
On 5/12/2018 05:27, degski wrote:
PS: @Paul, was not clear to me who wrote what [who was abusing his head], so maybe I missed something.
Pro-tip (@Osman): don't use Outlook for any mailing list (except the few where top-posting is tolerated) because Outlook cannot cope with anything except top-posting, especially in HTML formatted email.
And they steadfastly refuse to provide a way to "split" a quote block, which is all it would take to make this scenario actually work.
(In a pinch you can convert the email to text-only in Outlook first and then you can successfully reply to it, but that loses the quote markers so you'll have to add those in manually.)
The head-abusing Paul forgot to click format as plain-text :-( And yes Outlook is a nuisance making bottom posting messy, but I normally manage it well enough. Paul
participants (5)
-
degski
-
Edward Diener
-
Gavin Lambert
-
Osman Zakir
-
Paul A. Bristow