[Openmp-commits] [PATCH] D93727: [OpenMP] Add using bit flags to select Libomptarget Information

Vyacheslav Zakharin via Phabricator via Openmp-commits openmp-commits at lists.llvm.org
Tue Jan 26 12:03:10 PST 2021


vzakhari added inline comments.


================
Comment at: openmp/libomptarget/include/Debug.h:54-63
+static inline uint32_t getInfoLevel() {
+  static uint32_t InfoLevel = 0;
+  static std::once_flag Flag{};
+  std::call_once(Flag, []() {
+    if (char *EnvStr = getenv("LIBOMPTARGET_INFO"))
+      InfoLevel = std::stoi(EnvStr);
+  });
----------------
Hello.  Am I the only one who is getting `libomptarget.rtl.x86_64.so` build fail with `-DCMAKE_BUILD_TYPE=Debug`?

> ld: CMakeFiles/omptarget.rtl.x86_64.dir/__/generic-elf-64bit/src/rtl.cpp.o: in function `getInfoLevel()::{lambda()#1}::operator()() const':
> .../openmp/libomptarget/include/Debug.h:61: undefined reference to `getInfoLevel()::InfoLevel'
> ld: CMakeFiles/omptarget.rtl.x86_64.dir/__/generic-elf-64bit/src/rtl.cpp.o: relocation R_X86_64_PC32 against undefined symbol `_ZZL12getInfoLevelvE9InfoLevel' can not be used when making a shared object; recompile with -fPIC

Here is a small reproducer:

```
#include <mutex>

static inline uint32_t getInfoLevel() {
  static uint32_t InfoLevel = 0;
  static std::once_flag Flag{};
  std::call_once(Flag, []() {
      InfoLevel = 1;
  });

  return InfoLevel;
}
```

I cannot build a shared library from it using gcc: g++ -fPIC -std=c++14 test.cpp -shared -o test.so


> ld: /tmp/ccBpTXXs.o: relocation R_X86_64_PC32 against undefined symbol `_ZZL12getInfoLevelvE9InfoLevel' can not be used when making a shared object; recompile with -fPIC


The issue is reproducible with GCC 5.5.0 and 6.5.0, and does not reproduce with 7.3.0.  I believe LLVM's minimal requirement is 5.1, so it is a problem.

The issue seems to be caused by the fact that getInfoLevel() is not referenced in `openmp/libomptarget/plugins/generic-elf-64bit/src/rtl.cpp`


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D93727/new/

https://reviews.llvm.org/D93727



More information about the Openmp-commits mailing list