-
Notifications
You must be signed in to change notification settings - Fork 51
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
chore: use cross to build binaries #507
Open
lifeizhou-ap
wants to merge
45
commits into
v1.0
Choose a base branch
from
lifei/aarch64-linux
base: v1.0
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
45 commits
Select commit
Hold shift + click to select a range
16a4a7e
linux are completed
lifeizhou-ap 742a1e1
Merge branch 'v1.0' into lifei/aarch64-linux
lifeizhou-ap 0d3528e
use cross to build
lifeizhou-ap b2dbcbe
added toolchain properites
lifeizhou-ap af4bec3
added debug message to find pkg-config path
lifeizhou-ap 86cbb51
set pkg env variable
lifeizhou-ap 31f8405
temperarily change the trigger of the job. disabled release
lifeizhou-ap 1c96c6b
added backtrace
lifeizhou-ap d85aaff
set backtrace to full
lifeizhou-ap 54ab26f
set sysroot env
lifeizhou-ap e0b4c27
set more env var
lifeizhou-ap 63f5895
more env and with specific toolkit
lifeizhou-ap cf33c51
revert toolchain
lifeizhou-ap 6914123
run on macos
lifeizhou-ap 13bdc49
revert change
lifeizhou-ap 1f33d37
remove env var
lifeizhou-ap 809d65b
not install pkg-config
lifeizhou-ap ab1c3f7
add release step
lifeizhou-ap a42963b
fixed wrong variable
lifeizhou-ap 80317f8
remove unnecessary env
lifeizhou-ap 7abd3d3
turn on x86_64 linux
lifeizhou-ap a71ffe7
try x86_64 linux
lifeizhou-ap 4902cea
fixed workflow trigger
lifeizhou-ap d8c804b
turn on release x86_64 linux
lifeizhou-ap cddd0ca
start macos x86_64
lifeizhou-ap 366aec2
fixed workflow script
lifeizhou-ap ad78352
run aarch64 macos
lifeizhou-ap b5bbd30
added target of toolchain
lifeizhou-ap cea042f
fixed variable
lifeizhou-ap fde066c
reverted change
lifeizhou-ap 457d55e
turn on full backtrace
lifeizhou-ap 319fab6
added CROSS_NO_WARNINGS=0
lifeizhou-ap 075ec23
try x86_64 macos
lifeizhou-ap 77f414d
turn on release for macos
lifeizhou-ap aaefbe4
include all arch since they are all working now
lifeizhou-ap 05ccb59
clean up and add the notes for testing release on local machine
lifeizhou-ap b676a03
Merge branch 'v1.0' into lifei/aarch64-linux
lifeizhou-ap 13d28c7
reverted tag pattern change
lifeizhou-ap b29ec37
changed toolchain in build
lifeizhou-ap 66a3a72
final testing
lifeizhou-ap 04f5212
revert the toolchain change
lifeizhou-ap efb6e1a
update the doc
lifeizhou-ap c258cc3
reverted the trigger tag pattern
lifeizhou-ap d4d0f82
update the doc
lifeizhou-ap 24cc7cb
used correct build name
lifeizhou-ap File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
[target.aarch64-unknown-linux-gnu] | ||
xargo = false | ||
pre-build = [ | ||
"dpkg --add-architecture $CROSS_DEB_ARCH && apt-get update --fix-missing && apt-get install --assume-yes libxcb1-dev:$CROSS_DEB_ARCH libdbus-1-dev:$CROSS_DEB_ARCH", | ||
] | ||
|
||
# If you run the build on your local machine, | ||
# This is a workaround for the missing pkg-config path on aarch64 | ||
# You also need to add pkg-config:$CROSS_DEB_ARCH to the apt-get install command above | ||
#[target.aarch64-unknown-linux-gnu.env] | ||
#passthrough = ["PKG_CONFIG_PATH=/usr/lib/aarch64-linux-gnu/pkgconfig"] | ||
|
||
# If you run the build on your local machine, | ||
# You need to add pkg-config:$CROSS_DEB_ARCH to the apt-get install command below | ||
[target.x86_64-unknown-linux-gnu] | ||
xargo = false | ||
pre-build = [ | ||
"dpkg --add-architecture $CROSS_DEB_ARCH && apt-get update --fix-missing && apt-get install --assume-yes libxcb1-dev:$CROSS_DEB_ARCH libdbus-1-dev:$CROSS_DEB_ARCH", | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
# Instructions for running cross to test release builds locally | ||
|
||
## Prerequisites | ||
Before start, check the comments in `Cross.toml` to turn on some commented configs for the target you want to build. | ||
|
||
## Targets | ||
### aarch64-unknown-linux-gnu | ||
|
||
#### Build release | ||
```sh | ||
CROSS_BUILD_OPTS="--platform linux/amd64 --no-cache" CROSS_CONTAINER_OPTS="--platform linux/amd64" cross build --release --target aarch64-unknown-linux-gnu | ||
``` | ||
|
||
#### Inspect container created by cross for debugging | ||
```sh | ||
docker run --platform linux/amd64 -it <image-id> /bin/bash | ||
``` | ||
|
||
#### Testing the binary | ||
|
||
1. Download docker image for testing environment | ||
```sh | ||
docker run --rm --privileged multiarch/qemu-user-static --reset -p yes | ||
docker pull arm64v8/ubuntu | ||
``` | ||
2. Run the container | ||
pwd is the directory contains the binary built in the previous step on your host machine | ||
```sh | ||
docker run -v $(pwd):/app -it arm64v8/ubuntu /bin/bash | ||
``` | ||
|
||
3. Install dependencies in the container and set up api testing environment | ||
```sh | ||
apt update | ||
apt install libxcb1 libxcb1-dev libdbus-1-3 nvi | ||
mkdir -p ~/.config/goose | ||
# create goose config file | ||
# set api key env variable | ||
``` | ||
|
||
### x86_64-unknown-linux-gnu | ||
|
||
#### Build release | ||
```sh | ||
CROSS_BUILD_OPTS="--platform linux/amd64 --no-cache" CROSS_CONTAINER_OPTS="--platform linux/amd64" cross build --release --target x86_64-unknown-linux-gnu | ||
``` | ||
#### inspect container created by cross for debugging | ||
```sh | ||
docker run --platform linux/amd64 -it <image-id> /bin/bash | ||
``` | ||
|
||
#### Testing the binary | ||
|
||
1. Download docker image for testing environment | ||
```sh | ||
docker run --rm --privileged multiarch/qemu-user-static --reset -p yes | ||
docker pull --platform linux/amd64 debian:latest | ||
``` | ||
|
||
2. Run the container | ||
pwd is the directory contains the binary built in the previous step on your host machine | ||
```sh | ||
docker run --platform linux/amd64 -it -v "$(pwd)":/app debian:latest /bin/bash | ||
``` | ||
|
||
3. Install dependencies in the container and set up api testing environment | ||
```sh | ||
apt update | ||
apt install libxcb1 libxcb1-dev libdbus-1-3 nvi | ||
mkdir -p ~/.config/goose | ||
# create goose config file | ||
# set api key env variable | ||
``` | ||
|
||
### aarch64-apple-darwin | ||
|
||
#### build release | ||
```sh | ||
cross build --release --target aarch64-apple-darwin | ||
``` | ||
There is no docker image available for aarch64-apple-darwin. It will fall back to your host machine for building the binary if your host machine matches. | ||
|
||
#### testing the build | ||
If the binary is signed with a certificate, run | ||
```sh | ||
xattr -d com.apple.quarantine goose | ||
```` | ||
|
||
### x86_64-apple-darwin | ||
|
||
#### build release | ||
```sh | ||
cross build --release --target x86_64-apple-darwin | ||
``` | ||
|
||
There is no docker image available for x86_64-apple-darwin. It will fall back to your host machine for building the binary if your host machine matches. | ||
|
||
#### testing the build | ||
1. If the binary is signed with a certificate, run | ||
```sh | ||
xattr -d com.apple.quarantine goose | ||
```` | ||
2. If you are on Apple Silicon (ARM), you can use Rosetta to test the binary | ||
```sh | ||
softwareupdate --install-rosetta # make sure Rosetta 2 is installed | ||
``` | ||
|
||
```sh | ||
arch -x86_64 ./goose help | ||
``` |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The toolchain
actions-rust-lang/setup-rust-toolchain@v1
does not with cross. Not sure why.We can use hermit in the future to set up the rust so that we have consistent environment locally and the build environment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah that is fine