From 9d55436710b4b40ee4083696ec0f0109f43086b5 Mon Sep 17 00:00:00 2001 From: Ramon Asuncion Date: Sat, 6 Dec 2025 03:15:17 -0500 Subject: [PATCH 1/4] [Test][Embedded] Make dependencies print compatible with lit shell --- test/embedded/dependencies-print.swift | 32 ++++++++++++++++++-------- 1 file changed, 23 insertions(+), 9 deletions(-) diff --git a/test/embedded/dependencies-print.swift b/test/embedded/dependencies-print.swift index adaf41c2a6b56..00b4b24b92e26 100644 --- a/test/embedded/dependencies-print.swift +++ b/test/embedded/dependencies-print.swift @@ -1,16 +1,30 @@ // RUN: %empty-directory(%t) -// RUN: %target-swift-frontend -enable-experimental-feature Embedded -no-allocations %s -c -o %t/a.o - -// RUN: grep DEP\: %s | sed 's#// DEP\: ##' | sort > %t/allowed-dependencies.txt - -// Linux/ELF doesn't use the "_" prefix in symbol mangling. -// RUN: if [ %target-os == "linux-gnu" ]; then sed -E -i -e 's/^_(.*)$/\1/' %t/allowed-dependencies.txt; fi +// RUN: split-file %s %t +// RUN: %target-swift-frontend -enable-experimental-feature Embedded -no-allocations %t/test.swift -c -o %t/a.o // RUN: %llvm-nm --undefined-only --format=just-symbols %t/a.o | sort | tee %t/actual-dependencies.txt -// Fail if there is any entry in actual-dependencies.txt that's not in allowed-dependencies.txt -// RUN: test -z "`comm -13 %t/allowed-dependencies.txt %t/actual-dependencies.txt`" - +// RUN: %if target-os-linux-gnu %{ comm -13 %t/allowed-dependencies_linux.txt %t/actual-dependencies.txt > %t/extra.txt && test ! -s %t/extra.txt %} %else %{ comm -13 %t/allowed-dependencies_macos.txt %t/actual-dependencies.txt > %t/extra.txt && test ! -s %t/extra.txt %} + +//--- allowed-dependencies_macos.txt +___stack_chk_fail +___stack_chk_guard +___divti3 +___modti3 +_memmove +_memset +_putchar + +//--- allowed-dependencies_linux.txt +__stack_chk_fail +__stack_chk_guard +__divti3 +__modti3 +memmove +memset +putchar + +//--- test.swift // DEP: ___stack_chk_fail // DEP: ___stack_chk_guard // DEP: ___divti3 From 8ab2294ea054c1df30c16e6350642966ab83cc5b Mon Sep 17 00:00:00 2001 From: Ramon Date: Sun, 7 Dec 2025 03:40:51 -0500 Subject: [PATCH 2/4] [Test][Embedded] Sort allowed-dependencies files to fix comm comparison --- test/embedded/dependencies-print.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/embedded/dependencies-print.swift b/test/embedded/dependencies-print.swift index 00b4b24b92e26..33ef5bf379570 100644 --- a/test/embedded/dependencies-print.swift +++ b/test/embedded/dependencies-print.swift @@ -4,7 +4,7 @@ // RUN: %llvm-nm --undefined-only --format=just-symbols %t/a.o | sort | tee %t/actual-dependencies.txt -// RUN: %if target-os-linux-gnu %{ comm -13 %t/allowed-dependencies_linux.txt %t/actual-dependencies.txt > %t/extra.txt && test ! -s %t/extra.txt %} %else %{ comm -13 %t/allowed-dependencies_macos.txt %t/actual-dependencies.txt > %t/extra.txt && test ! -s %t/extra.txt %} +// RUN: %if target-os-linux-gnu %{ sort %t/allowed-dependencies_linux.txt -o %t/allowed-dependencies_linux.txt && comm -13 %t/allowed-dependencies_linux.txt %t/actual-dependencies.txt > %t/extra.txt && test ! -s %t/extra.txt %} %else %{ sort %t/allowed-dependencies_macos.txt -o %t/allowed-dependencies_macos.txt && comm -13 %t/allowed-dependencies_macos.txt %t/actual-dependencies.txt > %t/extra.txt && test ! -s %t/extra.txt %} //--- allowed-dependencies_macos.txt ___stack_chk_fail From cdfac5d2d6f55b6df6452c642366a6621ecb04d9 Mon Sep 17 00:00:00 2001 From: Ramon Asuncion Date: Sun, 7 Dec 2025 16:35:21 -0500 Subject: [PATCH 3/4] [Test][Embedded] Use lit OS feature (OS=linux-gnu) for conditional --- test/embedded/dependencies-print.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/embedded/dependencies-print.swift b/test/embedded/dependencies-print.swift index 33ef5bf379570..9ad70622b99a9 100644 --- a/test/embedded/dependencies-print.swift +++ b/test/embedded/dependencies-print.swift @@ -4,7 +4,7 @@ // RUN: %llvm-nm --undefined-only --format=just-symbols %t/a.o | sort | tee %t/actual-dependencies.txt -// RUN: %if target-os-linux-gnu %{ sort %t/allowed-dependencies_linux.txt -o %t/allowed-dependencies_linux.txt && comm -13 %t/allowed-dependencies_linux.txt %t/actual-dependencies.txt > %t/extra.txt && test ! -s %t/extra.txt %} %else %{ sort %t/allowed-dependencies_macos.txt -o %t/allowed-dependencies_macos.txt && comm -13 %t/allowed-dependencies_macos.txt %t/actual-dependencies.txt > %t/extra.txt && test ! -s %t/extra.txt %} +// RUN: %if OS=linux-gnu %{ sort %t/allowed-dependencies_linux.txt -o %t/allowed-dependencies_linux.txt && comm -13 %t/allowed-dependencies_linux.txt %t/actual-dependencies.txt > %t/extra.txt && test ! -s %t/extra.txt %} %else %{ sort %t/allowed-dependencies_macos.txt -o %t/allowed-dependencies_macos.txt && comm -13 %t/allowed-dependencies_macos.txt %t/actual-dependencies.txt > %t/extra.txt && test ! -s %t/extra.txt %} //--- allowed-dependencies_macos.txt ___stack_chk_fail From 6ef8fbdd279dc650025f7b6f31e57daa6c8b810f Mon Sep 17 00:00:00 2001 From: Ramon Asuncion Date: Mon, 8 Dec 2025 00:59:30 -0500 Subject: [PATCH 4/4] [Test][Embedded] Use per line %if guards in dependencies-print.swift --- test/embedded/dependencies-print.swift | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/test/embedded/dependencies-print.swift b/test/embedded/dependencies-print.swift index 9ad70622b99a9..31064f38ff142 100644 --- a/test/embedded/dependencies-print.swift +++ b/test/embedded/dependencies-print.swift @@ -4,7 +4,13 @@ // RUN: %llvm-nm --undefined-only --format=just-symbols %t/a.o | sort | tee %t/actual-dependencies.txt -// RUN: %if OS=linux-gnu %{ sort %t/allowed-dependencies_linux.txt -o %t/allowed-dependencies_linux.txt && comm -13 %t/allowed-dependencies_linux.txt %t/actual-dependencies.txt > %t/extra.txt && test ! -s %t/extra.txt %} %else %{ sort %t/allowed-dependencies_macos.txt -o %t/allowed-dependencies_macos.txt && comm -13 %t/allowed-dependencies_macos.txt %t/actual-dependencies.txt > %t/extra.txt && test ! -s %t/extra.txt %} +// RUN: %if OS=linux-gnu %{ sort %t/allowed-dependencies_linux.txt -o %t/allowed-dependencies_linux.txt %} +// RUN: %if OS=linux-gnu %{ comm -13 %t/allowed-dependencies_linux.txt %t/actual-dependencies.txt > %t/extra.txt %} +// RUN: %if OS=linux-gnu %{ test ! -s %t/extra.txt %} + +// RUN: %if OS=macosx %{ sort %t/allowed-dependencies_macos.txt -o %t/allowed-dependencies_macos.txt %} +// RUN: %if OS=macosx %{ comm -13 %t/allowed-dependencies_macos.txt %t/actual-dependencies.txt > %t/extra.txt %} +// RUN: %if OS=macosx %{ test ! -s %t/extra.txt %} //--- allowed-dependencies_macos.txt ___stack_chk_fail