Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use version.major for GCC version suffix #59485

Merged
merged 14 commits into from
Aug 21, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Formula/augustus.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

irb(main):003:0> gcc.linked_version.to_s.slice(/\d+/)
=> "10"
irb(main):004:0> gcc.installed_version.major
=> #<Version::NumericToken 10>

system "make"
end
end
Expand Down
2 changes: 1 addition & 1 deletion Formula/dynare.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

irb(main):006:0> gcc.version_suffix
=> "10"
irb(main):007:0> gcc.installed_version.major
=> #<Version::NumericToken 10>

system "make", "install", "FLIBS=#{flibs}"
end

Expand Down
2 changes: 1 addition & 1 deletion Formula/gcc.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def version_suffix
if build.head?
"HEAD"
else
version.to_s.slice(/\d+/)
version.major.to_s
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

irb(main):009:0> gcc.version.to_s.slice(/\d+/)
=> "10"
irb(main):010:0> gcc.version.major.to_s
=> "10"

end
end

Expand Down
4 changes: 2 additions & 2 deletions Formula/gcc@4.9.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

irb(main):012:0> Formula["gcc@4.9"].version.to_s.slice(/\d\.\d/)
=> "4.9"
irb(main):013:0> Formula["gcc@4.9"].version.major_minor.to_s
=> "4.9"
irb(main):014:0> Formula["gcc@4.9"].version.major_minor
=> #<Version:0x00007fde991012b8 @version="4.9">


args = [
"--build=x86_64-apple-darwin#{osmajor}",
Expand Down Expand Up @@ -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
4 changes: 2 additions & 2 deletions Formula/gcc@5.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

irb(main):016:0> Formula["gcc@5"].version.to_s.slice(/\d/)
=> "5"
irb(main):017:0> Formula["gcc@5"].version.major.to_s
=> "5"
irb(main):018:0> Formula["gcc@5"].version.major
=> #<Version::NumericToken 5>


# Even when suffixes are appended, the info pages conflict when
# install-info is run so pretend we have an outdated makeinfo
Expand Down Expand Up @@ -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
8 changes: 4 additions & 4 deletions Formula/gcc@6.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

irb(main):020:0> Formula["gcc@6"].version.to_s.slice(/\d/)
=> "6"
irb(main):021:0> Formula["gcc@6"].version.major.to_s
=> "6"
irb(main):022:0> Formula["gcc@6"].version.major
=> #<Version::NumericToken 6>


# Even when suffixes are appended, the info pages conflict when
# install-info is run so pretend we have an outdated makeinfo
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
8 changes: 4 additions & 4 deletions Formula/gcc@7.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

irb(main):024:0> Formula["gcc@7"].version.to_s.slice(/\d/)
=> "7"
irb(main):025:0> Formula["gcc@7"].version.major.to_s
=> "7"
irb(main):026:0> Formula["gcc@7"].version.major
=> #<Version::NumericToken 7>


# Even when suffixes are appended, the info pages conflict when
# install-info is run so pretend we have an outdated makeinfo
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
8 changes: 4 additions & 4 deletions Formula/gcc@8.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

irb(main):028:0> Formula["gcc@8"].version.to_s.slice(/\d/)
=> "8"
irb(main):029:0> Formula["gcc@8"].version.major.to_s
=> "8"
irb(main):030:0> Formula["gcc@8"].version.major
=> #<Version::NumericToken 8>


# Even when suffixes are appended, the info pages conflict when
# install-info is run so pretend we have an outdated makeinfo
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
16 changes: 9 additions & 7 deletions Formula/gcc@9.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

irb(main):032:0> Formula["gcc@9"].version.major.to_s
=> "9"
irb(main):033:0> Formula["gcc@9"].version.major
=> #<Version::NumericToken 9>


# 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.
Expand All @@ -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}
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
4 changes: 2 additions & 2 deletions Formula/gromacs.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

irb(main):006:0> gcc.version_suffix
=> "10"
irb(main):007:0> gcc.installed_version.major
=> #<Version::NumericToken 10>

]

mkdir "build" do
Expand Down
4 changes: 2 additions & 2 deletions Formula/imake.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

irb(main):006:0> gcc.version_suffix
=> "10"
irb(main):007:0> gcc.installed_version.major
=> #<Version::NumericToken 10>

assert_match "#{Formula["gcc"].opt_bin}/cpp-#{gcc_major_ver}", output
end
end
4 changes: 2 additions & 2 deletions Formula/kahip.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

irb(main):006:0> gcc.version_suffix
=> "10"
irb(main):007:0> gcc.installed_version.major
=> #<Version::NumericToken 10>

mkdir "build" do
system "cmake", *std_cmake_args, ".."
system "make", "install"
Expand Down
4 changes: 2 additions & 2 deletions Formula/lcov.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

irb(main):006:0> gcc.version_suffix
=> "10"
irb(main):007:0> gcc.installed_version.major
=> #<Version::NumericToken 10>


(testpath/"hello.c").write <<~EOS
#include <stdio.h>
Expand Down
2 changes: 1 addition & 1 deletion Formula/pipgrip.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

irb(main):034:0> gcc.version.to_s.split(".").first
=> "10"
irb(main):035:0> gcc.installed_version.major
=> #<Version::NumericToken 10>

(bin/"pipgrip").write_env_script(libexec/"bin/pipgrip",
{ CC: gcc_path/"gcc-#{gcc_version}", CXX: gcc_path/"g++-#{gcc_version}" })
end
Expand Down