Use unversioned GCC for runtime libraries when required.
- [x] Have you followed the guidelines in our Contributing document?
- [x] Have you checked to ensure there aren't other open Pull Requests for the same change?
- [x] Have you added an explanation of what your changes do and why you'd like us to include them?
- [ ] Have you written new tests for your changes? Here's an example.
- [x] Have you successfully run
brew stylewith your changes locally? - [x] Have you successfully run
brew typecheckwith your changes locally? - [ ] Have you successfully run
brew testswith your changes locally?
See discussion at Homebrew/homebrew-core#110010.
Review period will end on 2022-09-23 at 08:42:28 UTC.
Review period ended.
I'm a little confused by that, since this is my understanding of the conclusion of our discussion at Homebrew/homebrew-core#110010.
In any case:
This PR does not change the likelihood of needing both gcc and gcc@11 installed. Some users already need both without this change, and this PR does not change anything for them. (Nor does it change anything right now for users who currently don't need both installed.)
What this PR does change is the likelihood of needing three different versions of GCC installed. In particular, this PR makes sure that brew never forces you to have three versions installed, whereas not merging this PR will result in some users having three versions of GCC forced on them when GCC 13 comes along. (This happens, for instance, if you currently need both gcc@11 and gcc@12 without this change, and then gcc is upgraded to GCC 13 and you have a formula with a dependency on gcc.)
That said: needing multiple GCCs is not likely at all, at least for users who only use bottles. This is something you can always do in the default prefix (whenever a bottle is available). With this PR, you'll only ever need a second GCC if you build from source. On the other hand, without this PR, some bottle users will need two GCCs (gcc@12 and gcc) installed, even if they don't build from source.
I'm a little confused by that, since this is my understanding of the conclusion of our discussion at Homebrew/homebrew-core#110010.
Sorry about that.
What this PR does change is the likelihood of needing three different versions of GCC installed. In particular, this PR makes sure that
brewnever forces you to have three versions installed, whereas not merging this PR will result in some users having three versions of GCC forced on them when GCC 13 comes along. (This happens, for instance, if you currently need bothgcc@11andgcc@12without this change, and thengccis upgraded to GCC 13 and you have a formula with a dependency ongcc.)
Yeh, I'd rather we nailed down what we want to do here unless GCC 13 is landing imminently.
I'm ok with this change if we also consider bumping the compiler to gcc@12 and then ideally do something like allowing either gcc@12 or higher to be installed for folks that only need it at runtime and just gcc@12 for folks that need it from building from source.
I think we share the goal of minimising GCC versions: I think one for both runtime and building from source cases seems ideal.
Ok, here's an idea:
We make the compiler dependency a "soft" dependency, in the sense that brew install will still proceed without it installed (and use the unversioned gcc to compile), but build failures (and maybe brew doctor) will suggest a brew install gcc@11. [*]
This way, we make it a bit easier to make sure that users ever only need one GCC installed, but in the event that they need a second one, we nudge them towards the version we use in CI to maximise the probability of a successful source build.
[*] brew install proceeding and using the unversioned gcc may actually already be the current behaviour.
This way, we make it a bit easier to make sure that users ever only need one GCC installed, but in the event that they need a second one, we nudge them towards the version we use in CI to maximise the probability of a successful source build.
I'm suggesting we use GCC@12 in CI for build, too, given the weird Ubuntu libstdc++/compiler mismatch and the fact that we can just brew install gcc-12 or whatever it is in all our base images.
I'm suggesting we use GCC@12 in CI for build, too, given the weird Ubuntu libstdc++/compiler mismatch and the fact that we can just
brew install gcc-12or whatever it is in all our base images.
I don't want to use brew to install that, but maybe we can just apt install gcc-12 or something.
I don't want to use
brewto install that, but maybe we can justapt install gcc-12or something.
@carlocab In our workers: sure. When we install GCC for users: we should install the same one we use in CI for consistency. If we're going to install GCC for build and runtime on the same machine: these should ideally be the same GCC. If we're going to install GCC for runtime libraries only: I don't really care what version it is. If we're going to install GCC for build only: it should be the same we use in CI.
Does that makes sense? Do you agree?
If we're going to install GCC for runtime libraries only: I don't really care what version it is. If we're going to install GCC for build only: it should be the same we use in CI.
Yes, I agree with this.
However, I think I'd like to punt on making the GCC we build with GCC 12 -- that will require a bit more care and coordination to avoid disruption to Homebrew/core, and I think merging this will unblock Homebrew/actions#308. We need Homebrew/actions#308 to unbreak Homebrew/core -- our publish workflow has broken because brew is not in PATH. https://github.com/Homebrew/homebrew-core/actions/runs/3132629345/jobs/5085168240#step:3:18
I do think we should just move to use GCC 12 to build everything. There's really no point in using GCC 11 given that the GCC 12 runtime libraries are needed anyway.
I'm ambivalent about using the latest GCC at run time instead of what we use in CI. Either we should use GCC 12 for building and runtime of C/C++ programs, and the newest GCC for building and runtime of Fortran, or we use the newest version for all runtimes, and install GCC 12 when building C/C++ programs from source. Both of those solutions mean the user only ever has to have 2 versions of GCC installed, thought the latter choice does mean fewer users will need 2 versions installed.
Having said the above comments, I think we should probably merge this now so that we can fix the existing breakages.
I rebased to make sure tests run against the tip of master, but that turned out to be a bad idea...
Could not find 'brew' command in PATH.
https://github.com/Homebrew/brew/actions/runs/3133106631/jobs/5086140404