Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 23 additions & 9 deletions test/embedded/dependencies-print.swift
Original file line number Diff line number Diff line change
@@ -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 %{ 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
___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
Expand Down