Skip to content

Commit f0bec36

Browse files
dslomovCopybara-Service
authored and
Copybara-Service
committed
Automated rollback of commit 2aeaeba.
*** Reason for rollback *** Breaks C++ on gcc 4.8.4 (specifically, TensorFlow: #4474) Fixes #4474 *** Original change description *** When linking mostly-static Linux binaries, link libstdc++.a explicitly. This allows libstdc++ to be statically linked, which is normally only possible when invoking GCC as `g++` with the `-static-libstdc++` flag. Fixes #2840 See envoyproxy/envoy#415 for additional background and context. cc @htuch (for Envoy) and @calpeyser @hlopko (who I talked to earlier about this)... *** RELNOTES: None. PiperOrigin-RevId: 182519445
1 parent 8896d2e commit f0bec36

File tree

6 files changed

+1
-126
lines changed

6 files changed

+1
-126
lines changed

src/test/shell/bazel/BUILD

-7
Original file line numberDiff line numberDiff line change
@@ -367,13 +367,6 @@ sh_test(
367367
data = [":test-deps"],
368368
)
369369

370-
sh_test(
371-
name = "cc_static_binary_test",
372-
size = "medium",
373-
srcs = ["cc_static_binary_test.sh"],
374-
data = [":test-deps"],
375-
)
376-
377370
sh_test(
378371
name = "bazel_sandboxing_test",
379372
size = "large",

src/test/shell/bazel/cc_static_binary_test.sh

-89
This file was deleted.

src/test/shell/testenv.sh

-4
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,6 @@ function is_darwin() {
3030
[[ "${PLATFORM}" =~ darwin ]]
3131
}
3232

33-
function is_linux() {
34-
[[ "${PLATFORM}" =~ linux ]]
35-
}
36-
3733
function _log_base() {
3834
prefix=$1
3935
shift

tools/cpp/CROSSTOOL.tpl

-1
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,6 @@ toolchain {
129129
%{opt_content}
130130
}
131131
linking_mode_flags { mode: DYNAMIC }
132-
%{link_content}
133132

134133
%{coverage}
135134

tools/cpp/unix_cc_configure.bzl

+1-24
Original file line numberDiff line numberDiff line change
@@ -65,29 +65,6 @@ def _build_crosstool(d, prefix=" "):
6565
return "\n".join(lines)
6666

6767

68-
def _build_link_content():
69-
# `-static-libstdc++` is only supported when invoking GCC as `g++`, and
70-
# `-lstdc++` forces dynamic linking of libstdc++. To get desired
71-
# mostly-static behavior, invoke the link by explicitly naming a static
72-
# library archive.
73-
#
74-
# https://github.com/bazelbuild/bazel/issues/2840
75-
return """
76-
linking_mode_flags {
77-
mode: DYNAMIC
78-
linker_flag: "-lstdc++"
79-
}
80-
linking_mode_flags {
81-
mode: FULLY_STATIC
82-
linker_flag: "-lstdc++"
83-
}
84-
linking_mode_flags {
85-
mode: MOSTLY_STATIC
86-
linker_flag: "-l:libstdc++.a"
87-
}
88-
"""
89-
90-
9168
def _build_tool_path(d):
9269
"""Build the list of %-escaped tool_path for the CROSSTOOL file."""
9370
lines = []
@@ -242,6 +219,7 @@ def _crosstool_content(repository_ctx, cc, cpu_value, darwin):
242219
"-std=c++0x",
243220
] + _escaped_cplus_include_paths(repository_ctx),
244221
"linker_flag": [
222+
"-lstdc++",
245223
"-lm", # Some systems expect -lm in addition to -lstdc++
246224
# Anticipated future default.
247225
] + (
@@ -450,7 +428,6 @@ def configure_unix_toolchain(repository_ctx, cpu_value, overriden_tools):
450428
_build_tool_path(tool_paths),
451429
"%{opt_content}": _build_crosstool(opt_content, " "),
452430
"%{dbg_content}": _build_crosstool(dbg_content, " "),
453-
"%{link_content}": _build_link_content(),
454431
"%{cxx_builtin_include_directory}": "",
455432
"%{coverage}": _coverage_feature(darwin),
456433
"%{msvc_env_tmp}": "",

tools/cpp/windows_cc_configure.bzl

-1
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,6 @@ def configure_windows_toolchain(repository_ctx):
315315
"%{msys_x64_mingw_content}": _get_escaped_windows_msys_crosstool_content(repository_ctx, use_mingw = True),
316316
"%{opt_content}": "",
317317
"%{dbg_content}": "",
318-
"%{link_content}": "",
319318
"%{cxx_builtin_include_directory}": "",
320319
"%{coverage}": "",
321320
})

0 commit comments

Comments
 (0)