Skip to content

Commit e7390d1

Browse files
author
Doug Coleman
committed
Revert "utils: Add swiftenvs, which allow the overriding of compiler tools."
This reverts commit 2b923f3.
1 parent 9880f65 commit e7390d1

File tree

13 files changed

+160
-615
lines changed

13 files changed

+160
-615
lines changed

CMakeLists.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -420,10 +420,10 @@ swift_configure_components()
420420
# lipo is used to create universal binaries.
421421
if("${CMAKE_SYSTEM_NAME}" STREQUAL "Darwin")
422422
include(SwiftDarwin)
423-
if(CMAKE_LIPO)
424-
set(CMAKE_LIPO ${CMAKE_LIPO})
423+
if(SWIFT_LIPO)
424+
set(LIPO ${SWIFT_LIPO})
425425
else()
426-
find_toolchain_tool(CMAKE_LIPO "${SWIFT_DARWIN_XCRUN_TOOLCHAIN}" lipo)
426+
find_toolchain_tool(LIPO "${SWIFT_DARWIN_XCRUN_TOOLCHAIN}" lipo)
427427
endif()
428428
endif()
429429

benchmark/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ if(NOT SWIFT_LIBRARY_PATH)
147147
endif()
148148

149149
# If the CMAKE_C_COMPILER is already clang, don't find it again,
150-
# thus allowing the --cmake-c-compiler build-script argument to work here.
150+
# thus allowing the --host-cc build-script argument to work here.
151151
get_filename_component(c_compiler ${CMAKE_C_COMPILER} NAME)
152152

153153
if(${c_compiler} STREQUAL "clang")

benchmark/cmake/modules/AddSwiftBenchmarkSuite.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,7 @@ function (swift_benchmark_compile_archopts)
349349
${objcfile}
350350
"-o" "${OUTPUT_EXEC}"
351351
COMMAND
352-
${CMAKE_CODESIGN} "-f" "-s" "-" "${OUTPUT_EXEC}")
352+
"codesign" "-f" "-s" "-" "${OUTPUT_EXEC}")
353353
set(new_output_exec "${OUTPUT_EXEC}" PARENT_SCOPE)
354354
endfunction()
355355

benchmark/scripts/generate_harness/CMakeLists.txt_template

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ if(NOT SWIFT_LIBRARY_PATH)
6868
endif()
6969

7070
# If the CMAKE_C_COMPILER is already clang, don't find it again,
71-
# thus allowing the --cmake-c-compiler build-script argument to work here.
71+
# thus allowing the --host-cc build-script argument to work here.
7272
get_filename_component(c_compiler ${CMAKE_C_COMPILER} NAME)
7373

7474
if(${c_compiler} STREQUAL "clang")

cmake/modules/AddSwift.cmake

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -465,22 +465,22 @@ function(_add_swift_lipo_target)
465465
is_darwin_based_sdk("${LIPO_SDK}" IS_DARWIN)
466466
if(IS_DARWIN)
467467
if(LIPO_CODESIGN)
468-
set(codesign_command COMMAND "${CMAKE_CODESIGN}" "-f" "-s" "-" "${LIPO_OUTPUT}")
468+
set(codesign_command COMMAND "codesign" "-f" "-s" "-" "${LIPO_OUTPUT}")
469469
endif()
470470
# Use lipo to create the final binary.
471471
add_custom_command_target(unused_var
472-
COMMAND "${CMAKE_LIPO}" "-create" "-output" "${LIPO_OUTPUT}" ${source_binaries}
473-
${codesign_command}
474-
CUSTOM_TARGET_NAME "${LIPO_TARGET}"
475-
OUTPUT "${LIPO_OUTPUT}"
476-
DEPENDS ${source_targets})
472+
COMMAND "${LIPO}" "-create" "-output" "${LIPO_OUTPUT}" ${source_binaries}
473+
${codesign_command}
474+
CUSTOM_TARGET_NAME "${LIPO_TARGET}"
475+
OUTPUT "${LIPO_OUTPUT}"
476+
DEPENDS ${source_targets})
477477
else()
478478
# We don't know how to create fat binaries for other platforms.
479479
add_custom_command_target(unused_var
480-
COMMAND "${CMAKE_COMMAND}" "-E" "copy" "${source_binaries}" "${LIPO_OUTPUT}"
481-
CUSTOM_TARGET_NAME "${LIPO_TARGET}"
482-
OUTPUT "${LIPO_OUTPUT}"
483-
DEPENDS ${source_targets})
480+
COMMAND "${CMAKE_COMMAND}" "-E" "copy" "${source_binaries}" "${LIPO_OUTPUT}"
481+
CUSTOM_TARGET_NAME "${LIPO_TARGET}"
482+
OUTPUT "${LIPO_OUTPUT}"
483+
DEPENDS ${source_targets})
484484
endif()
485485
endfunction()
486486

cmake/modules/SwiftHandleGybSources.cmake

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,8 @@ function(handle_gyb_source_single dependency_out_var_name)
4141
${SWIFT_GYB_FLAGS}
4242
${GYB_SINGLE_FLAGS})
4343

44-
if(NOT "${CMAKE_GYB}" STREQUAL "")
45-
set(gyb_tool "${CMAKE_GYB}")
46-
set(gyb_tool_source "${gyb_tool}" "${gyb_tool}")
47-
else()
48-
set(gyb_tool "${SWIFT_SOURCE_DIR}/utils/gyb")
49-
set(gyb_tool_source "${gyb_tool}" "${gyb_tool}.py")
50-
endif()
44+
set(gyb_tool "${SWIFT_SOURCE_DIR}/utils/gyb")
45+
set(gyb_tool_source "${gyb_tool}" "${gyb_tool}.py")
5146

5247
get_filename_component(dir "${GYB_SINGLE_OUTPUT}" DIRECTORY)
5348
get_filename_component(basename "${GYB_SINGLE_OUTPUT}" NAME)

utils/build-script

Lines changed: 26 additions & 105 deletions
Original file line numberDiff line numberDiff line change
@@ -601,6 +601,8 @@ class BuildScriptInvocation(object):
601601
"--host-target", args.host_target,
602602
"--stdlib-deployment-targets",
603603
" ".join(args.stdlib_deployment_targets),
604+
"--host-cc", toolchain.cc,
605+
"--host-cxx", toolchain.cxx,
604606
"--darwin-xcrun-toolchain", args.darwin_xcrun_toolchain,
605607
"--darwin-deployment-version-osx=%s" % (
606608
args.darwin_deployment_version_osx),
@@ -611,8 +613,6 @@ class BuildScriptInvocation(object):
611613
"--darwin-deployment-version-watchos=%s" % (
612614
args.darwin_deployment_version_watchos),
613615
"--cmake", toolchain.cmake,
614-
"--cmake-c-compiler", toolchain.cc,
615-
"--cmake-cxx-compiler", toolchain.cxx,
616616
"--cmark-build-type", args.cmark_build_variant,
617617
"--llvm-build-type", args.llvm_build_variant,
618618
"--swift-build-type", args.swift_build_variant,
@@ -682,14 +682,6 @@ class BuildScriptInvocation(object):
682682
"--distcc",
683683
"--distcc-pump=%s" % toolchain.distcc_pump
684684
]
685-
if args.swiftenv_path:
686-
impl_args += [ "--swiftenv-path=%s" % args.swiftenv_path]
687-
if args.swiftenv_recreate:
688-
impl_args += [ "--swiftenv-recreate"]
689-
if args.swiftenv_script:
690-
impl_args += [ "--swiftenv-script=%s" % args.swiftenv_script]
691-
if args.swiftenv_make:
692-
impl_args += [ "--swiftenv-make=%s" % args.swiftenv_make]
693685
if args.enable_asan:
694686
impl_args += ["--enable-asan"]
695687
if args.enable_ubsan:
@@ -827,6 +819,12 @@ class BuildScriptInvocation(object):
827819
"--toolchain-prefix",
828820
swift_build_support.targets.darwin_toolchain_prefix(
829821
args.install_prefix),
822+
"--host-lipo", toolchain.lipo,
823+
]
824+
825+
if toolchain.libtool is not None:
826+
impl_args += [
827+
"--host-libtool", toolchain.libtool,
830828
]
831829

832830
# If we have extra_swift_args, combine all of them together and then
@@ -1046,47 +1044,6 @@ def clean_delay():
10461044
print('\b\b\b\bnow.')
10471045

10481046

1049-
def handle_swiftenv_args(args):
1050-
# Find clang in swiftenv if present
1051-
if args.swiftenv_path is None:
1052-
if args.swiftenv_recreate:
1053-
print(sys.argv[0], "error: using a swiftenv_recreate to make a swiftenv requires a destination in --swiftenv-path=", file=sys.stderr)
1054-
sys.exit(2) # 2 is the same as `argparse` error exit code.
1055-
1056-
if args.swiftenv_script is not None:
1057-
print(sys.argv[0], "error: using a swiftenv_script to make a swiftenv requires a destination in --swiftenv-path=", file=sys.stderr)
1058-
sys.exit(2) # 2 is the same as `argparse` error exit code.
1059-
1060-
if args.swiftenv_make is not None:
1061-
print(sys.argv[0], "error: using a swiftenv_make to make a swiftenv requires a destination in --swiftenv-path=", file=sys.stderr)
1062-
sys.exit(2) # 2 is the same as `argparse` error exit code.
1063-
1064-
if args.swiftenv_path is not None:
1065-
# mkdir the swiftenv_path
1066-
if not os.path.exists(args.swiftenv_path):
1067-
os.makedirs(args.swiftenv_path)
1068-
1069-
# Only use swiftenv_make/swiftenv_script if one is provided
1070-
# utils/swiftenv-make is default
1071-
if args.swiftenv_make is None:
1072-
args.swiftenv_make = os.path.join(
1073-
SWIFT_SOURCE_ROOT, "swift", "utils", "swiftenv-make")
1074-
else:
1075-
args.swiftenv_make = os.path.abspath(args.swiftenv_make)
1076-
1077-
# utils/swiftenv-script is default
1078-
if args.swiftenv_script is None:
1079-
args.swiftenv_script = os.path.join(
1080-
SWIFT_SOURCE_ROOT, "swift", "utils", "swiftenv-script")
1081-
else:
1082-
args.swiftenv_script = os.path.abspath(args.swiftenv_script)
1083-
1084-
print("args.swiftenv_path", args.swiftenv_path)
1085-
print("args.swiftenv_recreate", args.swiftenv_recreate)
1086-
print("args.swiftenv_make", args.swiftenv_make)
1087-
print("args.swiftenv_script", args.swiftenv_script)
1088-
1089-
10901047
# Main entry point for the preset mode.
10911048
def main_preset():
10921049
parser = argparse.ArgumentParser(
@@ -1113,19 +1070,6 @@ def main_preset():
11131070
"--show-presets",
11141071
help="list all presets and exit",
11151072
action=arguments.action.optional_bool)
1116-
parser.add_argument(
1117-
"--swiftenv-path",
1118-
help="the absolute path to a directory containing replacement compiler commands")
1119-
parser.add_argument(
1120-
"--swiftenv-recreate",
1121-
help="a flag that, when present, will recreate the swiftenv",
1122-
action=arguments.action.optional_bool)
1123-
parser.add_argument(
1124-
"--swiftenv-script",
1125-
help="the absolute path to a script that takes the place of toolchain commands, default uses utils/swiftenv-script")
1126-
parser.add_argument(
1127-
"--swiftenv-make",
1128-
help="the absolute path to a script that will set up a swiftenv, default uses utils/swiftenv-make")
11291073
parser.add_argument(
11301074
"--distcc",
11311075
help="use distcc",
@@ -1181,17 +1125,6 @@ def main_preset():
11811125
if args.build_jobs:
11821126
build_script_args += ["--jobs", str(args.build_jobs)]
11831127

1184-
handle_swiftenv_args(args)
1185-
1186-
if args.swiftenv_path is not None:
1187-
build_script_args += ["--swiftenv-path", str(args.swiftenv_path)]
1188-
if args.swiftenv_recreate:
1189-
build_script_args += ["--swiftenv-recreate"]
1190-
if args.swiftenv_make is not None:
1191-
build_script_args += ["--swiftenv-make", str(args.swiftenv_make)]
1192-
if args.swiftenv_script is not None:
1193-
build_script_args += ["--swiftenv-script", str(args.swiftenv_script)]
1194-
11951128
diagnostics.note(
11961129
"using preset '" + args.preset + "', which expands to \n\n" +
11971130
shell.quote_command(build_script_args) + "\n")
@@ -2048,31 +1981,27 @@ iterations with -O",
20481981
metavar="PATH")
20491982

20501983
parser.add_argument(
2051-
"--cmake-c-compiler",
1984+
"--host-cc",
20521985
help="the absolute path to CC, the 'clang' compiler for the host "
20531986
"platform. Default is auto detected.",
20541987
type=arguments.type.executable,
20551988
metavar="PATH")
20561989
parser.add_argument(
2057-
"--cmake-cxx-compiler",
1990+
"--host-cxx",
20581991
help="the absolute path to CXX, the 'clang++' compiler for the host "
20591992
"platform. Default is auto detected.",
20601993
type=arguments.type.executable,
20611994
metavar="PATH")
20621995
parser.add_argument(
2063-
"--swiftenv-path",
2064-
help="the absolute path to a directory containing replacement compiler commands")
2065-
parser.add_argument(
2066-
"--swiftenv-recreate",
2067-
help="a flag that, when present, will recreate the swiftenv",
2068-
default="false",
2069-
action=arguments.action.optional_bool)
2070-
parser.add_argument(
2071-
"--swiftenv-script",
2072-
help="the absolute path to a script that takes the place of toolchain commands")
1996+
"--host-lipo",
1997+
help="the absolute path to lipo. Default is auto detected.",
1998+
type=arguments.type.executable,
1999+
metavar="PATH")
20732000
parser.add_argument(
2074-
"--swiftenv-make",
2075-
help="the absolute path to a script that will set up a swiftenv, default uses utils/swiftenv-make")
2001+
"--host-libtool",
2002+
help="the absolute path to libtool. Default is auto detected.",
2003+
type=arguments.type.executable,
2004+
metavar="PATH")
20762005
parser.add_argument(
20772006
"--distcc",
20782007
help="use distcc in pump mode",
@@ -2244,22 +2173,14 @@ iterations with -O",
22442173
# Prepare and validate toolchain
22452174
toolchain = host_toolchain(xcrun_toolchain=args.darwin_xcrun_toolchain)
22462175

2247-
# Abstracted swiftenv_args for --preset and not
2248-
handle_swiftenv_args(args)
2249-
2250-
# Let args.cmake_c_compiler win over swiftenv's cc/cxx
2251-
if args.cmake_c_compiler is None and args.swiftenv_path is not None:
2252-
if os.path.exists(args.swiftenv_path + "/clang"):
2253-
args.cmake_c_compiler = args.swiftenv_path + "/clang"
2254-
if args.cmake_cxx_compiler is None and args.swiftenv_path is not None:
2255-
if os.path.exists(args.swiftenv_path + "/clang++"):
2256-
args.cmake_cxx_compiler = args.swiftenv_path + "/clang++"
2257-
2258-
if args.cmake_c_compiler is not None:
2259-
toolchain.cc = args.cmake_c_compiler
2260-
if args.cmake_cxx_compiler is not None:
2261-
toolchain.cxx = args.cmake_cxx_compiler
2262-
2176+
if args.host_cc is not None:
2177+
toolchain.cc = args.host_cc
2178+
if args.host_cxx is not None:
2179+
toolchain.cxx = args.host_cxx
2180+
if args.host_lipo is not None:
2181+
toolchain.lipo = args.host_lipo
2182+
if args.host_libtool is not None:
2183+
toolchain.libtool = args.host_libtool
22632184
if args.cmake is not None:
22642185
toolchain.cmake = args.cmake
22652186

0 commit comments

Comments
 (0)