[libcxx] [llvm] Review/transitive includes more portable (PR #110554)
Louis Dionne via llvm-commits
llvm-commits at lists.llvm.org
Mon Sep 30 11:57:55 PDT 2024
https://github.com/ldionne created https://github.com/llvm/llvm-project/pull/110554
None
>From 78d67e13a83c3a0e899c9a318fe3b8dff647c018 Mon Sep 17 00:00:00 2001
From: Louis Dionne <ldionne.2 at gmail.com>
Date: Mon, 30 Sep 2024 14:51:11 -0400
Subject: [PATCH 1/2] [libc++] Stop using awk in transitive includes test
For some reason, that doesn't work as expected on Github-hosted
runners and in Docker-in-Docker setups.
---
libcxx/test/libcxx/transitive_includes.gen.py | 9 ++---
.../libcxx/transitive_includes/expected.py | 35 +++++++++++++++++++
.../to_csv.py} | 0
3 files changed, 38 insertions(+), 6 deletions(-)
create mode 100755 libcxx/test/libcxx/transitive_includes/expected.py
rename libcxx/test/libcxx/{transitive_includes_to_csv.py => transitive_includes/to_csv.py} (100%)
diff --git a/libcxx/test/libcxx/transitive_includes.gen.py b/libcxx/test/libcxx/transitive_includes.gen.py
index 22075364bf1b79..f9a868128c6c83 100644
--- a/libcxx/test/libcxx/transitive_includes.gen.py
+++ b/libcxx/test/libcxx/transitive_includes.gen.py
@@ -55,7 +55,7 @@
print(
f"""\
-// RUN: %{{python}} %{{libcxx-dir}}/test/libcxx/transitive_includes_to_csv.py {' '.join(all_traces)} > %{{libcxx-dir}}/test/libcxx/transitive_includes/%{{cxx_std}}.csv
+// RUN: %{{python}} %{{libcxx-dir}}/test/libcxx/transitive_includes/to_csv.py {' '.join(all_traces)} > %{{libcxx-dir}}/test/libcxx/transitive_includes/%{{cxx_std}}.csv
"""
)
@@ -64,9 +64,6 @@
if header.endswith(".h"): # Skip C compatibility or detail headers
continue
- # Escape slashes for the awk command below
- escaped_header = header.replace("/", "\\/")
-
print(
f"""\
//--- {header}.sh.cpp
@@ -92,8 +89,8 @@
// RUN: mkdir %t
// RUN: %{{cxx}} %s %{{flags}} %{{compile_flags}} --trace-includes -fshow-skipped-includes --preprocess > /dev/null 2> %t/trace-includes.txt
-// RUN: %{{python}} %{{libcxx-dir}}/test/libcxx/transitive_includes_to_csv.py %t/trace-includes.txt > %t/actual_transitive_includes.csv
-// RUN: cat %{{libcxx-dir}}/test/libcxx/transitive_includes/%{{cxx_std}}.csv | awk '/^{escaped_header} / {{ print }}' > %t/expected_transitive_includes.csv
+// RUN: %{{python}} %{{libcxx-dir}}/test/libcxx/transitive_includes/to_csv.py %t/trace-includes.txt > %t/actual_transitive_includes.csv
+// RUN: %{{python}} %{{libcxx-dir}}/test/libcxx/transitive_includes/expected.py %{{cxx_std}} "{header}" > %t/expected_transitive_includes.csv
// RUN: diff -w %t/expected_transitive_includes.csv %t/actual_transitive_includes.csv
#include <{header}>
"""
diff --git a/libcxx/test/libcxx/transitive_includes/expected.py b/libcxx/test/libcxx/transitive_includes/expected.py
new file mode 100755
index 00000000000000..b2519f36b3974b
--- /dev/null
+++ b/libcxx/test/libcxx/transitive_includes/expected.py
@@ -0,0 +1,35 @@
+#!/usr/bin/env python
+# ===----------------------------------------------------------------------===##
+#
+# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+# See https://llvm.org/LICENSE.txt for license information.
+# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+#
+# ===----------------------------------------------------------------------===##
+
+import argparse
+import os
+
+
+if __name__ == "__main__":
+ parser = argparse.ArgumentParser(
+ description="""Extract the list of expected transitive includes for the given Standard and header.""",
+ )
+ parser.add_argument(
+ "standard",
+ default=None,
+ choices=["cxx03", "cxx11", "cxx14", "cxx20", "cxx23", "cxx26"],
+ )
+ parser.add_argument(
+ "header",
+ default=None,
+ help="The header to extract the expected transitive includes for."
+ )
+ args = parser.parse_args()
+
+ CSV_ROOT = os.path.dirname(__file__)
+ filename = os.path.join(CSV_ROOT, f"{args.standard}.csv")
+ with open(filename, 'r') as f:
+ for line in f.readlines():
+ if line.startswith(args.header + ' '):
+ print(line, end='') # lines already end in newline
diff --git a/libcxx/test/libcxx/transitive_includes_to_csv.py b/libcxx/test/libcxx/transitive_includes/to_csv.py
similarity index 100%
rename from libcxx/test/libcxx/transitive_includes_to_csv.py
rename to libcxx/test/libcxx/transitive_includes/to_csv.py
>From 27370baf43d66b436ede791dcf7d55dc19a0633b Mon Sep 17 00:00:00 2001
From: Louis Dionne <ldionne.2 at gmail.com>
Date: Mon, 30 Sep 2024 14:57:28 -0400
Subject: [PATCH 2/2] TMP: Try running job on Github-hosted runner to surface
the issue
---
.github/workflows/libcxx-build-and-test.yaml | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/.github/workflows/libcxx-build-and-test.yaml b/.github/workflows/libcxx-build-and-test.yaml
index b5e60781e00064..831db85ca8e5c2 100644
--- a/.github/workflows/libcxx-build-and-test.yaml
+++ b/.github/workflows/libcxx-build-and-test.yaml
@@ -49,7 +49,9 @@ env:
jobs:
stage1:
if: github.repository_owner == 'llvm'
- runs-on: libcxx-runners-8-set
+ runs-on: ubuntu-latest
+ container:
+ image: ghcr.io/libcxx/actions-builder:fozzie-live
continue-on-error: false
strategy:
fail-fast: false
More information about the llvm-commits
mailing list