Index: libcxx/test/CMakeLists.txt =================================================================== --- libcxx/test/CMakeLists.txt +++ libcxx/test/CMakeLists.txt @@ -34,6 +34,10 @@ serialize_lit_param(target_triple "\"${LLVM_DEFAULT_TARGET_TRIPLE}\"") endif() +if (CMAKE_SYSROOT) + serialize_lit_param(sysroot "\"${CMAKE_SYSROOT}\"") +endif() + if (LLVM_USE_SANITIZER) serialize_lit_param(use_sanitizer "\"${LLVM_USE_SANITIZER}\"") endif() Index: libcxx/test/configs/llvm-libc++-shared.cfg.in =================================================================== --- libcxx/test/configs/llvm-libc++-shared.cfg.in +++ libcxx/test/configs/llvm-libc++-shared.cfg.in @@ -3,8 +3,10 @@ lit_config.load_config(config, '@CMAKE_CURRENT_BINARY_DIR@/cmake-bridge.cfg') +local_sysroot = '@CMAKE_OSX_SYSROOT@' or '@CMAKE_SYSROOT@' +sysroot_flag = '--sysroot=' if '@CMAKE_SYSROOT@' else '-isysroot ' config.substitutions.append(('%{flags}', - '-pthread' + (' -isysroot {}'.format('@CMAKE_OSX_SYSROOT@') if '@CMAKE_OSX_SYSROOT@' else '') + '-pthread' + (' {}{}'.format(sysroot_flag, local_sysroot) if local_sysroot else '') )) config.substitutions.append(('%{compile_flags}', '-nostdinc++ -I %{include} -I %{target-include} -I %{libcxx}/test/support' Index: libcxx/test/configs/llvm-libc++-static.cfg.in =================================================================== --- libcxx/test/configs/llvm-libc++-static.cfg.in +++ libcxx/test/configs/llvm-libc++-static.cfg.in @@ -3,8 +3,10 @@ lit_config.load_config(config, '@CMAKE_CURRENT_BINARY_DIR@/cmake-bridge.cfg') +local_sysroot = '@CMAKE_OSX_SYSROOT@' or '@CMAKE_SYSROOT@' +sysroot_flag = '--sysroot=' if '@CMAKE_SYSROOT@' else '-isysroot ' config.substitutions.append(('%{flags}', - '-pthread' + (' -isysroot {}'.format('@CMAKE_OSX_SYSROOT@') if '@CMAKE_OSX_SYSROOT@' else '') + '-pthread' + (' {}{}'.format(sysroot_flag, local_sysroot) if local_sysroot else '') )) config.substitutions.append(('%{compile_flags}', '-nostdinc++ -I %{include} -I %{target-include} -I %{libcxx}/test/support' Index: libcxx/utils/libcxx/test/params.py =================================================================== --- libcxx/utils/libcxx/test/params.py +++ libcxx/utils/libcxx/test/params.py @@ -316,5 +316,8 @@ AddCompileFlag("-D_LIBCPP_REMOVE_TRANSITIVE_INCLUDES"), ], ), + Parameter(name='sysroot', type=str, default='', + help="sysroot to use", + actions=lambda sysroot: [AddCompileFlag(f"--sysroot={sysroot}")] if sysroot else []), ] # fmt: on Index: libcxxabi/test/CMakeLists.txt =================================================================== --- libcxxabi/test/CMakeLists.txt +++ libcxxabi/test/CMakeLists.txt @@ -53,6 +53,10 @@ serialize_lit_param(target_triple "\"${LLVM_DEFAULT_TARGET_TRIPLE}\"") endif() +if (CMAKE_SYSROOT) + serialize_lit_param(sysroot "\"${CMAKE_SYSROOT}\"") +endif() + foreach(param IN LISTS LIBCXXABI_TEST_PARAMS) string(REGEX REPLACE "(.+)=(.+)" "\\1" name "${param}") string(REGEX REPLACE "(.+)=(.+)" "\\2" value "${param}") Index: libcxxabi/test/configs/llvm-libc++abi-shared.cfg.in =================================================================== --- libcxxabi/test/configs/llvm-libc++abi-shared.cfg.in +++ libcxxabi/test/configs/llvm-libc++abi-shared.cfg.in @@ -3,8 +3,10 @@ lit_config.load_config(config, '@CMAKE_CURRENT_BINARY_DIR@/cmake-bridge.cfg') +local_sysroot = '@CMAKE_OSX_SYSROOT@' or '@CMAKE_SYSROOT@' +sysroot_flag = '--sysroot=' if '@CMAKE_SYSROOT@' else '-isysroot ' config.substitutions.append(('%{flags}', - '-isysroot {}'.format('@CMAKE_OSX_SYSROOT@') if '@CMAKE_OSX_SYSROOT@' else '' + '{}{}'.format(sysroot_flag, local_sysroot) if local_sysroot else '' )) config.substitutions.append(('%{compile_flags}', '-nostdinc++ -I %{include} -I %{cxx-include} -I %{cxx-target-include} %{maybe-include-libunwind} -I %{libcxx}/test/support -I %{libcxx}/src -D_LIBCPP_ENABLE_CXX17_REMOVED_UNEXPECTED_FUNCTIONS' Index: libcxxabi/test/configs/llvm-libc++abi-static.cfg.in =================================================================== --- libcxxabi/test/configs/llvm-libc++abi-static.cfg.in +++ libcxxabi/test/configs/llvm-libc++abi-static.cfg.in @@ -3,8 +3,10 @@ lit_config.load_config(config, '@CMAKE_CURRENT_BINARY_DIR@/cmake-bridge.cfg') +local_sysroot = '@CMAKE_OSX_SYSROOT@' or '@CMAKE_SYSROOT@' +sysroot_flag = '--sysroot=' if '@CMAKE_SYSROOT@' else '-isysroot ' config.substitutions.append(('%{flags}', - '-isysroot {}'.format('@CMAKE_OSX_SYSROOT@') if '@CMAKE_OSX_SYSROOT@' else '' + '{}{}'.format(sysroot_flag, local_sysroot) if local_sysroot else '' )) config.substitutions.append(('%{compile_flags}', '-nostdinc++ -I %{include} -I %{cxx-include} -I %{cxx-target-include} %{maybe-include-libunwind} -I %{libcxx}/test/support -I %{libcxx}/src -D_LIBCPP_ENABLE_CXX17_REMOVED_UNEXPECTED_FUNCTIONS' Index: libunwind/test/configs/llvm-libunwind-merged.cfg.in =================================================================== --- libunwind/test/configs/llvm-libunwind-merged.cfg.in +++ libunwind/test/configs/llvm-libunwind-merged.cfg.in @@ -18,8 +18,9 @@ compile_flags.append('-funwind-tables') local_sysroot = '@CMAKE_OSX_SYSROOT@' or '@CMAKE_SYSROOT@' +sysroot_flag = '--sysroot=' if '@CMAKE_SYSROOT@' else '-isysroot ' config.substitutions.append(('%{flags}', - '-isysroot {}'.format(local_sysroot) if local_sysroot else '' + '{}{}'.format(sysroot_flag, local_sysroot) if local_sysroot else '' )) config.substitutions.append(('%{compile_flags}', '-nostdinc++ -I %{{include}} {}'.format(' '.join(compile_flags)) Index: libunwind/test/configs/llvm-libunwind-shared.cfg.in =================================================================== --- libunwind/test/configs/llvm-libunwind-shared.cfg.in +++ libunwind/test/configs/llvm-libunwind-shared.cfg.in @@ -17,8 +17,9 @@ compile_flags.append('-funwind-tables') local_sysroot = '@CMAKE_OSX_SYSROOT@' or '@CMAKE_SYSROOT@' +sysroot_flag = '--sysroot=' if '@CMAKE_SYSROOT@' else '-isysroot ' config.substitutions.append(('%{flags}', - '-isysroot {}'.format(local_sysroot) if local_sysroot else '' + '{}{}'.format(sysroot_flag, local_sysroot) if local_sysroot else '' )) config.substitutions.append(('%{compile_flags}', '-nostdinc++ -I %{{include}} {}'.format(' '.join(compile_flags)) Index: libunwind/test/configs/llvm-libunwind-static.cfg.in =================================================================== --- libunwind/test/configs/llvm-libunwind-static.cfg.in +++ libunwind/test/configs/llvm-libunwind-static.cfg.in @@ -20,8 +20,9 @@ compile_flags.append('-funwind-tables') local_sysroot = '@CMAKE_OSX_SYSROOT@' or '@CMAKE_SYSROOT@' +sysroot_flag = '--sysroot=' if '@CMAKE_SYSROOT@' else '-isysroot ' config.substitutions.append(('%{flags}', - '-isysroot {}'.format(local_sysroot) if local_sysroot else '' + '{}{}'.format(sysroot_flag, local_sysroot) if local_sysroot else '' )) config.substitutions.append(('%{compile_flags}', '-nostdinc++ -I %{{include}} {}'.format(' '.join(compile_flags))