Skip to content

Commit 6d2cdd1

Browse files
committed
Fix bug in create_sysimg_from_object_file for Xcode 15 CLT
1 parent 8cd96a1 commit 6d2cdd1

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/PackageCompiler.jl

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -686,7 +686,17 @@ function create_sysimg_from_object_file(object_files::Vector{String},
686686
end
687687
mkpath(dirname(sysimage_path))
688688
# Prevent compiler from stripping all symbols from the shared lib.
689-
o_file_flags = Sys.isapple() ? `-Wl,-all_load $object_files` : `-Wl,--whole-archive $object_files -Wl,--no-whole-archive`
689+
if Sys.isapple()
690+
cltools_version_cmd = `pkgutil --pkg-info=com.apple.pkg.CLTools_Executables`
691+
cltools_version = match(r"version: (.*)\n", readchomp(cltools_version_cmd))[1]
692+
if startswith(cltools_version, "15")
693+
o_file_flags = `-Wl,-all_load $object_files -Wl,-ld_classic`
694+
else
695+
o_file_flags = `-Wl,-all_load $object_files`
696+
end
697+
else
698+
o_file_flags = `-Wl,--whole-archive $object_files -Wl,--no-whole-archive`
699+
end
690700
extra = get_extra_linker_flags(version, compat_level, soname)
691701
cmd = `$(bitflag()) $(march()) -shared -L$(julia_libdir()) -L$(julia_private_libdir()) -o $sysimage_path $o_file_flags $(Base.shell_split(ldlibs())) $extra`
692702
run_compiler(cmd; cplusplus=true)

0 commit comments

Comments
 (0)