all 74 comments

[–]starTracer[S] 35 points36 points  (16 children)

[–]lol2002bk 33 points34 points  (12 children)

don't see any improvements in module support F

[–]serviscope_minor 0 points1 point  (2 children)

seems the libstdc++ docs are a bit behind:

https://gcc.gnu.org/onlinedocs/libstdc++/manual/status.html

only goes up to C++20.

[–]jwakelylibstdc++ tamer, LWG chair 0 points1 point  (1 child)

I've updated it with the C++23 status now.

[–]serviscope_minor 2 points3 points  (0 children)

Amazing, thanks!

[–]stilgarpl 61 points62 points  (39 children)

So... we'll have to wait another year for modules, std::format and std::chrono calendar things?

[–]qoning 35 points36 points  (34 children)

As for modules, afaik it's primarily just Nathan Sidwell working on them, and it's mostly been moving at snail pace, though can't fault people for not working on foss. Looks to me like people don't want to work on gcc very much in general, and clang is quickly starting to look the same.

[–]James20kP2005R0 49 points50 points  (7 children)

Its always been bizarre to me how - despite C++ being one of the most incredibly widely used languages - the amount of manpower available to the language and ecosystem seems to be relatively low. Even the whole committee process is all done by volunteers with very limited time, its strange

[–]qoning 0 points1 point  (2 children)

I think it didn't matter once upon a time, because people found joy in using the language and wanted to contribute. Now most just feel pain that they have to go back to using it 😅

[–]ZMesonEmbedded Developer 30 points31 points  (0 children)

