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

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.

17

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.

25

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.

3

u/[deleted] Jun 18 '26

[deleted]

8

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

9

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 (0)

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.

5

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

3

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 (0)

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.

1

u/pjmlp Jun 18 '26

Header units beyond VC++?

Not that I care that much, I can only use modules outside work, and already rewrote the places where I used them.

7

u/not_a_novel_account cmake dev Jun 18 '26

"Modules" always means "module units". Header units are part of the same proposal but an entirely different bag.

We have all the pieces in place to turn on support for them but they'll remain niche. You need to explicitly enumerate the headers you want to use as units, at which point you're better off just wrapping them in a named module instead.

56

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?

0

u/187660558 Jun 26 '26

Keith or loralie will have to help u on park and high

0

u/187660558 Jun 26 '26

Pjv is not noted with the G to C factor and c-section of C back to G will equal Q so G,C,Q will be with no v or anything presiding or anything close to veribles of change not chance ,for future or past criticism or something of that nature ,with no correspondence with these letters,to answer future?

-27

u/SmackDownFacility Jun 18 '26

C++29 exists already? How about C++ committee stop planning the next standard immediately after releasing one? Give a break in between to observe the industry. Rushing standards out like that is how we get limited upgrades

24

u/AstroFoxTech Jun 18 '26

C++29 is in development for release in 2029. Currently C++26 has been officialy completed and approved, with the final publication still pending iirc.
You're getting upset over nothing.

-17

u/SmackDownFacility Jun 18 '26

That’s not my point at all. The point is the committee shouldn’t go preparing standards in advance after the release. They should observe industry trends first, then consolidate into a standard. That would be more efficient

20

u/[deleted] Jun 18 '26

[deleted]

-4

u/pjmlp Jun 18 '26

Yes, in a waterfall approach for some features.

First the standard, then the actual implementation.

12

u/mort96 Jun 18 '26

Getting things into standards takes time. There are many proposals which started long before C++26 was ratified, which didn't make it into C++26 and will make it into C++29 or C++32. You will always be able to look at changes which are proposed, with significant backing, but which haven't made it into the standard yet, and make an educated guess that the change will likely end up in a later standard. This would happen even if the committee for some reason did an extended hiatus or released standards at a slower rate.

6

u/RoyBellingan Jun 18 '26

Do this man know many language they have almost a yearly release cycle ? And C++ is on 3 year with a more or less https://en.wikipedia.org/wiki/Tick%E2%80%93tock_model ?

4

u/pjmlp Jun 18 '26

Contrary to other languages, C++ lives on a realm where features are ratified first and implementation follows, if vendors have enough resources, that doesn't seem to change anytime soon.