termux-packages
termux-packages copied to clipboard
[Bug]: Zig is unable to detect native libc by default
Problem description
~ $ zig version
0.13.0
~ $ zig libc
warning: Encountered error: FileNotFound, falling back to default ABI and dynamic linker.
error: unable to detect native libc: LibCRuntimeNotFound
~ $ termux-chroot
~ $ zig libc
# The directory that contains `stdlib.h`.
# On POSIX-like systems, include directories be found with: `cc -E -Wp,-v -xc /dev/null`
include_dir=/data/data/com.termux/files/usr/include
# The system-specific include directory. May be the same as `include_dir`.
# On Windows it's the directory that includes `vcruntime.h`.
# On POSIX it's the directory that includes `sys/errno.h`.
sys_include_dir=/data/data/com.termux/files/usr/include
# The directory that contains `crt1.o` or `crt2.o`.
# On POSIX, can be found with `cc -print-file-name=crt1.o`.
# Not needed when targeting MacOS.
crt_dir=/data/data/com.termux/files/usr/lib/gcc/aarch64-linux-android/14.1.0/../../../../aarch64-linux-android/lib
# The directory that contains `vcruntime.lib`.
# Only needed when targeting MSVC on Windows.
msvc_lib_dir=
# The directory that contains `kernel32.lib`.
# Only needed when targeting MSVC on Windows.
kernel32_lib_dir=
# The directory that contains `crtbeginS.o` and `crtendS.o`
# Only needed when targeting Haiku.
gcc_dir=
~ $ proot-distro login archlinux
[root@localhost ~]# zig libc
error: unable to detect native libc: LibCRuntimeNotFound
What steps will reproduce the bug?
~ $ cat main.c
#include <stdio.h>
int main() {
puts("ok");
}
~ $ zig cc -v
clang version 18.1.6
Target: aarch64-unknown-linux-musl
Thread model: posix
InstalledDir: /data/data/com.termux/files/usr/bin
~ $ zig cc main.c
warning: Encountered error: FileNotFound, falling back to default ABI and dynamic linker.
error: unable to create compilation: LibCRuntimeNotFound
~ $ zig cc main.c -target aarch64-linux-musl
~ $ ./a.out
ok
~ $ termux-chroot
~ $ zig cc main.c
ld.lld: error: unable to find library -lm
ld.lld: error: unable to find library -lc
ld.lld: error: unable to find library -ldl
~ $ zig cc main.c -target aarch64-linux-musl
~ $ ./a.out
ok
~ $ proot-distro login archlinux
[root@localhost ~]# zig cc main.c error: unable to create compilation: LibCRuntimeNotFound
[root@localhost ~]# zig cc main.c -target aarch64-linux-musl
[root@localhost ~]# ./a.out
ok
What is the expected behavior?
~ $ cat main.c
#include <stdio.h>
int main() {
puts("ok");
}
~ $ zig cc main.c
~ $ ./a.out
ok
System information
Termux Variables:
TERMUX_API_VERSION=0.50.1
TERMUX_APK_RELEASE=F_DROID
TERMUX_APP_PACKAGE_MANAGER=apt
TERMUX_APP_PID=25365
TERMUX_IS_DEBUGGABLE_BUILD=0
TERMUX_MAIN_PACKAGE_FORMAT=debian
TERMUX_VERSION=0.118.1
TERMUX__USER_ID=0
Packages CPU architecture:
aarch64
Subscribed repositories:
# sources.list
deb https://packages.termux.dev/apt/termux-main stable main
# tur-repo (sources.list.d/tur.list)
deb https://tur.kcubeterm.com tur-packages tur tur-on-device tur-continuous
# x11-repo (sources.list.d/x11.list)
deb https://packages.termux.dev/apt/termux-x11 x11 main
Updatable packages:
gsettings-desktop-schemas/x11 46.1 all [upgradable from: 46.0]
termux-tools version:
1.42.4
Android version:
14
Kernel build information:
Linux localhost 5.15.123-android13-8-00008-g3ca6a2912c7e-ab11087001 #1 SMP PREEMPT Sat Nov 11 06:58:10 UTC 2023 aarch64 Android
Device manufacturer:
Xiaomi
Device model:
23113RKC6C
LD Variables:
LD_LIBRARY_PATH=
LD_PRELOAD=/data/data/com.termux/files/usr/lib/libtermux-exec.so
Installed termux plugins:
com.termux.x11 versionCode:14
com.termux.api versionCode:51