[flang-commits] [flang] [flang][NFC] Fix BUILD_SHARED_LIBS build of FortranUtils (PR #217312)
Eugene Epshteyn via flang-commits
flang-commits at lists.llvm.org
Wed Aug 19 04:55:04 PDT 2026
https://github.com/eugeneepshteyn created https://github.com/llvm/llvm-project/pull/217312
[5ee2778b6072](https://github.com/llvm/llvm-project/commit/5ee2778b60725219579eb6d439e6b250c2ff1f85) ("[flang][OpenMP] Reuse canonical default mapper names for nested mappings", [#212251](https://github.com/llvm/llvm-project/pull/212251)) added calls to `fir::NameUniquer::deconstruct()` and `fir::NameUniquer::doGenerated()` in `flang/lib/Utils/OpenMP.cpp`, but did not add the library defining them, `FIRSupport`, to `FortranUtils`' `LINK_LIBS`.
With `BUILD_SHARED_LIBS=ON`, `libFortranUtils.so` is linked on its own with `-Wl,-z,defs` and fails:
```
FAILED: lib/libFortranUtils.so.24.0git
/usr/bin/ld: tools/flang/lib/Utils/CMakeFiles/FortranUtils.dir/OpenMP.cpp.o:
in function `Fortran::utils::openmp::getCanonicalDefaultDeclareMapperName(fir::RecordType)':
undefined reference to `fir::NameUniquer::deconstruct(llvm::StringRef)'
undefined reference to `fir::NameUniquer::doGenerated(llvm::ArrayRef<llvm::StringRef>,
llvm::ArrayRef<llvm::StringRef>, long, llvm::StringRef)'
collect2: error: ld returned 1 exit status
```
In the default static build those symbols are resolved at the final executable link instead, which is why pre-merge CI did not catch it.
This has been breaking two builders since that commit landed:
* `amdgpu-offload-build-only` — first bad [build 17020](https://lab.llvm.org/buildbot/#/builders/226/builds/17020)
* `amdgpu-offload-ubuntu-22-cmake-build-only` — first bad [build 56575](https://lab.llvm.org/buildbot/#/builders/203/builds/56575)
On builder 203 the preceding revision (`58153681c6fd`, [build 56574](https://lab.llvm.org/buildbot/#/builders/203/builds/56574)) was green.
The equivalent Bazel dependency was already added in [29c2660dc3c6](https://github.com/llvm/llvm-project/commit/29c2660dc3c6) ([#217305](https://github.com/llvm/llvm-project/pull/217305)); this is the CMake half of the same change. Compare [731ba68e800d](https://github.com/llvm/llvm-project/commit/731ba68e800d) ([#157828](https://github.com/llvm/llvm-project/pull/157828)), which fixed the same class of break in this file.
>From d199288fc6962f1a59cffaf47eaeff41a9ba3c66 Mon Sep 17 00:00:00 2001
From: Eugene Epshteyn <eepshteyn at nvidia.com>
Date: Wed, 19 Aug 2026 04:53:59 -0700
Subject: [PATCH] [flang][NFC] Fix BUILD_SHARED_LIBS build of FortranUtils
5ee2778b6072 ("[flang][OpenMP] Reuse canonical default mapper names for
nested mappings") added calls to fir::NameUniquer::deconstruct() and
fir::NameUniquer::doGenerated() in flang/lib/Utils/OpenMP.cpp, but did not
add the library defining them, FIRSupport, to FortranUtils' LINK_LIBS.
With BUILD_SHARED_LIBS=ON, libFortranUtils.so is linked on its own with
-Wl,-z,defs and fails with undefined references to both symbols:
undefined reference to `fir::NameUniquer::deconstruct(llvm::StringRef)'
undefined reference to `fir::NameUniquer::doGenerated(
llvm::ArrayRef<llvm::StringRef>, llvm::ArrayRef<llvm::StringRef>,
long, llvm::StringRef)'
In the default static build the symbols are resolved at the final
executable link instead, which is why pre-merge CI did not catch this.
This has been breaking the amdgpu-offload-build-only and
amdgpu-offload-ubuntu-22-cmake-build-only builders since that commit.
The equivalent Bazel dependency was already added in 29c2660dc3c6.
---
flang/lib/Utils/CMakeLists.txt | 1 +
1 file changed, 1 insertion(+)
diff --git a/flang/lib/Utils/CMakeLists.txt b/flang/lib/Utils/CMakeLists.txt
index 96c037561a8a5..e73c398834da5 100644
--- a/flang/lib/Utils/CMakeLists.txt
+++ b/flang/lib/Utils/CMakeLists.txt
@@ -17,6 +17,7 @@ add_flang_library(FortranUtils
LINK_LIBS
FIRDialect
FIRBuilder
+ FIRSupport
FortranEvaluate
FortranSupport
HLFIRDialect
More information about the flang-commits
mailing list