Skip to content
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

Build Syncthing with cgo and GOOS=android #873

Closed
calmh opened this issue Apr 1, 2017 · 8 comments
Closed

Build Syncthing with cgo and GOOS=android #873

calmh opened this issue Apr 1, 2017 · 8 comments

Comments

@calmh
Copy link
Member

calmh commented Apr 1, 2017

This will hopefully get you better networking support, and we can qualify the remaining Android specializations on the architecture at build time instead of checking at runtime. I tested the procedure and it works fine - at least the build does, I can't test the binaries.

https://gist.github.com/calmh/20c24afc283656695b76f7822c8c8997

@Nutomic
Copy link
Contributor

Nutomic commented Apr 1, 2017

@AudriusButkevicius @Zillode Could you try to integrate this with the existing build scripts? I'm really bad with the Go build tools unfortunately.

@AudriusButkevicius
Copy link
Member

I am still trying understand what this will give us.

@calmh
Copy link
Member Author

calmh commented Apr 1, 2017 via email

@AudriusButkevicius
Copy link
Member

AudriusButkevicius commented Apr 1, 2017

It mostly exists for gomobile reasons being able to bind with Java I assume.

From what I've looked at:

Audrius@Audrius src $ for A in `find -name '*.go' -or -name '*.s' | grep -v 'test' | grep -v '/cmd/' | grep -v '/build/'`; do grep -l android $A; done
./net/cgo_linux.go
./net/cgo_resnew.go
./net/cgo_resold.go
./net/cgo_socknew.go
./net/conf.go
./os/executable_procfs.go
./os/file_unix.go
./os/user/getgrouplist_unix.go
./os/user/listgroups_unix.go
./os/user/lookup_android.go
./os/user/lookup_stubs.go
./os/user/lookup_unix.go
./runtime/cgo/cgo.go
./runtime/internal/sys/gengoos.go
./runtime/internal/sys/zgoos_android.go
./runtime/internal/sys/zgoos_linux.go
./runtime/os_linux_arm.go
./runtime/rt0_android_386.s
./runtime/rt0_android_amd64.s
./runtime/rt0_android_arm.s
./runtime/rt0_android_arm64.s
./runtime/sys_linux_386.s
./runtime/sys_linux_amd64.s
./runtime/tls_arm.s
./runtime/write_err.go
./runtime/write_err_android.go
./time/zoneinfo_unix.go

logging to /dev/log/main
some asm tweaks for runtime and TLS
different location for tz defs
different location for tmpdir
disables fpu checks
disables user id/user group lookups
handling of /proc/self/exe (same as linux)
cgo resolver

@Nutomic
Copy link
Contributor

Nutomic commented Oct 12, 2017

Finally gave this a try, but running into errors, using this code:

cd ext/syncthing/src/github.com/syncthing/syncthing

CGO_ENABLED=1 CC=${ANDROID_NDK_HOME}/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/arm-linux-androideabi-gcc \
  go run build.go -goos android -goarch arm build

Output:

runtime/internal/sys
go install runtime/internal/sys: mkdir /usr/lib/go/pkg/android_arm: permission denied
exit status 1
exit status 1

So it looks like Go is trying to install stuff to system directories (which are handled by the package manager). I could make that work on my laptop, but definitely not on F-Droid. According to this issue, the only solution seems to be waiting for Go 1.10?

@calmh
Copy link
Member Author

calmh commented Oct 12, 2017

You can probably pass -pkgdir to handle that

@Nutomic
Copy link
Contributor

Nutomic commented Oct 13, 2017

It's working! But I didn't see any way to pass -pkgdir to build.go build, so I had to edit the file directly.

Other than that, I just have to update the build script.

@calmh
Copy link
Member Author

calmh commented Oct 13, 2017

Yeah, I meant to go build. But feel free to patch build.go to take a -pkgdir that is just passed along. I'm fine with having that.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants