[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 05:18:47 PDT 2026


eugeneepshteyn wrote:

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.

https://github.com/llvm/llvm-project/pull/217312


More information about the flang-commits mailing list