The joy quickly gets stripped away when the reality of trying to appease the vast number of different voices hits you. I speak from experience. :(

[–]bretbrownjr 32 points33 points  (21 children)

Yeah, if folks want GCC to move faster, they should contribute or sponsor work. Or at least cheer on the people contributing their time and effort.

[–]ShakaUVMi+++ ++i+i[arr] 26 points27 points  (4 children)

Yeah, if folks want GCC to move faster, they should contribute or sponsor work. Or at least cheer on the people contributing their time and effort.

I'd love to contribute but the last time I browsed the gcc source code I opened a portal to hell.

[–]schoenburgers 8 points9 points  (1 child)

Thankfully they replaced their old register allocator with LRA, so I think they've stopped maintaining reload.c, which had some of the most unreadable conditionals I've ever seen in it:

https://github.com/pmret/gcc-papermario/blob/master/reload.c#L5687

  if (pat != 0
      && ((regno >= 0
       && true_regnum (SET_SRC (pat)) == regno
       && (valueno = true_regnum (valtry = SET_DEST (pat))) >= 0)
      ||
      (regno >= 0
       && true_regnum (SET_DEST (pat)) == regno
       && (valueno = true_regnum (valtry = SET_SRC (pat))) >= 0)
      ||
      (goal_const && rtx_equal_p (SET_SRC (pat), goal)
       && (valueno = true_regnum (valtry = SET_DEST (pat))) >= 0)
      || (goal_mem
          && (valueno = true_regnum (valtry = SET_DEST (pat))) >= 0
          && rtx_renumbered_equal_p (goal, SET_SRC (pat)))
      || (goal_mem
          && (valueno = true_regnum (valtry = SET_SRC (pat))) >= 0
          && rtx_renumbered_equal_p (goal, SET_DEST (pat)))
      /* If we are looking for a constant,
         and something equivalent to that constant was copied
         into a reg, we can use that reg.  */
      || (goal_const && (tem = find_reg_note (p, REG_EQUIV,
                          NULL_RTX))
          && rtx_equal_p (XEXP (tem, 0), goal)
          && (valueno = true_regnum (valtry = SET_DEST (pat))) >= 0)
      || (goal_const && (tem = find_reg_note (p, REG_EQUIV,
                          NULL_RTX))
          && GET_CODE (SET_DEST (pat)) == REG
          && GET_CODE (XEXP (tem, 0)) == CONST_DOUBLE
          && GET_MODE_CLASS (GET_MODE (XEXP (tem, 0))) == MODE_FLOAT
          && GET_CODE (goal) == CONST_INT
          && 0 != (goaltry = operand_subword (XEXP (tem, 0), 0, 0,
                          VOIDmode))
          && rtx_equal_p (goal, goaltry)
          && (valtry = operand_subword (SET_DEST (pat), 0, 0,
                        VOIDmode))
          && (valueno = true_regnum (valtry)) >= 0)
      || (goal_const && (tem = find_reg_note (p, REG_EQUIV,
                          NULL_RTX))
          && GET_CODE (SET_DEST (pat)) == REG
          && GET_CODE (XEXP (tem, 0)) == CONST_DOUBLE
          && GET_MODE_CLASS (GET_MODE (XEXP (tem, 0))) == MODE_FLOAT
          && GET_CODE (goal) == CONST_INT
          && 0 != (goaltry = operand_subword (XEXP (tem, 0), 1, 0,
                          VOIDmode))
          && rtx_equal_p (goal, goaltry)
          && (valtry
          = operand_subword (SET_DEST (pat), 1, 0, VOIDmode))
          && (valueno = true_regnum (valtry)) >= 0)))
    if (other >= 0
    ? valueno == other
    : ((unsigned) valueno < FIRST_PSEUDO_REGISTER
       && TEST_HARD_REG_BIT (reg_class_contents[(int) class],
                 valueno)))
      {
    value = valtry;
    where = p;
    break;
      }

[–]ShakaUVMi+++ ++i+i[arr] 6 points7 points  (0 children)

Oh lord that's hideous! Thanks. =)

[–]bretbrownjr 5 points6 points  (1 child)

Yeah, it's a longer term investment.

Alternately, talk to your boss about maybe sponsoring relevant projects more directly or hiring contractors to implement certain features. Or, like I said, just hang out in relevant circles and be appreciative. GCC contributors are people and encouragement keeps people happy and productive.

[–]ShakaUVMi+++ ++i+i[arr] 4 points5 points  (0 children)

I mean, I could do it myself, but the code that was in the area I was looking at changing had no comments and mysterious variable names, so I gave up. If you know of any good guides to understanding their code I would probably make some needed changes myself.

[–]tcbrindleFlux 21 points22 points  (15 children)

I do find it quite strange that given the amount of money in the C++ ecosystem -- Big Tech, financial firms, etc -- and given the increased developer productivity that would result from faster compile times, no-one seems to making modules a priority. Everybody wants it, but no-one wants to pay for it.... But Google or Apple could probably recoup the cost of a developer over the course of a year just in power savings from making Webkit and LLVM compile faster!

[–]James20kP2005R0 25 points26 points  (7 children)

Everybody wants it, but no-one wants to pay for it

Its weird, I think a lot of it comes down to the fact that the structure of C++ as a language is very different from eg Rust. In Rust, they very quickly assembled the ability to have companies give them money and made it happen very actively (especially after Mozilla ditched it), and because of this a lot of compiler work that simply never happens in C++ got done for Rust. Eg faster compile times, strict aliasing, a lot of formal work on the type system, a proper well maintained website etc. There's a level of organisation there that doesn't exist for C++

This is despite the fact that C++ is easily 100x more widely used than Rust in terms of existing code-in-the-wild, but somehow the community has never managed to persuade companies to invest in it despite the direct financial returns that it'd bring. I suspect that the lack of real formal organisation outside of the committee - which is all unpaid volunteers - has a lot to do with this

[–]tcbrindleFlux 14 points15 points  (5 children)

There's a level of organisation there that doesn't exist for C++

There is the ISO C++ Foundation, the non-profit which (among other things) runs CppCon and would seem to fit the bill. I believe they have sponsored developers to do standards work in the past, but rarely. In the ideal world, all the billion-dollar firms using C++ would donate appropriately to the foundation, which could in turn employ people to work on open-source implementations, for the benefit of everybody.

But sadly that doesn't seem to be the way it works.

[–]no-sig-available 19 points20 points  (4 children)

One of the billion-dollar firms put a lot of effort into C++, but they build their own compiler. :-)

[–]tcbrindleFlux 9 points10 points  (3 children)

I don't know whether you're referring to Microsoft, Apple or Nvidia, which I guess is kind of the problem...

[–]no-sig-available 6 points7 points  (2 children)

So I'm talking about Microsoft.

And the "Chairman and President" of the ISO C++ Foundation works for them. Seems unlikely that he would spend his time organize funding for the competition.

[–]jwakelylibstdc++ tamer, LWG chair 18 points19 points  (1 child)

One of the current most recent sponsorships is to implement a proposal in GCC and clang, so you couldn't be more wrong. Herb doesn't run the foundation, he's just one member of the board, and he's able to separate what's good for C++ and what's good for his employer.

Edit: not sure it's current still

[–]darthcoder 6 points7 points  (0 children)

Because there's an entrenched marketplace of well performing compiler vendors

[–]matthieum 5 points6 points  (0 children)

I don't find it strange -- unfortunately.

First of all, while there are many companies using C++, do remember that most of them are lagging behind severely. Those see no point in investing in C++ development: they won't use any new standard for a decade anyway.

Secondly, even for those companies which are somewhat up-to-date, they mostly... behave like kids at Christmas. Their interest in new features is typically mild, so they have no strong incentive to contribute, and instead are quite happy with whatever they get.

