{"action":"created","issue":{"url":"https://api.github.com/repos/golang/go/issues/25175","repository_url":"https://api.github.com/repos/golang/go","labels_url":"https://api.github.com/repos/golang/go/issues/25175/labels{/name}","comments_url":"https://api.github.com/repos/golang/go/issues/25175/comments","events_url":"https://api.github.com/repos/golang/go/issues/25175/events","html_url":"https://github.com/golang/go/issues/25175","id":318809730,"number":25175,"title":"cmd/go: go build -msan passes invalid option to GCC","user":{"login":"daenney","id":569574,"avatar_url":"https://avatars1.githubusercontent.com/u/569574?v=4","gravatar_id":"","url":"https://api.github.com/users/daenney","html_url":"https://github.com/daenney","followers_url":"https://api.github.com/users/daenney/followers","following_url":"https://api.github.com/users/daenney/following{/other_user}","gists_url":"https://api.github.com/users/daenney/gists{/gist_id}","starred_url":"https://api.github.com/users/daenney/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/daenney/subscriptions","organizations_url":"https://api.github.com/users/daenney/orgs","repos_url":"https://api.github.com/users/daenney/repos","events_url":"https://api.github.com/users/daenney/events{/privacy}","received_events_url":"https://api.github.com/users/daenney/received_events","type":"User","site_admin":false},"labels":[{"id":373399998,"url":"https://api.github.com/repos/golang/go/labels/NeedsFix","name":"NeedsFix","color":"ededed","default":false},{"id":150880243,"url":"https://api.github.com/repos/golang/go/labels/help%20wanted","name":"help wanted","color":"fbca04","default":true}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":{"url":"https://api.github.com/repos/golang/go/milestones/6","html_url":"https://github.com/golang/go/milestone/6","labels_url":"https://api.github.com/repos/golang/go/milestones/6/labels","id":1055141,"number":6,"title":"Unplanned","description":"No plan to fix in any specific release.\r\n","creator":{"login":"rsc","id":104030,"avatar_url":"https://avatars1.githubusercontent.com/u/104030?v=4","gravatar_id":"","url":"https://api.github.com/users/rsc","html_url":"https://github.com/rsc","followers_url":"https://api.github.com/users/rsc/followers","following_url":"https://api.github.com/users/rsc/following{/other_user}","gists_url":"https://api.github.com/users/rsc/gists{/gist_id}","starred_url":"https://api.github.com/users/rsc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rsc/subscriptions","organizations_url":"https://api.github.com/users/rsc/orgs","repos_url":"https://api.github.com/users/rsc/repos","events_url":"https://api.github.com/users/rsc/events{/privacy}","received_events_url":"https://api.github.com/users/rsc/received_events","type":"User","site_admin":false},"open_issues":1292,"closed_issues":1037,"state":"open","created_at":"2015-04-06T20:47:19Z","updated_at":"2018-05-01T14:51:11Z","due_on":"2099-12-31T08:00:00Z","closed_at":null},"comments":3,"created_at":"2018-04-30T07:50:14Z","updated_at":"2018-05-01T15:04:49Z","closed_at":null,"author_association":"NONE","body":" ### What version of Go are you using (`go version`)?\r\n- 1.9.5\r\n- 1.10.1\r\n\r\n### Does this issue reproduce with the latest release?\r\nYes\r\n\r\n### What operating system and processor architecture are you using (`go env`)?\r\nLinux, amd64\r\n\r\n```\r\nGOARCH=\"amd64\"\r\nGOHOSTARCH=\"amd64\"\r\nGOHOSTOS=\"linux\"\r\nGOOS=\"linux\"\r\n```\r\n\r\n### What did you do?\r\n- Cloned a project that uses CGO, prometheus/node_exporter\r\n- Attempted to build with `go build -msan`\r\n\r\n### What did you expect to see?\r\nOne of:\r\n- The build proceeding as normal\r\n- The build outputting a user friendly error message notifying that `-msan` does not work with GCC (because GCC doesn't support `-fsanitize=memory`)\r\n\r\n\r\n### What did you see instead?\r\n```\r\n# runtime/cgo\r\ngcc: error: unrecognized argument to -fsanitize= option: 'memory'\r\n```\r\n\r\nThough `go env` correctly detected `CC=gcc` and `CXX=g++` it seems `go build` indiscriminately passes `-fsantize=memory` to the C compiler when calling `go build` with `-msan`. This should not be the case, as `-fsanitize=memory` is only available when using clang. Instead it should warn the invoker of `go build` about this with a friendly error message when `go env CC` is `gcc`.\r\n\r\nThe simple fix in this case was to `env CC=clang env CXX=clang++ go build -msan`.\r\n\r\n```\r\n$ gcc --version\r\ngcc (GCC) 7.3.1 20180406\r\nCopyright (C) 2017 Free Software Foundation, Inc.\r\nThis is free software; see the source for copying conditions.  There is NO\r\nwarranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\r\n\r\n$ clang --version\r\nclang version 6.0.0 (tags/RELEASE_600/final)\r\nTarget: x86_64-pc-linux-gnu\r\nThread model: posix\r\nInstalledDir: /usr/bin\r\n```\r\n\r\nMemorySaniziter 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)"},"comment":{"url":"https://api.github.com/repos/golang/go/issues/comments/385693753","html_url":"https://github.com/golang/go/issues/25175#issuecomment-385693753","issue_url":"https://api.github.com/repos/golang/go/issues/25175","id":385693753,"user":{"login":"bcmills","id":5200974,"avatar_url":"https://avatars3.githubusercontent.com/u/5200974?v=4","gravatar_id":"","url":"https://api.github.com/users/bcmills","html_url":"https://github.com/bcmills","followers_url":"https://api.github.com/users/bcmills/followers","following_url":"https://api.github.com/users/bcmills/following{/other_user}","gists_url":"https://api.github.com/users/bcmills/gists{/gist_id}","starred_url":"https://api.github.com/users/bcmills/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bcmills/subscriptions","organizations_url":"https://api.github.com/users/bcmills/orgs","repos_url":"https://api.github.com/users/bcmills/repos","events_url":"https://api.github.com/users/bcmills/events{/privacy}","received_events_url":"https://api.github.com/users/bcmills/received_events","type":"User","site_admin":false},"created_at":"2018-05-01T15:04:49Z","updated_at":"2018-05-01T15:04:49Z","author_association":"MEMBER","body":"@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 `-fsanitize=memory` but fail to produce a working binary anyway, particularly if the result is linked against a different `libc`.)\r\n\r\nhttps://github.com/golang/go/blob/7f6105f138b3836e9ad85b8da26d44c742bf217b/misc/cgo/testsanitizers/cc_test.go#L315-L353"}}
{"actor":{"display_login":"bcmills"}}