Skip to content

Commit 88da0de

Browse files
committed
Revert "[Libomp] Do not error on undefined version script symbols"
This reverts commit 096f93e. Revert "[Libomptarget] Make the plugins ingore undefined exported symbols" This reverts commit 3f62314. Revert "[LLD] Enable --no-undefined-version by default." This reverts commit 7ec8b0d. Three commits are reverted because of the current omp build fail with GNU ld. See discussion here: https://reviews.llvm.org/rG096f93e73dc3
1 parent 922346e commit 88da0de

19 files changed

+26
-38
lines changed

lld/ELF/Driver.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1242,7 +1242,7 @@ static void readConfigs(opt::InputArgList &args) {
12421242
config->trace = args.hasArg(OPT_trace);
12431243
config->undefined = args::getStrings(args, OPT_undefined);
12441244
config->undefinedVersion =
1245-
args.hasFlag(OPT_undefined_version, OPT_no_undefined_version, false);
1245+
args.hasFlag(OPT_undefined_version, OPT_no_undefined_version, true);
12461246
config->unique = args.hasArg(OPT_unique);
12471247
config->useAndroidRelrTags = args.hasFlag(
12481248
OPT_use_android_relr_tags, OPT_no_use_android_relr_tags, false);

lld/ELF/Options.td

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -440,7 +440,7 @@ defm unresolved_symbols:
440440
Eq<"unresolved-symbols", "Determine how to handle unresolved symbols">;
441441

442442
defm undefined_version: B<"undefined-version",
443-
"Allow unused version in version script (disabled by default)",
443+
"Allow unused version in version script (default)",
444444
"Report version scripts that refer undefined symbols">;
445445

446446
defm rsp_quoting: EEq<"rsp-quoting", "Quoting style for response files">,

lld/docs/ReleaseNotes.rst

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,6 @@ ELF Improvements
3131
* ``--compress-debug-sections=zstd`` is now available to compress debug
3232
sections with zstd (``ELFCOMPRESS_ZSTD``).
3333
(`D133548 <https://reviews.llvm.org/D133548>`_)
34-
* ``--no-undefined-version`` is now the default; symbols named in version
35-
scripts that have no matching symbol in the output will be reported. Use
36-
``--undefined-version`` to revert to the old behavior.
3734

3835
Breaking changes
3936
----------------

lld/docs/ld.lld.1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -352,8 +352,8 @@ Do not set the text data sections to be writable, page align sections.
352352
Disable target-specific relaxations. For x86-64 this disables R_X86_64_GOTPCRELX and R_X86_64_REX_GOTPCRELX GOT optimization.
353353
.It Fl -no-rosegment
354354
Do not put read-only non-executable sections in their own segment.
355-
.It Fl -undefined-version
356-
Do not report version scripts that refer to undefined symbols.
355+
.It Fl -no-undefined-version
356+
Report version scripts that refer undefined symbols.
357357
.It Fl -no-undefined
358358
Report unresolved symbols even if the linker is creating a shared library.
359359
.It Fl -no-warn-symbol-ordering

lld/test/ELF/verdef-defaultver.s

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %p/Inputs/verdef-defaultver.s -o %t1
55
# RUN: echo "V1 { global: a; b; local: *; };" > %t.script
66
# RUN: echo "V2 { global: b; c; } V1;" >> %t.script
7-
# RUN: ld.lld --hash-style=sysv -shared -soname shared %t1 --version-script %t.script --undefined-version -o %t.so
7+
# RUN: ld.lld --hash-style=sysv -shared -soname shared %t1 --version-script %t.script -o %t.so
88
# RUN: llvm-readobj -V --dyn-syms %t.so | FileCheck --check-prefix=DSO %s
99

1010
# DSO: DynamicSymbols [
@@ -195,9 +195,9 @@
195195
# EXE-NEXT: ]
196196

197197
# RUN: llvm-mc -filetype=obj -triple=x86_64 b.s -o b.o
198-
# RUN: ld.lld -shared --version-script=%t.script --fatal-warnings --undefined-version %t.so b.o -o b.so
198+
# RUN: ld.lld -shared --version-script=%t.script --fatal-warnings %t.so b.o -o b.so
199199
# RUN: llvm-readelf --dyn-syms b.so | FileCheck %s --check-prefix=PREEMPT
200-
# RUN: ld.lld -shared --version-script=%t.script --fatal-warnings --undefined-version b.o %t.so -o b.so
200+
# RUN: ld.lld -shared --version-script=%t.script --fatal-warnings b.o %t.so -o b.so
201201
# RUN: llvm-readelf --dyn-syms b.so | FileCheck %s --check-prefix=PREEMPT
202202

203203
# PREEMPT-DAG: a@@V1

lld/test/ELF/verdef-dependency.s

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# RUN: echo "LIBSAMPLE_1.0 { global: a; local: *; };" > %t.script
44
# RUN: echo "LIBSAMPLE_2.0 { global: b; local: *; } LIBSAMPLE_1.0;" >> %t.script
55
# RUN: echo "LIBSAMPLE_3.0 { global: c; } LIBSAMPLE_2.0;" >> %t.script
6-
# RUN: ld.lld --version-script %t.script --undefined-version -shared -soname shared %t.o -o %t.so
6+
# RUN: ld.lld --version-script %t.script -shared -soname shared %t.o -o %t.so
77
# RUN: llvm-readobj -V --dyn-syms %t.so | FileCheck --check-prefix=DSO %s
88

99
# DSO: VersionDefinitions [

lld/test/ELF/verneed.s

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
# REQUIRES: x86
22
# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %S/Inputs/verneed1.s -o %t1.o
33
# RUN: echo "v1 {}; v2 {}; v3 { global: f1; local: *; };" > %t.script
4-
# RUN: ld.lld -shared %t1.o --version-script %t.script --undefined-version -o %t1.so -soname verneed1.so.0
4+
# RUN: ld.lld -shared %t1.o --version-script %t.script -o %t1.so -soname verneed1.so.0
55
# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %S/Inputs/verneed2.s -o %t2.o
6-
# RUN: ld.lld -shared %t2.o --version-script %t.script --undefined-version -o %t2.so -soname verneed2.so.0
6+
# RUN: ld.lld -shared %t2.o --version-script %t.script -o %t2.so -soname verneed2.so.0
77

88
# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o
99
# RUN: ld.lld --hash-style=sysv %t.o %t1.so %t2.so -o %t

lld/test/ELF/version-script-extern-undefined.s

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o
44
# RUN: echo "FOO { global: extern \"C++\" { \"abb(int)\"; }; };" > %t.script
5-
# RUN: ld.lld --version-script %t.script --undefined-version -shared %t.o -o %t.so
5+
# RUN: ld.lld --version-script %t.script -shared %t.o -o %t.so
66
# RUN: llvm-readobj -V %t.so | FileCheck %s
77

88
# CHECK: VersionSymbols [

lld/test/ELF/version-script-local-preemptible.s

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
# RUN: echo "{ global: main; local: *; };" > %t.script
1111

1212
# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t.o
13-
# RUN: ld.lld %t.o %t.so -o %t -version-script %t.script --undefined-version
13+
# RUN: ld.lld %t.o %t.so -o %t -version-script %t.script
1414
# RUN: llvm-readelf -r --symbols %t | FileCheck %s
1515

1616
# CHECK: Relocation section '.rela.plt' at offset {{.*}} contains 1 entries:

lld/test/ELF/version-script-noundef.s

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@
22

33
# RUN: echo "VERSION_1.0 { global: bar; };" > %t.script
44
# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t.o
5-
# RUN: not ld.lld --version-script %t.script -shared %t.o -o /dev/null \
6-
# RUN: --fatal-warnings 2>&1 | FileCheck -check-prefix=ERR1 %s
5+
# RUN: ld.lld --version-script %t.script -shared %t.o -o /dev/null --fatal-warnings
76
# RUN: ld.lld --version-script %t.script -shared --undefined-version %t.o -o %t.so
87
# RUN: not ld.lld --version-script %t.script -shared --no-undefined-version \
98
# RUN: %t.o -o %t.so 2>&1 | FileCheck -check-prefix=ERR1 %s

lld/test/ELF/version-script-reassign.s

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
# RUN: llvm-readelf --dyn-syms %t.so | FileCheck --check-prefix=V1-SYM %s
2525

2626
# RUN: ld.lld -shared %t.o --version-script %t1.ver --version-script %t2w.ver \
27-
# RUN: -o %t.so --fatal-warnings --undefined-version
27+
# RUN: -o %t.so --fatal-warnings
2828
# RUN: llvm-readelf --dyn-syms %t.so | FileCheck --check-prefix=V1-SYM %s
2929

3030
# LOCAL: warning: attempt to reassign symbol 'foo' of VER_NDX_LOCAL to version 'V1'

openmp/libomptarget/plugins/CMakeLists.txt

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,12 @@ if(CMAKE_SYSTEM_PROCESSOR MATCHES "${tmachine}$")
3838
${LIBOMPTARGET_INCLUDE_DIR}
3939
${LIBOMPTARGET_DEP_LIBFFI_INCLUDE_DIR}
4040

41-
LINK_LIBS
42-
PRIVATE
43-
elf_common
44-
${LIBOMPTARGET_DEP_LIBFFI_LIBRARIES}
45-
${OPENMP_PTHREAD_LIB}
46-
"-Wl,--version-script=${CMAKE_CURRENT_SOURCE_DIR}/../exports"
47-
"-Wl,--undefined-version"
41+
LINK_LIBS
42+
PRIVATE
43+
elf_common
44+
${LIBOMPTARGET_DEP_LIBFFI_LIBRARIES}
45+
${OPENMP_PTHREAD_LIB}
46+
"-Wl,--version-script=${CMAKE_CURRENT_SOURCE_DIR}/../exports"
4847

4948
NO_INSTALL_RPATH
5049
)

