-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[cxx-interop] Add infrastructure to build and run tests on multiple targets. #36082
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
zoecarver
wants to merge
2
commits into
swiftlang:main
Choose a base branch
from
zoecarver:cxx/cross-compile-stdlib
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
test/Interop/Cxx/class/destructors-non-trivial-implicit-irgen.swift
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...x/class/inline-function-codegen/constructor-calls-function-from-nested-struct-irgen.swift
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
test/Interop/Cxx/class/inline-function-codegen/constructor-calls-function-irgen.swift
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
test/Interop/Cxx/class/inline-function-codegen/constructor-calls-method-irgen.swift
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
test/Interop/Cxx/class/inline-function-codegen/field-init-calls-function-irgen.swift
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
test/Interop/Cxx/class/inline-function-codegen/method-calls-function-irgen.swift
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...erop/Cxx/class/inline-function-codegen/method-calls-method-from-nested-struct-irgen.swift
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
test/Interop/Cxx/class/inline-function-codegen/method-calls-method-irgen.swift
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
test/Interop/Cxx/class/inline-function-codegen/static-var-init-calls-function-irgen.swift
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
test/Interop/Cxx/class/type-classification-non-trivial-irgen.swift
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
test/Interop/Cxx/templates/linkage-of-swift-symbols-for-imported-types-irgen.swift
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 3 additions & 1 deletion
4
test/Interop/Cxx/templates/partially-pre-defined-class-template-irgen.swift
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
test/Interop/Cxx/value-witness-table/custom-destructors-non-virtual-irgen.swift
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
test/Interop/Cxx/value-witness-table/witness-layout-opts-irgen.swift
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1245,6 +1245,7 @@ NINJA_SOURCE_DIR="${WORKSPACE}/ninja" | |
SWIFT_SOURCE_DIR="${WORKSPACE}/swift" | ||
LLVM_SOURCE_DIR="${WORKSPACE}/llvm-project/llvm" | ||
CMARK_SOURCE_DIR="${WORKSPACE}/cmark" | ||
USWIFT_SOURCE_DIR="${WORKSPACE}/uswift" | ||
LLDB_SOURCE_DIR="${WORKSPACE}/llvm-project/lldb" | ||
LLBUILD_SOURCE_DIR="${WORKSPACE}/llbuild" | ||
STRESSTEST_PACKAGE_DIR="${WORKSPACE}/swift-stress-tester" | ||
|
@@ -1266,6 +1267,7 @@ PRODUCTS=(llvm) | |
[[ "${SKIP_BUILD_LIBCXX}" ]] || PRODUCTS+=(libcxx) | ||
[[ "${SKIP_BUILD_LIBICU}" ]] || PRODUCTS+=(libicu) | ||
[[ "${SKIP_BUILD_SWIFT}" ]] || PRODUCTS+=(swift) | ||
PRODUCTS+=(uswift) | ||
[[ "${SKIP_BUILD_LLDB}" ]] || PRODUCTS+=(lldb) | ||
[[ "${SKIP_BUILD_LIBDISPATCH}" ]] || PRODUCTS+=(libdispatch) | ||
[[ "${SKIP_BUILD_STATIC_LIBDISPATCH}" ]] || PRODUCTS+=(libdispatch_static) | ||
|
@@ -1356,6 +1358,8 @@ function build_directory_bin() { | |
;; | ||
libicu) | ||
;; | ||
uswift) | ||
;; | ||
*) | ||
echo "error: unknown product: ${product}" | ||
exit 1 | ||
|
@@ -1759,6 +1763,91 @@ for host in "${ALL_HOSTS[@]}"; do | |
build_targets=(all) | ||
;; | ||
|
||
uswift) | ||
uswift_targets=( | ||
"macos-arm64" "arm64-apple-macosx10.9" | ||
"macos-x86_64" "x86_64-apple-macosx10.9" | ||
"linux-armv7" "armv7-unknown-linux-androideabi" | ||
"windows-x86_64" "x86_64-unknown-windows-msvc" | ||
) | ||
uswift_targets_length=${#uswift_targets[@]} | ||
|
||
cmake_options=( | ||
"${cmake_options[@]}" | ||
-D BUILD_SHARED_LIBS=NO | ||
-D CMAKE_Swift_COMPILER_WORKS=YES | ||
-D CMAKE_BUILD_TYPE=Release | ||
-D CMAKE_Swift_COMPILER=$(build_directory ${host} swift)/bin/swiftc | ||
) | ||
|
||
# Build uswift for each target. | ||
for (( i=1; i<${uswift_targets_length}+1; i+=2 )); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why? Why not do:
|
||
do | ||
uswift_target_name=${uswift_targets[$i-1]} | ||
uswift_target=${uswift_targets[$i]} | ||
all_cmake_options=( | ||
"${cmake_options[@]}" | ||
-D CMAKE_Swift_COMPILER_TARGET=${uswift_target} | ||
) | ||
|
||
if [[ "$uswift_target_name" == "windows-x86_64" ]] ; then | ||
all_cmake_options=( | ||
"${all_cmake_options[@]}" | ||
-D CMAKE_Swift_FLAGS="-use-ld=$(build_directory ${LOCAL_HOST} llvm)/bin/lld-link" | ||
) | ||
else | ||
all_cmake_options=( | ||
"${all_cmake_options[@]}" | ||
-D CMAKE_Swift_FLAGS="-Xfrontend -disable-legacy-type-info" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why not do this unconditionally? |
||
) | ||
fi | ||
|
||
build_dir=$(build_directory ${uswift_target_name} ${product}) | ||
|
||
generator_output_path="" | ||
if [[ "${CMAKE_GENERATOR}" == "Ninja" ]] ; then | ||
generator_output_path="${build_dir}/build.ninja" | ||
fi | ||
|
||
# Configure if necessary. | ||
cmake_cache_path="${build_dir}/CMakeCache.txt" | ||
if [[ "${RECONFIGURE}" || ! -f "${cmake_cache_path}" || \ | ||
( ! -z "${generator_output_path}" && ! -f "${generator_output_path}" ) ]] ; then | ||
call mkdir -p "${build_dir}" | ||
|
||
# Use `cmake-file-api` in case it is available. | ||
call mkdir -p "${build_dir}/.cmake/api/v1/query" | ||
call touch "${build_dir}/.cmake/api/v1/query/codemodel-v2" "${build_dir}/.cmake/api/v1/query/cache-v2" | ||
|
||
if [[ -n "${DISTCC}" ]]; then | ||
EXTRA_DISTCC_OPTIONS=("DISTCC_HOSTS=localhost,lzo,cpp") | ||
fi | ||
with_pushd "${build_dir}" \ | ||
call env "${EXTRA_DISTCC_OPTIONS[@]}" "${CMAKE}" "${all_cmake_options[@]}" "${EXTRA_CMAKE_OPTIONS[@]}" "${source_dir}" | ||
fi | ||
|
||
# Note: unconditionally build uswift because it is required for running some tests. | ||
if [[ "${CMAKE_GENERATOR}" == "Xcode" ]] ; then | ||
# Xcode generator uses "ALL_BUILD" instead of "all". | ||
# Also, xcodebuild uses -target instead of bare names. | ||
build_targets=("${build_targets[@]/all/ALL_BUILD}") | ||
build_targets=("${build_targets[@]/#/${BUILD_TARGET_FLAG} }") | ||
|
||
# Xcode can't restart itself if it turns out we need to reconfigure. | ||
# Do an advance build to handle that. | ||
call "${CMAKE_BUILD[@]}" "${build_dir}" $(cmake_config_opt ${product}) | ||
fi | ||
|
||
call "${CMAKE_BUILD[@]}" "${build_dir}" $(cmake_config_opt ${product}) -- "${BUILD_ARGS[@]}" ${build_targets[@]} | ||
|
||
# Copy over the uswift build. | ||
cp -a $(build_directory ${uswift_target_name} uswift) $(build_directory ${host} swift) | ||
done | ||
|
||
# We've already run cmake/build so we can just break out here. | ||
continue | ||
;; | ||
|
||
llvm) | ||
if [[ -n "${LLVM_NINJA_TARGETS_FOR_CROSS_COMPILE_HOSTS}" && $(is_cross_tools_host ${host}) ]] ; then | ||
build_targets=("${LLVM_NINJA_TARGETS_FOR_CROSS_COMPILE_HOSTS[@]}") | ||
|
@@ -1817,7 +1906,7 @@ for host in "${ALL_HOSTS[@]}"; do | |
"${llvm_cmake_options[@]}" | ||
) | ||
|
||
llvm_enable_projects=("clang") | ||
llvm_enable_projects=("clang" "lld") | ||
|
||
if [[ ! "${SKIP_BUILD_COMPILER_RT}" && ! $(is_cross_tools_host ${host}) ]]; then | ||
llvm_enable_projects+=("compiler-rt") | ||
|
@@ -1827,18 +1916,6 @@ for host in "${ALL_HOSTS[@]}"; do | |
llvm_enable_projects+=("clang-tools-extra") | ||
fi | ||
|
||
# On non-Darwin platforms, build lld so we can always have a | ||
# linker that is compatible with the swift we are using to | ||
# compile the stdlib. | ||
# | ||
# This makes it easier to build target stdlibs on systems that | ||
# have old toolchains without more modern linker features. | ||
if [[ "$(uname -s)" != "Darwin" ]] ; then | ||
if [[ ! "${SKIP_BUILD_LLD}" ]]; then | ||
llvm_enable_projects+=("lld") | ||
fi | ||
fi | ||
|
||
cmake_options+=( | ||
-DLLVM_ENABLE_PROJECTS="$(join ";" ${llvm_enable_projects[@]})" | ||
) | ||
|
@@ -1898,7 +1975,6 @@ for host in "${ALL_HOSTS[@]}"; do | |
;; | ||
|
||
swift) | ||
|
||
if [[ "${ANDROID_API_LEVEL}" ]]; then | ||
cmake_options=( | ||
"${cmake_options[@]}" | ||
|
@@ -2808,6 +2884,9 @@ for host in "${ALL_HOSTS[@]}"; do | |
libcxx) | ||
continue # We don't test libc++ | ||
;; | ||
uswift) | ||
continue # We don't test uswift | ||
;; | ||
swift) | ||
executable_target= | ||
results_targets= | ||
|
@@ -3159,6 +3238,9 @@ for host in "${ALL_HOSTS[@]}"; do | |
fi | ||
INSTALL_TARGETS=install-swift-components | ||
;; | ||
uswift) | ||
continue | ||
;; | ||
llbuild) | ||
if [[ -z "${INSTALL_LLBUILD}" ]] ; then | ||
continue | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that moving this to the next commit is better. Additionally, I'm not sure how I feel about this - this is a really really really complex way to do this. We already push lit well beyond what it should be used as, and this is particularly horrendous. Can we use a different approach for this? I think that adding the subdirectory as a multiple test suites in a lit.local.cfg might be better.