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

Fails to build in apple M1 #81

Closed
PauloRAndrade opened this issue Oct 25, 2021 · 3 comments · Fixed by #87
Closed

Fails to build in apple M1 #81

PauloRAndrade opened this issue Oct 25, 2021 · 3 comments · Fixed by #87

Comments

@PauloRAndrade
Copy link

Summary

I'm unable to compile protos since I got a macbook with an M1.

Steps to Reproduce

I run the following to compile:

docker run --platform linux/amd64 --rm -v ${PWD}:${PWD} -w ${PWD} rvolosatovs/protoc \
 		--proto_path=. \
 		--go_out=./pb/go \
 		--go_opt=paths=source_relative \
 		--go-grpc_out=./pb/go \
 		--go-grpc_opt=paths=source_relative \
 		--grpc-gateway_out=:./pb/go \
 		--grpc-gateway_opt=paths=source_relative \
 		--openapiv2_out=web/swagger \
                 PROTO_FILES

Running without --platform linux/amd64 returns the same error and throws the following warning: WARNING: The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested

What do you see now?

qemu: uncaught target signal 11 (Segmentation fault) - core dumped
--go_out: protoc-gen-go: Plugin killed by signal 11.
make: *** [protoc] Error 1

What do you want to see instead?

The protos being compiled.

Environment

MacBook Pro (13-inch, M1, 2020)
Apple M1
macOS Big Sur 11.6

How do you propose to implement this?

Adding an arm image would fix this I think.

Can you do this yourself and submit a Pull Request?

No idea if it is easy to port the dockerfile to also work in arm64

@rvolosatovs
Copy link
Owner

FWIW, https://github.com/tonistiigi/xx may be of help here, but I am not sure.

@twelvee
Copy link

twelvee commented Nov 28, 2021

I think I found the solution that helps me with same issue.
Its all about this line

RUN mkdir -p /upx && curl -sSL https://github.com/upx/upx/releases/download/v${UPX_VERSION}/upx-${UPX_VERSION}-amd64_linux.tar.xz | tar xJ --strip 1 -C /upx && \
    install -D /upx/upx /usr/local/bin/upx

The link https://github.com/upx/upx/releases/download/v${UPX_VERSION}/upx-${UPX_VERSION}-amd64_linux.tar.xz
has amd64 version, but you should replace it with arm64. Like that

RUN mkdir -p /upx && curl -sSL https://github.com/upx/upx/releases/download/v${UPX_VERSION}/upx-${UPX_VERSION}-arm64_linux.tar.xz | tar xJ --strip 1 -C /upx && \
    install -D /upx/upx /usr/local/bin/upx

Here's the same issue as I see:
open-telemetry/build-tools#42 (comment)

Sorry, just not able to create PR right now, because can't build the image by other reasons.
Here the image I tested https://hub.docker.com/r/twelvee/test-grpc (I've removed rust, dart and swift support as well, just in my purposes)

Hope that's helpful :)

@rvolosatovs
Copy link
Owner

rvolosatovs commented Nov 30, 2021

That makes a lot of sense, thank you for analysis - should be pretty simple to fix.

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

Successfully merging a pull request may close this issue.

3 participants