ldc icon indicating copy to clipboard operation
ldc copied to clipboard

[Android/termux] undefined symbol: __start___minfo

Open aquaratixc opened this issue 3 years ago • 5 comments

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)

aquaratixc avatar Feb 08 '22 16:02 aquaratixc

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.

kinke avatar Feb 08 '22 16:02 kinke

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

aquaratixc avatar Feb 08 '22 17:02 aquaratixc

If -linker= doesn't work either, Termux probably doesn't ship with bfd anymore.

kinke avatar Feb 08 '22 17:02 kinke

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?

Inkrementator avatar Sep 13 '22 00:09 Inkrementator

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).

kinke avatar Sep 13 '22 11:09 kinke