Skip to content

Commit 87d81d7

Browse files
committed
[bootstrap] Clean up the compiler arguments during bootstrap
This enhances the fake toolchain logic by symlinking the swiftmodule files in the x86_64 directory. This results in less number of overall compiler args that are required.
1 parent c430893 commit 87d81d7

File tree

1 file changed

+49
-44
lines changed

1 file changed

+49
-44
lines changed

Utilities/bootstrap

Lines changed: 49 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -227,9 +227,6 @@ class Target(object):
227227
compile_swift_node = '<compile-swift-%s>' % (self.name,)
228228
link_input_nodes.append(compile_swift_node)
229229

230-
if args.libdispatch_source_dir:
231-
other_args.extend(["-Xcc", "-fblocks"])
232-
233230
other_args.extend(["-swift-version", "4"])
234231

235232
print(" %s:" % json.dumps(compile_swift_node), file=output)
@@ -1143,21 +1140,44 @@ def main():
11431140
mkdir_p(usrdir)
11441141
symlink_force(os.path.join(sandbox_path, "lib"), usrdir)
11451142

1146-
if args.foundation_path:
1143+
if args.foundation_path and args.libdispatch_build_dir and args.xctest_path:
11471144
libswiftdir = os.path.join(sandbox_path, "lib", "swift", "linux")
1145+
libincludedir = os.path.join(libswiftdir, "x86_64")
11481146
mkdir_p(libswiftdir)
1149-
symlink_force(os.path.join(args.foundation_path, 'libFoundation.so'),
1150-
libswiftdir)
1151-
if args.libdispatch_build_dir:
1152-
symlink_force(os.path.join(args.libdispatch_build_dir,
1153-
'libBlocksRuntime.so'),
1154-
libswiftdir)
1155-
symlink_force(os.path.join(args.libdispatch_build_dir, "src", "libdispatch.so"),
1156-
libswiftdir)
1157-
symlink_force(os.path.join(args.libdispatch_build_dir, "src", "libswiftDispatch.so"),
1158-
libswiftdir)
1159-
1160-
make_fake_toolchain()
1147+
mkdir_p(libincludedir)
1148+
1149+
# Add libFoundation.
1150+
symlink_force(os.path.join(args.foundation_path, 'libFoundation.so'), libswiftdir)
1151+
1152+
# Add Foundation's swiftmodule.
1153+
for module_file in ["Foundation.swiftmodule", "Foundation.swiftdoc"]:
1154+
symlink_force(os.path.join(args.foundation_path, 'swift', module_file), libincludedir)
1155+
1156+
# Add CoreFoundation "framework". This just contains the header and the modulemap.
1157+
core_foundation_path = os.path.join(
1158+
args.foundation_path, "CoreFoundation-prefix", "System", "Library", "Frameworks", "CoreFoundation.framework")
1159+
symlink_force(core_foundation_path, libincludedir)
1160+
1161+
# Add symlinks for dispatch.
1162+
symlink_force(os.path.join(args.libdispatch_build_dir, 'libBlocksRuntime.so'), libswiftdir)
1163+
symlink_force(os.path.join(args.libdispatch_build_dir, "src", "libdispatch.so"), libswiftdir)
1164+
symlink_force(os.path.join(args.libdispatch_build_dir, "src", "libswiftDispatch.so"), libswiftdir)
1165+
1166+
# Add swiftmodules.
1167+
for module_file in ["Dispatch.swiftmodule", "Dispatch.swiftdoc"]:
1168+
symlink_force(os.path.join(args.libdispatch_build_dir, 'src', 'swift', module_file), libincludedir)
1169+
1170+
symlink_force(os.path.join(args.libdispatch_source_dir), os.path.join(libincludedir, "dispatch"))
1171+
1172+
# Add XCTest.
1173+
for module_file in ["XCTest.swiftmodule", "XCTest.swiftdoc"]:
1174+
symlink_force(os.path.join(args.xctest_path, module_file), libincludedir)
1175+
symlink_force(os.path.join(args.xctest_path, "libXCTest.so"), libswiftdir)
1176+
1177+
return (libswiftdir, libincludedir)
1178+
return (None, None)
1179+
1180+
(faketoolchain_libdir, faketoolchain_includedir) = make_fake_toolchain()
11611181

