-
-
Notifications
You must be signed in to change notification settings - Fork 197
Fix bug in create_sysimg_from_object_file for Xcode 15 CLT #935
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
6d2cdd1
1d955aa
7161e1a
3d8f36b
e17d3a8
8c4fda1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -686,7 +686,17 @@ 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() | ||
| cltools_version_cmd = `pkgutil --pkg-info=com.apple.pkg.CLTools_Executables` | ||
| cltools_version = match(r"version: (.*)\n", readchomp(cltools_version_cmd))[1] | ||
| if startswith(cltools_version, "15") | ||
|
||
| 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) | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should handle the case that
pkgutilis unable to locatecom.apple.pkg.CLTools_ExecutablesThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good call. Do you have any thoughts on what version we should assume under this failure case? I don't have a good feel for whether it's more likely that a system has been upgraded to the latest version or not, but given how Apple ties Xcode version to macOS version (and professional dev envs are eventually going to force OS updates) it may be safest to default to 15+ (i.e. to apply the flags).
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unfortunately it looks like there's a syntax ambiguity so that a lot of linkers interpret this flag as
-ld_classici.e. link againstlibd_classic.so, which will obviously fail.I'm not sure how far back we have to go before that becomes an issue. It also sounds like we might have to worry about using a different compiler not from XCode CLT.
Could we execute the compiler binary and ask it for its version directly?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While I have a general understanding of the problem you're describing, this is admittedly over my head. Maybe something like the first answer on this SO post could work?
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My biggest concern is that this patch assumes that the user is using the XCode CLT to compile on macOS, which is not necessarily true
By "execute the compiler binary directly", I mean a combination of either:
run_compiler(`` --version``)or similar to determine whether we're running the Xcode-provided compiler and which version.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've tinkered with this a bit and am still having a bit of trouble.
I've tried getting the path to the compiler with
Printing
compiler_source_pathresults in/Users/jaycook/.julia/juliaup/julia-1.8.5+0.aarch64.apple.darwin14/share/julia/base/compiler/compiler.jl. I was hoping more for something like/Library/Developer/CommandLineTools/usr/bin, where I could check for a string like "xcode" or "CommandLineTools".run_compiler()'s underlying call torun()does not appear to return the result of the command that's run. For example,print(run_compiler(`` --version``))results inProcess(``gcc --version``, ProcessExited(0)).If you're so inclined, do you care to toss up a commit for the implementation that you have in mind?