@@ -48,6 +48,24 @@ if get_target_os() in ['linux-gnu']:
4848 if os.path.exists(' /usr/include/c++/v1' ) or os.path.exists(' /usr/local/include/c++/v1' ):
4949 config.available_features.add(' system_wide_libcxx' )
5050
51+ if config.target_sdk_libcxx_path != ' ' :
52+ if os.path.exists(os.path.join(config.target_sdk_libcxx_path, " span" )):
53+ config.available_features.add(' std_span' )
54+ elif get_target_os() in [' linux-gnu' ]:
55+ for p in [' /usr/include/c++/' , ' /usr/local/include/c++/' ]:
56+ if not os.path.isdir(p):
57+ continue
58+ for subdir in os.listdir(p):
59+ if not subdir.isdigit():
60+ # skip paths libc++ paths like /usr/include/c++/v1, we want libstdc++ paths only (like /usr/include/c++/13)
61+ continue
62+ if os.path.exists(os.path.join(p, subdir, " span" )):
63+ config.available_features.add(' std_span' )
64+ elif get_target_os() in [' windows-msvc' ]:
65+ # We don't test on any versions of MSVC without std::span support.
66+ # FIXME: figure out where to do lookup for C++ stdlib headers on Windows - we'll probably need it eventually
67+ config.available_features.add(' std_span' )
68+
5169# Enable C++ interop when compiling Swift sources.
5270config.substitutions.insert(0, (' %target-interop-build-swift' ,
5371 ' %target-build-swift -cxx-interoperability-mode=default ' ))
0 commit comments