Skip to content

Commit

Permalink
compilers: drop support for GCC 4.9
Browse files Browse the repository at this point in the history
Also update documentation and tests to use non-disabled GCC.
  • Loading branch information
cho-m committed Aug 22, 2024
1 parent 4482e25 commit 378e8cf
Show file tree
Hide file tree
Showing 12 changed files with 51 additions and 57 deletions.
2 changes: 1 addition & 1 deletion Library/Homebrew/cmd/install.rb
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ class InstallCmd < AbstractCommand
}],
[:flag, "--cc=", {
description: "Attempt to compile using the specified <compiler>, which should be the name of the " \
"compiler's executable, e.g. `gcc-7` for GCC 7. In order to use LLVM's clang, specify " \
"compiler's executable, e.g. `gcc-9` for GCC 9. In order to use LLVM's clang, specify " \
"`llvm_clang`. To use the Apple-provided clang, specify `clang`. This option will only " \
"accept compilers that are provided by Homebrew or bundled with macOS. Please do not " \
"file issues if you encounter errors while using this option.",
Expand Down
4 changes: 2 additions & 2 deletions Library/Homebrew/compilers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
# frozen_string_literal: true

module CompilerConstants
GNU_GCC_VERSIONS = %w[4.9 5 6 7 8 9 10 11 12 13 14].freeze
GNU_GCC_REGEXP = /^gcc-(4\.9|[5-9]|10|11|12|13|14)$/
GNU_GCC_VERSIONS = %w[5 6 7 8 9 10 11 12 13 14].freeze
GNU_GCC_REGEXP = /^gcc-(#{GNU_GCC_VERSIONS.join("|")})$/
COMPILER_SYMBOL_MAP = {
"gcc" => :gcc,
"clang" => :clang,
Expand Down
14 changes: 4 additions & 10 deletions Library/Homebrew/test/ENV_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,8 @@

describe "#compiler" do
it "allows switching compilers" do
subject.public_send(:"gcc-6")
expect(subject.compiler).to eq("gcc-6")
subject.public_send(:"gcc-9")
expect(subject.compiler).to eq("gcc-9")
end
end

Expand Down Expand Up @@ -179,14 +179,8 @@
end

describe "#cxx11" do
it "supports gcc-5" do
env["HOMEBREW_CC"] = "gcc-5"
env.cxx11
expect(env["HOMEBREW_CCCFG"]).to include("x")
end

example "supports gcc-6" do
env["HOMEBREW_CC"] = "gcc-6"
it "supports gcc-9" do
env["HOMEBREW_CC"] = "gcc-9"
env.cxx11
expect(env["HOMEBREW_CCCFG"]).to include("x")
end
Expand Down
64 changes: 32 additions & 32 deletions Library/Homebrew/test/compiler_selector_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@
before do
allow(versions).to receive(:gcc_version) do |name|
case name
when "gcc-7" then Version.new("7.1")
when "gcc-6" then Version.new("6.1")
when "gcc-5" then Version.new("5.1")
when "gcc-4.9" then Version.new("4.9.1")
when "gcc-12" then Version.new("12.1")
when "gcc-11" then Version.new("11.1")
when "gcc-10" then Version.new("10.1")
when "gcc-9" then Version.new("9.1")
else Version::NULL
end
end
Expand All @@ -29,68 +29,68 @@
end

it "returns clang if it fails with non-Apple gcc" do
software_spec.fails_with(gcc: "7")
software_spec.fails_with(gcc: "12")
expect(selector.compiler).to eq(:clang)
end

it "still returns gcc-7 if it fails with gcc without a specific version" do
it "still returns gcc-12 if it fails with gcc without a specific version" do
software_spec.fails_with(:clang)
expect(selector.compiler).to eq("gcc-7")
expect(selector.compiler).to eq("gcc-12")
end

it "returns gcc-6 if gcc formula offers gcc-6 on mac", :needs_macos do
it "returns gcc-11 if gcc formula offers gcc-11 on mac", :needs_macos do
software_spec.fails_with(:clang)
allow(Formulary).to receive(:factory)
.with("gcc")
.and_return(instance_double(Formula, version: Version.new("6.0")))
expect(selector.compiler).to eq("gcc-6")
.and_return(instance_double(Formula, version: Version.new("11.0")))
expect(selector.compiler).to eq("gcc-11")
end

it "returns gcc-5 if gcc formula offers gcc-5 on linux", :needs_linux do
it "returns gcc-10 if gcc formula offers gcc-10 on linux", :needs_linux do
software_spec.fails_with(:clang)
allow(Formulary).to receive(:factory)
.with("gcc@11")
.and_return(instance_double(Formula, version: Version.new("5.0")))
expect(selector.compiler).to eq("gcc-5")
.and_return(instance_double(Formula, version: Version.new("10.0")))
expect(selector.compiler).to eq("gcc-10")
end

it "returns gcc-6 if gcc formula offers gcc-5 and fails with gcc-5 and gcc-7 on linux", :needs_linux do
it "returns gcc-11 if gcc formula offers gcc-10 and fails with gcc-10 and gcc-12 on linux", :needs_linux do
software_spec.fails_with(:clang)
software_spec.fails_with(gcc: "5")
software_spec.fails_with(gcc: "7")
software_spec.fails_with(gcc: "10")
software_spec.fails_with(gcc: "12")
allow(Formulary).to receive(:factory)
.with("gcc@11")
.and_return(instance_double(Formula, version: Version.new("5.0")))
expect(selector.compiler).to eq("gcc-6")
.and_return(instance_double(Formula, version: Version.new("10.0")))
expect(selector.compiler).to eq("gcc-11")
end

it "returns gcc-7 if gcc formula offers gcc-5 and fails with gcc <= 6 on linux", :needs_linux do
it "returns gcc-12 if gcc formula offers gcc-11 and fails with gcc <= 11 on linux", :needs_linux do
software_spec.fails_with(:clang)
software_spec.fails_with(:gcc) { version "6" }
software_spec.fails_with(:gcc) { version "11" }
allow(Formulary).to receive(:factory)
.with("gcc@11")
.and_return(instance_double(Formula, version: Version.new("5.0")))
expect(selector.compiler).to eq("gcc-7")
.and_return(instance_double(Formula, version: Version.new("11.0")))
expect(selector.compiler).to eq("gcc-12")
end

it "returns gcc-7 if gcc-7 is version 7.1 but spec fails with gcc-7 <= 7.0" do
it "returns gcc-12 if gcc-12 is version 12.1 but spec fails with gcc-12 <= 12.0" do
software_spec.fails_with(:clang)
software_spec.fails_with(gcc: "7") { version "7.0" }
expect(selector.compiler).to eq("gcc-7")
software_spec.fails_with(gcc: "12") { version "12.0" }
expect(selector.compiler).to eq("gcc-12")
end

it "returns gcc-6 if gcc-7 is version 7.1 but spec fails with gcc-7 <= 7.1" do
it "returns gcc-11 if gcc-12 is version 12.1 but spec fails with gcc-12 <= 12.1" do
software_spec.fails_with(:clang)
software_spec.fails_with(gcc: "7") { version "7.1" }
expect(selector.compiler).to eq("gcc-6")
software_spec.fails_with(gcc: "12") { version "12.1" }
expect(selector.compiler).to eq("gcc-11")
end

it "raises an error when gcc or llvm is missing (hash syntax)" do
software_spec.fails_with(:clang)
software_spec.fails_with(gcc: "7")
software_spec.fails_with(gcc: "6")
software_spec.fails_with(gcc: "5")
software_spec.fails_with(gcc: "4.9")
software_spec.fails_with(gcc: "12")
software_spec.fails_with(gcc: "11")
software_spec.fails_with(gcc: "10")
software_spec.fails_with(gcc: "9")

expect { selector.compiler }.to raise_error(CompilerSelectionError)
end
Expand Down
4 changes: 2 additions & 2 deletions completions/fish/brew.fish
Original file line number Diff line number Diff line change
Expand Up @@ -862,7 +862,7 @@ __fish_brew_complete_arg 'instal' -l bottle-arch -d 'Optimise bottles for the sp
__fish_brew_complete_arg 'instal' -l build-bottle -d 'Prepare the formula for eventual bottling during installation, skipping any post-install steps'
__fish_brew_complete_arg 'instal' -l build-from-source -d 'Compile formula from source even if a bottle is provided. Dependencies will still be installed from bottles if they are available'
__fish_brew_complete_arg 'instal' -l cask -d 'Treat all named arguments as casks'
__fish_brew_complete_arg 'instal' -l cc -d 'Attempt to compile using the specified compiler, which should be the name of the compiler\'s executable, e.g. `gcc-7` for GCC 7. In order to use LLVM\'s clang, specify `llvm_clang`. To use the Apple-provided clang, specify `clang`. This option will only accept compilers that are provided by Homebrew or bundled with macOS. Please do not file issues if you encounter errors while using this option'
__fish_brew_complete_arg 'instal' -l cc -d 'Attempt to compile using the specified compiler, which should be the name of the compiler\'s executable, e.g. `gcc-9` for GCC 9. In order to use LLVM\'s clang, specify `llvm_clang`. To use the Apple-provided clang, specify `clang`. This option will only accept compilers that are provided by Homebrew or bundled with macOS. Please do not file issues if you encounter errors while using this option'
__fish_brew_complete_arg 'instal' -l colorpickerdir -d 'Target location for Color Pickers (default: `~/Library/ColorPickers`)'
__fish_brew_complete_arg 'instal' -l debug -d 'If brewing fails, open an interactive debugging session with access to IRB or a shell inside the temporary build directory'
__fish_brew_complete_arg 'instal' -l debug-symbols -d 'Generate debug symbols on build. Source will be retained in a cache directory'
Expand Down Expand Up @@ -916,7 +916,7 @@ __fish_brew_complete_arg 'install' -l bottle-arch -d 'Optimise bottles for the s
__fish_brew_complete_arg 'install' -l build-bottle -d 'Prepare the formula for eventual bottling during installation, skipping any post-install steps'
__fish_brew_complete_arg 'install' -l build-from-source -d 'Compile formula from source even if a bottle is provided. Dependencies will still be installed from bottles if they are available'
__fish_brew_complete_arg 'install' -l cask -d 'Treat all named arguments as casks'
__fish_brew_complete_arg 'install' -l cc -d 'Attempt to compile using the specified compiler, which should be the name of the compiler\'s executable, e.g. `gcc-7` for GCC 7. In order to use LLVM\'s clang, specify `llvm_clang`. To use the Apple-provided clang, specify `clang`. This option will only accept compilers that are provided by Homebrew or bundled with macOS. Please do not file issues if you encounter errors while using this option'
__fish_brew_complete_arg 'install' -l cc -d 'Attempt to compile using the specified compiler, which should be the name of the compiler\'s executable, e.g. `gcc-9` for GCC 9. In order to use LLVM\'s clang, specify `llvm_clang`. To use the Apple-provided clang, specify `clang`. This option will only accept compilers that are provided by Homebrew or bundled with macOS. Please do not file issues if you encounter errors while using this option'
__fish_brew_complete_arg 'install' -l colorpickerdir -d 'Target location for Color Pickers (default: `~/Library/ColorPickers`)'
__fish_brew_complete_arg 'install' -l debug -d 'If brewing fails, open an interactive debugging session with access to IRB or a shell inside the temporary build directory'
__fish_brew_complete_arg 'install' -l debug-symbols -d 'Generate debug symbols on build. Source will be retained in a cache directory'
Expand Down
4 changes: 2 additions & 2 deletions completions/zsh/_brew
Original file line number Diff line number Diff line change
Expand Up @@ -1091,7 +1091,7 @@ _brew_instal() {
'(--cask)--bottle-arch[Optimise bottles for the specified architecture rather than the oldest architecture supported by the version of macOS the bottles are built on]' \
'(--cask --build-from-source --force-bottle)--build-bottle[Prepare the formula for eventual bottling during installation, skipping any post-install steps]' \
'(--cask --build-bottle --force-bottle)--build-from-source[Compile formula from source even if a bottle is provided. Dependencies will still be installed from bottles if they are available]' \
'(--cask)--cc[Attempt to compile using the specified compiler, which should be the name of the compiler'\''s executable, e.g. `gcc-7` for GCC 7. In order to use LLVM'\''s clang, specify `llvm_clang`. To use the Apple-provided clang, specify `clang`. This option will only accept compilers that are provided by Homebrew or bundled with macOS. Please do not file issues if you encounter errors while using this option]' \
'(--cask)--cc[Attempt to compile using the specified compiler, which should be the name of the compiler'\''s executable, e.g. `gcc-9` for GCC 9. In order to use LLVM'\''s clang, specify `llvm_clang`. To use the Apple-provided clang, specify `clang`. This option will only accept compilers that are provided by Homebrew or bundled with macOS. Please do not file issues if you encounter errors while using this option]' \
'(--formula)--colorpickerdir[Target location for Color Pickers (default: `~/Library/ColorPickers`)]' \
'--debug[If brewing fails, open an interactive debugging session with access to IRB or a shell inside the temporary build directory]' \
'(--cask)--debug-symbols[Generate debug symbols on build. Source will be retained in a cache directory]' \
Expand Down Expand Up @@ -1149,7 +1149,7 @@ _brew_install() {
'(--cask)--bottle-arch[Optimise bottles for the specified architecture rather than the oldest architecture supported by the version of macOS the bottles are built on]' \
'(--cask --build-from-source --force-bottle)--build-bottle[Prepare the formula for eventual bottling during installation, skipping any post-install steps]' \
'(--cask --build-bottle --force-bottle)--build-from-source[Compile formula from source even if a bottle is provided. Dependencies will still be installed from bottles if they are available]' \
'(--cask)--cc[Attempt to compile using the specified compiler, which should be the name of the compiler'\''s executable, e.g. `gcc-7` for GCC 7. In order to use LLVM'\''s clang, specify `llvm_clang`. To use the Apple-provided clang, specify `clang`. This option will only accept compilers that are provided by Homebrew or bundled with macOS. Please do not file issues if you encounter errors while using this option]' \
'(--cask)--cc[Attempt to compile using the specified compiler, which should be the name of the compiler'\''s executable, e.g. `gcc-9` for GCC 9. In order to use LLVM'\''s clang, specify `llvm_clang`. To use the Apple-provided clang, specify `clang`. This option will only accept compilers that are provided by Homebrew or bundled with macOS. Please do not file issues if you encounter errors while using this option]' \
'(--formula)--colorpickerdir[Target location for Color Pickers (default: `~/Library/ColorPickers`)]' \
'--debug[If brewing fails, open an interactive debugging session with access to IRB or a shell inside the temporary build directory]' \
'(--cask)--debug-symbols[Generate debug symbols on build. Source will be retained in a cache directory]' \
Expand Down
6 changes: 3 additions & 3 deletions docs/C++-Standard-Libraries.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ dependencies that you built on 10.8 or earlier. If you're reading this page beca
you were directed here by a build error, you can most likely fix the issue if
you reinstall all the dependencies of the package you're trying to build.

Example install using GCC 7:
Example install using GCC 9:

```sh
brew install gcc@7
brew install --cc=gcc-7 <formula>
brew install gcc@9
brew install --cc=gcc-9 <formula>
```
2 changes: 1 addition & 1 deletion docs/Custom-GCC-and-cross-compilers.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Homebrew depends on having an up-to-date version of Xcode because it comes with
Rather than merging formulae for either of these cases at this time, we're listing them on this page. If you come up with a formula for a new version of GCC or cross-compiler suite, please link to it here.

- Homebrew provides a `gcc` formula for use with Xcode 4.2+.
- Homebrew provides older GCC formulae, e.g. `gcc@7`.
- Homebrew provides older GCC formulae, e.g. `gcc@9`.
- Homebrew provides some cross-compilers and toolchains, but these are named to avoid clashing with the default tools, e.g. `i686-elf-gcc`, `x86_64-elf-gcc`.
- Homebrew provides LLVM's Clang, which is bundled with the `llvm` formula.
- [RISC-V](https://github.com/riscv/homebrew-riscv) provides the RISC-V toolchain including binutils and GCC.
2 changes: 1 addition & 1 deletion docs/Manpage.md
Original file line number Diff line number Diff line change
Expand Up @@ -587,7 +587,7 @@ upgrade *`formula`* if it is already installed but outdated.
`--cc`

: Attempt to compile using the specified *`compiler`*, which should be the name
of the compiler's executable, e.g. `gcc-7` for GCC 7. In order to use LLVM's
of the compiler's executable, e.g. `gcc-9` for GCC 9. In order to use LLVM's
clang, specify `llvm_clang`. To use the Apple-provided clang, specify `clang`.
This option will only accept compilers that are provided by Homebrew or
bundled with macOS. Please do not file issues if you encounter errors while
Expand Down
2 changes: 1 addition & 1 deletion docs/Tips-N'-Tricks.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

## Install previous versions of formulae

Some formulae in `homebrew/core` are made available as [versioned formulae](Versions.md) using a special naming format, e.g. `gcc@7`. If the version you're looking for isn't available, consider using `brew extract`.
Some formulae in `homebrew/core` are made available as [versioned formulae](Versions.md) using a special naming format, e.g. `gcc@9`. If the version you're looking for isn't available, consider using `brew extract`.

## Quickly remove something from Homebrew's prefix

Expand Down
2 changes: 1 addition & 1 deletion docs/Versions.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Formulae Versions

[homebrew/core](https://github.com/homebrew/homebrew-core) supports multiple versions of formulae by using a special naming format. For example, the formula for GCC 6 is named `gcc@6.rb` and begins with `class GccAT6 < Formula`.
[homebrew/core](https://github.com/homebrew/homebrew-core) supports multiple versions of formulae by using a special naming format. For example, the formula for GCC 9 is named `gcc@9.rb` and begins with `class GccAT9 < Formula`.

## Acceptable versioned formulae

Expand Down
2 changes: 1 addition & 1 deletion manpages/brew.1
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ An unsupported Homebrew development option to skip installing any dependencies o
Install the dependencies with specified options but do not install the formula itself\.
.TP
\fB\-\-cc\fP
Attempt to compile using the specified \fIcompiler\fP, which should be the name of the compiler\[u2019]s executable, e\.g\. \fBgcc\-7\fP for GCC 7\. In order to use LLVM\[u2019]s clang, specify \fBllvm_clang\fP\&\. To use the Apple\-provided clang, specify \fBclang\fP\&\. This option will only accept compilers that are provided by Homebrew or bundled with macOS\. Please do not file issues if you encounter errors while using this option\.
Attempt to compile using the specified \fIcompiler\fP, which should be the name of the compiler\[u2019]s executable, e\.g\. \fBgcc\-9\fP for GCC 9\. In order to use LLVM\[u2019]s clang, specify \fBllvm_clang\fP\&\. To use the Apple\-provided clang, specify \fBclang\fP\&\. This option will only accept compilers that are provided by Homebrew or bundled with macOS\. Please do not file issues if you encounter errors while using this option\.
.TP
\fB\-s\fP, \fB\-\-build\-from\-source\fP
Compile \fIformula\fP from source even if a bottle is provided\. Dependencies will still be installed from bottles if they are available\.
Expand Down

0 comments on commit 378e8cf

Please sign in to comment.