check for span in libstdc++ rather than libc++ on linux

This commit is contained in:
Henrik G. Olsson
2025-10-17 16:53:38 -07:00
parent c844d483ff
commit a5f9ec1d87

View File

@@ -44,18 +44,23 @@ else:
config.substitutions.insert(0, ('%target-abi', 'SYSV'))
config.substitutions.insert(0, ('%target-swift-flags', ''))
# target_sdk_libcxx_path is empty when targeting non-Darwin platforms
config.target_libcxx_path = config.target_sdk_libcxx_path
if get_target_os() in ['linux-gnu']:
for p in ['/usr/include/c++/v1', '/usr/local/include/c++/v1']:
if os.path.exists(p) or os.path.exists(p):
config.available_features.add('system_wide_libcxx')
config.target_libcxx_path = p
if os.path.exists('/usr/include/c++/v1') or os.path.exists('/usr/local/include/c++/v1'):
config.available_features.add('system_wide_libcxx')
if config.target_libcxx_path != '':
if config.target_sdk_libcxx_path != '':
if os.path.exists(os.path.join(config.target_sdk_libcxx_path, "span")):
config.available_features.add('std_span')
elif get_target_os() in ['linux-gnu']:
for p in ['/usr/include/c++/', '/usr/local/include/c++/']:
if not os.path.isdir(p):
continue
for subdir in os.listdir(p):
if not subdir.isdigit():
# skip paths libc++ paths like /usr/include/c++/v1, we want libstdc++ paths only (like /usr/include/c++/13)
continue
if os.path.exists(os.path.join(p, subdir, "span")):
config.available_features.add('std_span')
elif get_target_os() in ['windows-msvc']:
# We don't test on any versions of MSVC without std::span support.
# FIXME: figure out where to do lookup for C++ stdlib headers on Windows - we'll probably need it eventually