-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Compiling a program on termux aarch64 produces FileNotFound
errors
#14146
Comments
The same eight // main.zig
pub fn main() void {} Running |
FileNotFound
errors
|
can you show the output of the following 2 commands, where my_name_exe is what
|
|
Hmm perhaps the zig executable you are using has a dynamic linker path that is not found on your host. Maybe |
I found the native On Android, |
if (header_.e_type != ET_DYN) {
DL_ERR("\"%s\" has unexpected e_type: %d", name_.c_str(), header_.e_type);
return false;
} So it seems like that error might be unrelated. |
That looks like it is expecting a dynamic executable and iirc zig shipped in tarballs for linux are static for maximum platform compatibility. But yeah, unrelated. |
I think that since Android has a non-standard filesystem layout it doesn't know where to look for libraries. |
Things seem to work fine from within |
Edit: you can probably disregard this; I think I was conflating two different issues. In
but this fails on Termux. There may be a useful hint here that the filename to search for in this system is |
I think this is a pretty easy fix. Termux root userspace is at The solution then would be to detect if we're running on Termux and alter the path accordingly. It seems that |
Hi @DivergentClouds , It seems that @JerwuQu has fixed the problem in PR #15896. I hope this patch will be accepted and then someone will create a Termux package for ziglang. Regards. |
* Append Termux-specific path to `zig_examined_elf_files` to workaround different path for `env` binary. See also ziglang#14146 * Use same buffer for searching shebang line to search ELF magic constant, if any, and remove corresponding (now duplicate) check from `abiAndDynamicLinkerFromFile` * Fix not finding interpret path when it it separater from shebang by one or more blank spaces * Fix too big minimal limit of bytes from file (minimal shebang length instead of `buffer.len`) Signed-off-by: Eric Joldasov <bratishkaerik@getgoogleoff.me>
Clarifying criteria for me to consider this issue "solved": First, adjust the logic like this:
Can a termux user confirm that this would find Finally, send a patch to NixOS to remove this patch. Then this issue can be closed. |
Can confirm! |
This doesn't work with Nix: The correct approach for Nix would be:
|
Couldn't this issue be resolved by looking for The downside is that the Zig compiler seems to call the function that resolves Some paths Termux NixOS My Arch install |
Regarding But anyway the point of using I'm still sticking with the same Like I said, non-standard directories are probably listed first. We don't want a user's cute "env plus extra features" implementation from their home directory to get priority because it's less likely to have the same dynamic linker as the base system installation. For NixOS, The only alternative I am considering to this is to change the fallback logic after checking hard-coded What I like about solutions like this is that the little guys have a chance to participate. Somebody's hobby OS project could look at Zig's logic and make reasonable adjustments to their packaging and build system and make zig work correctly out of the box for their system. |
It does work in general: When in a Nix build (shell or sandbox), use the explicitly pinned-down version via
Using |
Are you sure it won't work? If it's a sandbox that means it should be excluding directories in Looks like it works just fine to me, poking around at a |
Yeah, it works with |
Outside of package management context, literally matching |
I'm not convinced of this argument for iterating in reversed order when looking at my own In my view, following the "correct" order and being able to quickly solve any issues that arise on non-standard platforms by asking "what does One could even argue scanning the full Ultimately it won't matter for the vast majority of users, so reverse order would also be fine, and I could pick up my PR again if the decision is firm. |
Why not just try I have quite a lengthy |
OK, I am convinced.
|
Note that #18778 introduces build option Update: |
I saw it pointed out a couple times that this works fine from inside a I tried passing Linker correct, but everything else broken:
Everything correct except the linker:The relevant line is
EDIT: worth noting that in my case (and I suspect most nix dev shells), the version of |
Here's the problem: Lines 3710 to 3712 in e2ec54b
It must be that when I pass And indeed if I take the produced |
I edited the file I actually had this error when trying to edit Zig source files after installing zig.vim, I added |
I want to add that the message disappears if you add |
I'm having same issue on termux when trying to build a zig project What i did: apt update && apt upgrade
apt install zig
mkdir hello
cd hello
zig init
zig build now I'm getting this error ~/labs/zigger $ ls install |
I think PATH should have priority over hard-coded location. I think logic should be like this: first try to search I think this plan should work same for most cases here (Nix, Termux etc.), and additionaly better for case described above than accepted soultion. BTW these UPD: implemented here https://www.github.com/ziglang/zig/pull/21540 |
Some information might help: ~/ziglang $ which env
/data/data/com.termux/files/usr/bin/env
~/ziglang $ ldd env
libandroid-support.so => /data/data/com.termux/files/usr/lib/libandroid-support.so
libgmp.so => /data/data/com.termux/files/usr/lib/libgmp.so
libiconv.so => /data/data/com.termux/files/usr/lib/libiconv.so
libc.so => /system/lib64/libc.so
ld-android.so => /system/lib64/ld-android.so
libdl.so => /system/lib64/libdl.so
~/ziglang $ which /bin/env
/bin/env
~/ziglang $ ldd /bin/env
libcrypto.so => /system/lib64/libcrypto.so
libz.so => /system/lib64/libz.so
liblog.so => /system/lib64/liblog.so
libprocessgroup.so => /system/lib64/libprocessgroup.so
libselinux.so => /system/lib64/libselinux.so
libc.so => /system/lib64/libc.so
libm.so => /system/lib64/libm.so
libdl.so => /system/lib64/libdl.so
ld-android.so => /system/lib64/ld-android.so
libc++.so => /system/lib64/libc++.so
libbase.so => /system/lib64/libbase.so
libcgrouprc.so => /system/lib64/libcgrouprc.so
libpcre2.so => /system/lib64/libpcre2.so
libpackagelistparser.so => /system/lib64/libpackagelistparser.so Environment paths: ~/ziglang $ echo $PREFIX
/data/data/com.termux/files/usr
~/ziglang $ echo $HOME
/data/data/com.termux/files/home
~/ziglang $ echo $PATH
/data/data/com.termux/files/usr/bin:/data/data/com.termux/files/home/.local/bin:/data/data/com.termux/files/home/.local/bin ~/ziglang $ ls /usr/bin
ls: cannot access '/usr/bin': No such file or directory
~/ziglang $ sudo ls /usr/bin
ls: cannot access '/usr/bin': No such file or directory |
Zig Version
0.11.0-dev.1012+4b5fc5239
Steps to Reproduce and Observed Behavior
Steps to reproduce
master
aarch64 Linux tarball from ziglang.org and extract itzig init-exe && zig build run
Observed Behavior
Interestingly, the outputted program behaves as expected, although I'm not sure if more complex programs would break.
Expected Behavior
The program should compile with no errors and run properly.
The text was updated successfully, but these errors were encountered: