Skip to content

Commit e712900

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 baf2f43 commit e712900

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
@@ -1032,6 +1032,46 @@ if run_os in (
10321032
):
10331033
target_mandates_stable_abi = "TRUE"
10341034
config.available_features.add('swift_only_stable_abi')
1035+
1036+
if run_os in ('macosx', 'ios', 'maccatalyst', 'tvos', 'watchos', 'xros'):
1037+
target_os_family = 'DARWIN'
1038+
target_os_binfmt = 'MACH-O'
1039+
elif run_os in ('windows-cygnus', 'windows-gnu', 'windows-msvc'):
1040+
target_os_family = 'WINDOWS'
1041+
target_os_binfmt = 'PE-COFF'
1042+
elif run_os in ('linux-gnu', 'linux-gnueabihf', 'linux-android', 'linux-androideabi'):
1043+
target_os_family = 'LINUX'
1044+
target_os_binfmt = 'ELF'
1045+
elif run_os in ('freebsd', 'openbsd'):
1046+
target_os_family = 'BSD'
1047+
target_os_binfmt = 'ELF'
1048+
else:
1049+
target_os_family = 'UNKNOWN'
1050+
target_os_binfmt = 'UNKNOWN'
1051+
1052+
config.available_features.add('OS_FAMILY={}'.format(target_os_family.lower()))
1053+
config.available_features.add('OS_BINFMT={}'.format(target_os_binfmt.lower()))
1054+
1055+
for family in ('DARWIN', 'WINDOWS', 'LINUX', 'BSD', 'UNKNOWN'):
1056+
if family == target_os_family:
1057+
subst = family
1058+
else:
1059+
subst = ""
1060+
config.substitutions.append(
1061+
('%target-os-family-{}'.format(family.lower()), subst)
1062+
)
1063+
config.substitutions.append(('%target-os-family', target_os_family))
1064+
1065+
for binfmt in ('MACH-O', 'PE-COFF', 'ELF', 'UNKNOWN'):
1066+
if binfmt == target_os_binfmt:
1067+
subst = binfmt
1068+
else:
1069+
subst = ""
1070+
config.substitutions.append(
1071+
('%target-os-binfmt-{}'.format(binfmt.lower()), subst)
1072+
)
1073+
config.substitutions.append(('%target-os-binfmt', target_os_binfmt))
1074+
10351075
config.substitutions.append(('%target-os-abi', target_os_abi))
10361076
config.substitutions.append(('%target-os-is-maccatalyst', target_os_is_maccatalyst))
10371077
config.substitutions.append(('%target-mandates-stable-abi',

0 commit comments

Comments
 (0)