Closed SMillerDev closed 1 year ago
The C optimisations we do for normal compilation not to apply to Go.
I don't agree with this? It seems reasonable and desirable for these to apply to CGo.
I don't agree with this? It seems reasonable and desirable for these to apply to CGo.
It seems from https://github.com/golang/go/issues/14669 that Go can't deal with optimisations.
It seems from golang/go#14669 that Go can't deal with optimisations.
Is this the case in literally every formula we have that uses CGo or just this one/a few?
It seems to only affect four formulae.
This happens when Go calls the function gccErrors
, which runs the C compiler and returns the errors from stderr
.
// gccErrors runs gcc over the C program stdin and returns
// the errors that gcc prints. That is, this function expects
// gcc to fail.
func (p *Package) gccErrors(stdin []byte, extraArgs ...string) string {
Passing anything other than -O0
can break parsing of the error messages, which is why Go filters out the -O
flags and then passes -O0
towards the end of the command.
Our compiler shim undoes what Go is doing here, and that seems to cause problems for some formulae. It's fixed when we set ENV.O0
, but that just ends up adding -O0
to every invocation of the compiler, rather than only in the instances where it is needed (i.e. when the compiler is invoked by gccErrors
).
Cool, thanks @carlocab. Yeh, that feels like it's worth a fix in the shim for. I don't think we should unconditionally disable the shim for all Go or CGo formula.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.
I was looking at this, and I don't think there's a way to fix this (i.e. pass -O0
if and only if the compiler is called by gccErrors
) without patching go
.
Thanks for checking this out @carlocab. How about we just use ENV.O0
or similar in def install
for this?
That's what we're already doing for some formulae, because we see build failures for those formulae. I guess the concern is that we might be silently miscompiling others we don't currently use ENV.O0
on. But I have no idea how likely this is -- I don't really use Go so I know very little about how the Go compiler works. Maybe @Bo98, @alebcay, or @issyl0 would know more?
If we don't want to patch Go, an alternative is to get rid of all -O
flag refurbishment/injection specifically when go
is the one calling the C compiler (perhaps implemented via a go
shim). That'll expose more of the refurbishment process to being interfered with by upstream build scripts, though. (Here's an example.)
I guess the concern is that we might be silently miscompiling others we don't currently use
ENV.O0
on.
I feel like we'd be getting issues if this were the case?
If we don't want to patch Go, an alternative is to get rid of all
-O
flag refurbishment/injection specifically whengo
is the one calling the C compiler (perhaps implemented via ago
shim).
This feels overkill to me given we can just selectively use ENV.O0
when needed?
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.
brew doctor
outputVerification
brew doctor
output" above saysYour system is ready to brew.
and am still able to reproduce my issue.brew update
twice and am still able to reproduce my issue.brew install wget
. If they do, open an issue at https://github.com/Homebrew/homebrew-core/issues/new/choose instead.brew config
outputWhat were you trying to do (and why)?
Build ethereum in https://github.com/Homebrew/homebrew-core/pull/123337
What happened (include all command output)?
Build failed without explicitly setting
ENV.O0
What did you expect to happen?
The C optimisations we do for normal compilation not to apply to Go.
Step-by-step reproduction instructions (by running
brew
commands)