Avoid throwing unnecessary exceptions by checking for paths existing and
creating formulae as late as possible. Additionally use instance
variables for some caching.
Without it, String#undent would fail on unindented strings, e.g.:
"foo".undent
NoMethodError: undefined method `length' for nil:NilClass`
ClosesHomebrew/homebrew#28873.
Signed-off-by: Adam Vandenberg <flangy@gmail.com>
In this case we need to handle the throwing on an exception when
attempting to initialize the gcc48 Formula object.
This initialization should be unnecessary if the core GCC is already
installed and rescued if not.
This code originated in a slightly different form in 8e88b22fd1ec65a344ce6e4facd6dad4b415b2ad:
8e88b22fd1/Library/Homebrew/extend/ENV.rb (L30-L32)
Back then, MacOS.default_compiler could return nil, which meant
ENV.compiler could do the same. This code was carried forward as the
surrounding code changed. At this point it should be unreachable.
On older Apple compilers "-O4" is known to cause build errors. On recent
clang, it's the same as "-O3" and you have to pass "-O3 -flto" to get
the old behavior.
It is activated by the same mechanism as the Homebrew/versions compilers
which now check if the GCC formula uses the same, correct version.
References Homebrew/homebrew#28418.
`MacOS::Xcode.without_clt? && MacOS.sdk_path.nil?` should never be true.
In its earliest form, this would raise a bare RuntimeError in an effort
to have the bug reported. Later, it was changed to silently disable
superenv. But we don't want to do that. If there's a bug, or the user's
system is misconfigured, we want to know, so that we can fix the bug, or
the user can fix their system. So let's remove the condition.
Symlinks in opt and LinkedKegs point directly at a keg in the cellar, so
only resolving one symlink should suffice, and make it clear what path
we are actually interested in.