[question] How to build for arm64
lyssar opened this issue ยท comments
Is there a way to compile php-grpc for arm64 and if yes what do I need todo?
Its not clear to me what I have to install before in general to be able build php-grpc from source at all.
Make install runs until he tries to copy and fails then because it was no file generated
/tmp/php-grpc# make install
Packaging Windows Build
Packaging Mac Build
Packaging Linux Build
Packaging FreeBSD Build
Packaging Protoc Windows Build
Packaging Protoc Mac Build
Packaging Protoc Linux Build
Packaging Protoc FreeBSD Build
cp protoc-gen-php-grpc /usr/local/bin/protoc-gen-php-grpc
cp: cannot stat 'protoc-gen-php-grpc': No such file or directory
make: *** [Makefile:9: install] Error 1
Can someone explain me how to do this correctly? :)
Since we are two weeks in now and no response yet here a little bump :) would love to build my containers with spiral on arm64 structures
I sincerely apologize, I missed this ticket ๐ At the moment there is no support for the arm64
for this package yet, but, on your own, you can try to run the following script:
#!/bin/bash
cd $(dirname "${BASH_SOURCE[0]}")
OD="$(pwd)"
# Pushes application version into the build information.
RR_VERSION=1.5.0
# Hardcode some values to the core package
LDFLAGS="$LDFLAGS -X github.com/spiral/roadrunner/cmd/rr/cmd.Version=${RR_VERSION}"
LDFLAGS="$LDFLAGS -X github.com/spiral/roadrunner/cmd/rr/cmd.BuildTime=$(date +%FT%T%z)"
LDFLAGS="$LDFLAGS -s"
build(){
echo Packaging $1 Build
bdir=rr-grpc-${RR_VERSION}-$2-$3
rm -rf builds/$bdir && mkdir -p builds/$bdir
GOOS=$2 GOARCH=$3 ./build.sh
if [ "$2" == "windows" ]; then
mv rr-grpc builds/$bdir/rr-grpc.exe
else
mv rr-grpc builds/$bdir
fi
cp README.md builds/$bdir
cp CHANGELOG.md builds/$bdir
cp LICENSE builds/$bdir
cd builds
if [ "$2" == "linux" ]; then
tar -zcf $bdir.tar.gz $bdir
else
zip -r -q $bdir.zip $bdir
fi
rm -rf $bdir
cd ..
}
build_protoc(){
echo Packaging Protoc $1 Build
bdir=protoc-gen-php-grpc-${RR_VERSION}-$2-$3
rm -rf builds/$bdir && mkdir -p builds/$bdir
GOOS=$2 GOARCH=$3 ./build.sh
if [ "$2" == "windows" ]; then
mv protoc-gen-php-grpc builds/$bdir/protoc-gen-php-grpc.exe
else
mv protoc-gen-php-grpc builds/$bdir
fi
cp README.md builds/$bdir
cp CHANGELOG.md builds/$bdir
cp LICENSE builds/$bdir
cd builds
if [ "$2" == "linux" ]; then
tar -zcf $bdir.tar.gz $bdir
else
zip -r -q $bdir.zip $bdir
fi
rm -rf $bdir
cd ..
}
if [ "$1" == "all" ]; then
rm -rf builds/
build "Linux" "linux" "arm64"
build_protoc "Linux" "linux" "arm64"
exit
fi
CGO_ENABLED=0 go build -trimpath -ldflags "$LDFLAGS -extldflags '-static'" -o "$OD/protoc-gen-php-grpc" cmd/protoc-gen-php-grpc/main.go
CGO_ENABLED=0 go build -trimpath -ldflags "$LDFLAGS -extldflags '-static'" -o "$OD/rr-grpc" cmd/rr-grpc/main.go
hey @48d90782
not problem and thanks for the script. I will test this over the weekend and will give you feedback afterwards!
Sorry for my late response on this.
I finally could test the script and it at least build but I couldn't test it yet with an application.
Something I noticed is that your have to execute build
after build all
otherwise no binaries are generated. The Makefile however is just executing build all
on install which leads to an error because no binaries are generated to move :)
I will try to add a test application to my container and will give feedback afterwards.
After a long time I finally could test it on a ARM System and it worked.
Little hint for anyone trying to get this to work with spiral framework: You must also compile the spiral binary like this one with a seperate script because the existing one is not prepared for multi arch.
@rustatian I could provide a multi arch version for the build script, but dunno if this is wanted atm? If not: I can close this issue.
Thank you @lyssar for your effort ๐๐ป
This plugin will be moved soon to the RR2 which already has build scripts for the arm64
platform. You can close the issue ๐
Okay cool :)
Thanks for your help again