Skip to content

Commit f212feb

Browse files
committed
Update Linux CI to use GCC 12
Update both the variables that dictate this and the documents that explain it.
1 parent 11426c9 commit f212feb

File tree

6 files changed

+32
-18
lines changed

6 files changed

+32
-18
lines changed

Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ RUN apt-get update \
4545
tzdata \
4646
jq \
4747
&& if [ "$(. /etc/lsb-release; echo "${DISTRIB_RELEASE}" | cut -d. -f1)" -ge 22 ]; then apt-get install -y --no-install-recommends skopeo; fi \
48+
&& if [ "$(. /etc/lsb-release; echo "${DISTRIB_RELEASE}" | cut -d. -f1)" -eq 22 ]; then apt-get install -y --no-install-recommends g++-12; fi \
4849
&& mkdir -p /etc/apt/keyrings \
4950
&& chmod 0755 /etc /etc/apt /etc/apt/keyrings \
5051
&& curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg | tee /etc/apt/keyrings/githubcli-archive-keyring.gpg >/dev/null \

Library/Homebrew/development_tools.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,11 @@ def llvm_clang_build_version
102102
end, T.nilable(Version))
103103
end
104104

105+
sig { returns(Pathname) }
106+
def host_gcc_path
107+
Pathname.new("/usr/bin/gcc")
108+
end
109+
105110
# Get the GCC version.
106111
#
107112
# @api internal

Library/Homebrew/extend/os/linux/development_tools.rb

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,17 @@ def locate(tool)
2929
sig { returns(Symbol) }
3030
def default_compiler = :gcc
3131

32+
sig { returns(Pathname) }
33+
def host_gcc_path
34+
@host_gcc_path ||= T.let(
35+
if OS::Linux.os_version.include?("Ubuntu 22.04")
36+
Pathname.new("/usr/bin/gcc-12")
37+
else
38+
Pathname.new("/usr/bin/gcc")
39+
end, T.nilable(Pathname)
40+
)
41+
end
42+
3243
sig { returns(T::Boolean) }
3344
def needs_libc_formula?
3445
return @needs_libc_formula unless @needs_libc_formula.nil?
@@ -41,13 +52,12 @@ def needs_libc_formula?
4152
def needs_compiler_formula?
4253
return @needs_compiler_formula unless @needs_compiler_formula.nil?
4354

44-
gcc = "/usr/bin/gcc"
45-
@needs_compiler_formula = T.let(if File.exist?(gcc)
46-
::DevelopmentTools.gcc_version(gcc) < OS::LINUX_GCC_CI_VERSION
47-
else
48-
true
49-
end, T.nilable(T::Boolean))
50-
!!@needs_compiler_formula
55+
@needs_compiler_formula = T.let(nil, T.nilable(T::Boolean))
56+
@needs_compiler_formula = if host_gcc_path.exist?
57+
::DevelopmentTools.gcc_version(host_gcc_path.to_s) < OS::LINUX_GCC_CI_VERSION
58+
else
59+
true
60+
end
5161
end
5262

5363
sig { returns(T::Hash[String, T.nilable(String)]) }

Library/Homebrew/extend/os/linux/system_config.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ def host_glibc_version
1919
end
2020

2121
def host_gcc_version
22-
gcc = Pathname.new "/usr/bin/gcc"
22+
gcc = DevelopmentTools.host_gcc_path
2323
return "N/A" unless gcc.executable?
2424

2525
`#{gcc} --version 2>/dev/null`[/ (\d+\.\d+\.\d+)/, 1]
@@ -47,7 +47,7 @@ def dump_verbose_config(out = $stdout)
4747
out.puts "OS: #{OS::Linux.os_version}"
4848
out.puts "WSL: #{OS::Linux.wsl_version}" if OS::Linux.wsl?
4949
out.puts "Host glibc: #{host_glibc_version}"
50-
out.puts "/usr/bin/gcc: #{host_gcc_version}"
50+
out.puts "#{DevelopmentTools.host_gcc_path}: #{host_gcc_version}"
5151
out.puts "/usr/bin/ruby: #{host_ruby_version}" if RUBY_PATH != HOST_RUBY_PATH
5252
["glibc", CompilerSelector.preferred_gcc, OS::LINUX_PREFERRED_GCC_RUNTIME_FORMULA, "xorg"].each do |f|
5353
out.puts "#{f}: #{formula_linked_version(f)}"

