Hi there, I just noticed that runtime detection doesn't appear to be working on my macOS computer with the portable build. I believe I have identified the issue. On macOS, BSD systems, and maybe Windows, an underscore (_) is prepended to all symbols, so the runtime detection assembly code is looking for the wrong symbol/variable. This applies to both x86/arm64.
See the mach-o ARM assembly below, which is looking for __blst_platform_cap (two underscores):
If you list symbols in libblst, you'll see that there are two different symbols:
$ nm libblst.a | ag cap
0000000000000004 C __blst_platform_cap
000000000001e828 D ___blst_platform_cap
The first symbol is from the assembly above, which creates a common variable __blst_platform_cap. The second (data) symbol ___blst_platform_cap (with an extra underscore) was created below. We care about the second one.
Hi there, I just noticed that runtime detection doesn't appear to be working on my macOS computer with the portable build. I believe I have identified the issue. On macOS, BSD systems, and maybe Windows, an underscore (
_
) is prepended to all symbols, so the runtime detection assembly code is looking for the wrong symbol/variable. This applies to both x86/arm64.See the mach-o ARM assembly below, which is looking for
__blst_platform_cap
(two underscores):https://github.com/supranational/blst/blob/5358144578b7b8b38e9b8d1da4f085057bbf1125/build/mach-o/sha256-armv8.S#L18
If you list symbols in libblst, you'll see that there are two different symbols:
The first symbol is from the assembly above, which creates a common variable
__blst_platform_cap
. The second (data) symbol___blst_platform_cap
(with an extra underscore) was created below. We care about the second one.https://github.com/supranational/blst/blob/5358144578b7b8b38e9b8d1da4f085057bbf1125/src/cpuid.c#L7
If I replace
__blst_platform_cap
with___blst_platform_cap
insha256-armv8.S
, my benchmark is noticeably faster.Not sure if this triage is 100% correct, but I think it's close enough.