termux / termux-packages

A package build system for Termux.
https://termux.dev
Other
13.28k stars 3.06k forks source link

[Bug]: ldc linking fails with LLD #11062

Closed ravener closed 1 year ago

ravener commented 2 years ago

Problem description

The default ldc2 command fails with the following linker error, however changing the linker to use ld seems to work fine.

~/d  ldc2 test.d
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
>>> the encapsulation symbol needs to be retained under --gc-sections properly; consider -z nostart-stop-gc (see https://lld.llvm.org/ELF/start-stop-gc)

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-14: error: linker command failed with exit code 1 (use -v to see invocation)
Error: /data/data/com.termux/files/usr/bin/cc failed with status: 1
 ✘  ~/d  ldc2 test.d -linker=ld
 ~/d  ./test
Hello, World!
 ~/d 

What steps will reproduce the bug?

Create a file test.d

module hello;

import std.stdio;

void main(string[] args) {
  writeln("Hello, World!");
}

Run ldc2 test.d

What is the expected behavior?

Compiles and links successfully without having to pass extra options

System information

termux-info:

Termux Variables:
TERMUX_API_VERSION=0.50.1
TERMUX_APK_RELEASE=F_DROID
TERMUX_APP_PACKAGE_MANAGER=apt
TERMUX_APP_PID=19342
TERMUX_IS_DEBUGGABLE_BUILD=0
TERMUX_MAIN_PACKAGE_FORMAT=debian
TERMUX_VERSION=0.118.0
Packages CPU architecture:
arm
Subscribed repositories:
# sources.list
deb https://dl.kcubeterm.com/termux-main stable main
# unstable-repo (sources.list.d/unstable.list)
deb https://grimler.se/unstable-packages unstable main
Updatable packages:
0verkill/stable 0.16-git-3 arm [upgradable from: 0.16-git-1]
ant/stable 1.10.12 all [upgradable from: 1.10.11-2]
apt/stable 2.5.0 arm [upgradable from: 2.2.0]
asciinema/stable 2.2.0 all [upgradable from: 2.0.2-5]
assimp/stable 5.2.4 arm [upgradable from: 4.1.0]
autoconf/stable 2.71-2 all [upgradable from: 2.69]
automake/stable 1.16.5 all [upgradable from: 1.16.1]
bash/stable 5.1.16-1 arm [upgradable from: 5.0.7-1]
bastet/stable 0.43.2-8 arm [upgradable from: 0.43.2-6]
bat/stable 0.21.0 arm [upgradable from: 0.18.3-1]
bftpd/stable 6.1 arm [upgradable from: 5.7]
binutils/stable 2.38 arm [upgradable from: 2.37-5]
bison/stable 3.8.2-2 arm [upgradable from: 3.8.1]
boost/stable 1.78.0-1 arm [upgradable from: 1.70.0-4]
bzip2/stable 1.0.8-6 arm [upgradable from: 1.0.8-5]
ca-certificates/stable 1:2022.04.26 all [upgradable from: 20211001]
command-not-found/stable 1.75 arm [upgradable from: 1.67]
coreutils/stable 9.1 arm [upgradable from: 8.32-6]
cups/stable 2.3.3-9 arm [upgradable from: 2.3.3-7]
curseofwar/stable 1.3.0-3 arm [upgradable from: 1.3.0-1]
dash/stable 0.5.11.5-1 arm [upgradable from: 0.5.10.2-1]
debianutils/stable 5.7 arm [upgradable from: 4.11.2]
dialog/stable 1.3-20220117-0 arm [upgradable from: 1.3-20210117-0]
diffutils/stable 3.8 arm [upgradable from: 3.7-2]
dns2tcp/stable 0.5.2-1 arm [upgradable from: 0.5.2]
dnsutils/stable 9.16.27 arm [upgradable from: 9.14.7]
dopewars/stable 1.6.1-4 arm [upgradable from: 1.6.1-2]
dos2unix/stable 7.4.2 arm [upgradable from: 7.4.0-1]
dpkg/stable 1.21.8 arm [upgradable from: 1.20.9-5]
file/stable 5.41-1 arm [upgradable from: 5.39-1]
findutils/stable 4.9.0-1 arm [upgradable from: 4.6.0-4]
fish/stable 3.4.1 arm [upgradable from: 3.1.2]
fontconfig-utils/stable 2.14.0 arm [upgradable from: 2.13.1-6]
fontconfig/stable 2.14.0 arm [upgradable from: 2.13.1-6]
freetype/stable 2.12.1 arm [upgradable from: 2.11.0]
fzf/stable 0.30.0 arm [upgradable from: 0.28.0]
gawk/stable 5.1.1-1 arm [upgradable from: 5.0.1-4]
gdb/stable 10.1-6 arm [upgradable from: 8.3-3]
gdbm/stable 1.22 arm [upgradable from: 1.18.1]
germanium/stable 1.2.2-1 arm [upgradable from: 1.2.2]
glib/stable 2.72.1-1 arm [upgradable from: 2.66.1-1]
gnupg/stable 2.3.6 arm [upgradable from: 2.2.20-3]
gpgv/stable 2.3.6 arm [upgradable from: 2.2.15-1]
gradle/stable 1:7.4.2 all [upgradable from: 1:7.3.1]
grep/stable 3.7-2 arm [upgradable from: 3.3-1]
gzip/stable 1.12 arm [upgradable from: 1.10-2]
hugo/stable 0.100.2 arm [upgradable from: 0.92.0]
inetutils/stable 1.9.4-13 arm [upgradable from: 1.9.4-12]
jo/stable 1.6 arm [upgradable from: 1.4-2]
kotlin/stable 1.6.21 all [upgradable from: 1.5.30]
less/stable 590 arm [upgradable from: 563]
leveldb/stable 1.23-1 arm [upgradable from: 1.22-3]
libandroid-spawn/stable 0.3 arm [upgradable from: 0.2-4]
libassuan/stable 2.5.5 arm [upgradable from: 2.5.3-1]
libbz2/stable 1.0.8-6 arm [upgradable from: 1.0.8-5]
libcaca/stable 0.99.beta20 arm [upgradable from: 0.99.beta19-6]
libcrypt/stable 0.2-5 arm [upgradable from: 0.2-2]
libdb/stable 18.1.40-3 arm [upgradable from: 18.1.32-1]
libedit/stable 20210910-3.1-0 arm [upgradable from: 20190324-3.1-0]
libevent/stable 2.1.12-1 arm [upgradable from: 2.1.11-1]
libexpat/stable 2.4.8 arm [upgradable from: 2.2.6]
libffi/stable 3.4.2 arm [upgradable from: 3.2.1-4]
libgcrypt/stable 1.10.1 arm [upgradable from: 1.8.5-1]
libgmp/stable 6.2.1-1 arm [upgradable from: 6.1.2-2]
libgnutls/stable 3.7.6 arm [upgradable from: 3.6.8-1]
libgpg-error/stable 1.45 arm [upgradable from: 1.36]
libidn2/stable 2.3.2 arm [upgradable from: 2.2.0]
libidn/stable 1.38 arm [upgradable from: 1.36-1]
libksba/stable 1.6.0 arm [upgradable from: 1.3.5-2]
libltdl/stable 2.4.6-8 arm [upgradable from: 2.4.6-6]
liblua53/stable 5.3.5-10 arm [upgradable from: 5.3.5-9]
libluajit/stable 1:2.1.0-beta3-3 arm [upgradable from: 1:2.1.0-beta3-2]
liblzma/stable 5.2.5-1 arm [upgradable from: 5.2.4-7]
libmpfr/stable 4.1.0-1 arm [upgradable from: 4.0.2-1]
libnettle/stable 3.7.3 arm [upgradable from: 3.5.1-1]
libnghttp2/stable 1.47.0 arm [upgradable from: 1.38.0]
libpcap/stable 1.10.1-1 arm [upgradable from: 1.10.0]
libpng/stable 1.6.37-3 arm [upgradable from: 1.6.37-1]
libpopt/stable 1.18-1 arm [upgradable from: 1.16-2]
libsasl/stable 2.1.28 arm [upgradable from: 2.1.27-1]
libsodium/stable 1.0.18-3 arm [upgradable from: 1.0.18-2]
libtalloc/stable 2.3.3 arm [upgradable from: 2.1.14-1]
libtool/stable 2.4.6-8 arm [upgradable from: 2.4.6-6]
libunistring/stable 1.0 arm [upgradable from: 0.9.10-2]
libuuid/stable 1.0.3-5 arm [upgradable from: 1.0.3-4]
libx11/stable 1.7.2-1 arm [upgradable from: 1.7.2]
libxcb/stable 1.15 arm [upgradable from: 1.14-3]
libxml2/stable 2.9.14 arm [upgradable from: 2.9.12-1]
libxslt/stable 1.1.35 arm [upgradable from: 1.1.33-3]
libzip/stable 1.8.0-4 arm [upgradable from: 1.7.3-1]
lighttpd/stable 1.4.64-3 arm [upgradable from: 1.4.61-1]
lua53/stable 5.3.5-10 arm [upgradable from: 5.3.5-9]
luajit/stable 1:2.1.0-beta3-3 arm [upgradable from: 1:2.1.0-beta3-2]
luarocks/stable 3.8.0 all [upgradable from: 3.1.3-5]
m4/stable 1.4.19-3 arm [upgradable from: 1.4.18-1]
make/stable 4.3-2 arm [upgradable from: 4.3-1]
man/stable 1.14.5-3 arm [upgradable from: 1.14.5-2]
manpages/stable 5.13-1 all [upgradable from: 5.10]
memcached/stable 1.6.12 arm [upgradable from: 1.6.9]
mlocate/stable 0.26-5 arm [upgradable from: 0.26-4]
moon-buggy/stable 1.0.51-5 arm [upgradable from: 1.0.51-4]
nano/stable 6.3 arm [upgradable from: 5.8]
navi/stable 2.20.1 arm [upgradable from: 2.18.0]
ncurses-ui-libs/stable 6.3-2 arm [upgradable from: 6.2.20200725-2]
ncurses-utils/stable 6.3-2 arm [upgradable from: 6.2.20200725-2]
ncurses/stable 6.3-2 arm [upgradable from: 6.2.20200725-2]
net-tools/stable 2.10.0 arm [upgradable from: 1.60.2017.02.21-2]
nethack/stable 3.6.6-6 arm [upgradable from: 3.6.6-3]
nim/stable 1.6.6 arm [upgradable from: 1.4.2]
no-more-secrets/stable 1.0.1-1 arm [upgradable from: 1.0.1]
nudoku/stable 2.1.0 arm [upgradable from: 2.0.0-1]
oniguruma/stable 6.9.8 arm [upgradable from: 6.9.7.1]
openjdk-17/stable 17.0-22 arm [upgradable from: 17.0-15]
pcre2/stable 10.40 arm [upgradable from: 10.37]
pcre/stable 8.45-1 arm [upgradable from: 8.45]
perl/stable 5.36.0 arm [upgradable from: 5.30.0]
pinentry/stable 1.2.0 arm [upgradable from: 1.1.0-4]
pkg-config/stable 0.29.2-1 arm [upgradable from: 0.29.2]
procps/stable 3.3.17-1 arm [upgradable from: 3.3.16-2]
proot/stable 5.1.107-54 arm [upgradable from: 5.1.107-40]
psmisc/stable 23.4 arm [upgradable from: 23.2-1]
pv/stable 1.6.20 arm [upgradable from: 1.6.6]
readline/stable 8.1.1 arm [upgradable from: 8.0]
resolv-conf/stable 1.3 arm [upgradable from: 1.2]
rsync/stable 3.2.4 arm [upgradable from: 3.1.3-5]
screenfetch/stable 3.9.1-1 all [upgradable from: 3.8.0]
sed/stable 4.8-2 arm [upgradable from: 4.7]
strace/stable 5.17 arm [upgradable from: 5.4]
swig/stable 4.0.2-1 arm [upgradable from: 4.0.0-1]
termux-create-package/stable 0.12.0 all [upgradable from: 0.10]
termux-keyring/stable 3.6 all [upgradable from: 2.3]
termux-licenses/stable 2.0-2 all [upgradable from: 2.0-1]
texinfo/stable 6.8-1 arm [upgradable from: 6.7]
tidy/stable 5.8.0-1 arm [upgradable from: 5.7.28-1]
tig/stable 2.5.5 arm [upgradable from: 2.5.1]
tmux/stable 3.3-1 arm [upgradable from: 3.1c]
tracepath/stable 20211215 arm [upgradable from: 20190709]
tree/stable 2.0.2 arm [upgradable from: 1.8.0-2]
ttf-dejavu/stable 2.37-8 all [upgradable from: 2.37-7]
tty-solitaire/stable 1.3.1 arm [upgradable from: 1.3.0-4]
unzip/stable 6.0-7 arm [upgradable from: 6.0-5]
util-linux/stable 2.38 arm [upgradable from: 2.33.1-3]
weechat/stable 3.0.1-7 arm [upgradable from: 3.0.1-5]
wrk/stable 4.2.0 arm [upgradable from: 4.1.0-2]
xxhash/stable 0.8.1 arm [upgradable from: 0.8.0-1]
xz-utils/stable 5.2.5-1 arm [upgradable from: 5.2.4-7]
yarn/stable 1.22.19 all [upgradable from: 1.22.10]
zlib/stable 1.2.12 arm [upgradable from: 1.2.11-5]
zstd/stable 1.5.2-1 arm [upgradable from: 1.5.0]
termux-tools version:
1.0
Android version:
9
Kernel build information:
Linux localhost 4.9.117+ #1 SMP PREEMPT Fri Apr 19 13:20:06 CST 2019 armv8l Android
Device manufacturer:
HUAWEI
Device model:
AMN-LX9
sk0kanik commented 2 years ago

4341

ravener commented 2 years ago

@sk0kanik saw that issue, the error is slightly different and he can also compile normally if he doesn't explicitly use lld, but currently lld is the default, there should somehow be a fix or a way to set ld as the default linker at the very least, so we don't have to worry about linker flags everytime. The issue is also quite old so I'm not sure how much stuff changed and what could be done now.

stale[bot] commented 2 years ago

This issue/PR has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

Grimler91 commented 2 years ago

I can reproduce it with up to date packages as well, so I guess we can patch it to change the default linker

fagci commented 2 years ago

ldc2 main.d -linker=ld Permanent fix (ld instead of empty)

ravener commented 2 years ago

@fagci Thanks, that solves it, setting the linker to ld in $PREFIX/etc/ldc2.conf.

@Grimler91 I think we could patch this file, it's simple and the user can override it if needed, luckily we don't need to touch the source code.

stale[bot] commented 2 years ago

This issue/PR has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.