You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
.subsections_via_symbols directive causes invalid symbol pruning in macOS x86-64 kernels #6089
OpenBLAS built with make TARGET=NEHALEM NOFORTRAN=1 (on Apple Silicon, the full invocation is arch -x86_64 make -j6 ARCH=x86_64 BINARY=64 CC="clang -arch x86_64" HOSTCC="clang -arch x86_64" TARGET=NEHALEM NOFORTRAN=1 shared) with Apple clang 21.0.0
The problem is that even without -Wl,-dead-strip the linker will still try to deduplicate labels unless -Wl,-no_deduplicate is provided explicitly. This happens to .L998 and .L999 in the sasum_k kernel.
I am testing via Rosetta on AArch64 macOS hardware, but I suspect this reproduces on proper x86-64 macOS targets.
Not sure what to make of this - your PRs look way too invasive for what may well be a bug in a specific linker version on an obsolescent target that (if I understand you correctly) gets triggered only by very specific non-default build options.
Agreed. The PRs are much bigger and more invasive than I would like...
I hope I can clarify the motivation. The goal for #6088 / #6087 is to allow the linker to remove unused code - #6090 is only needed to enable code pruning on macOS.
a bug in a specific linker version on an obsolescent target
x86_64-darwin happens to trigger this issue w/o dead-strip, but the problem is broader than that. The issue here happens as soon as you enable .subsections_via_symbols with a new enough clang, on any macOS target AFAIK and so dead-strip breaks OpenBLAS on macOS (incl. arm64) without #6090
The first two PRs apply to all platforms (--Wl,--gc-sections on Linux / MinGW + -Wl,-dead-strip on macOS) and they are trying to allow the linker to strip code under DYNAMIC_ARCH. Without them, gotoblas references all kernels even if you e.g. only rely on dgemm.
PRs are queued to be (likely) merged once 0.3.35 is released - you can either patch them into your build, or (as noted earlier in this issue) build with the classic linker
AFAIK the (de)duplication problem can be worked around for now by selecting the "classic" linker. The argument for deduplication was size reduction. In any case, backports would be up to downstream packagers...
Tracked this same bug down in our own project, then found this report. It would be nice to get a fix! We were building for mac/intel for a python package that might be run by a variety of users.
The short version is that we saw the problem in release mode and not debug mode, and were able to fix it when we added -Wl,-no_deduplicate when linking.
Here's a summary from Claude, with some edits from me to keep it vaguely readable:
libopenblas.a is linked into a C++ shared library (-dynamiclib). The link command has no -dead_strip, no LTO and no order file.
Symptom
The Release build segfaults in BLAS code (we have a backtrace inside dgemv_n_SANDYBRIDGE, in the assembly). The Debug build of the same code passes. Forcing each compiled core with OPENBLAS_CORETYPE (Prescott, Core2, Nehalem, Barcelona, Sandybridge, Haswell, Zen, Bulldozer, Piledriver, Steamroller, Excavator, and the default) made the same test fail every time, so it is not tied to one CPU or to the dispatcher's choice.
The Debug and Release link commands differ only in -g versus -O3 -DNDEBUG (and the d suffixes on library names). Both link the same libopenblas.a name from separate builds.
What is in the linked binaries
The x86_64 assembly objects have the .subsections_via_symbols flag set, and their .L labels are regular local symbols (nm shows them as t .L01, .L10 and so on), so each one begins its own atom.
I disassembled the linked Debug and Release dylibs. In dgemv_n_PRESCOTT.S, dgemv_n_CORE2.S, dgemv_n_BARCELONA.S and dgemv_n_SANDYBRIDGE.S, the block at .L01 (a movaps zeroing loop) is identical, because its jg is a self-relative branch, and nothing but the preceding block's fall-through reaches it.
Debug dylib: each of the four kernels has its own .L01.
Release dylib: all four .L01 symbols have the same address, inside _dgemv_n_PRESCOTT. CORE2, BARCELONA and SANDYBRIDGE have no .L01 of their own. In _dgemv_n_SANDYBRIDGE the 0x30 bytes at offset 0x110 in the object file are replaced by 16 zero bytes, the function is 0x20 bytes shorter, and execution falls from the preceding nopl into the zeros.
This looks like the linker's deduplication of identical atoms.
Workaround
We now pass -Wl,-no_deduplicate for the link. With it, all our tests pass again, including forcing every core, and re-running a test that crashed before. We have not tried -ld_classic ourselves.
Activity
topolarity commentedon Oct 2, 2026
Looks like this problem is specific to Apple's new linker from 2023. Building with
-Wl,-ld_classicalso works around the issue.martin-frbg commentedon Oct 2, 2026
Not sure what to make of this - your PRs look way too invasive for what may well be a bug in a specific linker version on an obsolescent target that (if I understand you correctly) gets triggered only by very specific non-default build options.
topolarity commentedon Oct 2, 2026
Agreed. The PRs are much bigger and more invasive than I would like...
I hope I can clarify the motivation. The goal for #6088 / #6087 is to allow the linker to remove unused code - #6090 is only needed to enable code pruning on macOS.
x86_64-darwinhappens to trigger this issue w/o dead-strip, but the problem is broader than that. The issue here happens as soon as you enable.subsections_via_symbolswith a new enoughclang, on any macOS target AFAIK and so dead-strip breaks OpenBLAS on macOS (incl. arm64) without #6090The first two PRs apply to all platforms (
--Wl,--gc-sectionson Linux / MinGW +-Wl,-dead-stripon macOS) and they are trying to allow the linker to strip code underDYNAMIC_ARCH. Without them,gotoblasreferences all kernels even if you e.g. only rely on dgemm.fix(docker): pin the OpenBLAS build that keeps macOS x86_64 kernels w…
feat(build): build OpenBLAS 0.3.34 with every arm64 kernel
elvisdukaj commentedon Nov 17, 2026
I just hit the same issue by consuming OpenBLAS from conan-center-index. Is there any progress on this?
martin-frbg commentedon Nov 17, 2026
PRs are queued to be (likely) merged once 0.3.35 is released - you can either patch them into your build, or (as noted earlier in this issue) build with the classic linker
elvisdukaj commentedon Nov 17, 2026
To be fair I'm a bit puzzled because this PRs mix a serious issue on Apple and improvement in size.
The linker issue is more relevant and I fixed it by adding
-Wl,-no_deduplicatelinker option. This may require a back port as well.Wouldn't this be enough?
martin-frbg commentedon Nov 17, 2026
AFAIK the (de)duplication problem can be worked around for now by selecting the "classic" linker. The argument for deduplication was size reduction. In any case, backports would be up to downstream packagers...
luciansmith commentedon Dec 3, 2026
Tracked this same bug down in our own project, then found this report. It would be nice to get a fix! We were building for mac/intel for a python package that might be run by a variety of users.
The short version is that we saw the problem in release mode and not debug mode, and were able to fix it when we added
-Wl,-no_deduplicatewhen linking.Here's a summary from Claude, with some edits from me to keep it vaguely readable:
Setup
Symptom
The Release build segfaults in BLAS code (we have a backtrace inside dgemv_n_SANDYBRIDGE, in the assembly). The Debug build of the same code passes. Forcing each compiled core with OPENBLAS_CORETYPE (Prescott, Core2, Nehalem, Barcelona, Sandybridge, Haswell, Zen, Bulldozer, Piledriver, Steamroller, Excavator, and the default) made the same test fail every time, so it is not tied to one CPU or to the dispatcher's choice.
The Debug and Release link commands differ only in -g versus -O3 -DNDEBUG (and the d suffixes on library names). Both link the same libopenblas.a name from separate builds.
What is in the linked binaries
The x86_64 assembly objects have the .subsections_via_symbols flag set, and their .L labels are regular local symbols (nm shows them as t .L01, .L10 and so on), so each one begins its own atom.
I disassembled the linked Debug and Release dylibs. In dgemv_n_PRESCOTT.S, dgemv_n_CORE2.S, dgemv_n_BARCELONA.S and dgemv_n_SANDYBRIDGE.S, the block at .L01 (a movaps zeroing loop) is identical, because its jg is a self-relative branch, and nothing but the preceding block's fall-through reaches it.
This looks like the linker's deduplication of identical atoms.
Workaround
We now pass -Wl,-no_deduplicate for the link. With it, all our tests pass again, including forcing every core, and re-running a test that crashed before. We have not tried -ld_classic ourselves.
Happy to test a patch against our CI.