r/cpp • • Jun 18 '26

GCC 17 Lands Initial Infrastructure For C++29

https://www.phoronix.com/news/GCC-17-std-CPP29-Experimental
130 Upvotes

38 comments sorted by

View all comments

50

u/Best_Froyo8941 Jun 18 '26

Would still like to ask how’s the module support going on now. Is the main bottleneck on the compiler side or the toolchain side like cmake ? Last time I try it with 26 standard. The cmake support is still experimental like.

16

u/not_a_novel_account cmake dev Jun 18 '26

There's no work left to do as far as stability goes. If your blocker was GCC or CMake, it shouldn't be.

24

u/llort_lemmort Jun 18 '26

As long as import std is experimental in CMake that's definitely a blocker for me.

22

u/not_a_novel_account cmake dev Jun 18 '26 edited Jun 18 '26

That might be awhile. It's going to remain experimental until someone decides how static libraries on MSVC are supposed to work, which is above my paygrade.

Right now they just don't, if you use import std in a static library on MSVC and then try to use that library in some other project (which doesn't import std, maybe isn't even written in C++) the link fails.

I tried to move it out of experimental in 4.3. Turns out people like static libraries. Back to experimental it went.

0

u/[deleted] Jun 18 '26

[deleted] — view deleted comment

7

u/not_a_novel_account cmake dev Jun 18 '26

Seperate codebase is the key here, although I'm not sure what VS does with the std.obj, maybe they vendor it inside the archive and that would work.

3

u/pjmlp Jun 18 '26

Static libraries definitely work with modules in VC++ with MSBuild, and import std, unless you mean something else.

https://github.com/pjmlp/RaytracingWeekend-CPP/tree/main/OneWeekend/RaytracingLib

8

u/not_a_novel_account cmake dev Jun 18 '26 edited Jun 18 '26

You're doing an import std in the main project, so std.obj is being provided there.

The problem is when you try to use a static library which wants import std in a project which does not itself do import std. CMake does not bundle std.obj into the archive, unless someone else provides it the link fails.

It's entirely possible VS is bundling std.obj and this "just works" for them even when consumed by projects which don't do import std themselves, like a plain C project. That's certainly a solution. I need to boot up a Windows box and check at some point.

3

u/pjmlp Jun 19 '26

I am on Windows and can have a look later today, with VC++ / MS Build though.

2

u/mapronV Jun 19 '26

Can you please share a result? I interested in result of this conversation!

→ More replies
→ More replies (1)

3

u/llort_lemmort Jun 18 '26

Is there an issue that I can follow for this? The merge request that restored the experimental gate for 4.3 only mentions 4 issues which have all been closed since.

7

u/not_a_novel_account cmake dev Jun 18 '26

These include both broken stdlib distributions and regressions in our implementation

The issues are for the latter. The former is discussed in the upstreams:

GCC/libstdc++ fixed in GCC 16, Clang/libc++ is not actually a blocker, MSVC/msvp*.dll is NOTABUG. The last one is a blocker until someone from on-high tells me how it's supposed to work. The DevCom focuses on ODR for DLLs but the static archive scenario is actually the more pressing problem.

4

u/Expert-Map-1126 vcpkg maintainer BillyONeal Jun 18 '26

"The downstream customer also needs to import std" is the usage model I remember being expected when this was discussed way back in Cologne

4

u/not_a_novel_account cmake dev Jun 18 '26

How does a Fortran consumer have import std in its usage model? It might not even have a C++ compiler available.

3

u/Expert-Map-1126 vcpkg maintainer BillyONeal Jun 18 '26

"That's the neat part you don't" 🤷 (You are saying more or less exactly what I was saying to the modules designers at the time. "How can I ship a std module that customers can use?" "You don't, customers have to build you themselves")

7

u/not_a_novel_account cmake dev Jun 18 '26

Well it works for literally every module on Earth except for import std under MSVC. The answer is very obvious IMHO, which is that std.obj should be a part of the runtime distribution. "std isn't special"

But if the official answer eventually becomes "this is how it works, you need a C++ compiler for MSVC import std", that's fine. It's more work; I just need that from on high because I don't want to implement that and have it change in 6 months.

→ More replies

6

u/_bstaletic Jun 18 '26

During gcc 16 development, there were bugs when one turns on both -fmodules and -freflection. Last time I checked modules and reflections still aren't a stable combination. I might need a newer gcc 17, as I haven't been following the most recent development.

4

u/Pretend-Guide-8664 Jun 18 '26

I thought the implementation was partial, aren't there some missing bits? Private partitions, implementation definitions visible by importers, something else. Going off of memory here

4

u/not_a_novel_account cmake dev Jun 18 '26

Oh GCC stuff, yes, I overstated the case. GCC has some edge features which are partial.

Private frags are pointless IMHO, but I shouldn't have said they covered everything.

→ More replies (2)

54

u/exodusTay Jun 18 '26

AI might take our jobs before modules are properly supported.

15

u/Tainted_Heisenberg Jun 18 '26

Modules are stable, is the tooling the problem, clangd-23 brings better intellisense in modules

6

u/CruzerNag Jun 18 '26

I've tried modules with CMake and ninja with both gcc and clang, and they've worked fine mostly. Apart from the std module, other things work fine with cmake.

And with xmake, even std module works without needing any configuration. So things are getting stable.

2

u/messmerd Jun 18 '26

Will they ever implement private module fragments? What's holding that up?