-
Notifications
You must be signed in to change notification settings - Fork 18k
cmd/go: go build -msan passes invalid option to GCC #25175
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
Comments
We should not ignore the What is your suggested fix? Although current versions of GCC does not support |
I'm not quite sure what a good solution is here. It's indeed possible that in newer releases these features will be supported. Do GCC/clang have any facilities that would allow to check whether a specific option is supported for an argument? So far all I've been able to get is Alternatively, is there a way we can wrap the error in this case with some more context? I don't think pattern matching on the error itself would be a very stable solution, but given that we know |
@daenney, we do probe for a working sanitizer in some of the cgo tests today, but the check is somewhat involved and also adds latency to the test. (Also consider that it's possible for the compiler to accept go/misc/cgo/testsanitizers/cc_test.go Lines 315 to 353 in 7f6105f
|
Mmm, I suppose something along those lines would work, though if it slows things down by much that might be annoying. Though I'm not exactly clear on how the check on the error message there would have much of a perf impact/slow things down?
That's true, but I wouldn't expect that to throw the error this bug is about. That seems like a fairly esoteric condition to me, though I suppose anything is possible. I'm also fine with leaving it as is. In theory this bug report would probably surface now if someone entered the specified error in a search engine paired with the go/golang keyword, hopefully providing the necessary context and workaround. I was hoping there was an easy way to improve the reporting around that error. It's not a very common flag to pass, in this case I was just attempting to debug a potentially cgo related issue which is hopefully not a common activity in gopher's daily lives. |
Since nobody has gotten to it since 1.10.1, I suspect that no one will in the near future; closing. |
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (
go env
)?Linux, amd64
What did you do?
go build -msan
What did you expect to see?
One of:
-msan
does not work with GCC (because GCC doesn't support-fsanitize=memory
)What did you see instead?
Though
go env
correctly detectedCC=gcc
andCXX=g++
it seemsgo build
indiscriminately passes-fsantize=memory
to the C compiler when callinggo build
with-msan
. This should not be the case, as-fsanitize=memory
is only available when using clang. Instead it should warn the invoker ofgo build
about this with a friendly error message whengo env CC
isgcc
.The simple fix in this case was to
env CC=clang env CXX=clang++ go build -msan
.MemorySaniziter is only supported on Linux with amd64, arm64 and mips64 according to the LLVM documentation, which might be worth checking for too (at least
GOOS=linux
seems like a pretty safe check)The text was updated successfully, but these errors were encountered: