Skip to content

Commit

Permalink
Revert "utils: Add swiftenvs, which allow the overriding of compiler …
Browse files Browse the repository at this point in the history
…tools."

This reverts commit 2b923f3.
  • Loading branch information
Doug Coleman committed Mar 23, 2017
1 parent 9880f65 commit e7390d1
Show file tree
Hide file tree
Showing 13 changed files with 160 additions and 615 deletions.
6 changes: 3 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -420,10 +420,10 @@ swift_configure_components()
# lipo is used to create universal binaries.
if("${CMAKE_SYSTEM_NAME}" STREQUAL "Darwin")
include(SwiftDarwin)
if(CMAKE_LIPO)
set(CMAKE_LIPO ${CMAKE_LIPO})
if(SWIFT_LIPO)
set(LIPO ${SWIFT_LIPO})
else()
find_toolchain_tool(CMAKE_LIPO "${SWIFT_DARWIN_XCRUN_TOOLCHAIN}" lipo)
find_toolchain_tool(LIPO "${SWIFT_DARWIN_XCRUN_TOOLCHAIN}" lipo)
endif()
endif()

Expand Down
2 changes: 1 addition & 1 deletion benchmark/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ if(NOT SWIFT_LIBRARY_PATH)
endif()

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

if(${c_compiler} STREQUAL "clang")
Expand Down
2 changes: 1 addition & 1 deletion benchmark/cmake/modules/AddSwiftBenchmarkSuite.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ function (swift_benchmark_compile_archopts)
${objcfile}
"-o" "${OUTPUT_EXEC}"
COMMAND
${CMAKE_CODESIGN} "-f" "-s" "-" "${OUTPUT_EXEC}")
"codesign" "-f" "-s" "-" "${OUTPUT_EXEC}")
set(new_output_exec "${OUTPUT_EXEC}" PARENT_SCOPE)
endfunction()

Expand Down
2 changes: 1 addition & 1 deletion benchmark/scripts/generate_harness/CMakeLists.txt_template
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ if(NOT SWIFT_LIBRARY_PATH)
endif()

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

if(${c_compiler} STREQUAL "clang")
Expand Down
20 changes: 10 additions & 10 deletions cmake/modules/AddSwift.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -465,22 +465,22 @@ function(_add_swift_lipo_target)
is_darwin_based_sdk("${LIPO_SDK}" IS_DARWIN)
if(IS_DARWIN)
if(LIPO_CODESIGN)
set(codesign_command COMMAND "${CMAKE_CODESIGN}" "-f" "-s" "-" "${LIPO_OUTPUT}")
set(codesign_command COMMAND "codesign" "-f" "-s" "-" "${LIPO_OUTPUT}")
endif()
# Use lipo to create the final binary.
add_custom_command_target(unused_var
COMMAND "${CMAKE_LIPO}" "-create" "-output" "${LIPO_OUTPUT}" ${source_binaries}
${codesign_command}
CUSTOM_TARGET_NAME "${LIPO_TARGET}"
OUTPUT "${LIPO_OUTPUT}"
DEPENDS ${source_targets})
COMMAND "${LIPO}" "-create" "-output" "${LIPO_OUTPUT}" ${source_binaries}
${codesign_command}
CUSTOM_TARGET_NAME "${LIPO_TARGET}"
OUTPUT "${LIPO_OUTPUT}"
DEPENDS ${source_targets})
else()
# We don't know how to create fat binaries for other platforms.
add_custom_command_target(unused_var
COMMAND "${CMAKE_COMMAND}" "-E" "copy" "${source_binaries}" "${LIPO_OUTPUT}"
CUSTOM_TARGET_NAME "${LIPO_TARGET}"
OUTPUT "${LIPO_OUTPUT}"
DEPENDS ${source_targets})
COMMAND "${CMAKE_COMMAND}" "-E" "copy" "${source_binaries}" "${LIPO_OUTPUT}"
CUSTOM_TARGET_NAME "${LIPO_TARGET}"
OUTPUT "${LIPO_OUTPUT}"
DEPENDS ${source_targets})
endif()
endfunction()

Expand Down
9 changes: 2 additions & 7 deletions cmake/modules/SwiftHandleGybSources.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,8 @@ function(handle_gyb_source_single dependency_out_var_name)
${SWIFT_GYB_FLAGS}
${GYB_SINGLE_FLAGS})

if(NOT "${CMAKE_GYB}" STREQUAL "")
set(gyb_tool "${CMAKE_GYB}")
set(gyb_tool_source "${gyb_tool}" "${gyb_tool}")
else()
set(gyb_tool "${SWIFT_SOURCE_DIR}/utils/gyb")
set(gyb_tool_source "${gyb_tool}" "${gyb_tool}.py")
endif()
set(gyb_tool "${SWIFT_SOURCE_DIR}/utils/gyb")
set(gyb_tool_source "${gyb_tool}" "${gyb_tool}.py")

get_filename_component(dir "${GYB_SINGLE_OUTPUT}" DIRECTORY)
get_filename_component(basename "${GYB_SINGLE_OUTPUT}" NAME)
Expand Down
131 changes: 26 additions & 105 deletions utils/build-script
Original file line number Diff line number Diff line change
Expand Up @@ -601,6 +601,8 @@ class BuildScriptInvocation(object):
"--host-target", args.host_target,
"--stdlib-deployment-targets",
" ".join(args.stdlib_deployment_targets),
"--host-cc", toolchain.cc,
"--host-cxx", toolchain.cxx,
"--darwin-xcrun-toolchain", args.darwin_xcrun_toolchain,
"--darwin-deployment-version-osx=%s" % (
args.darwin_deployment_version_osx),
Expand All @@ -611,8 +613,6 @@ class BuildScriptInvocation(object):
"--darwin-deployment-version-watchos=%s" % (
args.darwin_deployment_version_watchos),
"--cmake", toolchain.cmake,
"--cmake-c-compiler", toolchain.cc,
"--cmake-cxx-compiler", toolchain.cxx,
"--cmark-build-type", args.cmark_build_variant,
"--llvm-build-type", args.llvm_build_variant,
"--swift-build-type", args.swift_build_variant,
Expand Down Expand Up @@ -682,14 +682,6 @@ class BuildScriptInvocation(object):
"--distcc",
"--distcc-pump=%s" % toolchain.distcc_pump
]
if args.swiftenv_path:
impl_args += [ "--swiftenv-path=%s" % args.swiftenv_path]
if args.swiftenv_recreate:
impl_args += [ "--swiftenv-recreate"]
if args.swiftenv_script:
impl_args += [ "--swiftenv-script=%s" % args.swiftenv_script]
if args.swiftenv_make:
impl_args += [ "--swiftenv-make=%s" % args.swiftenv_make]
if args.enable_asan:
impl_args += ["--enable-asan"]
if args.enable_ubsan:
Expand Down Expand Up @@ -827,6 +819,12 @@ class BuildScriptInvocation(object):
"--toolchain-prefix",
swift_build_support.targets.darwin_toolchain_prefix(
args.install_prefix),
"--host-lipo", toolchain.lipo,
]

if toolchain.libtool is not None:
impl_args += [
"--host-libtool", toolchain.libtool,
]

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


def handle_swiftenv_args(args):
# Find clang in swiftenv if present
if args.swiftenv_path is None:
if args.swiftenv_recreate:
print(sys.argv[0], "error: using a swiftenv_recreate to make a swiftenv requires a destination in --swiftenv-path=", file=sys.stderr)
sys.exit(2) # 2 is the same as `argparse` error exit code.

if args.swiftenv_script is not None:
print(sys.argv[0], "error: using a swiftenv_script to make a swiftenv requires a destination in --swiftenv-path=", file=sys.stderr)
sys.exit(2) # 2 is the same as `argparse` error exit code.

if args.swiftenv_make is not None:
print(sys.argv[0], "error: using a swiftenv_make to make a swiftenv requires a destination in --swiftenv-path=", file=sys.stderr)
sys.exit(2) # 2 is the same as `argparse` error exit code.

if args.swiftenv_path is not None:
# mkdir the swiftenv_path
if not os.path.exists(args.swiftenv_path):
os.makedirs(args.swiftenv_path)

# Only use swiftenv_make/swiftenv_script if one is provided
# utils/swiftenv-make is default
if args.swiftenv_make is None:
args.swiftenv_make = os.path.join(
SWIFT_SOURCE_ROOT, "swift", "utils", "swiftenv-make")
else:
args.swiftenv_make = os.path.abspath(args.swiftenv_make)

# utils/swiftenv-script is default
if args.swiftenv_script is None:
args.swiftenv_script = os.path.join(
SWIFT_SOURCE_ROOT, "swift", "utils", "swiftenv-script")
else:
args.swiftenv_script = os.path.abspath(args.swiftenv_script)

print("args.swiftenv_path", args.swiftenv_path)
print("args.swiftenv_recreate", args.swiftenv_recreate)
print("args.swiftenv_make", args.swiftenv_make)
print("args.swiftenv_script", args.swiftenv_script)


# Main entry point for the preset mode.
def main_preset():
parser = argparse.ArgumentParser(
Expand All @@ -1113,19 +1070,6 @@ def main_preset():
"--show-presets",
help="list all presets and exit",
action=arguments.action.optional_bool)
parser.add_argument(
"--swiftenv-path",
help="the absolute path to a directory containing replacement compiler commands")
parser.add_argument(
"--swiftenv-recreate",
help="a flag that, when present, will recreate the swiftenv",
action=arguments.action.optional_bool)
parser.add_argument(
"--swiftenv-script",
help="the absolute path to a script that takes the place of toolchain commands, default uses utils/swiftenv-script")
parser.add_argument(
"--swiftenv-make",
help="the absolute path to a script that will set up a swiftenv, default uses utils/swiftenv-make")
parser.add_argument(
"--distcc",
help="use distcc",
Expand Down Expand Up @@ -1181,17 +1125,6 @@ def main_preset():
if args.build_jobs:
build_script_args += ["--jobs", str(args.build_jobs)]

handle_swiftenv_args(args)

if args.swiftenv_path is not None:
build_script_args += ["--swiftenv-path", str(args.swiftenv_path)]
if args.swiftenv_recreate:
build_script_args += ["--swiftenv-recreate"]
if args.swiftenv_make is not None:
build_script_args += ["--swiftenv-make", str(args.swiftenv_make)]
if args.swiftenv_script is not None:
build_script_args += ["--swiftenv-script", str(args.swiftenv_script)]

diagnostics.note(
"using preset '" + args.preset + "', which expands to \n\n" +
shell.quote_command(build_script_args) + "\n")
Expand Down Expand Up @@ -2048,31 +1981,27 @@ iterations with -O",
metavar="PATH")

parser.add_argument(
"--cmake-c-compiler",
"--host-cc",
help="the absolute path to CC, the 'clang' compiler for the host "
"platform. Default is auto detected.",
type=arguments.type.executable,
metavar="PATH")
parser.add_argument(
"--cmake-cxx-compiler",
"--host-cxx",
help="the absolute path to CXX, the 'clang++' compiler for the host "
"platform. Default is auto detected.",
type=arguments.type.executable,
metavar="PATH")
parser.add_argument(
"--swiftenv-path",
help="the absolute path to a directory containing replacement compiler commands")
parser.add_argument(
"--swiftenv-recreate",
help="a flag that, when present, will recreate the swiftenv",
default="false",
action=arguments.action.optional_bool)
parser.add_argument(
"--swiftenv-script",
help="the absolute path to a script that takes the place of toolchain commands")
"--host-lipo",
help="the absolute path to lipo. Default is auto detected.",
type=arguments.type.executable,
metavar="PATH")
parser.add_argument(
"--swiftenv-make",
help="the absolute path to a script that will set up a swiftenv, default uses utils/swiftenv-make")
"--host-libtool",
help="the absolute path to libtool. Default is auto detected.",
type=arguments.type.executable,
metavar="PATH")
parser.add_argument(
"--distcc",
help="use distcc in pump mode",
Expand Down Expand Up @@ -2244,22 +2173,14 @@ iterations with -O",
# Prepare and validate toolchain
toolchain = host_toolchain(xcrun_toolchain=args.darwin_xcrun_toolchain)

# Abstracted swiftenv_args for --preset and not
handle_swiftenv_args(args)

# Let args.cmake_c_compiler win over swiftenv's cc/cxx
if args.cmake_c_compiler is None and args.swiftenv_path is not None:
if os.path.exists(args.swiftenv_path + "/clang"):
args.cmake_c_compiler = args.swiftenv_path + "/clang"
if args.cmake_cxx_compiler is None and args.swiftenv_path is not None:
if os.path.exists(args.swiftenv_path + "/clang++"):
args.cmake_cxx_compiler = args.swiftenv_path + "/clang++"

if args.cmake_c_compiler is not None:
toolchain.cc = args.cmake_c_compiler
if args.cmake_cxx_compiler is not None:
toolchain.cxx = args.cmake_cxx_compiler

if args.host_cc is not None:
toolchain.cc = args.host_cc
if args.host_cxx is not None:
toolchain.cxx = args.host_cxx
if args.host_lipo is not None:
toolchain.lipo = args.host_lipo
if args.host_libtool is not None:
toolchain.libtool = args.host_libtool
if args.cmake is not None:
toolchain.cmake = args.cmake

Expand Down
Loading

0 comments on commit e7390d1

Please sign in to comment.