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

x/mobile/cmd/gomobile: init doesn't install darwin_arm and darwin_arm64 tools #11339

Closed
rakyll opened this issue Jun 22, 2015 · 13 comments
Closed
Milestone

Comments

@rakyll
Copy link
Contributor

rakyll commented Jun 22, 2015

gomobile init moves the pre-complied standard library under $GOROOT/pkg, but it should also move the tools (compile, asm, cgo, link, etc) under $GOROOT/pkg/tools/darwin_arm and $GOROOT/pkg/tools/darwin_arm64.

@rakyll rakyll self-assigned this Jun 22, 2015
@rakyll rakyll added this to the Go1.5 milestone Jun 22, 2015
@rakyll
Copy link
Contributor Author

rakyll commented Jun 22, 2015

Currently, the android/arm tools are installed to the NDK bin directory. We might prefer to have a $GOMOBILE/tools directory to dump the android and darwin tools there.

$GOMOBILE/tools/android_arm
$GOMOBILE/tools/darwin_arm
$GOMOBILE/tools/darwin64_arm

Any other suggestions?

cc/ @crawshaw @hyangah

@crawshaw
Copy link
Member

Are different tools still required? The only GOOS/GOARCH-specific entry I can find in cmd/dist is zdefaultcc.go in cgo. As CC_FOR_TARGET / CXX_FOR_TARGET are passed through, we may be able simply stop using the -toolexec trick.

@rakyll
Copy link
Contributor Author

rakyll commented Jun 23, 2015

After a fresh gomobile init with no darwin tools installed, this is what I observe.

