ldc
ldc copied to clipboard
[Android/termux] undefined symbol: __start___minfo
I installed the latest version of ldc in termux (via pkg, although I also tried it from the archive) I try to compile the usual hello world, the following error comes out:
ld.lld: error: undefined symbol: __start___minfo
>>> referenced by sections_android.d
>>> sections_android.o:(_D2rt16sections_android12initSectionsFNbNiZv) in archive /data/data/com.termux/files/usr/bin/../lib/libdruntime-ldc.a
ld.lld: error: undefined symbol: __stop___minfo
>>> referenced by sections_android.d
>>> sections_android.o:(_D2rt16sections_android12initSectionsFNbNiZv) in archive /data/data/com.termux/files/usr/bin/../lib/libdruntime-ldc.a
clang-13: error: linker command failed with exit code 1 (use -v to see invocation)
Our Android emulation requires the bfd linker (-linker=bfd
) - for another reason -, which should also eliminate this error. Newer Android NDKs bundle lld only AFAIK (edit: so Termux might too), so that's a problem and would require a custom linker script.
I tried and this is what happens:
clang-13: error: invalid linker name in argument '-fuse-ld=bfd'
Error: /data/data/com.termux/files/usr/bin/cc failed with status: 1
If -linker=
doesn't work either, Termux probably doesn't ship with bfd anymore.
https://github.com/termux/termux-packages/issues/11062
ldc2 main.d -linker=ld
So the fix is to just edit one line in $PREFIX/etc/ldc2.conf
default:
{
// default switches injected before all explicit command-line switches
switches = [
"-defaultlib=phobos2-ldc,druntime-ldc",
"-link-defaultlib-shared=false", "-linker=ld", // line 23, "-linker="->"-linker=ld"
];
Should this be fixed here in this project or by termux?
Ah, great find - should be fixed by Termux, I've never seen -fuse-ld=ld
being used (but -fuse-ld=bfd
, which somehow doesn't work for Termux IIRC).