-
Notifications
You must be signed in to change notification settings - Fork 0
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
fix: cross-compilation using Cross #21
Conversation
Modify the build script to fix GOCACHE and GOMODCACHE and let them point to a directory we can write to. Cross sets HOME to root (/), which is read-only for the user running the build. Signed-off-by: Miroslav Bajtoš <oss@bajtos.net>
Signed-off-by: Miroslav Bajtoš <oss@bajtos.net>
Signed-off-by: Miroslav Bajtoš <oss@bajtos.net>
Signed-off-by: Miroslav Bajtoš <oss@bajtos.net>
85ad8ca
to
17f58f3
Compare
Signed-off-by: Miroslav Bajtoš <oss@bajtos.net>
Nice. As of 17f58f3, the cross-compilation works - see I am going to push few more changes to simplify the setup. |
Signed-off-by: Miroslav Bajtoš <oss@bajtos.net>
Signed-off-by: Miroslav Bajtoš <oss@bajtos.net>
.expect("cannot obtain CARGO_TARGET_DIR from the environment"); | ||
|
||
cmd.env("GOCACHE", format!("{target_dir}/go/cache")) | ||
.env("GOMODCACHE", format!("{target_dir}/go/pkg-mod-cache")); |
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.
Discussion point:
I can move these two env vars to Dockerfile
.
That would simplify our build script, but it would mean that Rusty Lassie consumers will need to use Cross with Dockerfile
too, because AFAICT, there is no way how to change env variables using a pre-build
hook.
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.
I don't really know the space well, but it sounds to me like the refactor wouldn't add user value
// Overwrite Go CC config, unless it's already provided by the user | ||
// See https://github.com/golang/go/issues/28966 | ||
if env::var("CC").is_err() { | ||
cmd.env("CC", "aarch64-linux-gnu-gcc"); |
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.
It would be nice to set this via Dockerfile too, but that would prevent us from using a single Dockerfile for all targets.
FROM $CROSS_BASE_IMAGE | ||
|
||
RUN rm -rf /usr/local/go; | ||
RUN curl -L https://go.dev/dl/go1.20.5.linux-amd64.tar.gz | tar -xz -C /usr/local |
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.
nice, that's way cleaner and safer without the side effects :)
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.
Agreed. Thank you for nudging me to look beyond the first solution I found 👍🏻
.expect("cannot obtain CARGO_TARGET_DIR from the environment"); | ||
|
||
cmd.env("GOCACHE", format!("{target_dir}/go/cache")) | ||
.env("GOMODCACHE", format!("{target_dir}/go/pkg-mod-cache")); |
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.
I don't really know the space well, but it sounds to me like the refactor wouldn't add user value
Signed-off-by: Miroslav Bajtoš <oss@bajtos.net>
Modify the build script to fix GOCACHE and GOMODCACHE and let them point to a directory we can write to. Cross sets HOME to root (/), which is read-only for the user running the build.
This should fix the error I am observing in filecoin-station/zinnia#248, see also space-meridian/roadmap#19