Skip to content

Commit ba07d35

Browse files
authored
GH-45484: [C++] Drop support for the gold linker (#47780)
### Rationale for this change Because the gold linker is deprecated in GNU Binutils 2.44: https://lists.gnu.org/archive/html/info-gnu/2025-02/msg00001.html > In a change to our previous practice, in this release the > binutils-2.44.tar tarball does not contain the sources for the gold > linker. This is because the gold linker is now deprecated and will > eventually be removed unless volunteers step forward and offer to > continue development and maintenance. ### What changes are included in this PR? Remove `ARROW_USE_LD_GOLD` CMake option and related build code to build with gold linker. ### Are these changes tested? Via CI ### Are there any user-facing changes? The gold linker will be unsupported going forward. * GitHub Issue: #45484 Authored-by: Raúl Cumplido <raulcumplido@gmail.com> Signed-off-by: Sutou Kouhei <kou@clear-code.com>
1 parent a01b98f commit ba07d35

File tree

6 files changed

+0
-102
lines changed

6 files changed

+0
-102
lines changed

ci/scripts/cpp_build.sh

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,6 @@ else
228228
-DARROW_USE_ASAN=${ARROW_USE_ASAN:-OFF} \
229229
-DARROW_USE_CCACHE=${ARROW_USE_CCACHE:-ON} \
230230
-DARROW_USE_GLOG=${ARROW_USE_GLOG:-OFF} \
231-
-DARROW_USE_LD_GOLD=${ARROW_USE_LD_GOLD:-OFF} \
232231
-DARROW_USE_LLD=${ARROW_USE_LLD:-OFF} \
233232
-DARROW_USE_MOLD=${ARROW_USE_MOLD:-OFF} \
234233
-DARROW_USE_STATIC_CRT=${ARROW_USE_STATIC_CRT:-OFF} \

cpp/cmake_modules/DefineOptions.cmake

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -170,8 +170,6 @@ if(ARROW_DEFINE_OPTIONS)
170170
define_option(ARROW_USE_SCCACHE "Use sccache when compiling (if available),;\
171171
takes precedence over ccache if a storage backend is configured" ON)
172172

173-
define_option(ARROW_USE_LD_GOLD "Use ld.gold for linking on Linux (if available)" OFF)
174-
175173
define_option(ARROW_USE_LLD "Use the LLVM lld for linking (if available)" OFF)
176174

177175
define_option(ARROW_USE_MOLD "Use mold for linking on Linux (if available)" OFF)

cpp/cmake_modules/SetupCxxFlags.cmake

Lines changed: 0 additions & 89 deletions
Original file line numberDiff line numberDiff line change
@@ -540,95 +540,6 @@ if(ARROW_CPU_FLAG STREQUAL "aarch64")
540540
endif()
541541
endif()
542542

543-
# ----------------------------------------------------------------------
544-
# Setup Gold linker, if available. Code originally from Apache Kudu
545-
546-
# Interrogates the linker version via the C++ compiler to determine whether
547-
# we're using the gold linker, and if so, extracts its version.
548-
#
549-
# If the gold linker is being used, sets GOLD_VERSION in the parent scope with
550-
# the extracted version.
551-
#
552-
# Any additional arguments are passed verbatim into the C++ compiler invocation.
553-
function(GET_GOLD_VERSION)
554-
# The gold linker is only for ELF binaries, which macOS doesn't use.
555-
execute_process(COMMAND ${CMAKE_CXX_COMPILER} "-Wl,--version" ${ARGN}
556-
ERROR_QUIET
557-
OUTPUT_VARIABLE LINKER_OUTPUT)
558-
# We're expecting LINKER_OUTPUT to look like one of these:
559-
# GNU gold (version 2.24) 1.11
560-
# GNU gold (GNU Binutils for Ubuntu 2.30) 1.15
561-
if(LINKER_OUTPUT MATCHES "GNU gold")
562-
string(REGEX MATCH "GNU gold \\([^\\)]*\\) (([0-9]+\\.?)+)" _ "${LINKER_OUTPUT}")
563-
if(NOT CMAKE_MATCH_1)
564-
message(SEND_ERROR "Could not extract GNU gold version. "
565-
"Linker version output: ${LINKER_OUTPUT}")
566-
endif()
567-
set(GOLD_VERSION
568-
"${CMAKE_MATCH_1}"
569-
PARENT_SCOPE)
570-
endif()
571-
endfunction()
572-
573-
# Is the compiler hard-wired to use the gold linker?
574-
if(NOT WIN32 AND NOT APPLE)
575-
get_gold_version()
576-
if(GOLD_VERSION)
577-
set(MUST_USE_GOLD 1)
578-
elseif(ARROW_USE_LD_GOLD)
579-
# Can the compiler optionally enable the gold linker?
580-
get_gold_version("-fuse-ld=gold")
581-
582-
# We can't use the gold linker if it's inside devtoolset because the compiler
583-
# won't find it when invoked directly from make/ninja (which is typically
584-
# done outside devtoolset).
585-
execute_process(COMMAND which ld.gold
586-
OUTPUT_VARIABLE GOLD_LOCATION
587-
OUTPUT_STRIP_TRAILING_WHITESPACE ERROR_QUIET)
588-
if("${GOLD_LOCATION}" MATCHES "^/opt/rh/devtoolset")
589-
message(STATUS "Skipping optional gold linker (version ${GOLD_VERSION}) because "
590-
"it's in devtoolset")
591-
set(GOLD_VERSION)
592-
endif()
593-
endif()
594-
595-
if(GOLD_VERSION)
596-
# Older versions of the gold linker are vulnerable to a bug [1] which
597-
# prevents weak symbols from being overridden properly. This leads to
598-
# omitting of dependencies like tcmalloc (used in Kudu, where this
599-
# workaround was written originally)
600-
#
601-
# How we handle this situation depends on other factors:
602-
# - If gold is optional, we won't use it.
603-
# - If gold is required, we'll either:
604-
# - Raise an error in RELEASE builds (we shouldn't release such a product), or
605-
# - Drop tcmalloc in all other builds.
606-
#
607-
# 1. https://sourceware.org/bugzilla/show_bug.cgi?id=16979.
608-
if("${GOLD_VERSION}" VERSION_LESS "1.12")
609-
set(ARROW_BUGGY_GOLD 1)
610-
endif()
611-
if(MUST_USE_GOLD)
612-
message(STATUS "Using hard-wired gold linker (version ${GOLD_VERSION})")
613-
if(ARROW_BUGGY_GOLD)
614-
if("${ARROW_LINK}" STREQUAL "d" AND "${UPPERCASE_BUILD_TYPE}" STREQUAL "RELEASE")
615-
message(SEND_ERROR "Configured to use buggy gold with dynamic linking "
616-
"in a RELEASE build")
617-
endif()
618-
endif()
619-
elseif(NOT ARROW_BUGGY_GOLD)
620-
# The Gold linker must be manually enabled.
621-
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fuse-ld=gold")
622-
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fuse-ld=gold")
623-
message(STATUS "Using optional gold linker (version ${GOLD_VERSION})")
624-
else()
625-
message(STATUS "Optional gold linker is buggy, using ld linker instead")
626-
endif()
627-
else()
628-
message(STATUS "Using ld linker")
629-
endif()
630-
endif()
631-
632543
if(NOT WIN32 AND NOT APPLE)
633544
if(ARROW_USE_MOLD)
634545
find_program(LD_MOLD ld.mold)

dev/archery/archery/cli.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,8 +125,6 @@ def _apply_options(cmd, options):
125125
help="Use CMAKE_UNITY_BUILD")
126126
@click.option("--warn-level", default="production", type=warn_level_type,
127127
help="Controls compiler warnings -W(no-)error.")
128-
@click.option("--use-gold-linker", default=True, type=BOOL,
129-
help="Toggles ARROW_USE_LD_GOLD option.")
130128
@click.option("--simd-level", default="DEFAULT", type=simd_level,
131129
help="Toggles ARROW_SIMD_LEVEL option.")
132130
# Tests and benchmarks

dev/archery/archery/lang/cpp.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@ def __init__(self,
6262
with_brotli=None, with_bz2=None, with_lz4=None,
6363
with_snappy=None, with_zlib=None, with_zstd=None,
6464
# extras
65-
use_gold_linker=True,
6665
simd_level="DEFAULT",
6766
cmake_extras=None):
6867
self._cc = cc
@@ -114,7 +113,6 @@ def __init__(self,
114113
self.with_zlib = with_zlib
115114
self.with_zstd = with_zstd
116115

117-
self.use_gold_linker = use_gold_linker
118116
self.simd_level = simd_level
119117

120118
self.cmake_extras = cmake_extras
@@ -237,10 +235,6 @@ def _gen_defs(self):
237235
yield ("ARROW_WITH_ZLIB", truthifier(self.with_zlib))
238236
yield ("ARROW_WITH_ZSTD", truthifier(self.with_zstd))
239237

240-
# Some configurations don't like gnu gold linker.
241-
broken_with_gold_ld = [self.with_fuzzing, self.with_gandiva]
242-
if self.use_gold_linker and not any(broken_with_gold_ld):
243-
yield ("ARROW_USE_LD_GOLD", truthifier(self.use_gold_linker))
244238
yield ("ARROW_SIMD_LEVEL", or_else(self.simd_level, "DEFAULT"))
245239

246240
# Detect custom conda toolchain

docker-compose.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,6 @@ services:
290290
ARROW_ENABLE_TIMING_TESTS: # inherit
291291
ARROW_EXTRA_ERROR_CONTEXT: "ON"
292292
ARROW_MIMALLOC: "ON"
293-
ARROW_USE_LD_GOLD: "ON"
294293
BUILD_DOCS_PYTHON: "ON"
295294
volumes: &conda-volumes
296295
- .:/arrow:delegated
@@ -332,7 +331,6 @@ services:
332331
ARROW_MIMALLOC: "OFF"
333332
ARROW_RUNTIME_SIMD_LEVEL: "AVX2" # AVX512 not supported by Valgrind (ARROW-9851)
334333
ARROW_TEST_MEMCHECK: "ON"
335-
ARROW_USE_LD_GOLD: "ON"
336334
BUILD_WARNING_LEVEL: "PRODUCTION"
337335
ARROW_CTEST_TIMEOUT: 500
338336
volumes: *conda-volumes

0 commit comments

Comments
 (0)