Library/Homebrew/os.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@ def self.kernel_name
4949
LINUX_CI_OS_VERSION = "Ubuntu 22.04"
5050
LINUX_GLIBC_CI_VERSION = "2.35"
5151
LINUX_GLIBC_NEXT_CI_VERSION = "2.39"
52-
LINUX_GCC_CI_VERSION = "11.0"
53-
LINUX_PREFERRED_GCC_COMPILER_FORMULA = "gcc@11" # https://packages.ubuntu.com/jammy/gcc
52+
LINUX_GCC_CI_VERSION = "12.0"
53+
LINUX_PREFERRED_GCC_COMPILER_FORMULA = "gcc@12" # https://packages.ubuntu.com/jammy/gcc-12
5454
LINUX_PREFERRED_GCC_RUNTIME_FORMULA = "gcc"
5555

5656
if OS.mac?

docs/Linux-CI.md

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
last_review_date: "1970-01-01"
2+
last_review_date: "2025-03-28"
33
---
44

55
# Linux CI in `homebrew/core`
@@ -20,25 +20,23 @@ We have moved our CI to Ubuntu 22.04
2020

2121
Moving from Ubuntu 16.04 to Ubuntu 22.04 (and thus skipping version 18.04 and 20.04) took longer than expected.
2222

23-
We plan to proceed with regular updates from 2022 onwards. We aim to use the latest Ubuntu LTS version for our CI.
24-
25-
We will start using the latest Ubuntu LTS version for our CI no earlier than 3 months after its release and, ideally, no more than 12 months after its release.
23+
We plan to proceed with regular updates from 2022 onwards. We aim to use the oldest supported Ubuntu LTS version for our CI that provides the GCC version we need.
2624

2725
| Distribution | Glibc | GCC | LTS standard security maintenance |
2826
|---|---|---|---|
2927
| Ubuntu 14.04 | 2.19 | 4 | From 2014 to 2017 |
3028
| Ubuntu 16.04 | 2.23 | 5 | From 2017 to 2022 |
3129
| Ubuntu 20.04 | 2.31 | 5 | From 2020 to 2025 |
32-
| Ubuntu 22.04 | 2.35 | 11 | From 2022 to 2027 |
30+
| Ubuntu 22.04 | 2.35 | 11 (provides 12) | From 2022 to 2027 |
3331
| Ubuntu 24.04 | 2.39 | 13 | From 2024 to 2029 |
3432
| Ubuntu 26.04 | ? | ? | ? |
3533

3634
[Source](https://ubuntu.com/about/release-cycle)
3735

38-
## Why always use the latest version?
36+
## Why upgrade to a newer version?
3937

4038
Homebrew is a rolling-release package manager. We try to ship the newest things as quickly as possible, on macOS and Linux.
4139

4240
When a formula needs a newer GCC because our host GCC in CI is too old, we needed to make that formula depend on a newer Homebrew GCC. All C++ dependents of that formula immediately acquire a dependency on Homebrew GCC as well. While we have taken the steps to make sure this no longer holds up GCC updates, it still creates a maintenance burden. This problem is more likely for formula which are very actively maintained and try to use newer features of C++. We decided that we shouldn't have a maintenance burden for formulae which are doing the right thing by staying up to date. It makes a lot of sense for Homebrew maintainers to submit upstream fixes when formulae are not working with newer compilers. It makes a lot less sense for Homebrew maintainers to submit fixes because our host compiler is too old.
4341

44-
Note that `glibc` will need to be installed for more users as their `glibc` version will often be too old: disk space is cheap and we have can handle this situation for our users. This situation will often arise when update to a new LTS version and adoption of the new Ubuntu is still low during the first months. For the same reasons as above: we prefer to stay on the bleeding edge and give our users a gentle nudge to think about updating their OS.
42+
Note that `glibc` will need to be installed for more users as their `glibc` version will often be too old. This is not as smooth as using a newer GCC as we don't test this configuration in CI. This is why we want to balance the newest GCC with a more conservative `glibc`.

0 commit comments

Comments
 (0)