Skip to content

Commit 088937e

Browse files
committed
[bootstrap] Remove PackageDescription linking hack
SwiftPM's bootstrap script derives the linking command by calling swiftc with -###. I think this was needed in the past because we couldn't forward the -Xlinker args to the linker on linux. This no longer seems to be true since Swift is using clang++ on linux as the linker. The -Xlinker args are correctly forwarded to clang++ so we can stop using this hack. This hack surfaced an issue when trying to land the Codable in PackageDescription PR as we were dropping the swiftrt.o file during linking. <rdar://problem/45976814> SwiftPM shouldn't need to derive the linking command when producing its runtimes on linux
1 parent 34565c3 commit 088937e

File tree

1 file changed

+1
-20
lines changed

1 file changed

+1
-20
lines changed

Utilities/bootstrap

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -668,13 +668,6 @@ def process_runtime_libraries(build, args, lib_path):
668668
input_lib_path,
669669
"-target", "x86_64-apple-macosx10.10"]
670670
else:
671-
# Derive the command line to use by querying to swiftc
672-
# driver. Unfortunately we cannot use it directly due to the inability
673-
# to use an -X... style arg to pass arguments to the Clang driver, which
674-
# it calls before calling the linker.
675-
676-
# This is the command we would like to use.
677-
#
678671
# We include an RPATH entry so that the Swift libraries can be found
679672
# relative to where it will be installed (in 'lib/swift/pm/<version>/...').
680673
runtime_lib_path = os.path.join(lib_path, "libPackageDescription.so")
@@ -687,20 +680,8 @@ def process_runtime_libraries(build, args, lib_path):
687680
# We need to pass one swift file here to bypass the "no input files"
688681
# error.
689682
tf = tempfile.NamedTemporaryFile(suffix=".swift")
690-
cmds = subprocess.check_output(
691-
cmd + [tf.name, "-###"],
692-
universal_newlines=True).strip().split("\n")
693-
694-
# Get the link command 'swiftc' used.
695-
link_cmd = shlex.split(cmds[-1])
696-
697-
# Unqoute any quoted characters.
698-
link_cmd = [arg.replace("\\", "") for arg in link_cmd]
683+
cmd += [tf.name]
699684

700-
# Drop any .o files
701-
cmd = [arg for arg in link_cmd
702-
if arg.endswith(("swift_begin.o", "swift_end.o")) or
703-
(not arg.endswith((".o", ".autolink")))]
704685
subprocess.check_call(cmd)
705686
return (runtime_module_path, runtime_swiftdoc_path, runtime_lib_path)
706687

0 commit comments

Comments
 (0)