Skip to content

Commit 5b9d76b

Browse files
author
Tom Birch
committed
Move stdlib-deployment-targets calculation into build-script
* Demux uname info into a list of stdlib_deployment_targets in python * Generate list of allowed stdlib_cross_targets based on host info
1 parent a4df003 commit 5b9d76b

File tree

2 files changed

+54
-78
lines changed

2 files changed

+54
-78
lines changed

utils/build-script

Lines changed: 52 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -888,11 +888,55 @@ the number of parallel build jobs to use""",
888888
"--skip-build-benchmarks",
889889
]
890890

891-
if platform.system() == 'Darwin':
891+
system = platform.system()
892+
machine = platform.machine()
893+
894+
if system == 'Darwin':
892895
build_script_impl_inferred_args += [
893896
"--toolchain-prefix",
894897
swift_build_support.targets.darwin_toolchain_prefix(args.install_prefix),
895898
]
899+
stdlib_deployment_targets = [
900+
"macosx-x86_64",
901+
"iphonesimulator-i386",
902+
"iphonesimulator-x86_64",
903+
"appletvsimulator-x86_64",
904+
"watchsimulator-i386",
905+
906+
# Put iOS native targets last so that we test them last (it takes a
907+
# long time).
908+
"iphoneos-arm64",
909+
"iphoneos-armv7",
910+
"appletvos-arm64",
911+
"watchos-armv7k"
912+
]
913+
stdlib_cross_targets = [
914+
"linux-armv7"
915+
]
916+
elif system == 'Linux':
917+
arch_mapping = [
918+
('x86_64' , 'x86_64'),
919+
('armv6' , 'armv6'),
920+
('armv7' , 'armv7'),
921+
('aarch64' , 'aarch64'),
922+
('ppc64' , 'powerpc64'),
923+
('ppc64le' , 'powerpc64le')
924+
]
925+
arch_mapping = [(x, 'linux-'+y) for (x,y) in arch_mapping]
926+
927+
host_target = next(t for (s,t) in arch_mapping if machine.startswith(s))
928+
stdlib_deployment_targets = [host_target]
929+
930+
# All other linux-* targets
931+
stdlib_cross_targets = [t for (_,t) in arch_mapping]
932+
stdlib_cross_targets.remove(host_target)
933+
elif system == 'FreeBSD' and machine == 'amd64':
934+
stdlib_deployment_targets = ["freebsd-x86_64"]
935+
elif system == 'CYGWIN_NT-10' and machine == 'x86_64':
936+
stdlib_deployment_targets = ["cygwin-x86_64"]
937+
else:
938+
print_with_argv0("Unknown operating system")
939+
return 1
896940

897941
if args.build_subdir is None:
898942
# Create a name for the build directory.
@@ -1043,16 +1087,15 @@ the number of parallel build jobs to use""",
10431087
'watchsimulator',
10441088
])
10451089

