Skip to content

Commit 60a3d43

Browse files
committed
[new-bootstrap] Fix linux build
1 parent ad2b934 commit 60a3d43

File tree

3 files changed

+37
-30
lines changed

3 files changed

+37
-30
lines changed

Sources/SPMLLBuild/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ else()
1919
set_target_properties(libllbuildSwift
2020
PROPERTIES
2121
FRAMEWORK TRUE
22-
IMPORTED_LOCATION ${LLBUILD_BUILD_DIR}/lib/libllbuildSwift.dylib
22+
IMPORTED_LOCATION ${LLBUILD_BUILD_DIR}/lib
2323
INTERFACE_INCLUDE_DIRECTORIES ${LLBUILD_BUILD_DIR}/products/llbuildSwift)
2424
endif()
2525

@@ -34,7 +34,7 @@ target_link_libraries(SPMLLBuild PUBLIC
3434
if(LLBUILD_FRAMEWORK)
3535
target_link_libraries(SPMLLBuild PUBLIC -F libllbuildSwift)
3636
else()
37-
target_link_libraries(SPMLLBuild PUBLIC libllbuild libllbuildSwift)
37+
target_link_libraries(SPMLLBuild PUBLIC libllbuild -L libllbuildSwift)
3838
endif()
3939

4040
# NOTE(compnerd) workaround for CMake not setting up include flags yet

Sources/swift-build/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,4 @@ target_link_libraries(swift-build PRIVATE
1414
if(CMAKE_SYSTEM_NAME STREQUAL Windows)
1515
install(TARGETS swift-build
1616
DESTINATION bin)
17-
else()
1817
endif()

Utilities/new-bootstrap

Lines changed: 35 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -191,35 +191,36 @@ def bootstrap(args):
191191
args.bootstrap_path = os.path.join(args.target_path, "bootstrap")
192192
bootstrap_path = args.bootstrap_path
193193

194+
195+
cmake_swift_flags = ""
196+
if platform.system() == 'Darwin':
197+
cmake_swift_flags = "-sdk " + g_default_sysroot
198+
199+
if args.llbuild_link_framework:
200+
llbuild_arg = "-DLLBUILD_FRAMEWORK=%s" % args.llbuild_build_dir
201+
else:
202+
llbuild_dir = os.path.join(args.llbuild_build_dir, "cmake/modules")
203+
llbuild_arg = "-DLLBuild_DIR=" + llbuild_dir
204+
205+
swiftpm_build_path = os.path.join(args.target_path, args.conf)
206+
207+
cmd = [
208+
"cmake", "-G", "Ninja",
209+
"-DCMAKE_BUILD_TYPE:=Debug",
210+
"-DCMAKE_C_COMPILER:=clang",
211+
llbuild_arg,
212+
"-DCMAKE_Swift_FLAGS=" + cmake_swift_flags,
213+
"-DUSE_VENDORED_TSC=ON",
214+
"-DSWIFTPM_BUILD_DIR=" + swiftpm_build_path,
215+
"-DCMAKE_INSTALL_PREFIX=" + args.install_prefixes[0],
216+
g_project_root,
217+
]
218+
print(' '.join(cmd))
219+
194220
# Run CMake if needed.
195221
cmake_cache_path = os.path.join(bootstrap_path, "CMakeCache.txt")
196222
if not os.path.isfile(cmake_cache_path):
197223
mkdir_p(bootstrap_path)
198-
199-
cmake_swift_flags = ""
200-
if platform.system() == 'Darwin':
201-
cmake_swift_flags = "-sdk " + g_default_sysroot
202-
203-
if args.llbuild_link_framework:
204-
llbuild_arg = "-DLLBUILD_FRAMEWORK=%s" % args.llbuild_build_dir
205-
else:
206-
llbuild_dir = os.path.join(args.llbuild_build_dir, "cmake/modules")
207-
llbuild_arg = "-DLLBuild_DIR=" + llbuild_dir
208-
209-
swiftpm_build_path = os.path.join(args.target_path, args.conf)
210-
211-
cmd = [
212-
"cmake", "-G", "Ninja",
213-
"-DCMAKE_BUILD_TYPE:=Debug",
214-
"-DCMAKE_C_COMPILER:=clang",
215-
llbuild_arg,
216-
"-DCMAKE_Swift_FLAGS=" + cmake_swift_flags,
217-
"-DUSE_VENDORED_TSC=ON",
218-
"-DSWIFTPM_BUILD_DIR=" + swiftpm_build_path,
219-
"-DCMAKE_INSTALL_PREFIX=" + args.install_prefixes[0],
220-
g_project_root,
221-
]
222-
print(' '.join(cmd))
223224
subprocess.check_call(cmd, cwd=bootstrap_path)
224225

225226
# Build.
@@ -244,6 +245,7 @@ def build_swiftpm(args):
244245
os.path.join(args.llbuild_build_dir, "lib"),
245246
]
246247
env_cmd.append("DYLD_LIBRARY_PATH=%s" % (":".join(libs)))
248+
env_cmd.append("LD_LIBRARY_PATH=%s" % (":".join(libs)))
247249

248250
build_flags = []
249251
build_flags.append(os.path.join(args.bootstrap_path, "bin/swift-build"))
@@ -309,9 +311,15 @@ def main():
309311
args.build_path = os.path.abspath(args.build_path)
310312
args.swiftc_path = get_swiftc_path()
311313

312-
build_target = "x86_64-apple-macosx"
314+
if platform.system() == 'Darwin':
315+
build_target = "x86_64-apple-macosx"
316+
else:
317+
build_target = subprocess.check_output(
318+
["clang", "--print-target-triple"],
319+
universal_newlines=True).strip()
320+
313321
args.target_path = os.path.join(args.build_path, build_target)
314-
args.conf = 'debug' if args.release else 'release'
322+
args.conf = 'release' if args.release else 'debug'
315323

316324
if "build-pd" in build_actions:
317325
build_runtimes_only(args)

0 commit comments

Comments
 (0)