{"action":"created","issue":{"url":"https://api.github.com/repos/bazelbuild/bazel/issues/5090","repository_url":"https://api.github.com/repos/bazelbuild/bazel","labels_url":"https://api.github.com/repos/bazelbuild/bazel/issues/5090/labels{/name}","comments_url":"https://api.github.com/repos/bazelbuild/bazel/issues/5090/comments","events_url":"https://api.github.com/repos/bazelbuild/bazel/issues/5090/events","html_url":"https://github.com/bazelbuild/bazel/issues/5090","id":317423550,"number":5090,"title":"bazel uses invalid options when building with gcc on OS X","user":{"login":"rnburn","id":1923871,"avatar_url":"https://avatars3.githubusercontent.com/u/1923871?v=4","gravatar_id":"","url":"https://api.github.com/users/rnburn","html_url":"https://github.com/rnburn","followers_url":"https://api.github.com/users/rnburn/followers","following_url":"https://api.github.com/users/rnburn/following{/other_user}","gists_url":"https://api.github.com/users/rnburn/gists{/gist_id}","starred_url":"https://api.github.com/users/rnburn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rnburn/subscriptions","organizations_url":"https://api.github.com/users/rnburn/orgs","repos_url":"https://api.github.com/users/rnburn/repos","events_url":"https://api.github.com/users/rnburn/events{/privacy}","received_events_url":"https://api.github.com/users/rnburn/received_events","type":"User","site_admin":false},"labels":[{"id":192364170,"url":"https://api.github.com/repos/bazelbuild/bazel/labels/P2","name":"P2","color":"e99695","default":false},{"id":392619826,"url":"https://api.github.com/repos/bazelbuild/bazel/labels/category:%20rules%20%3E%20C++","name":"category: rules > C++","color":"d4c5f9","default":false},{"id":106503259,"url":"https://api.github.com/repos/bazelbuild/bazel/labels/type:%20bug","name":"type: bug","color":"0052cc","default":false}],"state":"open","locked":false,"assignee":{"login":"mhlopko","id":814566,"avatar_url":"https://avatars0.githubusercontent.com/u/814566?v=4","gravatar_id":"","url":"https://api.github.com/users/mhlopko","html_url":"https://github.com/mhlopko","followers_url":"https://api.github.com/users/mhlopko/followers","following_url":"https://api.github.com/users/mhlopko/following{/other_user}","gists_url":"https://api.github.com/users/mhlopko/gists{/gist_id}","starred_url":"https://api.github.com/users/mhlopko/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mhlopko/subscriptions","organizations_url":"https://api.github.com/users/mhlopko/orgs","repos_url":"https://api.github.com/users/mhlopko/repos","events_url":"https://api.github.com/users/mhlopko/events{/privacy}","received_events_url":"https://api.github.com/users/mhlopko/received_events","type":"User","site_admin":false},"assignees":[{"login":"mhlopko","id":814566,"avatar_url":"https://avatars0.githubusercontent.com/u/814566?v=4","gravatar_id":"","url":"https://api.github.com/users/mhlopko","html_url":"https://github.com/mhlopko","followers_url":"https://api.github.com/users/mhlopko/followers","following_url":"https://api.github.com/users/mhlopko/following{/other_user}","gists_url":"https://api.github.com/users/mhlopko/gists{/gist_id}","starred_url":"https://api.github.com/users/mhlopko/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mhlopko/subscriptions","organizations_url":"https://api.github.com/users/mhlopko/orgs","repos_url":"https://api.github.com/users/mhlopko/repos","events_url":"https://api.github.com/users/mhlopko/events{/privacy}","received_events_url":"https://api.github.com/users/mhlopko/received_events","type":"User","site_admin":false}],"milestone":null,"comments":4,"created_at":"2018-04-24T22:56:04Z","updated_at":"2018-04-29T02:05:10Z","closed_at":null,"author_association":"NONE","body":"> ATTENTION! Please read and follow:\r\n> - if this is a _question_ about how to build / test / query / deploy using Bazel, ask it on StackOverflow instead: https://stackoverflow.com/questions/tagged/bazel\r\n> - if this is a _discussion starter_, send it to bazel-discuss@googlegroups.com\r\n> - if this is a _bug_ or _feature request_, fill the form below as best as you can.\r\n\r\n### Description of the problem / feature request:\r\n\r\nIf you instruct bazel to build with gcc instead of clang on OSX, it uses incorrect options and fails.\r\n\r\n\r\n\r\n### Feature requests: what underlying problem are you trying to solve with this feature?\r\n\r\nBuilding with gcc on OSX.\r\n\r\n### Bugs: what's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.\r\n\r\nDo the following:\r\n\r\n```\r\n<install gcc>\r\ntouch WORKSPACE\r\necho \"int main() {return 0;}\" > main.cpp\r\necho \"cc_binary(name='t', srcs=['main.cpp'])\" > BUILD\r\nBAZEL_USE_CPP_ONLY_TOOLCHAIN=1 bazel build -s --action_env CC=/usr/local/bin/g++-7 //...\r\n```\r\nthis gives the error\r\n```\r\nRyans-MacBook-Pro:bug ryanburn$ BAZEL_USE_CPP_ONLY_TOOLCHAIN=1 bazel build -s --action_env CC=/usr/local/bin/g++-7 //...\r\nINFO: Analysed target //:t (6 packages loaded).\r\nINFO: Found 1 target...\r\nSUBCOMMAND: # //:t [action 'Compiling main.cpp']\r\n(cd /private/var/tmp/_bazel_ryanburn/21d27257ba2b6523f4d7bef0fbb4c292/execroot/__main__ && \\\r\n  exec env - \\\r\n    CC=/usr/local/bin/g++-7 \\\r\n    PATH=/opt/google-cloud-sdk/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/TeX/texbin:/Users/ryanburn/bin:/usr/local/opt/gettext/bin \\\r\n    PWD=/proc/self/cwd \\\r\n  external/local_config_cc/cc_wrapper.sh -U_FORTIFY_SOURCE -fstack-protector -Wall -Wthread-safety -Wself-assign -Wunused-but-set-parameter -Wno-free-nonheap-object -fno-omit-frame-pointer '-std=c++0x' -MD -MF bazel-out/darwin-fastbuild/bin/_objs/t/main.pic.d '-frandom-seed=bazel-out/darwin-fastbuild/bin/_objs/t/main.pic.o' -fPIC -iquote . -iquote bazel-out/darwin-fastbuild/genfiles -iquote external/bazel_tools -iquote bazel-out/darwin-fastbuild/genfiles/external/bazel_tools -fno-canonical-system-headers -Wno-builtin-macro-redefined '-D__DATE__=\"redacted\"' '-D__TIMESTAMP__=\"redacted\"' '-D__TIME__=\"redacted\"' -c main.cpp -o bazel-out/darwin-fastbuild/bin/_objs/t/main.pic.o)\r\nSUBCOMMAND: # //:t [action 'Creating runfiles tree bazel-out/darwin-fastbuild/bin/t.runfiles']\r\n(cd /private/var/tmp/_bazel_ryanburn/21d27257ba2b6523f4d7bef0fbb4c292/execroot/__main__ && \\\r\n  exec env - \\\r\n    CC=/usr/local/bin/g++-7 \\\r\n    PATH=/opt/google-cloud-sdk/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/TeX/texbin:/Users/ryanburn/bin:/usr/local/opt/gettext/bin \\\r\n  _bin/build-runfiles bazel-out/darwin-fastbuild/bin/t.runfiles_manifest bazel-out/darwin-fastbuild/bin/t.runfiles)\r\nERROR: /private/tmp/bug/BUILD:1:1: C++ compilation of rule '//:t' failed (Exit 1)\r\ng++-7: error: unrecognized command line option '-Wthread-safety'; did you mean '-fthread-jumps'?\r\ng++-7: error: unrecognized command line option '-Wself-assign'; did you mean '-Wcast-align'?\r\nTarget //:t failed to build\r\nUse --verbose_failures to see the command lines of failed build steps.\r\nINFO: Elapsed time: 7.710s, Critical Path: 0.07s\r\nFAILED: Build did NOT complete successfully\r\n```\r\n\r\n### What operating system are you running Bazel on?\r\n\r\nOSX\r\n\r\n### What's the output of `bazel info release`?\r\n\r\nrelease 0.12.0-homebrew\r\n\r\n### If `bazel info release` returns \"development version\" or \"(@non-git)\", tell us how you built Bazel.\r\n\r\n> Replace this line with your answer.\r\n\r\n### What's the output of `git remote get-url origin ; git rev-parse master ; git rev-parse HEAD` ?\r\n\r\n> Replace this line with your answer.\r\n\r\n###  Have you found anything relevant by searching the web?\r\n\r\nhttps://stackoverflow.com/questions/47624689/how-to-set-c-compiler-on-os-x-with-bazel\r\n\r\n### Any other information, logs, or outputs that you want to share?\r\n\r\n> Replace these lines with your answer.\r\n>\r\n> If the files are large, upload as attachment or provide link.\r\n"},"comment":{"url":"https://api.github.com/repos/bazelbuild/bazel/issues/comments/385219799","html_url":"https://github.com/bazelbuild/bazel/issues/5090#issuecomment-385219799","issue_url":"https://api.github.com/repos/bazelbuild/bazel/issues/5090","id":385219799,"user":{"login":"rnburn","id":1923871,"avatar_url":"https://avatars3.githubusercontent.com/u/1923871?v=4","gravatar_id":"","url":"https://api.github.com/users/rnburn","html_url":"https://github.com/rnburn","followers_url":"https://api.github.com/users/rnburn/followers","following_url":"https://api.github.com/users/rnburn/following{/other_user}","gists_url":"https://api.github.com/users/rnburn/gists{/gist_id}","starred_url":"https://api.github.com/users/rnburn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rnburn/subscriptions","organizations_url":"https://api.github.com/users/rnburn/orgs","repos_url":"https://api.github.com/users/rnburn/repos","events_url":"https://api.github.com/users/rnburn/events{/privacy}","received_events_url":"https://api.github.com/users/rnburn/received_events","type":"User","site_admin":false},"created_at":"2018-04-29T02:05:10Z","updated_at":"2018-04-29T02:05:10Z","author_association":"NONE","body":"I think there may be a few other places where clang-specific options are applied. I was able to compile a simple test after writing this wrapper script:\r\n```python\r\n#!/usr/bin/python\r\n\r\nimport os\r\nimport sys\r\n\r\ndrop_args = [\r\n      \"-Wthread-safety\",\r\n      \"-Wself-assign\",\r\n      \"-Wl,-no-as-needed\",\r\n      \"-Wl,-z,relro,-z,now\",\r\n]\r\n\r\ndef main():\r\n  compiler = \"/usr/local/bin/g++-7\"\r\n  argv = []\r\n  for arg in sys.argv[1:]:\r\n      if not arg in drop_args:\r\n          argv.append(arg)\r\n  os.execv(compiler, [compiler] + argv)\r\n\r\nif __name__ == \"__main__\":\r\n  main()\r\n\r\n```"}}
{"actor":{"display_login":"rnburn"}}