Skip to content

Conversation

nikic
Copy link
Contributor

@nikic nikic commented Sep 24, 2025

libstdc++15 makes use of an unroll pragma inside std::find_if(). This produces a warning if clang fails to unroll the loop. As this pragma is outside of our control, suppress the warning. Missed transforms are not something we care about in this context.

Related to #157666.

@nikic nikic requested a review from joker-eph September 24, 2025 08:57
@llvmbot llvmbot added the mlir label Sep 24, 2025
@llvmbot
Copy link
Member

llvmbot commented Sep 24, 2025

@llvm/pr-subscribers-mlir

Author: Nikita Popov (nikic)

Changes

libstdc++15 makes use of an unroll pragma inside std::find_if(). This produces a warning if clang fails to unroll the loop. As this pragma is outside of our control, suppress the warning. Missed transforms are not something we care about in this context.

Fixes #157666.


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

1 Files Affected:

  • (modified) mlir/CMakeLists.txt (+6)
diff --git a/mlir/CMakeLists.txt b/mlir/CMakeLists.txt
index 1a211f5495764..da340c4e36784 100644
--- a/mlir/CMakeLists.txt
+++ b/mlir/CMakeLists.txt
@@ -110,6 +110,12 @@ if(CMAKE_CXX_COMPILER_ID MATCHES "GNU")
   endif()
 endif()
 
+# libstdc++15 makes use of an unroll pragma inside std::find_if(). This
+# produces a warning if clang fails to unroll the loop. As this pragma is
+# outside of our control, suppress the warning.
+check_cxx_compiler_flag("-Wno-pass-failed" CXX_SUPPORTS_WNO_PASS_FAILED)
+append_if(CXX_SUPPORTS_WNO_PASS_FAILED "-Wno-pass-failed" CMAKE_CXX_FLAGS)
+
 # Installing the headers and docs needs to depend on generating any public
 # tablegen'd targets.
 # mlir-generic-headers are dialect-independent.

# produces a warning if clang fails to unroll the loop. As this pragma is
# outside of our control, suppress the warning.
check_cxx_compiler_flag("-Wno-pass-failed" CXX_SUPPORTS_WNO_PASS_FAILED)
append_if(CXX_SUPPORTS_WNO_PASS_FAILED "-Wno-pass-failed" CMAKE_CXX_FLAGS)
Copy link
Collaborator

@joker-eph joker-eph Sep 24, 2025

Choose a reason for hiding this comment

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

It's not clear to me why is this the right fix.
This seems like a workaround for a specific version of the toolchain, but doesn't this point out to a problem with the warning itself?
Either the warning should be opt-in (that is: this warning itself is conceptually flawed somehow), or it should be able to maybe not hit on system headers (which I don't see how do implement in a robust way), or just not warn on #pragma unroll (why is it a warning an not an "optimization remark"?) ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Even if the warning itself can be improved (which I'm not the right person to comment on), we still need this workaround, right? I don't want to need to use Clang main to build MLIR. This is currently the only warning when building with Clang 20. It's quite annoying to have to change my LLVM_ENABLE_WERROR configuration and rebuild the world any time I need to touch MLIR for some reason.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Sure, but it should be as narrow as possible. For example can we know in CMake what is the libstdc++ version?

Disabling gcc warnings is fairly common, but we dogfood clang warnings and I don't expect us to ever have to disable a clang warning unconditionally, instead I would think that it would get disabled for clang<20 and we also remove the warning from clang 21.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

To clarify because my previous comment was confusing: This problem still occurs with clang trunk, clang 20 is just what I use locally.

Disabling gcc warnings is fairly common, but we dogfood clang warnings and I don't expect us to ever have to disable a clang warning unconditionally

Why not? Not all warnings are interesting for all projects. Especially as we're starting from a -Wall -Wextra baseline configuration, it is expected that some warnings just aren't relevant for us. From a quick check, at least these Clang warnings are permanently disabled: -Wno-unused-parameter -Wno-long-long -Wno-noexcept-type -Wno-nested-anon-types

I would argue that this warning falls into the same category. Independently of the interaction with libstdc++ 15, this is just fundamentally not a warning we care about. It's something that LLVM runtimes might care about, but not LLVM projects. So I do think it's fine to unconditionally disable it.

Copy link
Collaborator

@joker-eph joker-eph Sep 29, 2025

Choose a reason for hiding this comment

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

Why not? Not all warnings are interesting for all projects.

Clang warnings aren't supposed to have false positive. That is, for -Wall -Wextra, at least when I use to work on clang such warning would be removed from -Wextra and moved to -Weverything.

