@@ -712,15 +712,7 @@ function create_sysimg_from_object_file(object_files::Vector{String},
712
712
mkpath (dirname (sysimage_path))
713
713
# Prevent compiler from stripping all symbols from the shared lib.
714
714
if Sys. isapple ()
715
- try
716
- cltools_version_cmd = ` pkgutil --pkg-info=com.apple.pkg.CLTools_Executables`
717
- cltools_version = match (r" version: (.*)\n " , readchomp (cltools_version_cmd))[1 ]
718
- global major_version = split (cltools_version, " ." )[1 ]
719
- catch e
720
- @warn " Could not determine the version of the Command Line Tools, assuming greater than 14"
721
- global major_version = " 15"
722
- end
723
- if parse (Int64, major_version) > 14
715
+ if _xcode_clt_major_version () > 14
724
716
o_file_flags = ` -Wl,-all_load $object_files -Wl,-ld_classic`
725
717
else
726
718
o_file_flags = ` -Wl,-all_load $object_files `
@@ -734,6 +726,24 @@ function create_sysimg_from_object_file(object_files::Vector{String},
734
726
return nothing
735
727
end
736
728
729
+ function _xcode_clt_major_version ()
730
+ cmd = ` pkgutil --pkg-info=com.apple.pkg.CLTools_Executables`
731
+ @debug " _xcode_clt_major_version(): Attempting to run command" cmd
732
+ # The `ignorestatus` allows us to proceed (with a warning) if
733
+ # the command does not run successfully.
734
+ output = strip (read (ignorestatus (cmd), String)) * " \n "
735
+ r = r" version: (.*)\n "
736
+ m = match (r, output)
737
+ if isnothing (m)
738
+ @warn " Could not determine the version of the Command Line Tools, assuming greater than 14"
739
+ major_version_str = " 15"
740
+ else
741
+ major_version_str = split (m[1 ], ' .' )[1 ]
742
+ end
743
+ major_version_int = parse (Int, major_version_str)
744
+ return major_version_int
745
+ end
746
+
737
747
function get_extra_linker_flags (version, compat_level, soname)
738
748
current_ver_arg = ` `
739
749
compat_ver_arg = ` `
0 commit comments