Skip to content

Commit 75d94e8

Browse files
jayscookPhilReinhold
authored andcommitted
Fix bug in create_sysimg_from_object_file for Xcode 15 CLT
Co-authored-by: Jay Cook <[email protected]> Co-authored-by: Phil Reinhold <[email protected]>
1 parent b4201d8 commit 75d94e8

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
@@ -711,7 +711,17 @@ function create_sysimg_from_object_file(object_files::Vector{String},
711711
end
712712
mkpath(dirname(sysimage_path))
713713
# Prevent compiler from stripping all symbols from the shared lib.
714-
o_file_flags = Sys.isapple() ? `-Wl,-all_load $object_files` : `-Wl,--whole-archive $object_files -Wl,--no-whole-archive`
714+
if Sys.isapple()
715+
cltools_version_cmd = `pkgutil --pkg-info=com.apple.pkg.CLTools_Executables`
716+
cltools_version = match(r"version: (.*)\n", readchomp(cltools_version_cmd))[1]
717+
if startswith(cltools_version, "15")
718+
o_file_flags = `-Wl,-all_load $object_files -Wl,-ld_classic`
719+
else
720+
o_file_flags = `-Wl,-all_load $object_files`
721+
end
722+
else
723+
o_file_flags = `-Wl,--whole-archive $object_files -Wl,--no-whole-archive`
724+
end
715725
extra = get_extra_linker_flags(version, compat_level, soname)
716726
cmd = `$(bitflag()) $(march()) -shared -L$(julia_libdir()) -L$(julia_private_libdir()) -o $sysimage_path $o_file_flags $(Base.shell_split(ldlibs())) $extra`
717727
run_compiler(cmd; cplusplus=true)

0 commit comments

Comments
 (0)