Skip to content

[bootstrap] Remove fake toolchain dead code from the bootstrap script #2397

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

Merged
merged 1 commit into from
Nov 4, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 0 additions & 31 deletions Sources/PackageLoading/ManifestLoader.swift
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,6 @@ public final class ManifestLoader: ManifestLoaderProtocol {
#endif
cmd += [resources.swiftCompiler.pathString]
cmd += ["--driver-mode=swift"]
cmd += bootstrapArgs()
cmd += verbosity.ccArgs
cmd += ["-L", runtimePath, "-lPackageDescription"]
cmd += interpreterFlags
Expand Down Expand Up @@ -470,36 +469,6 @@ public final class ManifestLoader: ManifestLoaderProtocol {
return manifestParseResult
}

/// Returns the extra manifest args required during SwiftPM's own bootstrap.
private func bootstrapArgs() -> [String] {
#if !os(Linux)
return []
#else
// The Linux bots require extra arguments in order to locate the corelibs.
// We can potentially drop this by installing some stable linux toolchain
// after Swift gets ABI and module stability.
//
// Compute if SwiftPM is bootstrapping.
let env = ProcessInfo.processInfo.environment
guard env.keys.contains("SWIFTPM_BOOTSTRAP") else { return [] }
guard let buildPathStr = env["SWIFTPM_BUILD_DIR"], let buildPath = try? AbsolutePath(validating: buildPathStr) else {
return []
}

// Construct the required search paths relative to the build directory.
let libdir = buildPath.appending(RelativePath(".bootstrap/lib/swift/linux"))
let incdir = libdir.appending(component: "x86_64")
let dispatchIncdir = incdir.appending(component: "dispatch")

return [
"-I\(incdir)",
"-I\(dispatchIncdir)",
"-L\(libdir)",
"-Xcc", "-F\(incdir)",
]
#endif
}

/// Returns path to the sdk, if possible.
private func sdkRoot() -> AbsolutePath? {
if let sdkRoot = _sdkRoot {
Expand Down
118 changes: 1 addition & 117 deletions Utilities/bootstrap
Original file line number Diff line number Diff line change
Expand Up @@ -262,20 +262,6 @@ class Target(object):
if dep_target.is_c:
import_paths.append(os.path.join(dep_target.module_root_dir, "include"))

if args.foundation_path:
import_paths.append(args.foundation_path)
other_args.extend(["-Xcc", "-F" + args.foundation_path])
import_paths.append(os.path.join(args.foundation_path, "swift"))
if args.libdispatch_build_dir:
import_paths.append(os.path.join(args.libdispatch_build_dir, 'lib'))
import_paths.append(os.path.join(args.libdispatch_build_dir, "src"))
import_paths.append(os.path.join(args.libdispatch_build_dir, "src", "swift"))
import_paths.append(os.path.join(args.libdispatch_build_dir, "src", "swift", "swift"))
if args.libdispatch_source_dir:
import_paths.append(args.libdispatch_source_dir)
if args.xctest_path:
import_paths.append(args.xctest_path)

# Add llbuild import paths.
llbuild_import_paths_value = llbuild_import_paths(args)
if llbuild_import_paths_value:
Expand Down Expand Up @@ -583,17 +569,6 @@ class llbuild(object):
if platform.system() == 'Linux':
link_command.extend(
["-Xlinker", "-rpath=$ORIGIN/../lib/swift/linux"])
if self.args.foundation_path:
link_command.extend([
"-L", self.args.foundation_path,
"-L", os.path.join(self.args.foundation_path, "Foundation")
])
if self.args.libdispatch_build_dir:
link_command.extend(['-L', self.args.libdispatch_build_dir,
'-L', os.path.join(self.args.libdispatch_build_dir, 'lib'),
'-Xlinker', '-lBlocksRuntime'])
link_command.extend(['-L', os.path.join(self.args.libdispatch_build_dir, "src"),
'-L', os.path.join(self.args.libdispatch_build_dir, 'lib')])

# Add llbuild link flags.
link_command.extend(llbuild_link_args(self.args))
Expand Down Expand Up @@ -959,9 +934,6 @@ def main():
help="Extra actions to perform. Can be any number of "
"the following: [clean, all, test, install]",
nargs="*", default=["all"])
parser.add_argument("--show-bin-path", action='store_true',
help="output the path to which the swiftpm binaries "
"are built")
parser.add_argument("--swiftc", dest="swiftc_path",
help="path to the swift compiler [%(default)s]",
metavar="PATH")
Expand All @@ -981,14 +953,6 @@ def main():
default=["/usr/local"], metavar="PATHS")
parser.add_argument("-v", "--verbose", action="store_true",
help="use verbose output")
parser.add_argument("--foundation", dest="foundation_path",
help="Path to Foundation build directory")
parser.add_argument("--xctest", dest="xctest_path",
help="Path to XCTest build directory")
parser.add_argument("--libdispatch-build-dir", dest="libdispatch_build_dir",
help="Path to the libdispatch build directory")
parser.add_argument("--libdispatch-source-dir", dest="libdispatch_source_dir",
help="Path to the libdispatch source directory")
parser.add_argument("--link-llbuild", dest="link_llbuild",
action="store_true", help="link llbuild", default=True)
parser.add_argument("--llbuild-link-framework", dest="llbuild_link_framework",
Expand Down Expand Up @@ -1040,10 +1004,6 @@ def main():
args.swiftc_path = os.path.abspath(args.swiftc_path)
if args.sbt_path:
args.sbt_path = os.path.abspath(args.sbt_path)
if args.foundation_path:
args.foundation_path = os.path.abspath(args.foundation_path)
if args.xctest_path:
args.xctest_path = os.path.abspath(args.xctest_path)
if args.llbuild_source_dir:
args.llbuild_source_dir = os.path.abspath(args.llbuild_source_dir)

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

if args.show_bin_path:
print(bindir)
sys.exit(0)

# If the action is "clean", just remove the bootstrap and build directories.
if "clean" in build_actions:
cmd = ["rm", "-rf", sandbox_path]
Expand Down Expand Up @@ -1181,7 +1137,6 @@ def main():
symlink_force(args.swiftc_path, os.path.join(bindir, "swift"))
symlink_force(args.swiftc_path, os.path.join(bindir, "swiftc"))
symlink_force(args.clang_path, os.path.join(bindir, "clang"))
symlink_force(args.sbt_path, os.path.join(bindir, "swift-build-tool"))
symlink_force(os.path.join(sandbox_path, "bin", "swift-build"),
bootstrapped_product)
if os.path.isdir(libdir) and not os.path.islink(libdir):
Expand All @@ -1194,62 +1149,7 @@ def main():
mkdir_p(usrdir)
symlink_force(os.path.join(sandbox_path, "lib"), usrdir)

if args.foundation_path and args.libdispatch_build_dir and args.xctest_path:
libswiftdir = os.path.join(sandbox_path, "lib", "swift", "linux")
libincludedir = os.path.join(libswiftdir, "x86_64")
mkdir_p(libswiftdir)
mkdir_p(libincludedir)

for module in ["Foundation", "FoundationNetworking", "FoundationXML"]:
# Add the library.
for subdir in ['Foundation', '']:
path = os.path.join(args.foundation_path, subdir, 'lib{}.so'.format(module))
if os.path.exists(path):
symlink_force(path, libswiftdir)
break

# Add Foundation's swiftmodule.
for extension in [".swiftmodule", ".swiftdoc"]:
symlink_force(os.path.join(args.foundation_path, 'swift', module + extension), libincludedir)

# Add CoreFoundation "framework". This just contains the header and the modulemap.
core_foundation_path = os.path.join(args.foundation_path, "CoreFoundation.framework")
symlink_force(core_foundation_path, libincludedir)
cf_url_session_path = os.path.join(args.foundation_path, "CFURLSessionInterface.framework")
symlink_force(cf_url_session_path, libincludedir)
cf_xml_path = os.path.join(args.foundation_path, "CFXMLInterface.framework")
symlink_force(cf_xml_path, libincludedir)

# Add symlinks for dispatch.
for library in ['libBlocksRuntime.so', 'libdispatch.so', 'libswiftDispatch.so']:
for subdir in ['lib', 'src', '']:
path = os.path.join(args.libdispatch_build_dir, subdir, library)
if os.path.exists(path):
symlink_force(path, libswiftdir)
break

# Add swiftmodules.
for module_file in ["Dispatch.swiftmodule", "Dispatch.swiftdoc"]:
paths = [
os.path.join(args.libdispatch_build_dir, 'src', 'swift', 'swift', module_file),
os.path.join(args.libdispatch_build_dir, 'src', 'swift', module_file),
]
for path in paths:
if os.path.exists(path):
symlink_force(path, libincludedir)
continue

symlink_force(os.path.join(args.libdispatch_source_dir), os.path.join(libincludedir, "dispatch"))

# Add XCTest.
for module_file in ["XCTest.swiftmodule", "XCTest.swiftdoc"]:
symlink_force(os.path.join(args.xctest_path, 'swift', module_file), libincludedir)
symlink_force(os.path.join(args.xctest_path, "libXCTest.so"), libswiftdir)

return (libswiftdir, libincludedir)
return (None, None)

(faketoolchain_libdir, faketoolchain_includedir) = make_fake_toolchain()
make_fake_toolchain()

# Build the package manager with itself.

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

if faketoolchain_includedir:
# This will take care of swiftmodules of Foundation and Dispatch.
build_flags.extend(["-Xswiftc", "-I{}".format(faketoolchain_includedir)])

# Pass -F flag for CoreFoundation.
build_flags.extend(["-Xswiftc", "-Xcc", "-Xswiftc", "-F{}".format(faketoolchain_includedir)])

# Pass -I for underlying Dispatch module.
build_flags.extend(["-Xswiftc", "-I{}".format(os.path.join(faketoolchain_includedir, "dispatch"))])

# Library search path.
build_flags.extend(["-Xlinker", "-L{}".format(faketoolchain_libdir)])

# Add an RPATH, so that the tests can be run directly.
build_flags.extend(["-Xlinker", "-rpath", "-Xlinker", faketoolchain_libdir])

# Add llbuild import flags.
for import_path in llbuild_import_paths(args):
build_flags.extend(["-Xswiftc", "-I%s" % import_path])
Expand Down