-
Notifications
You must be signed in to change notification settings - Fork 490
C++ modules: remove direct libstdc++ linkage #4933
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
Conversation
I think this was originally needed because sometimes we link c++ objects into an otherwise c program using gcc and not g++ |
Those C++ objects are managed by libtool. In my understanding, libtool should handle transitive dependencies automatically in case the C++ library is static (noinst_LTLIBRARIES). |
Hm, it may not be the case, and my patch may work only because we link against gRPC/protobuf libraries, which pull the standard lib transitively. I guess the proper fix would be detecting which standard c++ library we should use, but I can't come up with an easy implementation (checking clang++ vs. g++ is not a good one) |
Yeah, sometimes g++ is using libc++ and I guess clang can also use libstdc++. this is more of a platform decision. A simple and limited fix could be to just use libc++ on FreeBSD and libstdc++ on everything else. But I can see your PR compiled, so maybe we don't need any of those? |
It compiled on FreeBSD, however there seem to be problems running the result:
|
And the same problem on openSUSE Leap 15.5, which is unlike FreeBSD, is GCC-based:
|
It's not Linux vs. FreeBSD. It's GCC vs. CLANG. And CLANG is also used on MacOS and a number of Linux distros (Gentoo AFAIR from an earlier report). This patch seems to work for OpenTelemetry, but not for examples or cloud_auth. |
Yeah, we need to explicitly link against the correct C++ standard lib, because libtool won't track that for us. The "correct" way of doing that is not the easiest because even with gcc vs clang, you can override the default libc++ with a flag. |
Did a new compile on FreeBSD, this time after editing the source with sed:
The
|
FTR I have just tried with
https://ftp.gnu.org/old-gnu/Manuals/libtool-1.4.2/html_node/libtool_70.html
|
@alltilla Thanks for trying :) I'll try to solve it "perfectly" in an 1-hour time box. If I can't find a clean way, I'll just go with the gcc-clang check. |
I've found the most portable way of fixing this, I'll update the PR soon. |
e7da594
to
6948e75
Compare
@czanik Can you give it another go, please? :) |
Thanks @MrAnno. It seems that the GCC side is now OK (tested on openSUSE Leap 15.5, Tumbleweed needs a 3GB download before I can test). The FreeBSD / CLANG side also improved, only
|
Tumbleweed is also OK, which uses all the latest versions from GCC and other dependencies:
So, it seems that the only problem point left is |
We should link against the appropriate C++ standard lib (libc++ or libstdc++), but libtool does not follow such dependencies through static libraries. In order not to hard-code the C++ standard lib, the nodist_EXTRA_*_SOURCES trick can be used to force using the C++ linker: https://www.gnu.org/software/automake/manual/html_node/Libtool-Convenience-Libraries.html CMake does this by default in case it detects a static C++ library dependency. Signed-off-by: László Várady <laszlo.varady@anno.io>
6948e75
to
163c894
Compare
Signed-off-by: László Várady <laszlo.varady@anno.io>
Build FAILURE |
@kira-syslogng retest this please |
1 similar comment
@kira-syslogng retest this please |
libtool should follow transitive dependencies and link against the appropriate C++ standard lib (libc++ or libstdc++) automatically.
Fixes #4932, but let's wait for @alltilla's review because something doesn't seem right here.