-
Notifications
You must be signed in to change notification settings - Fork 375
Add linkage attributes to extern "C" blocks #429
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
base: master
Are you sure you want to change the base?
Conversation
Interesting, yes, let's fix this. CI is showing some build failures in |
Oh I see what you mean, the avx512 situation adds another dimension to the matrix. I'll need a bit to untangle this. |
Oh dear it's the workflow approval dance. |
A bit of scope creep later, now I've:
|
Works on my machine too! |
👋 Just generating a notification to make sure this PR isn't lost. |
Apologies for letting this sit for so long. I'll get back to it this weekend.
I think I added |
@@ -73,6 +73,10 @@ pub unsafe fn hash_many<const N: usize>( | |||
} | |||
|
|||
pub mod ffi { | |||
#[cfg_attr( | |||
blake3_sse2_ffi, | |||
link(name = "blake3_sse2_sse41_avx2_assembly", kind = "static") |
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.
All of these extensions have assembly implementations and intrinsics implementations, which we switch between with --feature prefer_intrinsics
. Do they all need the same treatment as AVX-512?
More broadly, could you help me understand what the link(...)
attribute actually means :)
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 started digging into this and actually now I have questions about why the compiler seems to correctly forward native libraries dependencies through the crate graph if they come from #[link(
but not if they come from command line arguments. I've poked some other compiler people, and I'll try to get back to you soon.
This crate is now used in the compiler since rust-lang/rust#126930.
The problem I'm fixing is just like rust-lang/rust#118084; if you try to run
After around 30 minutes (
-Zcross-crate-inline-threshold=always
makes compilation much slower) you getI think this is exactly the same problem as the above-linked issue: the blake3 crate does not have any
link(name =
attributes, so it only links correctly if all calls to theextern "C"
functions are monomorphized byblake3
crate. But with-Zcross-crate-inline-threshold=always
, nearly all monomorphization is done by the last crate to be compiled, and without these attributes we lose track of these symbols by the time we need them.I'm not filing an issue because I'm pretty sure nobody else cares about my silly flag continuing to work when bootstrapping the compiler, but I occasionally find legitimate codegen bugs with it, so I'm sending you the patch to keep it working.
I've confirmed in my local dev setup that this PR makes it again possible to build the compiler with
-Zcross-crate-inline-threshold=always
.