-
Notifications
You must be signed in to change notification settings - Fork 14.9k
Fix Debug Build Using GCC 15 #152223
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix Debug Build Using GCC 15 #152223
Conversation
Thank you for submitting a Pull Request (PR) to the LLVM Project! This PR will be automatically labeled and the relevant teams will be notified. If you wish to, you can add reviewers by using the "Reviewers" section on this page. If this is not working for you, it is probably because you do not have write permissions for the repository. In which case you can instead tag reviewers by name in a comment by using If you have received no comments on your PR for a week, you can request a review by "ping"ing the PR by adding a comment “Ping”. The common courtesy "ping" rate is once a week. Please remember that you are asking for valuable time from other developers. If you have further questions, they may be answered by the LLVM GitHub User Guide. You can also ask questions in a comment on this PR, on the LLVM Discord or on the forums. |
@llvm/pr-subscribers-flang-fir-hlfir Author: Patrick Simmons (linuxrocks123) ChangesFlang currently doesn't build in debug mode on GCC 15 due to missing dynamic libraries in some CMakeLists.txt files, and OpenMP doesn't link in debug mode due to the atomic library pulling in libstdc++ despite an incomplete attempt in the CMakeLists.txt to disable glibcxx assertions. This PR fixes these issues and allows Flang and the OpenMP runtime to build and link on GCC 15 in debug mode. Full diff: https://github.com/llvm/llvm-project/pull/152223.diff 3 Files Affected:
diff --git a/flang/lib/Optimizer/Builder/CMakeLists.txt b/flang/lib/Optimizer/Builder/CMakeLists.txt
index 31ae395805faf..eb4413887e67e 100644
--- a/flang/lib/Optimizer/Builder/CMakeLists.txt
+++ b/flang/lib/Optimizer/Builder/CMakeLists.txt
@@ -49,6 +49,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
diff --git a/openmp/runtime/src/CMakeLists.txt b/openmp/runtime/src/CMakeLists.txt
index 569061c6494b8..9a2d490bdd65d 100644
--- a/openmp/runtime/src/CMakeLists.txt
+++ b/openmp/runtime/src/CMakeLists.txt
@@ -168,7 +168,7 @@ endif()
# Disable libstdc++ assertions, even in an LLVM_ENABLE_ASSERTIONS build, to
# avoid an unwanted dependency on libstdc++.so.
if(NOT WIN32)
- add_definitions(-U_GLIBCXX_ASSERTIONS)
+ add_definitions(-U_GLIBCXX_ASSERTIONS -D_GLIBCXX_NO_ASSERTIONS)
endif()
# Add the OpenMP library
|
@LU-JOHN do you mind reviewing? |
Flang changes look good to me. Thanks! |
Looks good. |
…d std::exception symbols
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, but with a grain of salt, as I'm not /the/ expert on build system issues.
@linuxrocks123 Congratulations on having your first Pull Request (PR) merged into the LLVM Project! Your changes will be combined with recent changes from other authors, then tested by our build bots. If there is a problem with a build, you may receive a report in an email or a comment on this PR. Please check whether problems have been caused by your change specifically, as the builds can include changes from many authors. It is not uncommon for your change to be included in a build that fails due to someone else's changes, or infrastructure issues. How to do this, and the rest of the post-merge process, is covered in detail here. If your change does cause a problem, it may be reverted, or you can revert it yourself. This is a normal part of LLVM development. You can fix your changes and open a new PR to merge them again. If you don't get any reports, no action is required from you. Your changes are working as expected, well done! |
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/10/builds/11941 Here is the relevant piece of the build log for the reference
|
Don't add this option by default as it will expose backend errors when building for the AMDGPU:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be good if you could have explained which change fixes which gcc 15 error. If you would like to fix multiple unrelated build problems, consider multiple PRs.
add_definitions(-U_GLIBCXX_ASSERTIONS -D_GLIBCXX_NO_ASSERTIONS) | ||
add_compile_options($<$<COMPILE_LANGUAGE:CXX>:-fno-exceptions>) | ||
add_compile_options($<$<COMPILE_LANGUAGE:CXX>:-O2>) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
-U_GLIBCXX_ASSERTIONS
and-fno-exceptions
are already added in AddFlangRT.cmake._GLIBCXX_NO_ASSERTIONS
should not be necessary, but could be an alternative to-U_GLIBCXX_ASSERTIONS
- We prefer modern CMake style
- Adding
-O2
overrides the choice ofCMAKE_BUILD_TYPE
. What optimization level to use should be left to the user.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Re 2: A suggested alternative syntax would be helpful in understanding what you are suggesting.
Re 3: I don't like forcing -O2
either, but I don't see an alternative to making the DCE happen that's necessary to get rid of the offending undefined symbol.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
target_compile_options
and target_compile_definitions
. See AddFlangRT.cmake. _GLIBCXX_ASSERTIONS
and -fno-exceptions
are already handled there. If there are any issus with those, it should be fixed in AddFlangRT.cmake
, not here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Meinersbur after checking again, I can verify that -fno-exceptions
is present in compile_commands.json
in the current master, so there's no need for a line adding it in this PR. -O2
must still be added, or else the build succeeds but the Fortran compiler cannot create executables because its runtime library has an undefined symbol.
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. Fixes #150027 Same fix as included in #152223, but with only the changes necessary to fix #150027 (which is unrelated to GCC 15)
Since GCC 15.1, libstdc++ enabled assertions/hardening by default in non-optimized (-O0) builds [1]. That is, _GLIBCXX_ASSERTIONS is defined in the libstdc++ headers itself so defining/undefining it on the compiler command line no longer has an effect in non-optimized builds. As the commit message[2] suggests, define _GLIBCXX_NO_ASSERTIONS instead. For libstdc++ headers before 15.1, -U_GLIBCXX_ASSERTIONS still has to be on the command line as well. Defining _GLIBCXX_NO_ASSERTIONS was previously proposed in #152223 [1] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112808 [2] gcc-mirror/gcc@361d230
Flang currently doesn't build in debug mode on GCC 15 due to missing dynamic libraries in some CMakeLists.txt files, and OpenMP doesn't link in debug mode due to the atomic library pulling in libstdc++ despite an incomplete attempt in the CMakeLists.txt to disable glibcxx assertions. This PR fixes these issues and allows Flang and the OpenMP runtime to build and link on GCC 15 in debug mode.