openmp/libomptarget/plugins/amdgpu/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,6 @@ add_llvm_library(omptarget.rtl.amdgpu SHARED
8585
${LIBOMPTARGET_DEP_LIBRARIES}
8686
${OPENMP_PTHREAD_LIB}
8787
"-Wl,--version-script=${CMAKE_CURRENT_SOURCE_DIR}/../exports"
88-
"-Wl,--undefined-version"
8988
${LDFLAGS_UNDEFINED}
9089

9190
NO_INSTALL_RPATH

openmp/libomptarget/plugins/cuda/CMakeLists.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ if (LIBOMPTARGET_CAN_LINK_LIBCUDA AND NOT LIBOMPTARGET_FORCE_DLOPEN_LIBCUDA)
5555
${LIBOMPTARGET_DEP_CUDA_DRIVER_LIBRARIES}
5656
${OPENMP_PTHREAD_LIB}
5757
"-Wl,--version-script=${CMAKE_CURRENT_SOURCE_DIR}/../exports"
58-
"-Wl,--undefined-version"
5958
"-Wl,-z,defs"
6059

6160
NO_INSTALL_RPATH
@@ -78,7 +77,6 @@ else()
7877
MemoryManager
7978
${OPENMP_PTHREAD_LIB}
8079
"-Wl,--version-script=${CMAKE_CURRENT_SOURCE_DIR}/../exports"
81-
"-Wl,--undefined-version"
8280
"-Wl,-z,defs"
8381

8482
NO_INSTALL_RPATH

openmp/libomptarget/plugins/remote/server/CMakeLists.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,5 +29,4 @@ target_link_libraries(openmp-offloading-server
2929
absl::synchronization
3030
${OPENMP_PTHREAD_LIB}
3131
omp
32-
"-Wl,--version-script=${CMAKE_CURRENT_SOURCE_DIR}/../../exports"
33-
"-Wl,--undefined-version")
32+
"-Wl,--version-script=${CMAKE_CURRENT_SOURCE_DIR}/../../exports")

