{"action":"closed","issue":{"url":"https://api.github.com/repos/bazelbuild/bazel/issues/402","labels_url":"https://api.github.com/repos/bazelbuild/bazel/issues/402/labels{/name}","comments_url":"https://api.github.com/repos/bazelbuild/bazel/issues/402/comments","events_url":"https://api.github.com/repos/bazelbuild/bazel/issues/402/events","html_url":"https://github.com/bazelbuild/bazel/issues/402","id":103889475,"number":402,"title":"Problem with compiling Bazel with C++ in non-standard directory","user":{"login":"daiwei89","id":1715658,"avatar_url":"https://avatars.githubusercontent.com/u/1715658?v=3","gravatar_id":"","url":"https://api.github.com/users/daiwei89","html_url":"https://github.com/daiwei89","followers_url":"https://api.github.com/users/daiwei89/followers","following_url":"https://api.github.com/users/daiwei89/following{/other_user}","gists_url":"https://api.github.com/users/daiwei89/gists{/gist_id}","starred_url":"https://api.github.com/users/daiwei89/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/daiwei89/subscriptions","organizations_url":"https://api.github.com/users/daiwei89/orgs","repos_url":"https://api.github.com/users/daiwei89/repos","events_url":"https://api.github.com/users/daiwei89/events{/privacy}","received_events_url":"https://api.github.com/users/daiwei89/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/bazelbuild/bazel/labels/help%20wanted","name":"help wanted","color":"159818"}],"state":"closed","locked":false,"assignee":{"login":"damienmg","id":3721087,"avatar_url":"https://avatars.githubusercontent.com/u/3721087?v=3","gravatar_id":"","url":"https://api.github.com/users/damienmg","html_url":"https://github.com/damienmg","followers_url":"https://api.github.com/users/damienmg/followers","following_url":"https://api.github.com/users/damienmg/following{/other_user}","gists_url":"https://api.github.com/users/damienmg/gists{/gist_id}","starred_url":"https://api.github.com/users/damienmg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/damienmg/subscriptions","organizations_url":"https://api.github.com/users/damienmg/orgs","repos_url":"https://api.github.com/users/damienmg/repos","events_url":"https://api.github.com/users/damienmg/events{/privacy}","received_events_url":"https://api.github.com/users/damienmg/received_events","type":"User","site_admin":false},"milestone":null,"comments":3,"created_at":"2015-08-29T23:39:02Z","updated_at":"2015-09-22T11:29:47Z","closed_at":"2015-09-22T11:29:47Z","body":"I'm on CentOS 6.3 with gcc 4.9.2 installed under `/opt/gcc/4.9.2` instead of the default `/usr/local/bin`. I played around with `tools/cpp/CROSSTOOL` but it seems that it's not recognizing C++11 syntax, and thus might be using g++ 4.4 in the default path. The error I got is below:\r\n\r\n```\r\nINFO: From Compiling src/main/tools/process-tools.c:\r\ncc1plus: warning: command line option '-std=c99' is valid for C/ObjC but not for C++\r\nsrc/main/tools/process-tools.c:15:0: warning: \"_GNU_SOURCE\" redefined\r\n #define _GNU_SOURCE\r\n ^\r\n<command-line>:0:0: note: this is the location of the previous definition\r\nsrc/main/tools/process-tools.c: In function 'void HandleSignal(int, void (*)(int))':\r\nsrc/main/tools/process-tools.c:86:26: error: expected primary-expression before '.' token\r\n   struct sigaction sa = {.sa_handler = handler};\r\n                          ^\r\nsrc/main/tools/process-tools.c: In function 'void ClearSignalMask()':\r\nsrc/main/tools/process-tools.c:104:28: error: expected primary-expression before '.' token\r\n     struct sigaction sa = {.sa_handler = SIG_DFL};\r\n                            ^\r\nsrc/main/tools/process-tools.c: In function 'void SetTimeout(double)':\r\nsrc/main/tools/process-tools.c:120:29: error: expected primary-expression before '.' token\r\n   struct itimerval timer = {.it_interval.tv_sec = 0,\r\n                             ^\r\nsrc/main/tools/process-tools.c:121:29: error: expected primary-expression before '.' token\r\n                             .it_interval.tv_usec = 0,\r\n                             ^\r\nsrc/main/tools/process-tools.c:122:29: error: expected primary-expression before '.' token\r\n                             .it_value.tv_sec = (long)int_val,\r\n                             ^\r\nsrc/main/tools/process-tools.c:123:29: error: expected primary-expression before '.' token\r\n                             .it_value.tv_usec = (long)(fraction_val * 1e6)};\r\n                             ^\r\nERROR: /home/wdai/mldb/third_party/central/bazel/src/main/tools/BUILD:3:1: C++ compilation of rule '//src/main/tools:process-tools' failed: g++ failed: error executing \r\ncommand /opt/gcc/4.9.2/bin/g++ -U_FORTIFY_SOURCE '-D_FORTIFY_SOURCE=1' -fstack-protector -fPIE -Wall -Wunused-but-set-parameter -Wno-free-nonheap-object -fno-omit-frame\r\n-pointer -iquote . -iquote ... (remaining 18 argument(s) skipped): com.google.devtools.build.lib.shell.BadExitStatusException: Process exited with status 1.\r\nTarget //src:bazel failed to build\r\nUse --verbose_failures to see the command lines of failed build steps.\r\n```\r\n\r\nBelow is where I've changed `tools/cpp/CROSSTOOL`. I'm certain that the change is picked up by Bazel as the error msg changes with it, but I'm stuck at the error msg above.\r\n\r\n```\r\ntoolchain {\r\n  abi_version: \"local\"\r\n  abi_libc_version: \"local\"\r\n  builtin_sysroot: \"\"\r\n  compiler: \"compiler\"\r\n  host_system_name: \"local\"\r\n  needsPic: true\r\n  supports_gold_linker: false\r\n  supports_incremental_linker: false\r\n  supports_fission: false\r\n  supports_interface_shared_objects: false\r\n  supports_normalizing_ar: false\r\n  supports_start_end_lib: false\r\n  supports_thin_archives: false\r\n  target_libc: \"local\"\r\n  target_cpu: \"local\"\r\n  target_system_name: \"local\"\r\n  toolchain_identifier: \"local_linux\"\r\n\r\n  tool_path { name: \"ar\" path: \"/usr/bin/ar\" }\r\n  tool_path { name: \"compat-ld\" path: \"/usr/bin/ld\" }\r\n  tool_path { name: \"cpp\" path: \"/opt/gcc/4.9.2/bin/g++\" }\r\n  tool_path { name: \"dwp\" path: \"/usr/bin/dwp\" }\r\n  tool_path { name: \"gcc\" path: \"/opt/gcc/4.9.2/bin/g++\" }\r\n  cxx_flag: \"-std=c++11\"\r\n  linker_flag: \"-lstdc++\"\r\n  linker_flag: \"-B/usr/bin/\"\r\n\r\n  # TODO(bazel-team): In theory, the path here ought to exactly match the path\r\n  # used by gcc. That works because bazel currently doesn't track files at\r\n  # absolute locations and has no remote execution, yet. However, this will need\r\n  # to be fixed, maybe with auto-detection?\r\n  cxx_builtin_include_directory: \"/opt/gcc/4.9.2/include\"\r\n  cxx_builtin_include_directory: \"/usr/local/include\"\r\n  cxx_builtin_include_directory: \"/usr/include\"\r\n  tool_path { name: \"gcov\" path: \"/usr/bin/gcov\" }\r\n\r\n  # C(++) compiles invoke the compiler (as that is the one knowing where\r\n  # to find libraries), but we provide LD so other rules can invoke the linker.\r\n  tool_path { name: \"ld\" path: \"/usr/bin/ld\" }\r\n\r\n  tool_path { name: \"nm\" path: \"/usr/bin/nm\" }\r\n  tool_path { name: \"objcopy\" path: \"/usr/bin/objcopy\" }\r\n  objcopy_embed_flag: \"-I\"\r\n  objcopy_embed_flag: \"binary\"\r\n  tool_path { name: \"objdump\" path: \"/usr/bin/objdump\" }\r\n  tool_path { name: \"strip\" path: \"/usr/bin/strip\" }\r\n\r\n  # Anticipated future default.\r\n  unfiltered_cxx_flag: \"-no-canonical-prefixes\"\r\n\r\n  # Make C++ compilation deterministic. Use linkstamping instead of these\r\n  # compiler symbols.\r\n  unfiltered_cxx_flag: \"-Wno-builtin-macro-redefined\"\r\n  unfiltered_cxx_flag: \"-D__DATE__=\\\"redacted\\\"\"\r\n  unfiltered_cxx_flag: \"-D__TIMESTAMP__=\\\"redacted\\\"\"\r\n  unfiltered_cxx_flag: \"-D__TIME__=\\\"redacted\\\"\"\r\n\r\n # Security hardening on by default.\r\n  # Conservative choice; -D_FORTIFY_SOURCE=2 may be unsafe in some cases.\r\n  # We need to undef it before redefining it as some distributions now have\r\n  # it enabled by default.\r\n  compiler_flag: \"-U_FORTIFY_SOURCE\"\r\n  compiler_flag: \"-D_FORTIFY_SOURCE=1\"\r\n  compiler_flag: \"-fstack-protector\"\r\n  compiler_flag: \"-fPIE\"\r\n  linker_flag: \"-pie\"\r\n  linker_flag: \"-Wl,-z,relro,-z,now\"\r\n \r\n  # Enable coloring even if there's no attached terminal. Bazel removes the\r\n  # escape sequences if --nocolor is specified. This isn't supported by gcc\r\n  # on Ubuntu 14.04.\r\n  # compiler_flag: \"-fcolor-diagnostics\"\r\n \r\n  # All warnings are enabled. Maybe enable -Werror as well?\r\n  compiler_flag: \"-Wall\"\r\n  # Enable a few more warnings that aren't part of -Wall.\r\n  compiler_flag: \"-Wunused-but-set-parameter\"\r\n  # But disable some that are problematic.\r\n  compiler_flag: \"-Wno-free-nonheap-object\" # has false positives\r\n \r\n  # Keep stack frames for debugging, even in opt mode.\r\n  compiler_flag: \"-fno-omit-frame-pointer\"\r\n \r\n  # Anticipated future default.\r\n  linker_flag: \"-no-canonical-prefixes\"\r\n  # Have gcc return the exit code from ld.\r\n  linker_flag: \"-pass-exit-codes\"\r\n  # Stamp the binary with a unique identifier.\r\n  linker_flag: \"-Wl,--build-id=md5\"\r\n  linker_flag: \"-Wl,--hash-style=gnu\"\r\n  # Gold linker only? Can we enable this by default?\r\n  # linker_flag: \"-Wl,--warn-execstack\"\r\n  # linker_flag: \"-Wl,--detect-odr-violations\"\r\n\r\n  compilation_mode_flags {\r\n    mode: DBG\r\n    # Enable debug symbols.\r\n    compiler_flag: \"-g\"\r\n  }\r\n  compilation_mode_flags {\r\n    mode: OPT\r\n   \r\n    # No debug symbols.\r\n    # Maybe we should enable https://gcc.gnu.org/wiki/DebugFission for opt or\r\n    # even generally? However, that can't happen here, as it requires special\r\n    # handling in Bazel.\r\n    compiler_flag: \"-g0\"\r\n   \r\n    # Conservative choice for -O\r\n    # -O3 can increase binary size and even slow down the resulting binaries.\r\n    # Profile first and / or use FDO if you need better performance than this.\r\n    compiler_flag: \"-O2\"\r\n   \r\n    # Disable assertions\r\n    compiler_flag: \"-DNDEBUG\"\r\n   \r\n    # Removal of unused code and data at link time (can this increase binary size in some cases?).\r\n    compiler_flag: \"-ffunction-sections\"\r\n    compiler_flag: \"-fdata-sections\"\r\n    linker_flag: \"-Wl,--gc-sections\"\r\n  }\r\n}\r\n```"}}