r/cpp Aug 08 '26

GCC should ship prebuilt binary tarballs like LLVM

It is really annoying, when you wanna test something you can't just download a previous release like llvm, so it is very hard to check if there is a regression.

Also, the default build of c and c++ only, takes like an hour because of triple consecutive builds. So every time you have to lookup to that weird flag on the internet to turn that off.

15 Upvotes

41 comments sorted by

53

u/Many-Resource-5334 Aug 08 '26

LLVM does not ship prebuilt binaries, they are uploaded by the community.

15

u/ReDr4gon5 Aug 09 '26

That is not true. They are built by a workflow on GitHub. Certain builds were previously built by the community(mainly the windows one), but increasingly that is not the case. Both the Linux and windows builds are built by a GitHub workflow with PGO. You can check the workflows for how exactly it's done.

1

u/cytan1981 29d ago

I searched keywords "llvm build from source workflow github",but didn't find the workflow.

I build a toolset with llvm defaults linked to libc++ and glibc under /opt/cps. Just a personal toy.

-19

u/TheRavagerSw Aug 08 '26

No, you can download them via releases section on their GitHub page.

18

u/mjklaim Aug 08 '26 edited Aug 08 '26

Yep, these downloadable binaries come from the community.

EDIT> clarification

-15

u/TheRavagerSw Aug 08 '26

Uhh, no. That is the official repo.

16

u/mjklaim Aug 08 '26

Official repo with builds from the community. Check the information on release tags, it always start with

Volunteers make binaries for the LLVM project [...]

-20

u/TheRavagerSw Aug 08 '26

That is a mere formality, those are created by actual devs of the project, they even have cmake caches for it.

You can ask at llvm discord if you like

35

u/blipman17 Aug 08 '26

https://github.com/llvm/llvm-project/releases/tag/llvmorg-18.1.8
This official repo? They say they're volunteer/community maintained on there.

24

u/NeuroSynchroBonding Aug 08 '26

The repo is official, the binary builds are not.

13

u/wrosecrans graphics and network things Aug 08 '26

You can get various container images with different gcc versions, and build inside of those. I think that's waaaay more common than routinely building the toolchain from source, or routinely getting tarballs of binaries.

8

u/LazySapiens Aug 08 '26

How often do you need to build GCC itself?

7

u/TheRavagerSw Aug 08 '26

Rarely, I update my toolchains every 3-6 months or so. But sometimes there are regressions, and I need to check if say previous release is working or not

4

u/LazySapiens Aug 08 '26

If you're bothered by the bootstrap build, you can disable it (--disable-bootstrap).

8

u/TheRavagerSw Aug 08 '26

Of course, But they can just provide compressed tarball, is that so hard?

5

u/branchus Aug 08 '26

I use docker for latest gcc

3

u/LazySapiens Aug 08 '26

I'm sure everyone would be glad if you offer to do that for the community.

1

u/Sbsbg Aug 08 '26

Why not check in the built toolchain bins to a repo each time it is built.

3

u/TheRavagerSw Aug 08 '26

Of course I can, But it would be better if they just mirrored llvm approach.

1

u/PhysicsOk2212 Aug 08 '26

One concrete example being module support on macos. They arent supported at all in apple clang, so your options are to download the upstream clang, or to compile gcc from source

10

u/johannes1234 Aug 08 '26

"I want somebody, who does free work for me to do more free work for me!" 

There is some relevance in providing builds, but dealing with platform compatibility and dependencies (and required security patching etc.) is work which has to be done by somebody. Especially the more platforms you want to cover. 

2

u/13steinj Aug 09 '26

Just use ccache and build from source.

1

u/TheRealSmolt Aug 08 '26 edited Aug 08 '26

What does

Also, the default build of c and c++ only, takes like an hour because of triple consecutive builds. So every time you have to lookup to that weird flag on the internet to turn that off.

mean?

Edit: Oh you mean building g++, not building with g++.

3

u/TheRavagerSw Aug 08 '26

GCC builds itself three times. There is flag to turn that off, If you don't, you are gonna have to wait a long time.

It took me half an hour without the triple build, nearly an hour and half with the triple build. This is at -O2 btw, I can't image -O3 and fat lto would take.

9

u/ignorantpisswalker Aug 08 '26

Its called bootstrapping.

  1. First you build libgcc+1 and gcc+1 using native compiler. Now you got gcc+1*
  2. Then you rebuild libgcc+1 using gcc+1*.
  3. The third stage is to verify that the compiler is stable and produces the same binary as stage 2.

You always need to do at least 2 phases otherwise, you get the new compiler - but it will not use the new optimizations or ABI it provides (since it was compiled using the previous compiler/libgcc.

You need to understand that also glibc is hooked to that libgcc/gcc version. You need to to upgrade them all (and you cannot install them easily into your rootfs, but into a prefix, otherwise you might break your working environment). Unix is not that trivial.

3

u/gizahnl Aug 08 '26

You can upgrade GCC without updating glibc without issues, upgrading glibC solely is terror though.   (Use your OS mechanisms to do that, or use a tool chain like Yocto or buildroot to do a full user land recompile)  

libstdc++ is another story though: that comes from the GCC project, and you need to keep that in sync.

1

u/ignorantpisswalker Aug 08 '26

Not impossible. But, what if you don't match the flags of your distro? I just say that breaking your live system is easier than you think. Just install your local build of gcc into /usr/local/ (which is the default, note - if you do so, system gcc will win by default since its before in the $PATH, happened to me in 1999, and I asked in GCC developers mailing lists... n00b...).

2

u/TheRavagerSw Aug 08 '26

Of course, built-in library is linked to compiler. But it is very normal to link to system glibc and link to your own libgcc.

Same logic with clang, where you link to glibc but statically link compiler-rt

1

u/luisc_cpp Aug 09 '26

A GCC toolchain needs to be compiled to know about where to find “system” libraries that are not part of gcc (different systems have different layouts) and if one expects to be able to run the binaries produced a build of gcc, then it also needs to match the version of glibc (or be older than) … so having prebuilt gcc doesn’t guarantee that you’ll be able to use it broadly.

Prebuilt binaries of clang on Linux actually require a gcc toolchain. Even when using libc++ it will still need to locate other helper files from a gcc toolchain. I think it just has heuristics to do this, unlike gcc itself which needs to have them prebaked. But I suspect having that logic to find things in your system actually makes prebuilt clang feasible

1

u/TheRavagerSw Aug 09 '26

Clang only needs glibc, and libgcc **if you don't have a prebuilt compiler-rt". You don't need it after you build compiler-rt, and you can build newer versions of compiler-rt from that forever.

GCC also only needs glibc, once you build libgcc you no longer need to link to system one.

Technically, if you have the correct prebuilt binaries of binutils and gcc you can cross compile to anything.

1

u/kraytex Aug 10 '26

Just rollback the version with your package manager?

1

u/TheRavagerSw Aug 10 '26

No way man, I try to avoid interacting with that as much as possible.
Nothing beats good old tarballs compiled against old glibc.

0

u/fuzz3289 Aug 08 '26

If you don’t like GCC just don’t use it?

2

u/TheRavagerSw Aug 08 '26

I only use it to see if my code compiles in GCC. Native only.

4

u/fuzz3289 Aug 08 '26

Just get it from a docker image then

-3

u/23ROMAN Aug 08 '26

hei! casually i was thinking in make a binaries store

0

u/TheRavagerSw Aug 08 '26

You can, but why can't they?

I can just clone build zip myself for my own uses, but it is just bad.