openmp/libomptarget/plugins/remote/src/CMakeLists.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,7 @@ target_link_libraries(omptarget.rtl.rpc
3737
absl::synchronization
3838
${OPENMP_PTHREAD_LIB}
3939
omp
40-
"-Wl,--version-script=${CMAKE_CURRENT_SOURCE_DIR}/../../exports"
41-
"-Wl,--undefined-version")
40+
"-Wl,--version-script=${CMAKE_CURRENT_SOURCE_DIR}/../../exports")
4241

4342
# Report to the parent scope that we are building a plugin for RPC.
4443
set(LIBOMPTARGET_SYSTEM_TARGETS "${LIBOMPTARGET_SYSTEM_TARGETS} rpc" PARENT_SCOPE)

openmp/libomptarget/plugins/ve/CMakeLists.txt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ if(${LIBOMPTARGET_DEP_VEO_FOUND})
3737
${LIBOMPTARGET_DEP_LIBFFI_LIBRARIES}
3838
${additional_libs}
3939
"-Wl,--version-script=${CMAKE_CURRENT_SOURCE_DIR}/../exports -Wl,-z,defs"
40-
"-Wl,--undefined-version"
4140

4241
NO_INSTALL_RPATH
4342
)
@@ -56,8 +55,7 @@ if(${LIBOMPTARGET_DEP_VEO_FOUND})
5655
elf_common
5756
${LIBOMPTARGET_DEP_LIBFFI_LIBRARIES}
5857
${additional_libs}
59-
"-Wl,--version-script=${CMAKE_CURRENT_SOURCE_DIR}/../exports -Wl,-z,defs"
60-
"-Wl,--undefined-version")
58+
"-Wl,--version-script=${CMAKE_CURRENT_SOURCE_DIR}/../exports -Wl,-z,defs")
6159