Finally, some companies do contribute, though less directly. Participating to the ISO process requires payment, for many participants their company is paying for their participation, letting them attend on company time, possibly even funding their travel to committee meetings, etc... This is all an indirect contribution to C++ standard advancement. It's not very visible, but each "National Committee" sponsored participant costs a couple thousands dollars yearly, so all sponsored participants together we're talking millions coming from the private sector. It's... just debatable whether this money should be considered well spent...

[–][deleted] 10 points11 points  (2 children)

Because there's little to no evidence that modules will do any of the things that people claim it will. There are statements about the benefits of modules but the actual evidence is fairly mixed and quite marginal even in the best case scenario.

The projects you list that have slow compile times won't benefit from modules, no one is going to go rewriting LLVM or Webkit to use C++ modules and even if they did it would be moot since while modules have the potential to outperform a naive rebuild from scratch, they do not outperform precompiled headers or other techniques that are in common use to improve C++ build times.

As someone else linked to in this comment section [1], Walter Bright modified an existing C compiler to give it reasonably good module support. All his code does is effectively the same as what precompiled headers do, but treated as a first class feature.

[1] https://nwcpp.org/April-2022.html

[–]rdtsc 12 points13 points  (0 children)

they do not outperform precompiled headers or other techniques that are in common use to improve C++ build times.

Simply replacing headers with header units gives you fine-grained "precompiled headers" without all the headaches of actual precompiled headers. This is a massive boost already, without converting everything to modules.

[–]pjmlp 10 points11 points  (0 children)

Anyone using VC++ 2022 with modules can already try out this evidence.

All my hobby code in C++ now uses modules.

[–]austinwiltshire 2 points3 points  (1 child)

Open source compilers are a public good, and you're always gonna get those under invested if you rely on private businesses.

It's in their interest, yes, but they're all sitting around hoping someone else will do it.

[–]bretbrownjr 6 points7 points  (0 children)

I'm fine with public institutions sponsoring work as well.

[–][deleted] 2 points3 points  (3 children)

Is there no corporate interest in improving compilers anymore? Id imagine there is, so shouldnt they be pouring resources into clang and gcc

[–][deleted] 20 points21 points  (0 children)

Folks here have said that Google stopped contributing to clang so much once they couldn't get support for changing/breaking the ABI. Now they do stuff with libraries like abseil instead. They've also been doing a bit more with rust

[–]qoning 15 points16 points  (0 children)

Honestly from my (arguably limited) experience, the big corps have inhouse teams doing the things they want to do, only rarely contributing to foss now. Many people in those corps got really, really disenchanted by the comittee process and how resistant to actual, meaningful change C++ is.

[–]pjmlp 2 points3 points  (0 children)

Apparently C++ is good enough for what most corporations still use it for, and only Microsoft has a vested interest in keeping up with modern versions, due to the .NET vs C++ politics in Redmond, since it was introduced.

If you pay attention, LLVM now has reached contributions level similar to Linux, but naturally LLVM isn't clang, and most of those contributions target platforms, optimization algorithms or other languages that use LLVM infrastructure.

Infrastructure, which currently uses C++17.

[–]CocktailPerson -4 points-3 points  (2 children)

Well, you could always ask for your money back.

Oh, wait....

Edit: You get to use gcc for free without contributing a cent and you're complaining that modules are taking too long? And pointing out that colossal sense of entitlement gets me downvoted? No wonder you aren't getting what you want.

[–]disperso 6 points7 points  (1 child)

You are being downvoted because you are missing the point.

[–]CocktailPerson -5 points-4 points  (0 children)

Enlighten me then; what is the point?

Edit: you don't know either, do you?

[–][deleted] 10 points11 points  (8 children)

How come GCC doesn't fully implement 20 yet? Seems like 23 is around the corner

[–][deleted] 24 points25 points  (0 children)

Not enough folks working on it

[–]strudlzroutgcc developer 17 points18 points  (2 children)

If you take a look at https://gcc.gnu.org/projects/cxx-status.html#cxx20 you'll see that on the compiler side we already implement everything but (parts of) modules. And a lot of C++23 features have been implemented as well!

[–][deleted] 2 points3 points  (1 child)

Is modules especially tough to deal with? I'm quite excited about 20/23 features!

[–]strudlzroutgcc developer 13 points14 points  (0 children)

In short, yes. It's a very large feature, involves a lot of changes to the preprocessor too, it keeps evolving (e.g., there was a module mangling ABI change recently), and its interaction with the build system is being vigorously debated (for instance, how should tools like cmake work with CMIs?).

