Repository navigation
Conversation
The trial link which decides whether to build the extension with -static-libstdc++ used an empty function, so nothing was ever pulled out of libstdc++.a and the probe succeeded even when that archive cannot go into a shared object. On NetBSD libstdc++.a is not position-independent, so the probe passed and the real link then failed on a TPOFF32 relocation in eh_globals.o. Throw and catch an exception in the probe, so it links the same parts of the runtime the extension does. When the static archive is unusable the existing rpath fallback is now taken. Fixes linux-test-project#552 Signed-off-by: Zhaoqi Xu <lzy00419@outlook.com>
Collaborator
|
Would be good to understand why the tests fail. They are supposed to pass. |
Contributor
Author
|
Thanks for merging. I went back through
The failing set was the same on master and on the branch. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #552.
The
-static-libstdc++probe inlib/LcovUtil/Makefile.PLlinks an emptyextern "C"function, so it never pulls anything out oflibstdc++.a. It passes as long as the archive exists, even when the archive can't go into a shared object. That's what happens on NetBSD:libstdc++.aisn't built PIC, the probe passes, and the real link then fails on theR_X86_64_TPOFF32relocation ineh_globals.o.This makes the probe throw and catch an exception (the XS code uses exceptions too), so the trial link touches the same runtime pieces. When the static archive isn't usable, the existing rpath fallback is taken instead. I also changed the fallback message from "no static C++ library" to "no usable static C++ library", since there can be one that just doesn't work.
I don't have a NetBSD box, so I reproduced it on Linux (gcc 14.2, Debian) with a copy of
libstdc++.awhoseeh_globals.owas replaced by a non-PIC build using local-exec TLS, put in front withLCOV_CXX="g++ -L<dir>"(the dir also has alibstdc++.sosymlink to the real shared library, like a normal system lib dir):Makefile.PLpicks-static-libstdc++, thenmakefails withlibstdc++.a(eh_globals.o): relocation R_X86_64_TPOFF32 ... can not be used when making a shared object, the same error as in the issue.Makefile.PLprints the rpath message,makesucceeds, andLcovUtilloads.With the normal toolchain,
-static-libstdc++is still chosen and the builtLcovUtil.sohas no dynamiclibstdc++dependency.make checkhere gives 77 passed / 14 failed out of 91 on both master and this branch, with the same 14 failing on both (mostly genhtml tests hitting a fork/tempdir error in my environment, plusllvm2lcov), so nothing changes there.The changed lines are perltidy-clean (Perl-Tidy 20221112 with the repo's
.perltidyrc).