Skip to content

Commit

Permalink
Revert "[Libomp] Do not error on undefined version script symbols"
Browse files Browse the repository at this point in the history
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
  • Loading branch information
vzakhari committed Oct 13, 2022
1 parent 922346e commit 88da0de
Show file tree
Hide file tree
Showing 19 changed files with 26 additions and 38 deletions.
2 changes: 1 addition & 1 deletion lld/ELF/Driver.cpp
Expand Up @@ -1242,7 +1242,7 @@ static void readConfigs(opt::InputArgList &args) {
config->trace = args.hasArg(OPT_trace);
config->undefined = args::getStrings(args, OPT_undefined);
config->undefinedVersion =
args.hasFlag(OPT_undefined_version, OPT_no_undefined_version, false);
args.hasFlag(OPT_undefined_version, OPT_no_undefined_version, true);
config->unique = args.hasArg(OPT_unique);
config->useAndroidRelrTags = args.hasFlag(
OPT_use_android_relr_tags, OPT_no_use_android_relr_tags, false);
Expand Down
2 changes: 1 addition & 1 deletion lld/ELF/Options.td
Expand Up @@ -440,7 +440,7 @@ defm unresolved_symbols:
Eq<"unresolved-symbols", "Determine how to handle unresolved symbols">;

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

defm rsp_quoting: EEq<"rsp-quoting", "Quoting style for response files">,
Expand Down
3 changes: 0 additions & 3 deletions lld/docs/ReleaseNotes.rst
Expand Up @@ -31,9 +31,6 @@ ELF Improvements
* ``--compress-debug-sections=zstd`` is now available to compress debug
sections with zstd (``ELFCOMPRESS_ZSTD``).
(`D133548 <https://reviews.llvm.org/D133548>`_)
* ``--no-undefined-version`` is now the default; symbols named in version
scripts that have no matching symbol in the output will be reported. Use
``--undefined-version`` to revert to the old behavior.

Breaking changes
----------------
Expand Down
4 changes: 2 additions & 2 deletions lld/docs/ld.lld.1
Expand Up @@ -352,8 +352,8 @@ Do not set the text data sections to be writable, page align sections.
Disable target-specific relaxations. For x86-64 this disables R_X86_64_GOTPCRELX and R_X86_64_REX_GOTPCRELX GOT optimization.
.It Fl -no-rosegment
Do not put read-only non-executable sections in their own segment.
.It Fl -undefined-version
Do not report version scripts that refer to undefined symbols.
.It Fl -no-undefined-version
Report version scripts that refer undefined symbols.
.It Fl -no-undefined
Report unresolved symbols even if the linker is creating a shared library.
.It Fl -no-warn-symbol-ordering
Expand Down
6 changes: 3 additions & 3 deletions lld/test/ELF/verdef-defaultver.s
Expand Up @@ -4,7 +4,7 @@
# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %p/Inputs/verdef-defaultver.s -o %t1
# RUN: echo "V1 { global: a; b; local: *; };" > %t.script
# RUN: echo "V2 { global: b; c; } V1;" >> %t.script
# RUN: ld.lld --hash-style=sysv -shared -soname shared %t1 --version-script %t.script --undefined-version -o %t.so
# RUN: ld.lld --hash-style=sysv -shared -soname shared %t1 --version-script %t.script -o %t.so
# RUN: llvm-readobj -V --dyn-syms %t.so | FileCheck --check-prefix=DSO %s

# DSO: DynamicSymbols [
Expand Down Expand Up @@ -195,9 +195,9 @@
# EXE-NEXT: ]

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

# PREEMPT-DAG: a@@V1
Expand Down
2 changes: 1 addition & 1 deletion lld/test/ELF/verdef-dependency.s
Expand Up @@ -3,7 +3,7 @@
# RUN: echo "LIBSAMPLE_1.0 { global: a; local: *; };" > %t.script
# RUN: echo "LIBSAMPLE_2.0 { global: b; local: *; } LIBSAMPLE_1.0;" >> %t.script
# RUN: echo "LIBSAMPLE_3.0 { global: c; } LIBSAMPLE_2.0;" >> %t.script
# RUN: ld.lld --version-script %t.script --undefined-version -shared -soname shared %t.o -o %t.so
# RUN: ld.lld --version-script %t.script -shared -soname shared %t.o -o %t.so
# RUN: llvm-readobj -V --dyn-syms %t.so | FileCheck --check-prefix=DSO %s

# DSO: VersionDefinitions [
Expand Down
4 changes: 2 additions & 2 deletions lld/test/ELF/verneed.s
@@ -1,9 +1,9 @@
# REQUIRES: x86
# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %S/Inputs/verneed1.s -o %t1.o
# RUN: echo "v1 {}; v2 {}; v3 { global: f1; local: *; };" > %t.script
# RUN: ld.lld -shared %t1.o --version-script %t.script --undefined-version -o %t1.so -soname verneed1.so.0
# RUN: ld.lld -shared %t1.o --version-script %t.script -o %t1.so -soname verneed1.so.0
# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %S/Inputs/verneed2.s -o %t2.o
# RUN: ld.lld -shared %t2.o --version-script %t.script --undefined-version -o %t2.so -soname verneed2.so.0
# RUN: ld.lld -shared %t2.o --version-script %t.script -o %t2.so -soname verneed2.so.0

# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o
# RUN: ld.lld --hash-style=sysv %t.o %t1.so %t2.so -o %t
Expand Down
2 changes: 1 addition & 1 deletion lld/test/ELF/version-script-extern-undefined.s
Expand Up @@ -2,7 +2,7 @@

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

# CHECK: VersionSymbols [
Expand Down
2 changes: 1 addition & 1 deletion lld/test/ELF/version-script-local-preemptible.s
Expand Up @@ -10,7 +10,7 @@
# RUN: echo "{ global: main; local: *; };" > %t.script

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

# CHECK: Relocation section '.rela.plt' at offset {{.*}} contains 1 entries:
Expand Down
3 changes: 1 addition & 2 deletions lld/test/ELF/version-script-noundef.s
Expand Up @@ -2,8 +2,7 @@

# RUN: echo "VERSION_1.0 { global: bar; };" > %t.script
# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t.o
# RUN: not ld.lld --version-script %t.script -shared %t.o -o /dev/null \
# RUN: --fatal-warnings 2>&1 | FileCheck -check-prefix=ERR1 %s
# RUN: ld.lld --version-script %t.script -shared %t.o -o /dev/null --fatal-warnings
# RUN: ld.lld --version-script %t.script -shared --undefined-version %t.o -o %t.so
# RUN: not ld.lld --version-script %t.script -shared --no-undefined-version \
# RUN: %t.o -o %t.so 2>&1 | FileCheck -check-prefix=ERR1 %s
Expand Down
2 changes: 1 addition & 1 deletion lld/test/ELF/version-script-reassign.s
Expand Up @@ -24,7 +24,7 @@
# RUN: llvm-readelf --dyn-syms %t.so | FileCheck --check-prefix=V1-SYM %s

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

# LOCAL: warning: attempt to reassign symbol 'foo' of VER_NDX_LOCAL to version 'V1'
Expand Down
13 changes: 6 additions & 7 deletions openmp/libomptarget/plugins/CMakeLists.txt
Expand Up @@ -38,13 +38,12 @@ if(CMAKE_SYSTEM_PROCESSOR MATCHES "${tmachine}$")
${LIBOMPTARGET_INCLUDE_DIR}
${LIBOMPTARGET_DEP_LIBFFI_INCLUDE_DIR}

LINK_LIBS
PRIVATE
elf_common
${LIBOMPTARGET_DEP_LIBFFI_LIBRARIES}
${OPENMP_PTHREAD_LIB}
"-Wl,--version-script=${CMAKE_CURRENT_SOURCE_DIR}/../exports"
"-Wl,--undefined-version"
LINK_LIBS
PRIVATE
elf_common
${LIBOMPTARGET_DEP_LIBFFI_LIBRARIES}
${OPENMP_PTHREAD_LIB}
"-Wl,--version-script=${CMAKE_CURRENT_SOURCE_DIR}/../exports"

NO_INSTALL_RPATH
)
Expand Down
1 change: 0 additions & 1 deletion openmp/libomptarget/plugins/amdgpu/CMakeLists.txt
Expand Up @@ -85,7 +85,6 @@ add_llvm_library(omptarget.rtl.amdgpu SHARED
${LIBOMPTARGET_DEP_LIBRARIES}
${OPENMP_PTHREAD_LIB}
"-Wl,--version-script=${CMAKE_CURRENT_SOURCE_DIR}/../exports"
"-Wl,--undefined-version"
${LDFLAGS_UNDEFINED}

NO_INSTALL_RPATH
Expand Down
2 changes: 0 additions & 2 deletions openmp/libomptarget/plugins/cuda/CMakeLists.txt
Expand Up @@ -55,7 +55,6 @@ if (LIBOMPTARGET_CAN_LINK_LIBCUDA AND NOT LIBOMPTARGET_FORCE_DLOPEN_LIBCUDA)
${LIBOMPTARGET_DEP_CUDA_DRIVER_LIBRARIES}
${OPENMP_PTHREAD_LIB}
"-Wl,--version-script=${CMAKE_CURRENT_SOURCE_DIR}/../exports"
"-Wl,--undefined-version"
"-Wl,-z,defs"

NO_INSTALL_RPATH
Expand All @@ -78,7 +77,6 @@ else()
MemoryManager
${OPENMP_PTHREAD_LIB}
"-Wl,--version-script=${CMAKE_CURRENT_SOURCE_DIR}/../exports"
"-Wl,--undefined-version"
"-Wl,-z,defs"

NO_INSTALL_RPATH
Expand Down
3 changes: 1 addition & 2 deletions openmp/libomptarget/plugins/remote/server/CMakeLists.txt
Expand Up @@ -29,5 +29,4 @@ target_link_libraries(openmp-offloading-server
absl::synchronization
${OPENMP_PTHREAD_LIB}
omp
"-Wl,--version-script=${CMAKE_CURRENT_SOURCE_DIR}/../../exports"
"-Wl,--undefined-version")
"-Wl,--version-script=${CMAKE_CURRENT_SOURCE_DIR}/../../exports")
3 changes: 1 addition & 2 deletions openmp/libomptarget/plugins/remote/src/CMakeLists.txt
Expand Up @@ -37,8 +37,7 @@ target_link_libraries(omptarget.rtl.rpc
absl::synchronization
${OPENMP_PTHREAD_LIB}
omp
"-Wl,--version-script=${CMAKE_CURRENT_SOURCE_DIR}/../../exports"
"-Wl,--undefined-version")
"-Wl,--version-script=${CMAKE_CURRENT_SOURCE_DIR}/../../exports")

