Skip to content

Commit

Permalink
cc_configure: Remove hardcoded link option "-B/usr/bin"
Browse files Browse the repository at this point in the history
Putting -B/usr/bin on the link line breaks use of custom C/C++ toolchain
since support binaries such as ld, as, etc., will incorrectly "leak" to
the build machine.

Fixes bazelbuild#5634

Archeaology: It looks like this logic was originally added here:

  810d60a Apr 22 2016 dmarting@google.com
  "cc_configure: Add -B to compiler flag too"

.. and that that was done to get Tensor Flow building on some (but failing
on other?) versions of RedHat. bazelbuild#1152.

This may have also "fixed" the hombrew builds for
bazelbuild#1177.

Testing Done:

* Building envoy on older Centos host using non-host
  crosscompiler. Build fails without the fix and succeeds with the fix.

* bazel test //src/test/java/com/google/devtools/build/lib:all
  1 flaky test failed before and after:
  bazel test //src/test/java/com/google/devtools/build/lib:vfs_test
  • Loading branch information
mzeren-vmw committed Oct 11, 2018
1 parent aab8bee commit 778b21d
Show file tree
Hide file tree
Showing 4 changed files with 1 addition and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ toolchain {
tool_path { name: "gcc" path: "/usr/bin/gcc" }
cxx_flag: "-std=c++0x"
linker_flag: "-lstdc++"
linker_flag: "-B/usr/bin/"

# TODO(bazel-team): In theory, the path here ought to exactly match the path
# used by gcc. That works because bazel currently doesn't track files at
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,6 @@ toolchain {
compiler_flag: "-fstack-protector"
compiler_flag: "-Wall"
compiler_flag: "-Wl,-z,-relro,-z,now"
compiler_flag: "-B/usr/bin"
compiler_flag: "-B/usr/bin"
compiler_flag: "-Wunused-but-set-parameter"
compiler_flag: "-Wno-free-nonheap-object"
compiler_flag: "-fno-omit-frame-pointer"
Expand All @@ -173,8 +171,6 @@ toolchain {
linker_flag: "-lstdc++"
linker_flag: "-lm"
linker_flag: "-Wl,-no-as-needed"
linker_flag: "-B/usr/bin"
linker_flag: "-B/usr/bin"
linker_flag: "-pass-exit-codes"
needsPic: true
objcopy_embed_flag: "-I"
Expand Down
2 changes: 0 additions & 2 deletions tools/cpp/CROSSTOOL
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ toolchain {
tool_path { name: "gcc" path: "/usr/bin/gcc" }
cxx_flag: "-std=c++0x"
linker_flag: "-lstdc++"
linker_flag: "-B/usr/bin/"

# TODO(bazel-team): In theory, the path here ought to exactly match the path
# used by gcc. That works because bazel currently doesn't track files at
Expand Down Expand Up @@ -271,7 +270,6 @@ toolchain {
tool_path { name: "gcc" path: "/usr/bin/clang" }
cxx_flag: "-std=c++0x"
linker_flag: "-lstdc++"
linker_flag: "-B/usr/bin/"

# TODO(bazel-team): In theory, the path here ought to exactly match the path
# used by gcc. That works because bazel currently doesn't track files at
Expand Down
7 changes: 1 addition & 6 deletions tools/cpp/unix_cc_configure.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -282,8 +282,6 @@ def _crosstool_content(repository_ctx, cc, cpu_value, darwin):
"dynamic_lookup",
"-headerpad_max_install_names",
] if darwin else bin_search_flag + [
# Always have -B/usr/bin, see https://github.com/bazelbuild/bazel/issues/760.
"-B/usr/bin",
# Gold linker only? Can we enable this by default?
# "-Wl,--warn-execstack",
# "-Wl,--detect-odr-violations"
Expand Down Expand Up @@ -318,10 +316,7 @@ def _crosstool_content(repository_ctx, cc, cpu_value, darwin):
] + ((
_add_compiler_option_if_supported(repository_ctx, cc, "-Wthread-safety") +
_add_compiler_option_if_supported(repository_ctx, cc, "-Wself-assign")
) if darwin else bin_search_flag + [
# Always have -B/usr/bin, see https://github.com/bazelbuild/bazel/issues/760.
"-B/usr/bin",
]) + (
)) + (
# Disable problematic warnings.
_add_compiler_option_if_supported(repository_ctx, cc, "-Wunused-but-set-parameter") +
# has false positives
Expand Down

0 comments on commit 778b21d

Please sign in to comment.