diff --git a/src/PackageCompiler.jl b/src/PackageCompiler.jl index 5f3d89e7..037b577c 100644 --- a/src/PackageCompiler.jl +++ b/src/PackageCompiler.jl @@ -686,7 +686,23 @@ function create_sysimg_from_object_file(object_files::Vector{String}, end mkpath(dirname(sysimage_path)) # Prevent compiler from stripping all symbols from the shared lib. - o_file_flags = Sys.isapple() ? `-Wl,-all_load $object_files` : `-Wl,--whole-archive $object_files -Wl,--no-whole-archive` + if Sys.isapple() + try + cltools_version_cmd = `pkgutil --pkg-info=com.apple.pkg.CLTools_Executables` + cltools_version = match(r"version: (.*)\n", readchomp(cltools_version_cmd))[1] + global major_version = split(cltools_version, ".")[1] + catch e + @warn "Could not determine the version of the Command Line Tools, assuming greater than 14" + global major_version = "15" + end + if parse(Int64, major_version) > 14 + o_file_flags = `-Wl,-all_load $object_files -Wl,-ld_classic` + else + o_file_flags = `-Wl,-all_load $object_files` + end + else + o_file_flags = `-Wl,--whole-archive $object_files -Wl,--no-whole-archive` + end extra = get_extra_linker_flags(version, compat_level, soname) cmd = `$(bitflag()) $(march()) -shared -L$(julia_libdir()) -L$(julia_private_libdir()) -o $sysimage_path $o_file_flags $(Base.shell_split(ldlibs())) $extra` run_compiler(cmd; cplusplus=true) @@ -1411,7 +1427,7 @@ function bundle_julia_libexec(ctx, dest_dir) p7zip_exe = basename(p7zip_path) cp(p7zip_path, joinpath(bundle_libexec_dir, p7zip_exe)) - return + return end function recursive_dir_size(path)