Skip to content

Commit ebeda7d

Browse files
committed
[Test] Update section_asm to work on non-ELF platforms again.
On ELF platforms, the output will be slightly different to non-ELF platforms. The test should ideally run everywhere, however, so we need to be able to distinguish these platforms by changing the lit.cfg to add some extra variables. rdar://123504095
1 parent 5cdf513 commit ebeda7d

File tree

2 files changed

+71
-6
lines changed

2 files changed

+71
-6
lines changed

test/IRGen/section_asm.swift

Lines changed: 31 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,52 @@
1-
// RUN: %target-swift-frontend -enable-experimental-feature SymbolLinkageMarkers -primary-file %S/section.swift -S -parse-as-library | %FileCheck %s
1+
// RUN: %target-swift-frontend -enable-experimental-feature SymbolLinkageMarkers -primary-file %S/section.swift -S -parse-as-library | %FileCheck --check-prefix CHECK%target-os-binfmt-elf %s
2+
23
// REQUIRES: swift_in_compiler
34
// UNSUPPORTED: CPU=wasm32
45

5-
// CHECK: .section{{.*}}"__TEXT,__mysection","ax"
6+
// CHECK: .section{{.*}}__TEXT,__mysection
67
// CHECK-NOT: .section
78
// CHECK: $s7section3fooyyF:
89

9-
// CHECK: .section{{.*}}"__TEXT,__mysection","ax"
10+
// CHECK: .section{{.*}}__TEXT,__mysection
1011
// CHECK-NOT: .section
1112
// CHECK: $s7section8MyStructV3fooyyF:
1213

13-
// CHECK: .section{{.*}}"__DATA,__mysection","aw"
14+
// CHECK: .section{{.*}}__DATA,__mysection
1415
// CHECK-NOT: .section
1516
// CHECK: $s7section2g0Sivp:
1617
// CHECK-NOT: .section
1718
// CHECK: $s7section2g1Si_Sitvp:
1819
// CHECK-NOT: .section
1920
// CHECK: $s7section2g2Sbvp:
20-
// CHECK: .section{{.*}}"__DATA,__mysection","awR"
21+
// CHECK-NOT: .section
2122
// CHECK: $s7section2g3Sbvp:
22-
// CHECK: .section{{.*}}"__DATA,__mysection","aw"
23+
// CHECK-NOT: .section
2324
// CHECK: $s7section2g4SpySiGSgvp:
2425
// CHECK-NOT: .section
2526
// CHECK: $s7section2g5SpySiGSgvp:
2627
// CHECK-NOT: .section
2728
// CHECK: $s7section8MyStructV7static0SivpZ:
29+
30+
// CHECKELF: .section{{.*}}"__TEXT,__mysection","ax"
31+
// CHECKELF-NOT: .section
32+
// CHECKELF: $s7section3fooyyF:
33+
34+
// CHECKELF: .section{{.*}}"__TEXT,__mysection","ax"
35+
// CHECKELF-NOT: .section
36+
// CHECKELF: $s7section8MyStructV3fooyyF:
37+
38+
// CHECKELF: .section{{.*}}"__DATA,__mysection","aw"
39+
// CHECKELF-NOT: .section
40+
// CHECKELF: $s7section2g0Sivp:
41+
// CHECKELF-NOT: .section
42+
// CHECKELF: $s7section2g1Si_Sitvp:
43+
// CHECKELF-NOT: .section
44+
// CHECKELF: $s7section2g2Sbvp:
45+
// CHECKELF: .section{{.*}}"__DATA,__mysection","awR"
46+
// CHECKELF: $s7section2g3Sbvp:
47+
// CHECKELF: .section{{.*}}"__DATA,__mysection","aw"
48+
// CHECKELF: $s7section2g4SpySiGSgvp:
49+
// CHECKELF-NOT: .section
50+
// CHECKELF: $s7section2g5SpySiGSgvp:
51+
// CHECKELF-NOT: .section
52+
// CHECKELF: $s7section8MyStructV7static0SivpZ:

test/lit.cfg

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1027,6 +1027,46 @@ if run_os in (
10271027
):
10281028
target_mandates_stable_abi = "TRUE"
10291029
config.available_features.add('swift_only_stable_abi')
1030+
1031+
if run_os in ('macosx', 'ios', 'maccatalyst', 'tvos', 'watchos', 'xros'):
1032+
target_os_family = 'DARWIN'
1033+
target_os_binfmt = 'MACH-O'
1034+
elif run_os in ('windows-cygnus', 'windows-gnu', 'windows-msvc'):
1035+
target_os_family = 'WINDOWS'
1036+
target_os_binfmt = 'PE-COFF'
1037+
elif run_os in ('linux-gnu', 'linux-gnueabihf', 'linux-android', 'linux-androideabi'):
1038+
target_os_family = 'LINUX'
1039+
target_os_binfmt = 'ELF'
1040+
elif run_os in ('freebsd', 'openbsd'):
1041+
target_os_family = 'BSD'
1042+
target_os_binfmt = 'ELF'
1043+
else:
1044+
target_os_family = 'UNKNOWN'
1045+
target_os_binfmt = 'UNKNOWN'
1046+
1047+
config.available_features.add('OS_FAMILY={}'.format(target_os_family.lower()))
1048+
config.available_features.add('OS_BINFMT={}'.format(target_os_binfmt.lower()))
1049+
1050+
for family in ('DARWIN', 'WINDOWS', 'LINUX', 'BSD', 'UNKNOWN'):
1051+
if family == target_os_family:
1052+
subst = family
1053+
else:
1054+
subst = ""
1055+
config.substitutions.append(
1056+
('%target-os-family-{}'.format(family.lower()), subst)
1057+
)
1058+
config.substitutions.append(('%target-os-family', target_os_family))
1059+
1060+
for binfmt in ('MACH-O', 'PE-COFF', 'ELF', 'UNKNOWN'):
1061+
if binfmt == target_os_binfmt:
1062+
subst = binfmt
1063+
else:
1064+
subst = ""
1065+
config.substitutions.append(
1066+
('%target-os-binfmt-{}'.format(binfmt.lower()), subst)
1067+
)
1068+
config.substitutions.append(('%target-os-binfmt', target_os_binfmt))
1069+
10301070
config.substitutions.append(('%target-os-abi', target_os_abi))
10311071
config.substitutions.append(('%target-os-is-maccatalyst', target_os_is_maccatalyst))
10321072
config.substitutions.append(('%target-mandates-stable-abi',

0 commit comments

Comments
 (0)