1046-
host_build_script_impl_args = []
1047-
1048-
if platform.system() != 'Linux':
1049-
host_build_script_impl_args += [
1050-
"--skip-build-linux"
1090+
host_build_script_impl_args = [
1091+
"--stdlib-deployment-targets=" + " ".join(stdlib_deployment_targets)
10511092
]
10521093

10531094
check_call(build_script_impl_args + host_build_script_impl_args)
10541095

10551096
if args.cross_compile_stdlib_targets:
1097+
# Filter cross_compile_stdlib_targets by those supported for this host
1098+
stdlib_cross_targets = set(stdlib_cross_targets).intersection(args.cross_compile_stdlib_targets)
10561099
# Currently only cross-compiling the swift libraries is supported.
10571100
# Building the swift compiler would require building llvm too.
10581101
llvm_path = os.path.join(build_dir, "llvm-"+args.host_target, 'bin')
@@ -1067,9 +1110,10 @@ the number of parallel build jobs to use""",
10671110
"--build-swift-tools=0"
10681111
]
10691112

1070-
for target in args.cross_compile_stdlib_targets:
1113+
for target in stdlib_cross_targets:
10711114
check_call(build_script_impl_args +
1072-
["--cross-compile-deployment-targets=" + target])
1115+
["--cross-compile-deployment-targets=" + target,
1116+
"--stdlib-deployment-targets=" + target])
10731117

10741118
if args.symbols_package:
10751119
print('--- Creating symbols package ---')

utils/build-script-impl

Lines changed: 2 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,7 @@ KNOWN_SETTINGS=(
181181
install-libdispatch "" "whether to install libdispatch"
182182
darwin-install-extract-symbols "" "whether to extract symbols with dsymutil during installations"
183183
host-target "" "The host target. LLVM, Clang, and Swift will be built for this target. The built LLVM and Clang will be used to compile Swift for the cross-compilation targets. **This argument is required**"
184+
stdlib-deployment-targets "" "The space separated list of stdlib targets to build"
184185
cross-compile-deployment-targets "" "space-separated list of targets to cross-compile Swift for"
185186
cross-compile-sysroot "" "sysroot to use when cross-compiling"
186187
cross-compile-toolchain-bin "" "toolchain binary dir to use when cross-compiling"
@@ -816,76 +817,6 @@ function is_cross_tools_deployment_target() {
816817
done
817818
}
818819

819-
# A list of deployment targets that we compile or cross-compile the
820-
# Swift standard library for.
821-
STDLIB_DEPLOYMENT_TARGETS=()
822-
case "$(uname -s -m)" in
823-
Linux\ x86_64)
824-
STDLIB_DEPLOYMENT_TARGETS=(
825-
"linux-x86_64"
826-
)
827-
;;
828-
Linux\ armv6*)
829-
STDLIB_DEPLOYMENT_TARGETS=(
830-
"linux-armv6"
831-
)
832-
;;
833-
Linux\ armv7*)
834-
STDLIB_DEPLOYMENT_TARGETS=(
835-
"linux-armv7"
836-
)
837-
;;
838-
Linux\ aarch64)
839-
STDLIB_DEPLOYMENT_TARGETS=(
840-
"linux-aarch64"
841-
)
842-
;;
843-
Linux\ ppc64)
844-
STDLIB_DEPLOYMENT_TARGETS=(
845-
"linux-powerpc64"
846-
)
847-
;;
848-
Linux\ ppc64le)
849-
STDLIB_DEPLOYMENT_TARGETS=(
850-
"linux-powerpc64le"
851-
)
852-
;;
853-
Darwin\ x86_64)
854-
STDLIB_DEPLOYMENT_TARGETS=(
855-
"macosx-x86_64"
856-
"iphonesimulator-i386"
857-
"iphonesimulator-x86_64"
858-
"appletvsimulator-x86_64"
859-
"watchsimulator-i386"
860-
861-
# Put iOS native targets last so that we test them last (it takes a
862-
# long time).
863-
"iphoneos-arm64"
864-
"iphoneos-armv7"
865-
"appletvos-arm64"
866-
"watchos-armv7k"
867-
"linux-armv7"
868-
)
869-
;;
870-
871-
FreeBSD\ amd64)
872-
STDLIB_DEPLOYMENT_TARGETS=(
873-
"freebsd-x86_64"
874-
)
875-
;;
876-
877-
CYGWIN_NT-10.0\ x86_64)
878-
STDLIB_DEPLOYMENT_TARGETS=(
879-
"cygwin-x86_64"
880-
)
881-
;;
882-
883-
*)
884-
echo "Unknown operating system"
885-
exit 1
886-
;;
887-
esac
888-
889820
#
890821
# Calculate source directories for each product.
891822
#
@@ -978,6 +909,7 @@ SWIFT_STDLIB_TARGETS=()
978909
SWIFT_BENCHMARK_TARGETS=()
979910
SWIFT_RUN_BENCHMARK_TARGETS=()
980911
SWIFT_TEST_TARGETS=()
912+
STDLIB_DEPLOYMENT_TARGETS=($STDLIB_DEPLOYMENT_TARGETS)
981913
for deployment_target in "${STDLIB_DEPLOYMENT_TARGETS[@]}"; do
982914
build_for_this_target=1
983915
test_this_target=1

0 commit comments

Comments
 (0)