-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Fix symbol trampolines for OSX and export jl_n_threads
#38938
Conversation
I wonder if somebody who as access to an Apple M1 Mac could double check there that the exports are right? |
It turns out that aarch64 assembly syntax uses `;` as the comment character, not as the statement separator. So we need to polyfill that. We also set an alignment of 4 bytes (`2^2`) which is required on Apple targets, but is also a good idea on most other aarch64 machines.
Although we were dispatching to the right symbol, the name of the re-exported symbol was lacking its leading underscore.
Ah, thanks for this @imciner2! Good catch. I'm going to push a commit to this branch that fixes some problems with the I'm also going to push a commit to fix the incorrectly-exported name on win32. Thanks for your attention to detail; please do open any further issues you find! |
Without this, it was defined in both `libjulia` and `libjulia-internal`, causing `libjulia-internal`'s updates to not be visible.
Okay, so I took a look into the |
There's still an error on aarch64 linux; something is going wrong with the trampolines, but that shouldn't stop us from merging this. I will work through the aarch64-linux issues with Jameson or Keno next week. This should get merged once it goes green on all but aarch64-linux. |
Thanks for looking into the macOS CI failure and fixing that. The need to only have the definition inside the public library and reference that from the internal library should probably be documented somewhere so that it isn't forgotten. |
Hmm, looks like the Windows CI is now failing because of a definition error with |
JL_DLLEXPORT should be used because it will automatically switch between importing and exporting the symbol as needed.
Ok, I think I have fixed the Windows symbol issue - I believe it needs to be defined as |
@staticfloat I was just looking at the symbol exports, and I think there is a problem with trying to export I have an idea of how to fix this, so I will try prototyping that on Sunday (it is late my in time currently). |
Yep, you're right, it should be
This should only be a problem if a pointer is smaller than an |
Before it was always creating the variables as a pointer even if they are being referenced as a differnt type in the internal library.
The declaration has been moved to julia.h, which is already included in this file.
I've just pushed the changes I had in mind. Basically it is just another list of data that also has a type associated with it. While it may be safe right now to abuse a pointer that way, I would say we shouldn't count on it. The fix was fairly simple anyway.
As for the |
@vtjnash Just pinging you to take a quick look at this; I'm trying to remember what we decided on data symbols here. Now that I think harder, I think maybe we honestly do want I'm also not entirely sure what we want to do about non-pointer-types being exported. The last time we ran into this ( |
I think we just said there wasn't a case where it had been needed before now |
Alright, Jameson and I like this, so let's just provide the type for all variables; for the others right now you can specify I will be looking into the |
Thank you for working on this. Is there a good rule which functions and variables marked with |
On Windows, we have a special list of libraries that we search for default symbol resolution. Now that we have symbols defined in `libjulia` and then imported by `libjulia-internal`, we need to make certain that we search `libjulia-internal` first (so that we find non-trampoline functions first) and then `libjulia` (so that we do in fact eventually find the symbols at all).
@@ -1,12 +1,27 @@ | |||
#include "../../src/jl_exported_funcs.inc" | |||
|
|||
// On macOS, we need to prepend underscores on symbols | |||
#if defined(__APPLE__) && defined(__MACH__) |
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.
When were you running 9.x Classic MacOS userpace, and not using the mach kernel???
@KristofferC the backport1.6 label was removed, but this PR does not seem to be completely backported; indeed, the most important commit (from my POV) in this PR here was c33bd77 which fixes issue #38925 but the error ("Symbol not found: _jl_cstr_to_string") still occurs in the release-1.6 branch; and indeed as far as I can tell, that commit is neither backported in the release-1.6 branch, nor in PR #39160. As far a I can tell, that's the only missing commit from this PR, though. |
The symbol trampoline for OSX wasn't prepending the underscore to the name properly when defining the trampoline function, so it wasn't appearing in a form that it could be linked against.
I am marking as a draft because I think there may be an issue with the
libjulia
public library on 32-bit Windows as well where there is a mismatch between underscore prepending and no underscore (at least by my reading of the trampoline file for i686). I don't have a 32-bit Windows available to actually test this on though, so some help there would be appreciated.Also expose
jl_n_threads
as a public data object in the library since it is exposed asJL_DLLEXPORT
in the main code.Fixes #38925