termux / termux-root-packages

Termux packages that are only usable by root users.
Other
1.04k stars 295 forks source link

Add containerd package #222

Closed FreddieOliveira closed 3 years ago

FreddieOliveira commented 3 years ago

Containerd is actually a docker dependency. Pls, check if the build script is correct since the other packages (dockerd and dockercli) will have the same structure.

FreddieOliveira commented 3 years ago

i686 test failed with: /tmp/go-link-949764692/go.o:go.go:_cgo_init: error: undefined reference to 'x_cgo_init' I'm not sure why. I didn't have this issue here compiling for aarch64.

FreddieOliveira commented 3 years ago

It seems it has to do with CGO_ENABLED var being 0. Setting it to 1 may fix the problem. I didn't try though. I compiled the package on my device inside Termux. Maybe this is the case to mark this package as TERMUX_ON_DEVICE_BUILD or setting CGO_ENABLED for cross compilation.


I've just realized the CGO_ENABLED is already being set to 1 in the termux_step_setup_toolchain.sh script 🤨

ghost commented 3 years ago

It seems it has to do with CGO_ENABLED var being 0.

CGO must be always on for Android.

ghost commented 3 years ago

Your build.sh won't work here due to attempt to run cross-compiled executable:

go run cmd/gen-manpages/main.go containerd.8 man
fork/exec /tmp/go-build640298035/b001/exe/main: exec format error
make: *** [Makefile:225: man/ctr.8] Error 1
make: *** Waiting for unfinished jobs....
fork/exec /tmp/go-build266114902/b001/exe/main: exec format error

You need to reset variables GOARCH, GOOS and others set by build-package.sh when compiling program which should run on host environment.

FreddieOliveira commented 3 years ago

I've checked the test logs and it built the binaries successfully, but failed when generating the man pages. I'll try to figure out why exactly.

FreddieOliveira commented 3 years ago

When running make man, it complies an auxiliary executable called md2man. Then, it uses this executable to generate the manuals. Probably that's when the error arises, because this binary shouldn't be cross compiled. I'll try to unset the env vars before executing make man

FreddieOliveira commented 3 years ago
+ man/containerd.8
go run cmd/gen-manpages/main.go containerd.8 man
# runtime/cgo
gcc_amd64.S:25:8: error: unknown token in expression
 pushq %rbx
       ^
gcc_amd64.S:25:8: error: invalid operand
 pushq %rbx
       ^

Generating a man page turned out to be more hassle than generating the binary itself.

@xeffyr Maybe I'm unsetting more variables than needed.

ghost commented 3 years ago

@FreddieOliveira unset GOOS GOARCH CGO_LDFLAGS CC CXX CFLAGS CXXFLAGS LDFLAGS. Look build.sh of hugo from termux-packages, it does similar steps to generate manpages.

FreddieOliveira commented 3 years ago

Look build.sh of hugo from termux-packages, it does similar steps to generate manpages.

Cool, fixing the unsets solved the issue. But unfortunately it was able to compile only for aarch64.

Do you know why the other archs failed with that undefined reference error?

Maybe that's fixable. I'll try to compile on device (inside Termux) in another phone I have arm32.

FreddieOliveira commented 3 years ago

Maybe that's fixable. I'll try to compile on device (inside Termux) in another phone I have arm32.

Indeed, it was fixable. When compiling in my other phone I was getting the very same undefined reference error, till I realize the shim_cgo flag needs to be enabled for other architectures other than aarch64, for whatever reason. I've unblacklisted the others archs and now it sucessfully builds for all of them.

@xeffyr I believe now we're good to go.