Skip to content

Commit 342dea8

Browse files
committed
[Interop][testing] Use libc++ from target Darwin SDK for clang check invocations
1 parent 0312e06 commit 342dea8

File tree

1 file changed

+41
-34
lines changed

1 file changed

+41
-34
lines changed

test/lit.cfg

Lines changed: 41 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -574,40 +574,6 @@ config.substitutions.append( ('%clang',
574574
"%r %s" %
575575
(config.clang, clang_mcp_opt)) )
576576

577-
extraCheckWarningFlags = (
578-
# Turn on all warnings and promote them to errors
579-
'-Weverything -Werror '
580-
# Don't warn about unused macros in our clang header.
581-
'-Wno-unused-macros '
582-
# Don't warn about module imports used at #includes.
583-
'-Wno-incomplete-module -Wno-auto-import '
584-
# Don't warn about any variadic macros we might have.
585-
'-Wno-variadic-macros '
586-
# Don't warn about any C++98 compatibility issues.
587-
'-Wno-c++98-compat-pedantic '
588-
# Don't warn about poison system directories in the Linux system paths.
589-
'-Wno-poison-system-directories '
590-
# For -fmodules-cache-path, when modules are off.
591-
'-Wno-unused-command-line-argument '
592-
# Don't warn about nullability specifiers in C/C++ code.
593-
'-Wno-nullability-extension ')
594-
595-
# Verifies that a C++ file can be compiled without warnings except for some exceptions.
596-
config.substitutions.insert(0, ('%check-c-header-in-clang',
597-
'%clang -fsyntax-only -x c-header ' + extraCheckWarningFlags +
598-
# Use standard header/framework search paths.
599-
'-F %%clang-importer-sdk-path/frameworks '
600-
'-I %%clang-include-dir '
601-
'-isysroot %r/Inputs/clang-importer-sdk' % config.test_source_root) )
602-
603-
# Verifies that a C++ file can be compiled without warnings except for some exceptions.
604-
config.substitutions.insert(0, ('%check-cxx-header-in-clang',
605-
'%clangxx -fsyntax-only -x c++-header ' + extraCheckWarningFlags +
606-
# Use standard header/framework search paths.
607-
'-F %%clang-importer-sdk-path/frameworks '
608-
'-I %%clang-include-dir '
609-
'-isysroot %r/Inputs/clang-importer-sdk' % config.test_source_root) )
610-
611577
###
612578

613579
def disallow(execName):
@@ -984,6 +950,7 @@ config.target_msvc_runtime_opt = ''
984950
config.target_static_library_prefix = 'lib'
985951
config.target_static_library_suffix = '.a'
986952
config.target_env_prefix = ''
953+
config.target_sdk_libcxx_path = ''
987954

988955
if run_vendor == 'apple':
989956
target_specific_module_triple = '{}-apple-{}'.format(
@@ -1000,6 +967,7 @@ if run_vendor == 'apple':
1000967
config.target_codesign = "codesign -f -s -"
1001968
config.target_library_path_var = "DYLD_LIBRARY_PATH"
1002969
config.target_runtime = "objc"
970+
config.target_sdk_libcxx_path = os.path.join(config.variant_sdk, 'usr', 'include', 'c++', 'v1')
1003971

1004972
config.available_features.add('libdispatch')
1005973
config.available_features.add('foundation')
@@ -2297,6 +2265,45 @@ if platform.system() != 'Darwin' or swift_test_mode == 'optimize_none_with_impli
22972265
# When changing substitutions, update docs/Testing.md.
22982266
#
22992267

2268+
if config.target_sdk_libcxx_path != '':
2269+
config.substitutions.append(('%cxx-stdlib-include', '-nostdinc++ -isystem "%s"' % config.target_sdk_libcxx_path))
2270+
else:
2271+
config.substitutions.append(('%cxx-stdlib-include', ''))
2272+
2273+
extraCheckWarningFlags = (
2274+
# Turn on all warnings and promote them to errors
2275+
'-Weverything -Werror '
2276+
# Don't warn about unused macros in our clang header.
2277+
'-Wno-unused-macros '
2278+
# Don't warn about module imports used at #includes.
2279+
'-Wno-incomplete-module -Wno-auto-import '
2280+
# Don't warn about any variadic macros we might have.
2281+
'-Wno-variadic-macros '
2282+
# Don't warn about any C++98 compatibility issues.
2283+
'-Wno-c++98-compat-pedantic '
2284+
# Don't warn about poison system directories in the Linux system paths.
2285+
'-Wno-poison-system-directories '
2286+
# For -fmodules-cache-path, when modules are off.
2287+
'-Wno-unused-command-line-argument '
2288+
# Don't warn about nullability specifiers in C/C++ code.
2289+
'-Wno-nullability-extension ')
2290+
2291+
# Verifies that a C++ file can be compiled without warnings except for some exceptions.
2292+
config.substitutions.insert(0, ('%check-c-header-in-clang',
2293+
'%clang -fsyntax-only -x c-header ' + extraCheckWarningFlags +
2294+
# Use standard header/framework search paths.
2295+
'-F %%clang-importer-sdk-path/frameworks '
2296+
'-I %%clang-include-dir '
2297+
'-isysroot %r/Inputs/clang-importer-sdk' % config.test_source_root) )
2298+
2299+
# Verifies that a C++ file can be compiled without warnings except for some exceptions.
2300+
config.substitutions.insert(0, ('%check-cxx-header-in-clang',
2301+
'%clangxx -fsyntax-only -x c++-header ' + extraCheckWarningFlags +
2302+
# Use standard header/framework search paths.
2303+
'-F %%clang-importer-sdk-path/frameworks '
2304+
'-I %%clang-include-dir %%cxx-stdlib-include '
2305+
'-isysroot %r/Inputs/clang-importer-sdk' % config.test_source_root) )
2306+
23002307
# Different OS's require different prefixes for the environment variables to be
23012308
# propagated to the calling contexts.
23022309
# In order to make tests OS-agnostic, names of environment variables should be

0 commit comments

Comments
 (0)