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

fix: cross-compilation using Cross #21

Merged
merged 9 commits into from
Jun 14, 2023
Merged

fix: cross-compilation using Cross #21

merged 9 commits into from
Jun 14, 2023

Conversation

bajtos
Copy link
Member

@bajtos bajtos commented Jun 13, 2023

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

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>
@bajtos bajtos requested a review from juliangruber June 13, 2023 14:26
bajtos added 3 commits June 13, 2023 16:26
Signed-off-by: Miroslav Bajtoš <oss@bajtos.net>
Signed-off-by: Miroslav Bajtoš <oss@bajtos.net>
Signed-off-by: Miroslav Bajtoš <oss@bajtos.net>
Cross.toml Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
Signed-off-by: Miroslav Bajtoš <oss@bajtos.net>
@bajtos bajtos force-pushed the enable-cross-compilation branch from 85ad8ca to 17f58f3 Compare June 13, 2023 15:19
Signed-off-by: Miroslav Bajtoš <oss@bajtos.net>
@bajtos
Copy link
Member Author

bajtos commented Jun 13, 2023

Nice. As of 17f58f3, the cross-compilation works - see
https://github.com/filecoin-station/rusty-lassie/actions/runs/5257343506

I am going to push few more changes to simplify the setup.

bajtos added 2 commits June 13, 2023 17:28
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"));
Copy link
Member Author

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.

Copy link
Member

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");
Copy link
Member Author

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.

@bajtos bajtos requested a review from juliangruber June 13, 2023 15:36
@bajtos bajtos changed the title fix: cross-compilation using Cros fix: cross-compilation using Cross Jun 13, 2023
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
Copy link
Member

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 :)

Copy link
Member Author

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"));
Copy link
Member

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>
@bajtos bajtos enabled auto-merge (squash) June 14, 2023 05:49
@bajtos bajtos merged commit 6be43df into main Jun 14, 2023
@bajtos bajtos deleted the enable-cross-compilation branch June 14, 2023 05:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants