Skip to content

Commit bcdfa33

Browse files
committed
[bootstrap] Remove fake toolchain dead code from the bootstrap script
Thanks to swiftlang/swift#28035, we can start simplifying the bootstrap script and remove lots of horrible hacks that we currently have. <rdar://problem/56849141>
1 parent 8a87ae8 commit bcdfa33

File tree

2 files changed

+1
-148
lines changed

2 files changed

+1
-148
lines changed

Sources/PackageLoading/ManifestLoader.swift

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,6 @@ public final class ManifestLoader: ManifestLoaderProtocol {
391391
#endif
392392
cmd += [resources.swiftCompiler.pathString]
393393
cmd += ["--driver-mode=swift"]
394-
cmd += bootstrapArgs()
395394
cmd += verbosity.ccArgs
396395
cmd += ["-L", runtimePath, "-lPackageDescription"]
397396
cmd += interpreterFlags
@@ -470,36 +469,6 @@ public final class ManifestLoader: ManifestLoaderProtocol {
470469
return manifestParseResult
471470
}
472471

473-
/// Returns the extra manifest args required during SwiftPM's own bootstrap.
474-
private func bootstrapArgs() -> [String] {
475-
#if !os(Linux)
476-
return []
477-
#else
478-
// The Linux bots require extra arguments in order to locate the corelibs.
479-
// We can potentially drop this by installing some stable linux toolchain
480-
// after Swift gets ABI and module stability.
481-
//
482-
// Compute if SwiftPM is bootstrapping.
483-
let env = ProcessInfo.processInfo.environment
484-
guard env.keys.contains("SWIFTPM_BOOTSTRAP") else { return [] }
485-
guard let buildPathStr = env["SWIFTPM_BUILD_DIR"], let buildPath = try? AbsolutePath(validating: buildPathStr) else {
486-
return []
487-
}
488-
489-
// Construct the required search paths relative to the build directory.
490-
let libdir = buildPath.appending(RelativePath(".bootstrap/lib/swift/linux"))
491-
let incdir = libdir.appending(component: "x86_64")
492-
let dispatchIncdir = incdir.appending(component: "dispatch")
493-
494-
return [
495-
"-I\(incdir)",
496-
"-I\(dispatchIncdir)",
497-
"-L\(libdir)",
498-
"-Xcc", "-F\(incdir)",
499-
]
500-
#endif
501-
}
502-
503472
/// Returns path to the sdk, if possible.
504473
private func sdkRoot() -> AbsolutePath? {
505474
if let sdkRoot = _sdkRoot {

Utilities/bootstrap

Lines changed: 1 addition & 117 deletions
Original file line numberDiff line numberDiff line change
@@ -262,20 +262,6 @@ class Target(object):
262262
if dep_target.is_c:
263263
import_paths.append(os.path.join(dep_target.module_root_dir, "include"))
264264

265-
if args.foundation_path:
266-
import_paths.append(args.foundation_path)
267-
other_args.extend(["-Xcc", "-F" + args.foundation_path])
268-
import_paths.append(os.path.join(args.foundation_path, "swift"))
269-
if args.libdispatch_build_dir:
270-
import_paths.append(os.path.join(args.libdispatch_build_dir, 'lib'))
271-
import_paths.append(os.path.join(args.libdispatch_build_dir, "src"))
272-
import_paths.append(os.path.join(args.libdispatch_build_dir, "src", "swift"))
273-
import_paths.append(os.path.join(args.libdispatch_build_dir, "src", "swift", "swift"))
274-
if args.libdispatch_source_dir:
275-
import_paths.append(args.libdispatch_source_dir)
276-
if args.xctest_path:
277-
import_paths.append(args.xctest_path)
278-
279265
# Add llbuild import paths.
280266
llbuild_import_paths_value = llbuild_import_paths(args)
281267
if llbuild_import_paths_value:
@@ -583,17 +569,6 @@ class llbuild(object):
583569
if platform.system() == 'Linux':
584570
link_command.extend(
585571
["-Xlinker", "-rpath=$ORIGIN/../lib/swift/linux"])
586-
if self.args.foundation_path:
587-
link_command.extend([
588-
"-L", self.args.foundation_path,
589-
"-L", os.path.join(self.args.foundation_path, "Foundation")
590-
])
591-
if self.args.libdispatch_build_dir:
592-
link_command.extend(['-L', self.args.libdispatch_build_dir,
593-
'-L', os.path.join(self.args.libdispatch_build_dir, 'lib'),
594-
'-Xlinker', '-lBlocksRuntime'])
595-
link_command.extend(['-L', os.path.join(self.args.libdispatch_build_dir, "src"),
596-
'-L', os.path.join(self.args.libdispatch_build_dir, 'lib')])
597572

598573
# Add llbuild link flags.
599574
link_command.extend(llbuild_link_args(self.args))
@@ -959,9 +934,6 @@ def main():
959934
help="Extra actions to perform. Can be any number of "
960935
"the following: [clean, all, test, install]",
961936
nargs="*", default=["all"])
962-
parser.add_argument("--show-bin-path", action='store_true',
963-
help="output the path to which the swiftpm binaries "
964-
"are built")
965937
parser.add_argument("--swiftc", dest="swiftc_path",
966938
help="path to the swift compiler [%(default)s]",
967939
metavar="PATH")
@@ -981,14 +953,6 @@ def main():
981953
default=["/usr/local"], metavar="PATHS")
982954
parser.add_argument("-v", "--verbose", action="store_true",
983955
help="use verbose output")
984-
parser.add_argument("--foundation", dest="foundation_path",
985-
help="Path to Foundation build directory")
986-
parser.add_argument("--xctest", dest="xctest_path",
987-
help="Path to XCTest build directory")
988-
parser.add_argument("--libdispatch-build-dir", dest="libdispatch_build_dir",
989-
help="Path to the libdispatch build directory")
990-
parser.add_argument("--libdispatch-source-dir", dest="libdispatch_source_dir",
991-
help="Path to the libdispatch source directory")
992956
parser.add_argument("--link-llbuild", dest="link_llbuild",
993957
action="store_true", help="link llbuild", default=True)
994958
parser.add_argument("--llbuild-link-framework", dest="llbuild_link_framework",
@@ -1040,10 +1004,6 @@ def main():
10401004
args.swiftc_path = os.path.abspath(args.swiftc_path)
10411005
if args.sbt_path:
10421006
args.sbt_path = os.path.abspath(args.sbt_path)
1043-
if args.foundation_path:
1044-
args.foundation_path = os.path.abspath(args.foundation_path)
1045-
if args.xctest_path:
1046-
args.xctest_path = os.path.abspath(args.xctest_path)
10471007
if args.llbuild_source_dir:
10481008
args.llbuild_source_dir = os.path.abspath(args.llbuild_source_dir)
10491009

@@ -1091,10 +1051,6 @@ def main():
10911051
libdir = os.path.join(target_path, "lib")
10921052
bindir = os.path.join(target_path, conf)
10931053

1094-
if args.show_bin_path:
1095-
print(bindir)
1096-
sys.exit(0)
1097-
10981054
# If the action is "clean", just remove the bootstrap and build directories.
10991055
if "clean" in build_actions:
11001056
cmd = ["rm", "-rf", sandbox_path]
@@ -1181,7 +1137,6 @@ def main():
11811137
symlink_force(args.swiftc_path, os.path.join(bindir, "swift"))
11821138
symlink_force(args.swiftc_path, os.path.join(bindir, "swiftc"))
11831139
symlink_force(args.clang_path, os.path.join(bindir, "clang"))
1184-
symlink_force(args.sbt_path, os.path.join(bindir, "swift-build-tool"))
11851140
symlink_force(os.path.join(sandbox_path, "bin", "swift-build"),
11861141
bootstrapped_product)
11871142
if os.path.isdir(libdir) and not os.path.islink(libdir):
@@ -1194,62 +1149,7 @@ def main():
11941149
mkdir_p(usrdir)
11951150
symlink_force(os.path.join(sandbox_path, "lib"), usrdir)
11961151

1197-
if args.foundation_path and args.libdispatch_build_dir and args.xctest_path:
1198-
libswiftdir = os.path.join(sandbox_path, "lib", "swift", "linux")
1199-
libincludedir = os.path.join(libswiftdir, "x86_64")
1200-
mkdir_p(libswiftdir)
1201-
mkdir_p(libincludedir)
1202-
1203-
for module in ["Foundation", "FoundationNetworking", "FoundationXML"]:
1204-
# Add the library.
1205-
for subdir in ['Foundation', '']:
1206-
path = os.path.join(args.foundation_path, subdir, 'lib{}.so'.format(module))
1207-
if os.path.exists(path):
1208-
symlink_force(path, libswiftdir)
1209-
break
1210-
1211-
# Add Foundation's swiftmodule.
1212-
for extension in [".swiftmodule", ".swiftdoc"]:
1213-
symlink_force(os.path.join(args.foundation_path, 'swift', module + extension), libincludedir)
1214-
1215-
# Add CoreFoundation "framework". This just contains the header and the modulemap.
1216-
core_foundation_path = os.path.join(args.foundation_path, "CoreFoundation.framework")
1217-
symlink_force(core_foundation_path, libincludedir)
1218-
cf_url_session_path = os.path.join(args.foundation_path, "CFURLSessionInterface.framework")
1219-
symlink_force(cf_url_session_path, libincludedir)
1220-
cf_xml_path = os.path.join(args.foundation_path, "CFXMLInterface.framework")
1221-
symlink_force(cf_xml_path, libincludedir)
1222-
1223-
# Add symlinks for dispatch.
1224-
for library in ['libBlocksRuntime.so', 'libdispatch.so', 'libswiftDispatch.so']:
1225-
for subdir in ['lib', 'src', '']:
1226-
path = os.path.join(args.libdispatch_build_dir, subdir, library)
1227-
if os.path.exists(path):
1228-
symlink_force(path, libswiftdir)
1229-
break
1230-
1231-
# Add swiftmodules.
1232-
for module_file in ["Dispatch.swiftmodule", "Dispatch.swiftdoc"]:
1233-
paths = [
1234-
os.path.join(args.libdispatch_build_dir, 'src', 'swift', 'swift', module_file),
1235-
os.path.join(args.libdispatch_build_dir, 'src', 'swift', module_file),
1236-
]
1237-
for path in paths:
1238-
if os.path.exists(path):
1239-
symlink_force(path, libincludedir)
1240-
continue
1241-
1242-
symlink_force(os.path.join(args.libdispatch_source_dir), os.path.join(libincludedir, "dispatch"))
1243-
1244-
# Add XCTest.
1245-
for module_file in ["XCTest.swiftmodule", "XCTest.swiftdoc"]:
1246-
symlink_force(os.path.join(args.xctest_path, 'swift', module_file), libincludedir)
1247-
symlink_force(os.path.join(args.xctest_path, "libXCTest.so"), libswiftdir)
1248-
1249-
return (libswiftdir, libincludedir)
1250-
return (None, None)
1251-
1252-
(faketoolchain_libdir, faketoolchain_includedir) = make_fake_toolchain()
1152+
make_fake_toolchain()
12531153

12541154
# Build the package manager with itself.
12551155

@@ -1275,22 +1175,6 @@ def main():
12751175
# Append the versioning build flags.
12761176
build_flags.extend(create_versoning_args(args))
12771177

1278-
if faketoolchain_includedir:
1279-
# This will take care of swiftmodules of Foundation and Dispatch.
1280-
build_flags.extend(["-Xswiftc", "-I{}".format(faketoolchain_includedir)])
1281-
1282-
# Pass -F flag for CoreFoundation.
1283-
build_flags.extend(["-Xswiftc", "-Xcc", "-Xswiftc", "-F{}".format(faketoolchain_includedir)])
1284-
1285-
# Pass -I for underlying Dispatch module.
1286-
build_flags.extend(["-Xswiftc", "-I{}".format(os.path.join(faketoolchain_includedir, "dispatch"))])
1287-
1288-
# Library search path.
1289-
build_flags.extend(["-Xlinker", "-L{}".format(faketoolchain_libdir)])
1290-
1291-
# Add an RPATH, so that the tests can be run directly.
1292-
build_flags.extend(["-Xlinker", "-rpath", "-Xlinker", faketoolchain_libdir])
1293-
12941178
# Add llbuild import flags.
12951179
for import_path in llbuild_import_paths(args):
12961180
build_flags.extend(["-Xswiftc", "-I%s" % import_path])

0 commit comments

Comments
 (0)