Skip to content

Commit 686c415

Browse files
committed
build: use GNU ld instead of gold for GCC build
Gold is deprecated beginning from GNU binutils 2.44. It is no longer included in standard binutils release and it is scheduled for complete removal. Signed-off-by: Tero Saarni <tero.saarni@est.tech>
1 parent 8b38e06 commit 686c415

File tree

6 files changed

+14
-8
lines changed

6 files changed

+14
-8
lines changed

.bazelrc

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ build:linux --conlyopt=-fexceptions
7676
build:linux --fission=dbg,opt
7777
build:linux --features=per_object_debug_info
7878
build:linux --action_env=BAZEL_LINKLIBS=-l%:libstdc++.a
79-
build:linux --action_env=BAZEL_LINKOPTS=-lm:-fuse-ld=gold
79+
build:linux --action_env=BAZEL_LINKOPTS=-lm:-fuse-ld=bfd
8080

8181
# We already have absl in the build, define absl=1 to tell googletest to use absl for backtrace.
8282
build --define absl=1
@@ -109,7 +109,7 @@ build:clang-pch --define=ENVOY_CLANG_PCH=1
109109
build:libstdc++ --@envoy//bazel:libc++=false
110110
build:libstdc++ --@envoy//bazel:libstdc++=true
111111

112-
# Use gold linker for gcc compiler.
112+
# Gcc with libstdc++
113113
build:gcc --config=libstdc++
114114
build:gcc --test_env=HEAPCHECK=
115115
build:gcc --action_env=BAZEL_COMPILER=gcc
@@ -127,7 +127,10 @@ build:gcc --cxxopt=-Wno-missing-requires
127127
build:gcc --cxxopt=-Wno-dangling-reference
128128
build:gcc --cxxopt=-Wno-nonnull-compare
129129
build:gcc --incompatible_enable_cc_toolchain_resolution=false
130-
build:gcc --linkopt=-fuse-ld=gold --host_linkopt=-fuse-ld=gold
130+
build:gcc --linkopt=-fuse-ld=bfd --host_linkopt=-fuse-ld=bfd
131+
build:gcc --features=-supports_start_end_lib --host_features=-supports_start_end_lib
132+
# Optimize for memory usage during linking to avoid OOM kills.
133+
build:gcc --linkopt=-Wl,--no-keep-memory
131134

132135
# Clang-tidy
133136
# TODO(phlax): enable this, its throwing some errors as well as finding more issues

bazel/rbe/toolchains/configs/linux/gcc/cc/BUILD

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,13 +101,12 @@ cc_toolchain_config(
101101
dbg_compile_flags = ["-g"],
102102
host_system_name = "local",
103103
link_flags = [
104-
"-fuse-ld=lld",
104+
"-fuse-ld=bfd",
105105
"-Wl,-no-as-needed",
106106
"-Wl,-z,relro,-z,now",
107107
"-B/usr/bin",
108108
"-pass-exit-codes",
109109
"-lm",
110-
"-fuse-ld=gold",
111110
],
112111
link_libs = ["-l:libstdc++.a"],
113112
opt_compile_flags = [
@@ -119,7 +118,7 @@ cc_toolchain_config(
119118
"-fdata-sections",
120119
],
121120
opt_link_flags = ["-Wl,--gc-sections"],
122-
supports_start_end_lib = True,
121+
supports_start_end_lib = False,
123122
target_libc = "local",
124123
target_system_name = "local",
125124
tool_paths = {

bazel/rbe/toolchains/gcc.env.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"BAZEL_COMPILER": "gcc",
33
"BAZEL_LINKLIBS": "-l%:libstdc++.a",
4-
"BAZEL_LINKOPTS": "-lm:-fuse-ld=gold",
4+
"BAZEL_LINKOPTS": "-lm:-fuse-ld=bfd",
55
"CC": "gcc",
66
"CXX": "g++",
77
"PATH": "/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/opt/llvm/bin"

bazel/rbe/toolchains/rbe_toolchains_config.bzl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ _CLANG_LIBCXX_ENV = dicts.add(_CLANG_ENV, {
3131
_GCC_ENV = {
3232
"BAZEL_COMPILER": "gcc",
3333
"BAZEL_LINKLIBS": "-l%:libstdc++.a",
34-
"BAZEL_LINKOPTS": "-lm:-fuse-ld=gold",
34+
"BAZEL_LINKOPTS": "-lm:-fuse-ld=bfd",
3535
"CC": "gcc",
3636
"CXX": "g++",
3737
"PATH": "/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/opt/llvm/bin",

changelogs/current.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,9 @@ minor_behavior_changes:
9494
Cap the frame size for streamed grpc at 1MB. Without this change there was a small chance
9595
that if a request streamed in sufficiently faster than it was processed, a frame larger than
9696
4MB could be encoded, which most upstream grpc services would, by default, treat as an error.
97+
- area: build
98+
change: |
99+
GCC build now use GNU ld. The gold linker was deprecated in binutils 2.44.
97100
98101
bug_fixes:
99102
# *Changes expected to improve the state of the world and are unlikely to have negative effects*

test/server/config_validation/BUILD

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ envoy_cc_fuzz_test(
9393
size = "large",
9494
srcs = ["config_fuzz_test.cc"],
9595
corpus = "//test/server:server_fuzz_test_corpus",
96+
rbe_pool = "6gig",
9697
deps = [
9798
"//source/common/common:thread_lib",
9899
"//source/server/config_validation:server_lib",

0 commit comments

Comments
 (0)