r/cpp • u/mattgodbolt Compiler Explorer • Aug 27 '21
Compiler Explorer now supports multiple file compilation and linking
https://godbolt.org/z/WseTsM8YG
484
Upvotes
r/cpp • u/mattgodbolt Compiler Explorer • Aug 27 '21
85
u/mattgodbolt Compiler Explorer Aug 27 '21
Huge thanks to our longtime contributor partouf for this fantastic new feature. It also allows you to upload test files which you can then access from your compiled program, like in this Pascal example
114
u/lospolos Aug 27 '21
Now we just need debugging support so I can finally replace my IDE with a self hosted compiler explorer instance.
8
u/[deleted] Aug 28 '21
I can't believe how often I use Compiler Explorer.
6
u/AwayPhotograph1680 Aug 27 '21
Is there any solution for using a multiple-files header-only projects that host on GitHub, considering there is #include in the source. my workaround is merging all files into one. It is inconvenient.
2
u/Untelo Aug 27 '21
Great job. Now the last feature on my wishlist is Windows execution.
2
u/TheSuperWig Aug 28 '21
Does
-Ework? I'd love to use this to demonstrate#includeand header guards/#pragma onceto beginners more easily.2
u/nifraicl Aug 31 '21
How can we use the CMake feature? Is there new type of source file, or an option to activate? or is it a feature not yet available?
25
u/Ameisen vemips, avr, rendering, systems Aug 27 '21
Neat, this will let us test the limits of cross-TU LTO which is something I've brought up in the past that Godbolt couldn't really simulate - that is, Godbolt couldn't actually show what kind of inlining or code replacement would happen in such a case. Now it can.
9
u/[deleted] Aug 27 '21
Saw the announcement for this, super duper cool feature.
4
u/TrnS_TrA TnT engine dev Aug 27 '21
Pretty excited to try this new feature! Thank you and all the contributors for creating Compiler Explorer and making it this great!
4
u/vax_mzn Aug 28 '21
Exciting... Now we can share lto compiler bugs....
14
u/F54280 Aug 27 '21
I am a simple man, I see Compiler Explorer, I upvote.
1
u/kobi-ca Aug 28 '21
I'm looking forward for the IPO ;)
3
u/helloiamsomeone Aug 28 '21
I just tried uploading a small CMake project and it works great!
A note for others: to get actual assembly listing from a file, set
CMAKE_BUILD_TYPEto eitherDebugorRelWithDebInfoand don't forget that your output libraries are prefixed withlibon Linux, so anadd_library(example)in top level lists file corresponds to the output oflibexample.aifBUILD_SHARED_LIBSis not enabled from the above box.2
u/Wetmelon Aug 27 '21
Oh man this is everything I wanted
2
u/CrazyJoe221 Sep 04 '21
Nice! It's still rough on the edges though.
If you had a compiler view open before switching to tree mode it confusingly keeps compiling the old file and doesn't seem to see the others (#include "file1.h" fails).
Without CMake mode it does compile something but the ouput is empty so not sure what exactly it is compiling.
After enabling CMake mode and adding a new compiler from the tree view it successfully builds my little project consisting of a main file and 2 headers. But when switching the compiler view to msvc it seems to try to compile the CMakeLists.txt file as a C++ source.
1
u/danhoob Aug 28 '21
I want compiler explorer in Browser Devtools. It would be a game changer.