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

Also provide binaries for Android ARM #1578

Closed
wants to merge 1 commit into from
Closed

Also provide binaries for Android ARM #1578

wants to merge 1 commit into from

Conversation

thunder-coding
Copy link

Closes #1556

@@ -150,6 +151,9 @@ platform-unixlike:
platform-android-arm64:
make GOOS=android GOARCH=arm64 NPMDIR=npm/esbuild-android-arm64 platform-unixlike

platform-android-arm:
make GOOS=android GOARCH=arm NPMDIR=npm/esbuild-android-arm platform-unixlike
Copy link
Owner

@evanw evanw Sep 8, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am unable to run this on my computer. I get this:

$ make GOOS=android GOARCH=arm NPMDIR=npm/esbuild-android-arm platform-unixlike
test -n "android" && test -n "arm" && test -n "npm/esbuild-android-arm"
mkdir -p "npm/esbuild-android-arm/bin"
cd "npm/esbuild-android-arm" && npm version "0.12.25" --allow-same-version
v0.12.25
CGO_ENABLED=0 GOOS="android" GOARCH="arm" go build "-ldflags=-s -w" -trimpath -o "npm/esbuild-android-arm/bin/esbuild" ./cmd/esbuild
# github.com/evanw/esbuild/cmd/esbuild
loadinternal: cannot find runtime/cgo
/usr/local/go/pkg/tool/darwin_amd64/link: running clang failed: exit status 1
ld: warning: option -s is obsolete and being ignored
ld: unknown option: -z
clang: error: linker command failed with exit code 1 (use -v to see invocation)

make: *** [platform-unixlike] Error 2

This is on macOS 11.5.1. I don't understand why cgo is apparently enabled despite CGO_ENABLED=0. Here is a reduced reproduction:

$ cat main.go 
package main

import "runtime/debug"

func main() {
	debug.SetGCPercent(-1)
}

$ CGO_ENABLED=0 GOOS="android" GOARCH="arm" go build main.go
# command-line-arguments
loadinternal: cannot find runtime/cgo
/usr/local/go/pkg/tool/darwin_amd64/link: running clang failed: exit status 1
ld: unknown option: -z
clang: error: linker command failed with exit code 1 (use -v to see invocation)

This appears to be a bug in Go.

Edit: I have filed this bug as golang/go#48246.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you try compiling with older Golang versions?

Don't know why but I feel it's somehow related to wrong dynamic linker path when cross compiling issue (not mentioning the issue here since it may be unrelated)

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Go team said that "internal linking" is unsupported with Android ARM and building this requires a C toolchain to build. Maybe this means I need to build this on a 32-bit Android ARM device?

Are you able to build esbuild using this command? If so, what OS version, CPU architecture, and Go version are you on?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was able to build on Android ARM 7.0 using on Termux using

go build ./cmd/esbuild

The Golang version I had was the latest in official Termux repository as of writing this comment.

go version output

go version go1.16.7 android/arm

and I have a esbuild binary.

And about cross compiling, you need to get the C compiler from Android SDK.

If you need some example on how to do it see termux/termux-packages

Under scripts/build/termux_step_setup_toolchain.sh, you can see how it's setting up CC, CXX and other environment variables (along with some other changes which might not be needed here)

@evanw
Copy link
Owner

evanw commented Jan 22, 2022

I'm closing this as I don't want to complicate esbuild's deploy process by having to install the entire Android build toolchain for this one platform. All of the other 18 platforms I already support can be built fine by Go on any platform without installing anything. I still don't understand why Go doesn't support cross-platform builds for this platform in particular (Go and Android are even both Google projects!) but that's up to them I guess. If you want to run esbuild on 32-bit Android ARM, you'll have to build it yourself. Sorry.

@evanw evanw closed this Jan 22, 2022
@evanw evanw mentioned this pull request Jun 21, 2022
@evanw evanw mentioned this pull request Sep 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Also provide binaries for Android arm
2 participants