Julia without libstdc++
Julia doesn't need C++ except for LLVM I believe, but not libstdc++ (I assumed before needed for all C++ programs):
https://stackoverflow.com/questions/3714167/g-without-libstdc-can-it-be-done-a-very-configurable-lightweight-libstd
Writing c++ programs without libstdc++ is easy. I'm doing it for decades. Just avoid linking with libstdc++. That's easy: either use gcc for linking instead of g++, or provide a fake libstdc++ with only new, del and a few other functions.
What first caught my eye, and this program is cool, and should also support Julia:
https://github.com/LorenDB/polyglot/pull/1/files
Note: For C++, zig toolchain uses only [LLVM]C++ ABI (no [GNU]
libstdc++) by default.
https://github.com/LorenDB/polyglot/blob/master/capabilities.md
A. I want to know if this is practical, or any known objections, so I first want to open an issue, in case there are known problems.
B. FYI: E.g. Swift (also D) allows for bidirectional C++ interop (with limitations currently i.e. not new C++moduls support), so if we need libstdc++ then maybe consider c++call addition to Julia...:
https://www.swift.org/documentation/cxx-interop/
Apologies, but I don't understand what you are asking about:
A. I want to know if this is practical,
If what is practical?
Are you asking whether it would be possible to extend https://github.com/LorenDB/polyglot to support Julia?
What the title says, Julia without libstdc++.so, that is bundled with Julia. You can for some C++ programs. I understand if LLVM requires it, but it is optional in a sense... Seeing "zig toolchain uses only [LLVM]C++ ABI (no [GNU] libstdc++)" got me thinking but yes zig doesn't need LLVM at runtime, never, and actually neither at compile-time, but then optional.
As a first step for a prototype if you do:
julia --compile=min
then not open LLVM, and thus not libstc++.
But why? What goal do you hope to achieve by this?
There are plenty packages that uses JLLs which contain C++ code, so some form of bundling libstdc++ or equivalent is inevitable, perhaps as a plain JLL. So the best you could hope for is that it is not always loaded.
Well that's true, I was thinking smaller compiled programs (actually seeing the just announced Julia proprietary AOT compiler this might be outdated, since I think it always compiles to C++ and thus maybe needs this library, and 1-2 MB it achives is already rather good, with few limitations).
Those C++ dependencies would then need to depend on a JLL that adds libstdc++ back, and if not this seems it would be a breaking change.
Alternative might be, not distributing the C++ stdlib, but dynamically link it? I'm unclear on why that is not done, more (with Julia or) other projects. I guess it develops much faster than the C standard library that IS usually dynamically linked, also by Julia.
I'm mostly just thinking if this is possible at all, for pure Julia code. If such code projects are rare because of 1 or more C++ dependencies, then maybe why bother...
[I believe Python relies heavily on C, not C++ officially, not sure about most dependencies, so you can do a lot with Julia and/or Python. R however relies a lot on C++.]
I think there are several misconceptions in play here. E.g. libstdc++ is dynamically linked, always. And I don't think it is a major contributor in terms of size either.
@PallHaraldsson please keep issue on GitHub focused and actionable. For discussing ideas like this discourse is a better medium.
I thought the proposal was actionable, and still do (i.e. not to link to it at all); also the alternative, link but not bundle:
libstdc++ is dynamically linked, always.
Sorry, meant to say dynamically linked to libstdc++ provided by the system (i.e. not needing to bundle with), i.e. the one I get (or rather already preexisting) with:
sudo apt-get install libstdc++6