11621182
# Build the package manager with itself.
11631183

@@ -1183,36 +1203,21 @@ def main():
11831203
# Append the versioning build flags.
11841204
build_flags.extend(create_versoning_args(args))
11851205

1186-
if args.foundation_path:
1187-
build_flags.extend(["-Xswiftc", "-I{}".format(os.path.join(args.foundation_path, "swift"))])
1188-
core_foundation_path = os.path.join(args.foundation_path, "CoreFoundation-prefix", "System", "Library", "Frameworks")
1189-
build_flags.extend(["-Xswiftc", "-Xcc", "-Xswiftc", "-F{}".format(core_foundation_path)])
1190-
# Tell the linker where to look for XCTest, but autolinking
1191-
# knows to pass -lXCTest.
1192-
build_flags.extend(["-Xlinker", "-L", "-Xlinker", args.foundation_path])
1193-
# Add an RPATH, so that the tests can be run directly.
1194-
build_flags.extend(["-Xlinker", "-rpath", "-Xlinker", args.foundation_path])
1206+
if faketoolchain_includedir:
1207+
# This will take care of swiftmodules of Foundation and Dispatch.
1208+
build_flags.extend(["-Xswiftc", "-I{}".format(faketoolchain_includedir)])
1209+
1210+
# Pass -F flag for CoreFoundation.
1211+
build_flags.extend(["-Xswiftc", "-Xcc", "-Xswiftc", "-F{}".format(faketoolchain_includedir)])
1212+
1213+
# Pass -I for underlying Dispatch module.
1214+
build_flags.extend(["-Xswiftc", "-I{}".format(os.path.join(faketoolchain_includedir, "dispatch"))])
1215+
1216+
# Library search path.
1217+
build_flags.extend(["-Xlinker", "-L{}".format(faketoolchain_libdir)])
11951218

1196-
if args.xctest_path:
1197-
# Tell the linker where to look for XCTest, but autolinking
1198-
# knows to pass -lXCTest.
1199-
build_flags.extend(["-Xlinker", "-L", "-Xlinker", args.xctest_path])
12001219
# Add an RPATH, so that the tests can be run directly.
1201-
build_flags.extend(["-Xlinker", "-rpath", "-Xlinker", args.xctest_path])
1202-
build_flags.extend(["-Xswiftc", "-I{}".format(args.xctest_path)])
1203-
1204-
if args.libdispatch_build_dir:
1205-
build_flags.extend(["-Xlinker", "-L{}".format(
1206-
os.path.join(args.libdispatch_build_dir, "src"))])
1207-
build_flags.extend(["-Xswiftc", "-I{}".format(
1208-
os.path.join(args.libdispatch_build_dir, "src"))])
1209-
build_flags.extend(["-Xswiftc", "-I{}".format(
1210-
os.path.join(args.libdispatch_build_dir, "src", "swift"))])
1211-
build_flags.extend(["-Xswiftc", "-I{}".format(
1212-
args.libdispatch_source_dir)])
1213-
build_flags.extend(["-Xcc", "-fblocks"])
1214-
build_flags.extend(['-Xlinker', '-L', '-Xlinker', args.libdispatch_build_dir,
1215-
'-Xlinker', '-lBlocksRuntime'])
1220+
build_flags.extend(["-Xlinker", "-rpath", "-Xlinker", faketoolchain_libdir])
12161221

12171222
# Add llbuild import flags.
12181223
for import_path in llbuild_import_paths(args):

0 commit comments

Comments
 (0)