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

build statically-linked sui-node for testing on glibc-based hosts #18611

Merged
merged 1 commit into from
Jul 12, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions docker/sui-node-deterministic/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,11 @@ ARG PROFILE
ARG GIT_REVISION

ENV RUST_BACKTRACE=1
ENV RUSTFLAGS='-C target-feature=-crt-static -C codegen-units=1'
ENV RUSTFLAGS='-C target-feature=+crt-static -C codegen-units=1'
ENV GIT_REVISION=${GIT_REVISION}
ENV PROFILE=${PROFILE}

RUN --network=none cargo build --frozen --profile ${PROFILE} --bin sui-node
RUN --network=none cargo build --target x86_64-unknown-linux-musl --frozen --profile ${PROFILE} --bin sui-node
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this part needed? or is the fixing of the rust flags enough?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it actually is needed:

 => CACHED [build 7/8] COPY --from=linux-headers . /                                                                                                                                            0.0s
=> ERROR [build 8/8] RUN --network=none cargo build --frozen --profile release --bin sui-node                                                                                                  5.1s
------
> [build 8/8] RUN --network=none cargo build --frozen --profile release --bin sui-node:
5.010 error: cannot produce proc-macro for `ark-ff-asm v0.4.2` as the target `x86_64-unknown-linux-musl` does not support these crate types
------
Dockerfile:67
--------------------
 65 |     ENV PROFILE=${PROFILE}
 66 |     
 67 | >>> RUN --network=none cargo build --frozen --profile ${PROFILE} --bin sui-node
 68 |     
 69 |     FROM scratch AS install
--------------------
ERROR: failed to solve: process "/bin/sh -c cargo build --frozen --profile ${PROFILE} --bin sui-node" did not complete successfully: exit code: 101

(other references to this issue of needing to specify --target

rust-lang/rust#78210 (comment)

https://msfjarvis.dev/posts/building-static-rust-binaries-for-linux/

The reason behind this seems to be a bug with cargo, where the RUSTFLAGS are applied to the target platform only when --target is explicitly provided


FROM scratch AS install

Expand All @@ -78,7 +78,7 @@ COPY --from=musl . /rootfs
# support current + legacy paths
RUN mkdir -p /rootfs/opt/sui/bin
RUN mkdir -p /rootfs/usr/local/bin
COPY --from=build sui/target/release/sui-node /rootfs/opt/sui/bin/sui-node
COPY --from=build sui/target/x86_64-unknown-linux-musl/release/sui-node /rootfs/opt/sui/bin/sui-node


RUN --network=none find /rootfs -exec touch -hcd "@0" "{}" +
Expand Down
Loading