From d1dff79cb22848af1a5aa7b41b83d1ad50e82c91 Mon Sep 17 00:00:00 2001 From: Seeker Date: Tue, 11 Aug 2020 13:39:35 -0700 Subject: [PATCH 01/14] gcc@4.9: use version.major_minor for version suffix --- Formula/gcc@4.9.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Formula/gcc@4.9.rb b/Formula/gcc@4.9.rb index bed244749dd0c..720151dcc90c0 100644 --- a/Formula/gcc@4.9.rb +++ b/Formula/gcc@4.9.rb @@ -86,7 +86,7 @@ def install # Build dependencies in-tree, to avoid having versioned formulas resources.each { |r| r.stage(buildpath/r.name) } - version_suffix = version.to_s.slice(/\d\.\d/) + version_suffix = version.major_minor.to_s args = [ "--build=x86_64-apple-darwin#{osmajor}", @@ -162,7 +162,7 @@ def add_suffix(file, suffix) return 0; } EOS - system bin/"gcc-4.9", "-o", "hello-c", "hello-c.c" + system bin/"gcc-#{version.major_minor}", "-o", "hello-c", "hello-c.c" assert_equal "Hello, world!\n", `./hello-c` end end From 037e0c2c4d96fc96d6d0b27e77f15afee8f305ba Mon Sep 17 00:00:00 2001 From: Seeker Date: Tue, 11 Aug 2020 13:40:54 -0700 Subject: [PATCH 02/14] gcc@5: use version.major for version suffix --- Formula/gcc@5.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Formula/gcc@5.rb b/Formula/gcc@5.rb index 5c8ba3b375176..783ca1eb8fc16 100644 --- a/Formula/gcc@5.rb +++ b/Formula/gcc@5.rb @@ -75,7 +75,7 @@ def install # C, C++, ObjC and Fortran compilers are always built languages = %w[c c++ fortran objc obj-c++] - version_suffix = version.to_s.slice(/\d/) + version_suffix = version.major.to_s # Even when suffixes are appended, the info pages conflict when # install-info is run so pretend we have an outdated makeinfo @@ -153,7 +153,7 @@ def add_suffix(file, suffix) return 0; } EOS - system bin/"gcc-5", "-o", "hello-c", "hello-c.c" + system bin/"gcc-#{version.major}", "-o", "hello-c", "hello-c.c" assert_equal "Hello, world!\n", `./hello-c` end end From cf177eb6637b81967442974a8716f9d98c38c8df Mon Sep 17 00:00:00 2001 From: Seeker Date: Tue, 11 Aug 2020 13:40:54 -0700 Subject: [PATCH 03/14] gcc@6: use version.major for version suffix --- Formula/gcc@6.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Formula/gcc@6.rb b/Formula/gcc@6.rb index 19288bab1a431..609b8ea2c7150 100644 --- a/Formula/gcc@6.rb +++ b/Formula/gcc@6.rb @@ -44,7 +44,7 @@ def install # C, C++, ObjC, Fortran compilers are always built languages = %w[c c++ objc obj-c++ fortran] - version_suffix = version.to_s.slice(/\d/) + version_suffix = version.major.to_s # Even when suffixes are appended, the info pages conflict when # install-info is run so pretend we have an outdated makeinfo @@ -124,7 +124,7 @@ def add_suffix(file, suffix) return 0; } EOS - system "#{bin}/gcc-6", "-o", "hello-c", "hello-c.c" + system "#{bin}/gcc-#{version.major}", "-o", "hello-c", "hello-c.c" assert_equal "Hello, world!\n", `./hello-c` (testpath/"hello-cc.cc").write <<~EOS @@ -135,7 +135,7 @@ def add_suffix(file, suffix) return 0; } EOS - system "#{bin}/g++-6", "-o", "hello-cc", "hello-cc.cc" + system "#{bin}/g++-#{version.major}", "-o", "hello-cc", "hello-cc.cc" assert_equal "Hello, world!\n", `./hello-cc` fixture = <<~EOS @@ -150,7 +150,7 @@ def add_suffix(file, suffix) end EOS (testpath/"in.f90").write(fixture) - system "#{bin}/gfortran-6", "-o", "test", "in.f90" + system "#{bin}/gfortran-#{version.major}", "-o", "test", "in.f90" assert_equal "done", `./test`.strip end end From ff4e8ee36fd1c76c9eb0954d6b9b720196a95882 Mon Sep 17 00:00:00 2001 From: Seeker Date: Tue, 11 Aug 2020 13:40:54 -0700 Subject: [PATCH 04/14] gcc@7: use version.major for version suffix --- Formula/gcc@7.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Formula/gcc@7.rb b/Formula/gcc@7.rb index a4c035c304d9e..e8c57e4fa9859 100644 --- a/Formula/gcc@7.rb +++ b/Formula/gcc@7.rb @@ -31,7 +31,7 @@ def install # GCC will suffer build errors if forced to use a particular linker. ENV.delete "LD" - version_suffix = version.to_s.slice(/\d/) + version_suffix = version.major.to_s # Even when suffixes are appended, the info pages conflict when # install-info is run so pretend we have an outdated makeinfo @@ -112,7 +112,7 @@ def add_suffix(file, suffix) return 0; } EOS - system "#{bin}/gcc-7", "-o", "hello-c", "hello-c.c" + system "#{bin}/gcc-#{version.major}", "-o", "hello-c", "hello-c.c" assert_equal "Hello, world!\n", `./hello-c` (testpath/"hello-cc.cc").write <<~EOS @@ -123,7 +123,7 @@ def add_suffix(file, suffix) return 0; } EOS - system "#{bin}/g++-7", "-o", "hello-cc", "hello-cc.cc" + system "#{bin}/g++-#{version.major}", "-o", "hello-cc", "hello-cc.cc" assert_equal "Hello, world!\n", `./hello-cc` (testpath/"test.f90").write <<~EOS @@ -137,7 +137,7 @@ def add_suffix(file, suffix) write(*,"(A)") "Done" end EOS - system "#{bin}/gfortran-7", "-o", "test", "test.f90" + system "#{bin}/gfortran-#{version.major}", "-o", "test", "test.f90" assert_equal "Done\n", `./test` end end From 6e36a02341c1f73949cfbe1b8af7490b15cbe670 Mon Sep 17 00:00:00 2001 From: Seeker Date: Tue, 11 Aug 2020 13:40:55 -0700 Subject: [PATCH 05/14] gcc@8: use version.major for version suffix --- Formula/gcc@8.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Formula/gcc@8.rb b/Formula/gcc@8.rb index 9a42c212b5a8f..304e98b5bca42 100644 --- a/Formula/gcc@8.rb +++ b/Formula/gcc@8.rb @@ -31,7 +31,7 @@ def install # GCC will suffer build errors if forced to use a particular linker. ENV.delete "LD" - version_suffix = version.to_s.slice(/\d/) + version_suffix = version.major.to_s # Even when suffixes are appended, the info pages conflict when # install-info is run so pretend we have an outdated makeinfo @@ -115,7 +115,7 @@ def add_suffix(file, suffix) return 0; } EOS - system "#{bin}/gcc-8", "-o", "hello-c", "hello-c.c" + system "#{bin}/gcc-#{version.major}", "-o", "hello-c", "hello-c.c" assert_equal "Hello, world!\n", `./hello-c` (testpath/"hello-cc.cc").write <<~EOS @@ -126,7 +126,7 @@ def add_suffix(file, suffix) return 0; } EOS - system "#{bin}/g++-8", "-o", "hello-cc", "hello-cc.cc" + system "#{bin}/g++-#{version.major}", "-o", "hello-cc", "hello-cc.cc" assert_equal "Hello, world!\n", `./hello-cc` (testpath/"test.f90").write <<~EOS @@ -140,7 +140,7 @@ def add_suffix(file, suffix) write(*,"(A)") "Done" end EOS - system "#{bin}/gfortran-8", "-o", "test", "test.f90" + system "#{bin}/gfortran-#{version.major}", "-o", "test", "test.f90" assert_equal "Done\n", `./test` end end From e08b29bc9ca47707438676e64d26b0f3eaf289c0 Mon Sep 17 00:00:00 2001 From: Seeker Date: Tue, 11 Aug 2020 13:40:55 -0700 Subject: [PATCH 06/14] gcc@9: use version.major for version suffix --- Formula/gcc@9.rb | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/Formula/gcc@9.rb b/Formula/gcc@9.rb index 7df52eb9f6f48..449b08594ad13 100644 --- a/Formula/gcc@9.rb +++ b/Formula/gcc@9.rb @@ -32,6 +32,8 @@ def install # GCC will suffer build errors if forced to use a particular linker. ENV.delete "LD" + version_suffix = version.major.to_s + # Even when suffixes are appended, the info pages conflict when # install-info is run so pretend we have an outdated makeinfo # to prevent their build. @@ -49,11 +51,11 @@ def install args = %W[ --build=x86_64-apple-darwin#{osmajor} --prefix=#{prefix} - --libdir=#{lib}/gcc/9 + --libdir=#{lib}/gcc/#{version_suffix} --disable-nls --enable-checking=release --enable-languages=#{languages.join(",")} - --program-suffix=-9 + --program-suffix=-#{version_suffix} --with-gmp=#{Formula["gmp"].opt_prefix} --with-mpfr=#{Formula["mpfr"].opt_prefix} --with-mpc=#{Formula["libmpc"].opt_prefix} @@ -78,7 +80,7 @@ def install # Ensure correct install names when linking against libgcc_s; # see discussion in https://github.com/Homebrew/legacy-homebrew/pull/34303 - inreplace "libgcc/config/t-slibgcc-darwin", "@shlib_slibdir@", "#{HOMEBREW_PREFIX}/lib/gcc/9" + inreplace "libgcc/config/t-slibgcc-darwin", "@shlib_slibdir@", "#{HOMEBREW_PREFIX}/lib/gcc/#{version_suffix}" mkdir "build" do system "../configure", *args @@ -93,7 +95,7 @@ def install # Handle conflicts between GCC formulae and avoid interfering # with system compilers. # Rename man7. - Dir.glob(man7/"*.7") { |file| add_suffix file, "9" } + Dir.glob(man7/"*.7") { |file| add_suffix file, version_suffix } # Even when we disable building info pages some are still installed. info.rmtree end @@ -114,7 +116,7 @@ def add_suffix(file, suffix) return 0; } EOS - system "#{bin}/gcc-9", "-o", "hello-c", "hello-c.c" + system "#{bin}/gcc-#{version.major}", "-o", "hello-c", "hello-c.c" assert_equal "Hello, world!\n", `./hello-c` (testpath/"hello-cc.cc").write <<~EOS @@ -125,7 +127,7 @@ def add_suffix(file, suffix) return 0; } EOS - system "#{bin}/g++-9", "-o", "hello-cc", "hello-cc.cc" + system "#{bin}/g++-#{version.major}", "-o", "hello-cc", "hello-cc.cc" assert_equal "Hello, world!\n", `./hello-cc` (testpath/"test.f90").write <<~EOS @@ -139,7 +141,7 @@ def add_suffix(file, suffix) write(*,"(A)") "Done" end EOS - system "#{bin}/gfortran-9", "-o", "test", "test.f90" + system "#{bin}/gfortran-#{version.major}", "-o", "test", "test.f90" assert_equal "Done\n", `./test` end end From a270d8e71d42a27a34fe11a68fe162660b86e3da Mon Sep 17 00:00:00 2001 From: Seeker Date: Tue, 11 Aug 2020 13:41:29 -0700 Subject: [PATCH 07/14] gcc: use version.major for version suffix --- Formula/gcc.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Formula/gcc.rb b/Formula/gcc.rb index eded66e98e0ca..d5a70c1a2de5b 100644 --- a/Formula/gcc.rb +++ b/Formula/gcc.rb @@ -34,7 +34,7 @@ def version_suffix if build.head? "HEAD" else - version.to_s.slice(/\d+/) + version.major.to_s end end From 6e67f457543fdff19d4dacfd1d3b7d22a6a8d16a Mon Sep 17 00:00:00 2001 From: Seeker Date: Tue, 11 Aug 2020 13:44:30 -0700 Subject: [PATCH 08/14] augustus: use installed_version.major for gcc version suffix --- Formula/augustus.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Formula/augustus.rb b/Formula/augustus.rb index 17ff46560a94d..cd26d56539a79 100644 --- a/Formula/augustus.rb +++ b/Formula/augustus.rb @@ -40,7 +40,7 @@ def install # to upstream in 2016 (see https://github.com/nextgenusfs/funannotate/issues/3). # See also https://github.com/Gaius-Augustus/Augustus/issues/64 cd "src" do - with_env("HOMEBREW_CC" => Formula["gcc"].opt_bin/"gcc-#{Formula["gcc"].linked_version.to_s.slice(/\d+/)}") do + with_env("HOMEBREW_CC" => Formula["gcc"].opt_bin/"gcc-#{Formula["gcc"].installed_version.major}") do system "make" end end From d36b3c1617d16ea4a908d84962dcb7ce966ac253 Mon Sep 17 00:00:00 2001 From: Seeker Date: Tue, 11 Aug 2020 13:44:30 -0700 Subject: [PATCH 09/14] dynare: use installed_version.major for gcc version suffix --- Formula/dynare.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Formula/dynare.rb b/Formula/dynare.rb index 176d8307a65f4..bcd9b41f2a595 100644 --- a/Formula/dynare.rb +++ b/Formula/dynare.rb @@ -63,7 +63,7 @@ def install "--disable-doc" # Octave hardcodes its paths which causes problems on GCC minor version bumps gcc = Formula["gcc"] - flibs = "-L#{gcc.lib/"gcc"/gcc.version_suffix} -lgfortran -lquadmath -lm" + flibs = "-L#{gcc.lib/"gcc"/gcc.installed_version.major} -lgfortran -lquadmath -lm" system "make", "install", "FLIBS=#{flibs}" end From f8a4b6a50ec9af55be865753c6733ecea956e9f2 Mon Sep 17 00:00:00 2001 From: Seeker Date: Tue, 11 Aug 2020 13:44:30 -0700 Subject: [PATCH 10/14] gromacs: use installed_version.major for gcc version suffix --- Formula/gromacs.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Formula/gromacs.rb b/Formula/gromacs.rb index f0e732f87d89e..f35d5f8a25ae7 100644 --- a/Formula/gromacs.rb +++ b/Formula/gromacs.rb @@ -25,8 +25,8 @@ def install "/usr/bin/ld" args = std_cmake_args + %W[ - -DCMAKE_C_COMPILER=gcc-#{Formula["gcc"].version_suffix} - -DCMAKE_CXX_COMPILER=g++-#{Formula["gcc"].version_suffix} + -DCMAKE_C_COMPILER=gcc-#{Formula["gcc"].installed_version.major} + -DCMAKE_CXX_COMPILER=g++-#{Formula["gcc"].installed_version.major} ] mkdir "build" do From 10af96d1218bc91d35994eb6905c37a2259065a4 Mon Sep 17 00:00:00 2001 From: Seeker Date: Tue, 11 Aug 2020 13:44:30 -0700 Subject: [PATCH 11/14] imake: use installed_version.major for gcc version suffix --- Formula/imake.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Formula/imake.rb b/Formula/imake.rb index 5793cd8049b95..472ea4dfab0ad 100644 --- a/Formula/imake.rb +++ b/Formula/imake.rb @@ -29,7 +29,7 @@ def install ENV.deparallelize # imake runtime is broken when used with clang's cpp - cpp_program = Formula["gcc"].opt_bin/"cpp-#{Formula["gcc"].version_suffix}" + cpp_program = Formula["gcc"].opt_bin/"cpp-#{Formula["gcc"].installed_version.major}" inreplace "imakemdep.h", /::CPPCMD::/, cpp_program inreplace "imake.man", /__cpp__/, cpp_program @@ -52,7 +52,7 @@ def install test do # Use pipe_output because the return code is unimportant here. output = pipe_output("#{bin}/imake -v -s/dev/null -f/dev/null -T/dev/null 2>&1") - gcc_major_ver = Formula["gcc"].version_suffix + gcc_major_ver = Formula["gcc"].installed_version.major assert_match "#{Formula["gcc"].opt_bin}/cpp-#{gcc_major_ver}", output end end From b20710d0daa95fc62afe9967f2adaa9420bafef5 Mon Sep 17 00:00:00 2001 From: Seeker Date: Tue, 11 Aug 2020 13:44:31 -0700 Subject: [PATCH 12/14] kahip: use installed_version.major for gcc version suffix --- Formula/kahip.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Formula/kahip.rb b/Formula/kahip.rb index 3ffe0dc698dc4..df25762926507 100644 --- a/Formula/kahip.rb +++ b/Formula/kahip.rb @@ -17,8 +17,8 @@ class Kahip < Formula depends_on "open-mpi" def install - ENV["CC"] = Formula["gcc"].opt_bin/"gcc-#{Formula["gcc"].version_suffix}" - ENV["CXX"] = Formula["gcc"].opt_bin/"g++-#{Formula["gcc"].version_suffix}" + ENV["CC"] = Formula["gcc"].opt_bin/"gcc-#{Formula["gcc"].installed_version.major}" + ENV["CXX"] = Formula["gcc"].opt_bin/"g++-#{Formula["gcc"].installed_version.major}" mkdir "build" do system "cmake", *std_cmake_args, ".." system "make", "install" From 76872eb1e4f928a671db9d466637a6b401fdc592 Mon Sep 17 00:00:00 2001 From: Seeker Date: Tue, 11 Aug 2020 13:44:31 -0700 Subject: [PATCH 13/14] lcov: use installed_version.major for gcc version suffix --- Formula/lcov.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Formula/lcov.rb b/Formula/lcov.rb index a5955c8206369..1ff45760314d6 100644 --- a/Formula/lcov.rb +++ b/Formula/lcov.rb @@ -55,8 +55,8 @@ def install end test do - gcc = Formula["gcc"].opt_bin/"gcc-#{Formula["gcc"].version_suffix}" - gcov = Formula["gcc"].opt_bin/"gcov-#{Formula["gcc"].version_suffix}" + gcc = Formula["gcc"].opt_bin/"gcc-#{Formula["gcc"].installed_version.major}" + gcov = Formula["gcc"].opt_bin/"gcov-#{Formula["gcc"].installed_version.major}" (testpath/"hello.c").write <<~EOS #include From 39e47899278828fd7064b3507f5ddc8458a8e46b Mon Sep 17 00:00:00 2001 From: Seeker Date: Mon, 17 Aug 2020 11:15:27 -0700 Subject: [PATCH 14/14] pipgrip: use installed_version.major for gcc version suffix --- Formula/pipgrip.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Formula/pipgrip.rb b/Formula/pipgrip.rb index 948bbe16ef7f8..18766bc9c062e 100644 --- a/Formula/pipgrip.rb +++ b/Formula/pipgrip.rb @@ -53,7 +53,7 @@ def install venv.pip_install buildpath gcc_path = Formula["gcc"].opt_bin - gcc_version = Formula["gcc"].version.to_s.split(".").first + gcc_version = Formula["gcc"].installed_version.major (bin/"pipgrip").write_env_script(libexec/"bin/pipgrip", { CC: gcc_path/"gcc-#{gcc_version}", CXX: gcc_path/"g++-#{gcc_version}" }) end