# Report to the parent scope that we are building a plugin for RPC.
set(LIBOMPTARGET_SYSTEM_TARGETS "${LIBOMPTARGET_SYSTEM_TARGETS} rpc" PARENT_SCOPE)
4 changes: 1 addition & 3 deletions openmp/libomptarget/plugins/ve/CMakeLists.txt
Expand Up @@ -37,7 +37,6 @@ if(${LIBOMPTARGET_DEP_VEO_FOUND})
${LIBOMPTARGET_DEP_LIBFFI_LIBRARIES}
${additional_libs}
"-Wl,--version-script=${CMAKE_CURRENT_SOURCE_DIR}/../exports -Wl,-z,defs"
"-Wl,--undefined-version"

NO_INSTALL_RPATH
)
Expand All @@ -56,8 +55,7 @@ if(${LIBOMPTARGET_DEP_VEO_FOUND})
elf_common
${LIBOMPTARGET_DEP_LIBFFI_LIBRARIES}
${additional_libs}
"-Wl,--version-script=${CMAKE_CURRENT_SOURCE_DIR}/../exports -Wl,-z,defs"
"-Wl,--undefined-version")
"-Wl,--version-script=${CMAKE_CURRENT_SOURCE_DIR}/../exports -Wl,-z,defs")

# Report to the parent scope that we are building a plugin.
set(LIBOMPTARGET_SYSTEM_TARGETS
Expand Down
2 changes: 1 addition & 1 deletion openmp/runtime/cmake/LibompHandleFlags.cmake
Expand Up @@ -99,7 +99,7 @@ function(libomp_get_ldflags ldflags)
IF_DEFINED CMAKE_C_OSX_COMPATIBILITY_VERSION_FLAG)
libomp_append(ldflags_local -Wl,--warn-shared-textrel LIBOMP_HAVE_WARN_SHARED_TEXTREL_FLAG)
libomp_append(ldflags_local -Wl,--as-needed LIBOMP_HAVE_AS_NEEDED_FLAG)
libomp_append(ldflags_local "-Wl,--version-script=${LIBOMP_SRC_DIR}/exports_so.txt -Wl,--undefined-version" LIBOMP_HAVE_VERSION_SCRIPT_FLAG)
libomp_append(ldflags_local "-Wl,--version-script=${LIBOMP_SRC_DIR}/exports_so.txt" LIBOMP_HAVE_VERSION_SCRIPT_FLAG)
libomp_append(ldflags_local -static-libgcc LIBOMP_HAVE_STATIC_LIBGCC_FLAG)
libomp_append(ldflags_local -Wl,-z,noexecstack LIBOMP_HAVE_Z_NOEXECSTACK_FLAG)
libomp_append(ldflags_local -no-intel-extensions LIBOMP_HAVE_NO_INTEL_EXTENSIONS_FLAG)
Expand Down
4 changes: 2 additions & 2 deletions openmp/runtime/cmake/config-ix.cmake
Expand Up @@ -34,7 +34,7 @@ function(libomp_check_version_symbols retval)
}")
set(version_script_source "VER1 { }; VER2 { } VER1;")
file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/__version_script.txt "${version_script_source}")
set(CMAKE_REQUIRED_FLAGS "-Wl,--version-script=${CMAKE_CURRENT_BINARY_DIR}/__version_script.txt -Wl,--undefined-version")
set(CMAKE_REQUIRED_FLAGS -Wl,--version-script=${CMAKE_CURRENT_BINARY_DIR}/__version_script.txt)
check_c_source_compiles("${source_code}" ${retval})
set(${retval} ${${retval}} PARENT_SCOPE)
file(REMOVE ${CMAKE_CURRENT_BINARY_DIR}/__version_script.txt)
Expand Down Expand Up @@ -132,7 +132,7 @@ elseif(NOT APPLE)
libomp_check_linker_flag(-Wl,-x LIBOMP_HAVE_X_FLAG)
libomp_check_linker_flag(-Wl,--warn-shared-textrel LIBOMP_HAVE_WARN_SHARED_TEXTREL_FLAG)
libomp_check_linker_flag(-Wl,--as-needed LIBOMP_HAVE_AS_NEEDED_FLAG)
libomp_check_linker_flag("-Wl,--version-script=${LIBOMP_SRC_DIR}/exports_so.txt -Wl,--undefined-version" LIBOMP_HAVE_VERSION_SCRIPT_FLAG)
libomp_check_linker_flag("-Wl,--version-script=${LIBOMP_SRC_DIR}/exports_so.txt" LIBOMP_HAVE_VERSION_SCRIPT_FLAG)
libomp_check_linker_flag(-static-libgcc LIBOMP_HAVE_STATIC_LIBGCC_FLAG)
libomp_check_linker_flag(-Wl,-z,noexecstack LIBOMP_HAVE_Z_NOEXECSTACK_FLAG)
endif()
Expand Down

0 comments on commit 88da0de

Please sign in to comment.