$ CGO_ENABLED=1 GOARCH=arm64 go build .
# runtime/cgo
/Users/jbd/go/src/runtime/cgo/gcc_arm64.S:27:16: error: brackets expression not supported on this target
 stp x19, x20, [sp, #-16]!
               ^
/Users/jbd/go/src/runtime/cgo/gcc_arm64.S:28:16: error: brackets expression not supported on this target
 stp x21, x22, [sp, #-16]!
               ^
/Users/jbd/go/src/runtime/cgo/gcc_arm64.S:29:16: error: brackets expression not supported on this target
 stp x23, x24, [sp, #-16]!
               ^
/Users/jbd/go/src/runtime/cgo/gcc_arm64.S:30:16: error: brackets expression not supported on this target
 stp x25, x26, [sp, #-16]!
               ^
/Users/jbd/go/src/runtime/cgo/gcc_arm64.S:31:16: error: brackets expression not supported on this target
 stp x27, x28, [sp, #-16]!
               ^
/Users/jbd/go/src/runtime/cgo/gcc_arm64.S:32:16: error: brackets expression not supported on this target
 stp x29, x30, [sp, #-16]!
               ^
/Users/jbd/go/src/runtime/cgo/gcc_arm64.S:33:2: error: unknown use of instruction mnemonic without a size suffix
 mov x29, sp
 ^
/Users/jbd/go/src/runtime/cgo/gcc_arm64.S:35:2: error: unknown use of instruction mnemonic without a size suffix
 mov x19, x0
 ^
/Users/jbd/go/src/runtime/cgo/gcc_arm64.S:36:2: error: unknown use of instruction mnemonic without a size suffix
 mov x20, x1
 ^
/Users/jbd/go/src/runtime/cgo/gcc_arm64.S:37:2: error: unknown use of instruction mnemonic without a size suffix
 mov x0, x2
 ^
/Users/jbd/go/src/runtime/cgo/gcc_arm64.S:39:2: error: invalid instruction mnemonic 'blr'
 blr x20
 ^~~
/Users/jbd/go/src/runtime/cgo/gcc_arm64.S:40:2: error: invalid instruction mnemonic 'blr'
 blr x19
 ^~~
/Users/jbd/go/src/runtime/cgo/gcc_arm64.S:42:16: error: brackets expression not supported on this target
 ldp x29, x30, [sp], #16
               ^
/Users/jbd/go/src/runtime/cgo/gcc_arm64.S:43:16: error: brackets expression not supported on this target
 ldp x27, x28, [sp], #16
               ^
/Users/jbd/go/src/runtime/cgo/gcc_arm64.S:44:16: error: brackets expression not supported on this target
 ldp x25, x26, [sp], #16
               ^
/Users/jbd/go/src/runtime/cgo/gcc_arm64.S:45:16: error: brackets expression not supported on this target
 ldp x23, x24, [sp], #16
               ^
/Users/jbd/go/src/runtime/cgo/gcc_arm64.S:46:16: error: brackets expression not supported on this target
 ldp x21, x22, [sp], #16
               ^
/Users/jbd/go/src/runtime/cgo/gcc_arm64.S:47:16: error: brackets expression not supported on this target
 ldp x19, x20, [sp], #16
               ^
/Users/jbd/go/src/runtime/cgo/gcc_arm64.S:53:2: error: invalid instruction mnemonic 'b'
 b 1b
 ^

Fails with the same with the right clang.

$ CC_FOR_TARGET=$HOME/go/misc/ios/clangwrap.sh CXX_FOR_TARGET=$HOME/go/misc/ios/clangwrap.sh  CGO_ENABLED=1 GOARCH=arm64 go build .
# runtime/cgo
/Users/jbd/go/src/runtime/cgo/gcc_arm64.S:27:16: error: brackets expression not supported on this target
 stp x19, x20, [sp, #-16]!
               ^
/Users/jbd/go/src/runtime/cgo/gcc_arm64.S:28:16: error: brackets expression not supported on this target
 stp x21, x22, [sp, #-16]!
               ^
/Users/jbd/go/src/runtime/cgo/gcc_arm64.S:29:16: error: brackets expression not supported on this target
 stp x23, x24, [sp, #-16]!
               ^
/Users/jbd/go/src/runtime/cgo/gcc_arm64.S:30:16: error: brackets expression not supported on this target
 stp x25, x26, [sp, #-16]!
               ^
/Users/jbd/go/src/runtime/cgo/gcc_arm64.S:31:16: error: brackets expression not supported on this target
 stp x27, x28, [sp, #-16]!
               ^
/Users/jbd/go/src/runtime/cgo/gcc_arm64.S:32:16: error: brackets expression not supported on this target
 stp x29, x30, [sp, #-16]!
               ^
/Users/jbd/go/src/runtime/cgo/gcc_arm64.S:33:2: error: unknown use of instruction mnemonic without a size suffix
 mov x29, sp
 ^
/Users/jbd/go/src/runtime/cgo/gcc_arm64.S:35:2: error: unknown use of instruction mnemonic without a size suffix
 mov x19, x0
 ^
/Users/jbd/go/src/runtime/cgo/gcc_arm64.S:36:2: error: unknown use of instruction mnemonic without a size suffix
 mov x20, x1
 ^
/Users/jbd/go/src/runtime/cgo/gcc_arm64.S:37:2: error: unknown use of instruction mnemonic without a size suffix
 mov x0, x2
 ^
/Users/jbd/go/src/runtime/cgo/gcc_arm64.S:39:2: error: invalid instruction mnemonic 'blr'
 blr x20
 ^~~
/Users/jbd/go/src/runtime/cgo/gcc_arm64.S:40:2: error: invalid instruction mnemonic 'blr'
 blr x19
 ^~~
/Users/jbd/go/src/runtime/cgo/gcc_arm64.S:42:16: error: brackets expression not supported on this target
 ldp x29, x30, [sp], #16
               ^
/Users/jbd/go/src/runtime/cgo/gcc_arm64.S:43:16: error: brackets expression not supported on this target
 ldp x27, x28, [sp], #16
               ^
/Users/jbd/go/src/runtime/cgo/gcc_arm64.S:44:16: error: brackets expression not supported on this target
 ldp x25, x26, [sp], #16
               ^
/Users/jbd/go/src/runtime/cgo/gcc_arm64.S:45:16: error: brackets expression not supported on this target
 ldp x23, x24, [sp], #16
               ^
/Users/jbd/go/src/runtime/cgo/gcc_arm64.S:46:16: error: brackets expression not supported on this target
 ldp x21, x22, [sp], #16
               ^
/Users/jbd/go/src/runtime/cgo/gcc_arm64.S:47:16: error: brackets expression not supported on this target
 ldp x19, x20, [sp], #16
               ^
/Users/jbd/go/src/runtime/cgo/gcc_arm64.S:53:2: error: invalid instruction mnemonic 'b'
 b 1b
 ^

@rakyll
Copy link
Contributor Author

rakyll commented Jun 23, 2015

The problem is about the missing darwin tools under GOROOT. With the tools installed, I can reproduce the problem above. I have limited knowledge about cross compilers. Could someone take another look if buildDarwinARMCC is missing anything critical. https://github.com/golang/mobile/blob/master/cmd/gomobile/init.go#L232

cc/ @crawshaw @minux

@crawshaw
Copy link
Member

You can go ahead and install the tools in GOMOBILE/tools/GOOS_GOARCH for now, I'll look into removing the use of toolexec in 1.6.

@gopherbot
Copy link

CL https://golang.org/cl/11345 mentions this issue.

@rakyll
Copy link
Contributor Author

rakyll commented Jun 24, 2015

Bad news. Moving tools to GOMOBILE/tools/GOOS_GOARCH and using toolexec didn't fix the problem. Darwin/arm tools are ARM-only and don't execute on my host machine even though Android tools such as GOMOBILE/android-ndk-r10d/arm/bin/compile works on darwin/amd64.

Good news. I inspected how Go toolchain is invoked if I bootstrap a darwin/arm cross compiler manually. It uses darwin_amd64 tools and clangwrapper.sh with some arguments missing from where we invoke the gomobile builds for iOS.

/Users/jbd/go/src/../misc/ios/clangwrap.sh -I . -fPIC -marm -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fno-common -print-libgcc-file-name

If I use clangwrapper as CC_FOR_TARGET and CXX_FOR_TARGET with these arguments, iOS builds will be probably achievable.

@rakyll
Copy link
Contributor Author

rakyll commented Jun 24, 2015

Added the missing CC_FOR_TARGET, CXX_FOR_TARGET and the required arguments to the go build. See https://go-review.googlesource.com/#/c/11345/.

@rakyll
Copy link
Contributor Author

rakyll commented Jun 24, 2015

golang/mobile@597df59 doesn't fix it. I was testing it against a bad environment probably. The CL sets a CCFLAGS environmental variable, but go tooling doesn't handle such a var.

gomobile build  .
# runtime/cgo
clang: error: argument unused during compilation: '-mno-thumb'
gomobile: exit status 2

I would prefer this issue is handled by someone who is knowledgable about the toolchain.

@rakyll rakyll removed their assignment Jun 24, 2015
@gopherbot
Copy link

CL https://golang.org/cl/11453 mentions this issue.

rakyll added a commit to golang/mobile that referenced this issue Jun 25, 2015
This reverts commit 597df59.

Reverting the change since, runtime/cgo is still not buildable and CCFLAGS is not a valid env variable. See golang/go#11339 for more information.

Change-Id: I2f168508d1ca72f5c75ff641938fd3b304939617
Reviewed-on: https://go-review.googlesource.com/11453
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
@rakyll
Copy link
Contributor Author

rakyll commented Jun 25, 2015

As a temporary workaround, I will copy the go binary into GOMOBILE/bin/darwin_arm64/bin and will invoke the darwin/arm builds from there.

In theory, any Go binary with CC_FOR_TARGET=clangwrap.sh and CXX_FOR_TARGET=clangwrap.sh must be behaving similarly but clangwrap.sh isn't used even though these environment variables are set. There might be a bug with the cross compilation toolchain invocation.

cc/ @rsc

@gopherbot
Copy link

CL https://golang.org/cl/11614 mentions this issue.

@rakyll
Copy link
Contributor Author

rakyll commented Jun 29, 2015

Closed via golang/mobile@beece5b.

@rakyll rakyll closed this as completed Jun 29, 2015
@golang golang locked and limited conversation to collaborators Jun 28, 2016
imWildCat pushed a commit to imWildCat/go-mobile that referenced this issue Apr 10, 2021
This CL will be followed by another change to remove the
misc/ios/clangwrapper.sh dependency.

Updates golang/go#11043.

Fixes golang/go#11339.

Change-Id: I82466f8d845945935ab82d3d0b75f5af9e1ef3ec
Reviewed-on: https://go-review.googlesource.com/11345
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
imWildCat pushed a commit to imWildCat/go-mobile that referenced this issue Apr 11, 2021
This CL will be followed by another change to remove the
misc/ios/clangwrapper.sh dependency.

Updates golang/go#11043.

Fixes golang/go#11339.

Change-Id: I82466f8d845945935ab82d3d0b75f5af9e1ef3ec
Reviewed-on: https://go-review.googlesource.com/11345
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
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

3 participants