tinygo icon indicating copy to clipboard operation
tinygo copied to clipboard

tinygo build fails with error: could not find build id in %!s(<nil>) on Android

Open wasmasmr opened this issue 3 years ago • 3 comments
trafficstars

I installed release v0.24.0 with go install. When I tried to build a simple test program with the resulting executable I got this error: error: could not find build id in %!s(<nil>). Presumably it is caused by this line. My operating system is Android and my architecture is arm64. I was using Termux as my terminal. Changing the GOOS and GOARCH environment variables didn't help. file can read the build id of the executable. tinygo version outputs: tinygo version 0.24.0 android/arm64 (using go version go1.18.3 and LLVM version 14.0.6).

wasmasmr avatar Jul 11 '22 14:07 wasmasmr

I guess using tinygo on android wasn't as straightforward as I though. If I add "android" to this line the build id error goes away, but I still get different errors such as this: /data/data/com.termux/files/usr/lib/go/src/syscall/exec_linux.go:105:13: unknown GOOS/GOARCH for syscall: android/arm64. If I change the GOOS environment variable to linux I get different output: error: open /data/data/com.termux/files/home/tinygo/lib/musl/arch/aarch64/bits/alltypes.h.in: no such file or directory.

wasmasmr avatar Jul 11 '22 16:07 wasmasmr

git clone --recursive solves the last error and rewards me with new ones: clang-14: error no such file or directory: '/data/data/com.termux/files/home/tinygo/lib/compiler-rt-builtins/absvdi2.c' and a couple other missing files. This was with GOOS=linux. Without it I still get the same errors as before. It seems that if I can find those missing files the build will probably succeed with GOOS=linux.

wasmasmr avatar Jul 11 '22 16:07 wasmasmr

My operating system is Android and my architecture is arm64.

I don't think anybody has tried this before, so congratulations for the effort! (I've also never heard about Termux but should check it out, it looks cool!).

If I add "android" to this line the build id error goes away,

Seems like a reasonable fix. Feel free to send a PR with this fix, and other places that use runtime.GOOS and only check for "linux".

git clone --recursive solves the last error and rewards me with new ones: clang-14: error no such file or directory: '/data/data/com.termux/files/home/tinygo/lib/compiler-rt-builtins/absvdi2.c' and a couple other missing files.

You need to run make llvm-source to fix this. It will download the LLVM source, of which only a small part is actually needed (some files in the llvm-project/compiler-rt directory). You can find more details in the Makefile, under the build/release target. You could also take a look here for inspiration.

aykevl avatar Jul 15 '22 13:07 aykevl

Released as part of v0.26.0

deadprogram avatar Sep 30 '22 06:09 deadprogram