extend/ENV/std: ignore fails_with during brew test.

The compiler used to a build a formula is typically not needed during
the test.

This will allow us to get rid of some `:test` dependencies, which were
added to prevent `brew` from throwing a `CompilerSelectionError` because
the formula declares `fails_with` the default compiler.

This also helps us get more accurate results from `brew linkage` in
cases of unintended linkage with the compiler used to build.

Fixes #11795.
This commit is contained in:
Carlo Cabrera 2022-09-21 22:45:19 +08:00
parent 5b02645210
commit e9bcab6986
No known key found for this signature in database
GPG Key ID: C74D447FC549A1D0

View File

@ -57,7 +57,14 @@ module Stdenv
# Os is the default Apple uses for all its stuff so let's trust them # Os is the default Apple uses for all its stuff so let's trust them
define_cflags "-Os #{SAFE_CFLAGS_FLAGS}" define_cflags "-Os #{SAFE_CFLAGS_FLAGS}"
begin
send(compiler) send(compiler)
rescue CompilerSelectionError => e
# We don't care if our compiler fails to build the formula during `brew test`.
raise e unless testing_formula
send(DevelopmentTools.default_compiler)
end
return unless cc&.match?(GNU_GCC_REGEXP) return unless cc&.match?(GNU_GCC_REGEXP)