(also: if this shouldn't be MLIR specific, if this is a warning that the LLVM project wants to disable, I would argue to do it globally)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I agree that this shouldn't really be MLIR specific, I've moved it into LLVM. I've also added a FIXME referencing the issue so we can reconsider disabling this warning once the specific interaction with libstdc++ is resolved.

libstdc++15 makes use of an unroll pragma inside std::find_if(). This
produces a warning if clang fails to unroll the loop. As this pragma is
outside of our control, suppress the warning.
@llvmbot llvmbot added the cmake Build system in general and CMake in particular label Sep 29, 2025
@nikic nikic changed the title [MLIR][CMake] Suppress -Wpass-failed warning [CMake] Suppress -Wpass-failed warning Sep 29, 2025
@nikic
Copy link
Contributor Author

nikic commented Oct 7, 2025

@joker-eph Are you fine with the updated variant?

@joker-eph
Copy link
Collaborator

Sorry I missed the previous update, LG

@nikic nikic merged commit 1ab69d7 into llvm:main Oct 8, 2025
10 checks passed
@nikic nikic deleted the mlir-pass-failed branch October 8, 2025 08:34
@llvm-ci
Copy link
Collaborator

llvm-ci commented Oct 8, 2025

LLVM Buildbot has detected a new failure on builder ppc64le-lld-multistage-test running on ppc64le-lld-multistage-test while building llvm at step 12 "build-stage2-unified-tree".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/168/builds/16549

Here is the relevant piece of the build log for the reference
Step 12 (build-stage2-unified-tree) failure: build (failure) (timed out)
...
-- Performing Test C_WCOMMENT_ALLOWS_LINE_WRAP
-- Performing Test C_WCOMMENT_ALLOWS_LINE_WRAP - Success
-- Performing Test C_SUPPORTS_MISLEADING_INDENTATION_FLAG
-- Performing Test C_SUPPORTS_MISLEADING_INDENTATION_FLAG - Success
-- Performing Test CXX_SUPPORTS_MISLEADING_INDENTATION_FLAG
-- Performing Test CXX_SUPPORTS_MISLEADING_INDENTATION_FLAG - Success
-- Performing Test C_SUPPORTS_CTAD_MAYBE_UNSPPORTED_FLAG
-- Performing Test C_SUPPORTS_CTAD_MAYBE_UNSPPORTED_FLAG - Success
-- Performing Test CXX_SUPPORTS_CTAD_MAYBE_UNSPPORTED_FLAG
-- Performing Test CXX_SUPPORTS_CTAD_MAYBE_UNSPPORTED_FLAG - Success
-- Performing Test C_SUPPORTS_NO_PASS_FAILED_FLAG
-- Performing Test C_SUPPORTS_NO_PASS_FAILED_FLAG - Success
-- Performing Test CXX_SUPPORTS_NO_PASS_FAILED_FLAG
-- Performing Test CXX_SUPPORTS_NO_PASS_FAILED_FLAG - Success
-- Performing Test LINKER_SUPPORTS_COLOR_DIAGNOSTICS
-- Performing Test LINKER_SUPPORTS_COLOR_DIAGNOSTICS - Success
-- Looking for os_signpost_interval_begin
-- Looking for os_signpost_interval_begin - not found
-- Looking for flock
-- Looking for flock - found
-- Linker detection: LLD
-- Performing Test LLVM_LINKER_SUPPORTS_B_SYMBOLIC_FUNCTIONS
-- Performing Test LLVM_LINKER_SUPPORTS_B_SYMBOLIC_FUNCTIONS - Success
-- Performing Test HAS_WERROR_GLOBAL_CTORS
-- Performing Test HAS_WERROR_GLOBAL_CTORS - Success
-- Performing Test LLVM_HAS_NOGLOBAL_CTOR_MUTEX
-- Performing Test LLVM_HAS_NOGLOBAL_CTOR_MUTEX - Success
-- Looking for __x86_64__
-- Looking for __x86_64__ - not found
-- Found Git: /usr/bin/git (found version "2.43.5")
-- Looking for logf128
-- Looking for logf128 - not found
-- Targeting AArch64
-- Targeting AMDGPU
-- Targeting ARM
-- Targeting AVR
-- Targeting BPF
-- Targeting Hexagon
-- Targeting Lanai
-- Targeting LoongArch
-- Targeting Mips
-- Targeting MSP430
-- Targeting NVPTX
-- Targeting PowerPC
-- Targeting RISCV
-- Targeting Sparc
-- Targeting SPIRV
-- Targeting SystemZ
-- Targeting VE

@llvm-ci
Copy link
Collaborator

llvm-ci commented Oct 8, 2025

LLVM Buildbot has detected a new failure on builder clang-ppc64le-linux-test-suite running on ppc64le-clang-test-suite while building llvm at step 6 "test-build-unified-tree-check-all".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/95/builds/18655

Here is the relevant piece of the build log for the reference
Step 6 (test-build-unified-tree-check-all) failure: test (failure)
******************** TEST 'LeakSanitizer-AddressSanitizer-powerpc64le :: TestCases/create_thread_leak.cpp' FAILED ********************
Exit Code: 2

Command Output (stderr):
--
/home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-test-suite/clang-ppc64le-test-suite/build/./bin/clang  --driver-mode=g++ -O0  -m64 -fno-function-sections  -gline-tables-only -fsanitize=address -I/home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-test-suite/clang-ppc64le-test-suite/llvm-project/compiler-rt/test/lsan/../ -pthread /home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-test-suite/clang-ppc64le-test-suite/llvm-project/compiler-rt/test/lsan/TestCases/create_thread_leak.cpp -o /home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-test-suite/clang-ppc64le-test-suite/build/runtimes/runtimes-bins/compiler-rt/test/lsan/POWERPC64LEAsanConfig/TestCases/Output/create_thread_leak.cpp.tmp # RUN: at line 3
+ /home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-test-suite/clang-ppc64le-test-suite/build/./bin/clang --driver-mode=g++ -O0 -m64 -fno-function-sections -gline-tables-only -fsanitize=address -I/home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-test-suite/clang-ppc64le-test-suite/llvm-project/compiler-rt/test/lsan/../ -pthread /home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-test-suite/clang-ppc64le-test-suite/llvm-project/compiler-rt/test/lsan/TestCases/create_thread_leak.cpp -o /home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-test-suite/clang-ppc64le-test-suite/build/runtimes/runtimes-bins/compiler-rt/test/lsan/POWERPC64LEAsanConfig/TestCases/Output/create_thread_leak.cpp.tmp
not  /home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-test-suite/clang-ppc64le-test-suite/build/runtimes/runtimes-bins/compiler-rt/test/lsan/POWERPC64LEAsanConfig/TestCases/Output/create_thread_leak.cpp.tmp 10 1 0 0 2>&1 | FileCheck /home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-test-suite/clang-ppc64le-test-suite/llvm-project/compiler-rt/test/lsan/TestCases/create_thread_leak.cpp --check-prefixes=LEAK,LEAK123 # RUN: at line 4
+ not /home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-test-suite/clang-ppc64le-test-suite/build/runtimes/runtimes-bins/compiler-rt/test/lsan/POWERPC64LEAsanConfig/TestCases/Output/create_thread_leak.cpp.tmp 10 1 0 0
+ FileCheck /home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-test-suite/clang-ppc64le-test-suite/llvm-project/compiler-rt/test/lsan/TestCases/create_thread_leak.cpp --check-prefixes=LEAK,LEAK123
not  /home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-test-suite/clang-ppc64le-test-suite/build/runtimes/runtimes-bins/compiler-rt/test/lsan/POWERPC64LEAsanConfig/TestCases/Output/create_thread_leak.cpp.tmp 10 0 1 0 2>&1 | FileCheck /home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-test-suite/clang-ppc64le-test-suite/llvm-project/compiler-rt/test/lsan/TestCases/create_thread_leak.cpp --check-prefixes=LEAK,LEAK234 # RUN: at line 5
+ not /home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-test-suite/clang-ppc64le-test-suite/build/runtimes/runtimes-bins/compiler-rt/test/lsan/POWERPC64LEAsanConfig/TestCases/Output/create_thread_leak.cpp.tmp 10 0 1 0
+ FileCheck /home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-test-suite/clang-ppc64le-test-suite/llvm-project/compiler-rt/test/lsan/TestCases/create_thread_leak.cpp --check-prefixes=LEAK,LEAK234
not  /home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-test-suite/clang-ppc64le-test-suite/build/runtimes/runtimes-bins/compiler-rt/test/lsan/POWERPC64LEAsanConfig/TestCases/Output/create_thread_leak.cpp.tmp 10 0 0 1 2>&1 | FileCheck /home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-test-suite/clang-ppc64le-test-suite/llvm-project/compiler-rt/test/lsan/TestCases/create_thread_leak.cpp --check-prefixes=LEAK,LEAK234 # RUN: at line 6
+ FileCheck /home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-test-suite/clang-ppc64le-test-suite/llvm-project/compiler-rt/test/lsan/TestCases/create_thread_leak.cpp --check-prefixes=LEAK,LEAK234
+ not /home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-test-suite/clang-ppc64le-test-suite/build/runtimes/runtimes-bins/compiler-rt/test/lsan/POWERPC64LEAsanConfig/TestCases/Output/create_thread_leak.cpp.tmp 10 0 0 1
FileCheck error: '<stdin>' is empty.
FileCheck command line:  FileCheck /home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-test-suite/clang-ppc64le-test-suite/llvm-project/compiler-rt/test/lsan/TestCases/create_thread_leak.cpp --check-prefixes=LEAK,LEAK234

--

********************


Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cmake Build system in general and CMake in particular mlir
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants