Skip to content

Conversation

Meinersbur
Copy link
Member

@Meinersbur Meinersbur commented Aug 26, 2025

In contrast to linking a static library, when linking a shared library all referenced symbols must be available in either the objects files, static libraries, or shared libraries passed to the linker command line and cannot be deferred to when building the executable.

We have buildbots that build with BUILD_SHARED_LIBS=ON such that new link symbol dependencies (e.g. by a new call of a non-inlined function from a header of another component) are detected post-commit, but we don't seem to have any for Flang, which means such build breakages may go unnoticed.

Fixes #150027

Same fix as included in #152223, but with only the changes necessary to fix #150027 (which is unrelated with GCC 15)

@llvmbot llvmbot added flang Flang issues not falling into any other category flang:fir-hlfir labels Aug 26, 2025
@llvmbot
Copy link
Member

llvmbot commented Aug 26, 2025

@llvm/pr-subscribers-flang-fir-hlfir

Author: Michael Kruse (Meinersbur)

Changes

In contrast to linking a static library, when linking a shared library all referenced symbols must be available in either the objects files, static libraries, or shared libraries passed to the linker command line and cannot be deferred to when building the executable.

We have buildbots that build with BUILD_SHARED_LIBS=ON such that new link symbol dependencies (e.g. by a new call of a non-inlined function from a header of another component) are detected post-commit, but we don't seem to have any for Flang, which means such build breakages may go unnoticed.

Fixes #150027

Same fix as included #152223, but with only the changes necessary to fix #150027.


Full diff: https://github.com/llvm/llvm-project/pull/155422.diff

2 Files Affected:

  • (modified) flang/lib/Optimizer/Builder/CMakeLists.txt (+1)
  • (modified) flang/lib/Optimizer/HLFIR/Transforms/CMakeLists.txt (+2)
diff --git a/flang/lib/Optimizer/Builder/CMakeLists.txt b/flang/lib/Optimizer/Builder/CMakeLists.txt
index 8fb36a750d433..404afd185fd31 100644
--- a/flang/lib/Optimizer/Builder/CMakeLists.txt
+++ b/flang/lib/Optimizer/Builder/CMakeLists.txt
@@ -50,6 +50,7 @@ add_flang_library(FIRBuilder
   FIRDialectSupport
   FIRSupport
   FortranEvaluate
+  FortranSupport
   HLFIRDialect
 
   MLIR_DEPS
diff --git a/flang/lib/Optimizer/HLFIR/Transforms/CMakeLists.txt b/flang/lib/Optimizer/HLFIR/Transforms/CMakeLists.txt
index cc74273d9c5d9..3775a13e31e95 100644
--- a/flang/lib/Optimizer/HLFIR/Transforms/CMakeLists.txt
+++ b/flang/lib/Optimizer/HLFIR/Transforms/CMakeLists.txt
@@ -27,6 +27,8 @@ add_flang_library(HLFIRTransforms
   FIRSupport
   FIRTransforms
   FlangOpenMPTransforms
+  FortranEvaluate
+  FortranSupport
   HLFIRDialect
 
   LINK_COMPONENTS

Copy link
Contributor

@pawosm-arm pawosm-arm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks like a reapply of something that already worked for us.

@clementval
Copy link
Contributor

We have this one for flang -> https://lab.llvm.org/buildbot/#/builders/80

Copy link
Contributor

@vzakhari vzakhari left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

@Meinersbur
Copy link
Member Author

Meinersbur commented Aug 26, 2025

We have this one for flang -> lab.llvm.org/buildbot#/builders/80

Mmmh, I would have assumed it should be failing then because Fortran::common::die() is not an inlined function that would be inlined in a release build. However, #150027 (comment) already explains why it does not occur in optimized builds.

@Meinersbur Meinersbur merged commit 17a49c4 into llvm:main Aug 26, 2025
12 checks passed
@pawosm-arm
Copy link
Contributor

Is the release/21.x branch also affected?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
flang:fir-hlfir flang Flang issues not falling into any other category
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[flang][regression] Can't build flang, it fails at link time
5 participants