Skip to content

Commit 4746e38

Browse files
committed
[Libomptarget] Fix multiply defined symbol during linking
This patch adds the `weak` identifier to the openmp device environment variable. The changes introduced in https://reviews.llvm.org/D117211 result in multiply defined symbols. Because the symbol is potentially included multiple times for each offloading file we will get symbol colisions, and because it needs to have external visiblity it should be weak. Reviewed By: JonChesterfield Differential Revision: https://reviews.llvm.org/D117231
1 parent bf7d997 commit 4746e38

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

openmp/libomptarget/DeviceRTL/src/Configuration.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ extern uint32_t __omp_rtl_debug_kind; // defined by CGOpenMPRuntimeGPU
2424

2525
// TODO: We want to change the name as soon as the old runtime is gone.
2626
DeviceEnvironmentTy CONSTANT(omptarget_device_environment)
27-
__attribute__((used, retain));
27+
__attribute__((used, retain, weak));
2828

2929
uint32_t config::getDebugKind() {
3030
return __omp_rtl_debug_kind & omptarget_device_environment.DebugKind;

openmp/libomptarget/deviceRTLs/amdgcn/src/target_impl.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ typedef uint64_t __kmpc_impl_lanemask_t;
3232
#define ALIGN(N) __attribute__((aligned(N)))
3333
#define PLUGIN_ACCESSIBLE \
3434
__attribute__((used)) /* Don't discard values the plugin reads */ \
35+
__attribute__((weak)) /* We may have multiple definitions */ \
3536
__attribute__((retain)) /* Also needed to keep values alive */ \
3637
__attribute__((visibility("default"))) /* Access via SHT_HASH */ \
3738
__attribute__((section(".data"))) /* Not .bss, can write before load */

0 commit comments

Comments
 (0)