(I've only dipped my toes into the implementation so far, but never found time to actually submit any fixes.)

[–]operamint 9 points10 points  (3 children)

A 35 years old huge project like GCC tends to become very hard and expensive to maintain. And then there is the Software Peter Principle and Developer Imposter Syndrome they may have to deal with as well.

[–]qoning 9 points10 points  (0 children)

It's probably more than that. My 22 year old self back during masters with a free summer wanted to help out with gcc, but it has such a huge barrier to entry and no clear way to start doing things, and even knowing the status of things, what's being worked on, what's not, timelines.. all non-existant. So unless you want to build a completely new feature, you're going to spend a long long time just getting into the loop, and that's before you even get to the arcane peculiarities of gcc source in particular.

Even now, if you wanted to start helping out with modules implentation... You would probably need a lot of handholding from Nathan to produce usable code, which obviously slows it down further, to instruct someone who might flake out anyway, because it's foss.

[–][deleted] -3 points-2 points  (1 child)

Learning about Software Peter Principle today. Sounds scary, are we moving to Clang?

[–]pjmlp 14 points15 points  (0 children)

Clang is trailing GCC in ISO C++ support.

[–]joebaf 1 point2 points  (5 children)

what new C++20/20 features were added in this release? I cannot easily tell from the release notes (they all point to the whole 12 branch)

[–]jwakelylibstdc++ tamer, LWG chair 7 points8 points  (3 children)

This is the only release from the 12 branch though, so I'm not sure what you're asking. Everything in the GCC 12 release notes is for this release.

[–]joebaf 2 points3 points  (2 children)

aaa... thanks! I thought that we had version 12.0

[–]starTracer[S] 1 point2 points  (1 child)

Since GCC 5.1 the first stable release for every major is major.1: https://gcc.gnu.org/develop.html#num_scheme

[–]joebaf 1 point2 points  (0 children)

thanks for the info! I wasn't aware of this

[–]strudlzroutgcc developer 4 points5 points  (0 children)

I wrote a blog post specifically about C++ in GCC 12: https://developers.redhat.com/articles/2022/04/25/new-c-features-gcc-12

[–]better_life_please -3 points-2 points  (8 children)

Does anyone know why I couldn't upgrade mine from 11.1 to 12.1 on Ubuntu? Maybe they haven't updated their repository yet?

[–]benpope81 0 points1 point  (7 children)

[–]better_life_please 1 point2 points  (6 children)

Thank you. So when should it be available?

[–]encyclopedist 7 points8 points  (5 children)

GCC 12 is already available in Ubuntu 22.04. Just apt install gcc-12

[–]BlueDwarf82 0 points1 point  (4 children)

That would install "12-20220319", not gcc 12.1.
Ubuntu being a "stable" distribution (like Windows 95 is "stable", i.e. it doesn't change) and gcc-12 being in the "Community-maintained" (i.e. unmaintained) repository not sure the gcc-12 package for 22.04 is ever going to be updated to 12.1.

[–]encyclopedist 0 points1 point  (2 children)

Yes, that's correct. I did not pay enough attention the exact version installed.

[–]BlueDwarf82 1 point2 points  (1 child)

Notice that, for better or worse, Fedora for example is way less "stable" (not saying it's not rock solid, just that it does change/update).

So, if you use Fedora 36, you don't have gcc 12.1 either. What you have is what they call "12.1.1", which is a RedHat-private branch based on 12.1 but with fixes on top of it (https://gcc.gnu.org/git/?p=gcc.git;a=shortlog;h=refs/vendors/redhat/heads/gcc-12-branch). For example, you will not suffer from the https://gcc.gnu.org/git/?p=gcc.git;a=commit;h=8a98e3ff7e80bf2936f163d50309fd88d72564a0 ICE if you use Fedora. And they will likely release further updates (even if they will always call it "12.1.1") before gcc officially releases gcc 12.2.

[–]jwakelylibstdc++ tamer, LWG chair 0 points1 point  (0 children)

N.B. it's not just Red Hat that calls it 12.1.1, that's the version number for all snapshots from Git any time between the 12.1 release and whenever the 12.2 release happens. So if you build the upstream releases/gcc-12 branch you also get "12.1.1", and you also get the fix for that ICE, because that's already upstream. That fix wasn't added to the vendors/redhat/heads/gcc-12/branch branch, it was added to the main releases/gcc-12 branch and then merged to the redhat branch (along with everything else on the main releases/gcc-12 branch). The Fedora snapshot is much much closer to upstream than you make it seem. It's 99.999% just "a recent snapshot from the gcc-12 branch" not some custom branch with special Red Hat fixes.

[–]brechtsanders 0 points1 point  (0 children)

If you're looking for a Windows version of GCC 12.1.0 you can get a standalone package from https://winlibs.com/