From 67af0eac9c68a1ecab3ddd6efb2c23fdb0505410 Mon Sep 17 00:00:00 2001 From: Wenju He Date: Tue, 7 Jul 2026 03:22:37 -0700 Subject: [PATCH] [SYCL][Test] Disable 2 failing tests on old libstdc++ via lit features Both tests fail on RHEL 8.8/gcc 8.5. Add feature detection to sycl/test/lit.cfg.py, probing the predefined macros of the toolchain in use (modeled on libcxx's compilerMacros()): - glibcxx-ge-11: from _GLIBCXX_RELEASE, for device_only_no_iostream.cpp, whose root cause is pulling in on older libstdc++. - cpp_lib_span: from __cpp_lib_span with -std=c++20, for negative_test.cpp, whose root cause is being unavailable on older libstdc++, not a C++20 language-mode issue. CMPLRLLVM-76646 Co-authored-by: Claude Sonnet 5 --- .../basic_tests/device_only_no_iostream.cpp | 2 ++ .../negative_test.cpp | 1 + sycl/test/lit.cfg.py | 32 +++++++++++++++++++ 3 files changed, 35 insertions(+) diff --git a/sycl/test/basic_tests/device_only_no_iostream.cpp b/sycl/test/basic_tests/device_only_no_iostream.cpp index afb12ab00ed17..484569c4a7740 100644 --- a/sycl/test/basic_tests/device_only_no_iostream.cpp +++ b/sycl/test/basic_tests/device_only_no_iostream.cpp @@ -26,6 +26,8 @@ // Filesystem transitively pulls in iostream, so we intentionally exclude // sycl.hpp from this test. // +// UNSUPPORTED: linux && !glibcxx-ge-11 +// // RUN: %clangxx -fsycl -fsycl-device-only -include %S/Inputs/khr_all.hpp \ // RUN: -c %s -o %t.o -MD -MF - | FileCheck %s // diff --git a/sycl/test/extensions/DeviceImageBackendContent/negative_test.cpp b/sycl/test/extensions/DeviceImageBackendContent/negative_test.cpp index a5fb0476830a7..eb4f526c369cf 100644 --- a/sycl/test/extensions/DeviceImageBackendContent/negative_test.cpp +++ b/sycl/test/extensions/DeviceImageBackendContent/negative_test.cpp @@ -1,4 +1,5 @@ // RUN: %clang -fsycl -fsyntax-only -std=c++20 -Xclang -verify -Xclang -verify-ignore-unexpected=note,warning %s +// UNSUPPORTED: linux && !cpp_lib_span #include #include diff --git a/sycl/test/lit.cfg.py b/sycl/test/lit.cfg.py index 6d723460c14dd..36cd6ee65489c 100644 --- a/sycl/test/lit.cfg.py +++ b/sycl/test/lit.cfg.py @@ -198,6 +198,38 @@ if not dump_only_tests: llvm_config.use_clang(additional_flags=additional_flags) + # Detect libstdc++ behavior that %clangxx picks up on this host, so tests + # can be gated on actual libstdc++ properties instead of a nonexistent + # "gcc11"-style feature. Modeled after libcxx's compilerMacros() in + # libcxx/utils/libcxx/test/dsl.py. + def get_predefined_macros(include, std=None): + probe = tempfile.NamedTemporaryFile(suffix=".cpp", delete=False) + try: + probe.write(("#include <%s>\n" % include).encode()) + probe.close() + cmd = [config.clang, "-dM", "-E", probe.name] + if std: + cmd.insert(1, "-std=%s" % std) + return subprocess.check_output(cmd, stderr=subprocess.DEVNULL).decode() + except (subprocess.CalledProcessError, OSError): + return "" + finally: + os.unlink(probe.name) + + if platform.system() == "Linux": + match = re.search( + r"#define _GLIBCXX_RELEASE (\d+)", get_predefined_macros("version") + ) + if match and int(match.group(1)) >= 11: + config.available_features.add("glibcxx-ge-11") + + # negative_test.cpp expects __cpp_lib_span-gated diagnostics; older + # libstdc++ versions don't provide , so __cpp_lib_span stays + # undefined even with -std=c++20 and the expected-error annotations + # under "#ifdef __cpp_lib_span" never get compiled in. + if "#define __cpp_lib_span" in get_predefined_macros("span", std="c++20"): + config.available_features.add("cpp_lib_span") + # Set timeout for test = 10 mins try: import psutil