Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 893962 - dev-python/numpy uses C++ headers, but does not link with CXX
Summary: dev-python/numpy uses C++ headers, but does not link with CXX
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Gentoo Science Related Packages
URL:
Whiteboard:
Keywords: PATCH
Depends on:
Blocks: systemwide-libcxx
  Show dependency tree
 
Reported: 2023-02-11 21:22 UTC by Jannik Glückert
Modified: 2023-06-12 00:46 UTC (History)
4 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jannik Glückert 2023-02-11 21:22:27 UTC
Numpy is mostly written in C, but contains a few C++ files that include STL headers.
In libstdc++, all the used definitions seem to be defined inline, but this is not the case with libc++. Either way, a non-freestanding C++ TU should *always* be linked via the CXX linker driver, but numpy links it's libraries with CC.

In practice, this leads to numpy emitting relocations against the libc++ symbol `_ZNSt3__122__libcpp_verbose_abortEPKcz`, but as libc++ is not included in the link, the resulting libraries are unusable. Furthermore, a C++ compiler is allowed to pull in a runtime support library as it desires when building a non-freestanding TU, so this is very brittle even with libstdc++.

I haven't gathered the courage to dig through the beautiful numpy build system just yet, but the fix should be fairly simple.
Comment 1 Sheng Yu 2023-02-12 00:30:42 UTC
I do confirm add LDFLAGS="${LDFLAGS} -lstdc++" fixed this.
Upstream hasn't decided what to do with.
Comment 2 hugegameartgd 2023-04-23 12:38:56 UTC
See https://github.com/numpy/numpy/issues/23122 (bug) and https://github.com/numpy/numpy/pull/23601 (patch).
Comment 3 Mike Batterton 2023-06-11 16:49:44 UTC
I can confirm that the above patch fixes the issue. Without this patch dev-python/matplotlib fails to compile throwing a _ZNSt3__122__libcpp_verbose_abortEPKcz symbol is missing error. The above patch to numpy fixes dev-python/matplotlib. I'm sure there could be other python packages that this is affecting.
Comment 4 Larry the Git Cow gentoo-dev 2023-06-12 00:45:00 UTC
The bug has been closed via the following commit(s):

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=95bc234cf4f8d823d890a17571c7d517b42e6c4e

commit 95bc234cf4f8d823d890a17571c7d517b42e6c4e
Author:     Sam James <sam@gentoo.org>
AuthorDate: 2023-06-12 00:44:01 +0000
Commit:     Sam James <sam@gentoo.org>
CommitDate: 2023-06-12 00:44:06 +0000

    dev-python/numpy: fix build/link with libcxx
    
    New revision as this pretty much only worked by chance before and could
    affect the installed files as a result.
    
    Closes: https://bugs.gentoo.org/893962
    Signed-off-by: Sam James <sam@gentoo.org>

 .../numpy/files/numpy-1.24.3-fix-c++-linkage.patch |  25 +++
 dev-python/numpy/numpy-1.24.3-r1.ebuild            | 176 +++++++++++++++++++++
 2 files changed, 201 insertions(+)
Comment 5 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2023-06-12 00:46:01 UTC
(In reply to Mike Batterton from comment #3)
> I can confirm that the above patch fixes the issue. Without this patch
> dev-python/matplotlib fails to compile throwing a
> _ZNSt3__122__libcpp_verbose_abortEPKcz symbol is missing error. The above
> patch to numpy fixes dev-python/matplotlib. I'm sure there could be other
> python packages that this is affecting.

Thanks for the nudge. For some reason, I was convinced newer numpy was closer around the corner than it really was. So, backported.