6260
# Report to the parent scope that we are building a plugin.
6361
set(LIBOMPTARGET_SYSTEM_TARGETS

openmp/runtime/cmake/LibompHandleFlags.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ function(libomp_get_ldflags ldflags)
9999
IF_DEFINED CMAKE_C_OSX_COMPATIBILITY_VERSION_FLAG)
100100
libomp_append(ldflags_local -Wl,--warn-shared-textrel LIBOMP_HAVE_WARN_SHARED_TEXTREL_FLAG)
101101
libomp_append(ldflags_local -Wl,--as-needed LIBOMP_HAVE_AS_NEEDED_FLAG)
102-
libomp_append(ldflags_local "-Wl,--version-script=${LIBOMP_SRC_DIR}/exports_so.txt -Wl,--undefined-version" LIBOMP_HAVE_VERSION_SCRIPT_FLAG)
102+
libomp_append(ldflags_local "-Wl,--version-script=${LIBOMP_SRC_DIR}/exports_so.txt" LIBOMP_HAVE_VERSION_SCRIPT_FLAG)
103103
libomp_append(ldflags_local -static-libgcc LIBOMP_HAVE_STATIC_LIBGCC_FLAG)
104104
libomp_append(ldflags_local -Wl,-z,noexecstack LIBOMP_HAVE_Z_NOEXECSTACK_FLAG)
105105
libomp_append(ldflags_local -no-intel-extensions LIBOMP_HAVE_NO_INTEL_EXTENSIONS_FLAG)

openmp/runtime/cmake/config-ix.cmake

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ function(libomp_check_version_symbols retval)
3434
}")
3535
set(version_script_source "VER1 { }; VER2 { } VER1;")
3636
file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/__version_script.txt "${version_script_source}")
37-
set(CMAKE_REQUIRED_FLAGS "-Wl,--version-script=${CMAKE_CURRENT_BINARY_DIR}/__version_script.txt -Wl,--undefined-version")
37+
set(CMAKE_REQUIRED_FLAGS -Wl,--version-script=${CMAKE_CURRENT_BINARY_DIR}/__version_script.txt)
3838
check_c_source_compiles("${source_code}" ${retval})
3939
set(${retval} ${${retval}} PARENT_SCOPE)
4040
file(REMOVE ${CMAKE_CURRENT_BINARY_DIR}/__version_script.txt)
@@ -132,7 +132,7 @@ elseif(NOT APPLE)
132132
libomp_check_linker_flag(-Wl,-x LIBOMP_HAVE_X_FLAG)
133133
libomp_check_linker_flag(-Wl,--warn-shared-textrel LIBOMP_HAVE_WARN_SHARED_TEXTREL_FLAG)
134134
libomp_check_linker_flag(-Wl,--as-needed LIBOMP_HAVE_AS_NEEDED_FLAG)
135-
libomp_check_linker_flag("-Wl,--version-script=${LIBOMP_SRC_DIR}/exports_so.txt -Wl,--undefined-version" LIBOMP_HAVE_VERSION_SCRIPT_FLAG)
135+
libomp_check_linker_flag("-Wl,--version-script=${LIBOMP_SRC_DIR}/exports_so.txt" LIBOMP_HAVE_VERSION_SCRIPT_FLAG)
136136
libomp_check_linker_flag(-static-libgcc LIBOMP_HAVE_STATIC_LIBGCC_FLAG)
137137
libomp_check_linker_flag(-Wl,-z,noexecstack LIBOMP_HAVE_Z_NOEXECSTACK_FLAG)
138138
endif()

0 commit comments

Comments
 (0)