Skip to content

Commit

Permalink
Merge pull request #20 from BCWResearch/static-shanghai
Browse files Browse the repository at this point in the history
Static linking
  • Loading branch information
patrick-bcw authored Aug 15, 2024
2 parents a965cb1 + d5e238f commit 6572fcd
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 4 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions optimized-worker.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ ARG PROFILE=release
# forward the docker argument so that the script below can read it
ENV PROFILE=${PROFILE}

ENV RUSTFLAGS='-C target-cpu=native -Zlinker-features=-lld'
ENV RUSTFLAGS='-C target-feature=+crt-static -C target-cpu=native -Zlinker-features=-lld'

# Build the application.
RUN \
Expand All @@ -56,7 +56,7 @@ cp -r pgo-profiles/* /artifacts/pgo-profiles

# use the cache mount
# (we will not be able to to write to e.g `/src/target` because it is bind-mounted)
CARGO_TARGET_DIR=/artifacts cargo pgo optimize build -- --bin worker --locked "--profile=${PROFILE}"
CARGO_TARGET_DIR=/artifacts cargo pgo optimize build -- --bin worker --locked "--profile=${PROFILE}" --target=x86_64-unknown-linux-gnu

# narrow the find call to SUBDIR because if we just copy out all executables
# we will break the cache invariant
Expand Down Expand Up @@ -104,4 +104,4 @@ COPY --from=build ["/output/worker", "/usr/local/bin/"]
# --uid "${UID}" \
# user
# USER user
CMD ["worker"]
CMD ["worker"]
4 changes: 3 additions & 1 deletion pgo-worker.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ WORKDIR /src

COPY . .

ENV RUSTFLAGS='-C target-feature=+crt-static -C target-cpu=native -Zlinker-features=-lld'

# Build the application.
RUN \
# cache artifacts and the cargo registry to speed up subsequent builds
Expand All @@ -40,7 +42,7 @@ RUN \
<<EOF
set -eux

cargo pgo build -- --locked --bin worker
cargo pgo build -- --locked --bin worker --target=x86_64-unknown-linux-gnu

EOF

Expand Down
13 changes: 13 additions & 0 deletions zero_bin/worker/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,19 @@ tracing-subscriber = { workspace = true }
clap = { workspace = true }
tokio = { workspace = true }
log = "0.4.21"
alloy = { git = "https://github.com/alloy-rs/alloy", tag = 'v0.1.1', default-features = false, features = [
"consensus",
"json-rpc",
"rlp",
"rpc",
"rpc-client",
"rpc-types-eth",
"rpc-types-trace",
"providers",
"transports",
"transport-http",
"rpc-types-debug",
] }

# Local dependencies
ops = { workspace = true }
Expand Down

0 comments on commit 6572fcd

Please sign in to comment.