Skip to content

Commit c844d48

Browse files
committed
[cxx-interop] Add llvm-lit feature 'std_span'
This adds a check in lit.local.cfg for whether the current C++ stdlib contains the 'span' header. If so, the llvm-lit feature 'std_span' is set. Also adds 'REQUIRES: std_span' to interop tests that include 'span'. This means we no longer have to choose between blanket disabling `std::span` tests on all Linux distributions, or listing every Linux distro with a libstdc++ version without `std::span` support as unsupported. I couldn't find any existing path to the MSVC stdlib in lit, and we don't test versions of MSVC old enought to not support std::span anyways, so 'std_span' is unconditionally enabled when targeting windows-msvc. rdar://161999160 rdar://161999174 rdar://162106580 rdar://162106619 rdar://162106643 rdar://162106653 rdar://162106722 rdar://162106747
1 parent cd378b9 commit c844d48

File tree

13 files changed

+27
-9
lines changed

13 files changed

+27
-9
lines changed

test/Interop/Cxx/class/access/swiftify-private-fileid.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
// RUN: %target-swift-frontend -emit-ir -I %swift_src_root/lib/ClangImporter/SwiftBridging -plugin-path %swift-plugin-dir %t/blessed.swift -module-name main -I %t/Inputs -o %t/out -Xcc -std=c++20 -cxx-interoperability-mode=default -enable-experimental-feature SafeInteropWrappers -verify
55

66
// REQUIRES: swift_feature_SafeInteropWrappers
7+
// REQUIRES: std_span
78

89
//--- Inputs/swiftify-non-public.h
910
#pragma once

test/Interop/Cxx/class/safe-interop-mode.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
// REQUIRES: objc_interop
77
// REQUIRES: swift_feature_LifetimeDependence
8+
// REQUIRES: std_span
89

910
//--- Inputs/module.modulemap
1011
module Test {

test/Interop/Cxx/stdlib/std-span-interface.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
// REQUIRES: swift_feature_SafeInteropWrappers
99
// REQUIRES: swift_feature_Lifetimes
10-
// REQUIRES: rdar161999174
10+
// REQUIRES: std_span
1111

1212
#if !BRIDGING_HEADER
1313
import StdSpan

test/Interop/Cxx/stdlib/std-span-transformed-execution.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
// REQUIRES: swift_feature_LifetimeDependence
88

99
// REQUIRES: executable_test
10+
// REQUIRES: std_span
1011

1112
#if !BRIDGING_HEADER
1213
import StdSpan

test/Interop/Cxx/stdlib/use-std-span-typechecker.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
// RUN: %target-typecheck-verify-swift -I %S/Inputs -enable-experimental-cxx-interop -Xcc -std=c++20 2>&1
2+
// REQUIRES: std_span
23

34
import StdSpan
45

test/Interop/Cxx/stdlib/use-std-span.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
// UNSUPPORTED: OS=windows-msvc
66

77
// REQUIRES: executable_test
8+
// REQUIRES: std_span
89

910
import StdlibUnittest
1011
#if !BRIDGING_HEADER

test/Interop/Cxx/swiftify-import/import-as-instance-method.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
// REQUIRES: swift_feature_SafeInteropWrappers
2+
// REQUIRES: std_span
23

34
// RUN: %empty-directory(%t)
45
// RUN: split-file %s %t

test/Interop/Cxx/swiftify-import/span-in-ctor.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
// REQUIRES: swift_feature_SafeInteropWrappers
2+
// REQUIRES: std_span
23

34
// RUN: rm -rf %t
45
// RUN: split-file %s %t

test/Interop/CxxToSwiftToCxx/span/span-execution.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
// RUN: %target-run %t/swift-cxx-execution | %FileCheck %s
1111

1212
// REQUIRES: executable_test
13+
// REQUIRES: std_span
1314

1415
//--- header.h
1516
#include <cstdint>

test/Interop/lit.local.cfg

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,22 @@ else:
4444
config.substitutions.insert(0, ('%target-abi', 'SYSV'))
4545
config.substitutions.insert(0, ('%target-swift-flags', ''))
4646

47+
# target_sdk_libcxx_path is empty when targeting non-Darwin platforms
48+
config.target_libcxx_path = config.target_sdk_libcxx_path
49+
4750
if get_target_os() in ['linux-gnu']:
48-
if os.path.exists('/usr/include/c++/v1') or os.path.exists('/usr/local/include/c++/v1'):
49-
config.available_features.add('system_wide_libcxx')
51+
for p in ['/usr/include/c++/v1', '/usr/local/include/c++/v1']:
52+
if os.path.exists(p) or os.path.exists(p):
53+
config.available_features.add('system_wide_libcxx')
54+
config.target_libcxx_path = p
55+
56+
if config.target_libcxx_path != '':
57+
if os.path.exists(os.path.join(config.target_sdk_libcxx_path, "span")):
58+
config.available_features.add('std_span')
59+
elif get_target_os() in ['windows-msvc']:
60+
# We don't test on any versions of MSVC without std::span support.
61+
# FIXME: figure out where to do lookup for C++ stdlib headers on Windows - we'll probably need it eventually
62+
config.available_features.add('std_span')
5063

5164
# Enable C++ interop when compiling Swift sources.
5265
config.substitutions.insert(0, ('%target-interop-build-swift',

0 commit comments

Comments
 (0)