diff --git a/.cargo/config.toml b/.cargo/config.toml index ed2158e4..123a6ca2 100644 --- a/.cargo/config.toml +++ b/.cargo/config.toml @@ -97,12 +97,14 @@ rustflags = [ # The rust flags for this would be ["-C", "linker-flavor=lld-link"] [target.aarch64-unknown-linux-gnu] -# Target Graviton3+ +# Keep the default aarch64 Linux build portable. Release jobs that produce a +# Neoverse 512-bit vector/SVE artifact can opt in by setting a full +# CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_RUSTFLAGS replacement that includes +# target-cpu=neoverse-512tvb, plus LORE_AARCH64_NEOVERSE_512TVB=1 for C sources. rustflags = [ "--cfg", "tokio_unstable", "-C", "force-unwind-tables=yes", "-C", "force-frame-pointers=yes", - "-C", "target-cpu=neoverse-512tvb", # Leave debug symbols in the binary for now, we want these in place for the server binary, but still split them via # package-cli.sh for CLI binaries. "-C", "split-debuginfo=off", diff --git a/docs/how-to/deploy-local-lore-server.md b/docs/how-to/deploy-local-lore-server.md index a389639a..3765967b 100644 --- a/docs/how-to/deploy-local-lore-server.md +++ b/docs/how-to/deploy-local-lore-server.md @@ -15,7 +15,7 @@ In this guide, you'll deploy local Lore Servers — with durable storage and a c The binary and Docker paths are mutually exclusive, and each is complete on its own — follow one top to bottom. - **[Run from the binary](#run-from-the-binary):** Fewer moving parts and native performance. Pick this to run `loreserver` directly on the host. -- **[Run with Docker](#run-with-docker):** An isolated container. Pick this if you'd rather not put a binary on the host — but note the `linux/amd64` emulation caveat on Apple Silicon in the build step. +- **[Run with Docker](#run-with-docker):** An isolated container. Pick this if you'd rather not put a binary on the host. ## Run from the binary @@ -196,12 +196,9 @@ The binary and Docker paths are mutually exclusive, and each is complete on its This needs Docker (and WSL2 on Windows) and the Lore repository cloned locally. Building the image compiles the server, so it needs several GB of free RAM. From the repository root: ```bash - docker build --platform linux/amd64 -f lore-server/Dockerfile -t lore-server . + docker build -f lore-server/Dockerfile -t lore-server . ``` - > [!NOTE] - > On Apple Silicon or Windows (both arm64 and amd64), build and run with `--platform linux/amd64` as shown. The `linux/arm64` server image targets AWS Graviton3 (SVE), an instruction set those CPUs lack. - 2. **Run it with default settings.** Map both the TCP and UDP sides of port `41337` and the HTTP port `41339`: diff --git a/lore-base/build.rs b/lore-base/build.rs index a3d087ee..a0b69282 100644 --- a/lore-base/build.rs +++ b/lore-base/build.rs @@ -5,6 +5,8 @@ use std::path::Path; include!("../build-helper.rs"); +const AARCH64_NEOVERSE_512TVB_ENV: &str = "LORE_AARCH64_NEOVERSE_512TVB"; + fn main() -> Result<(), Box> { // Populate environment with build details vergen::Emitter::default() @@ -25,7 +27,9 @@ fn main() -> Result<(), Box> { .opt_level(3) .includes(Some(native_dir.join("thirdparty"))); - if platform == "linux" && arch == "aarch64" { + println!("cargo:rerun-if-env-changed={AARCH64_NEOVERSE_512TVB_ENV}"); + + if platform == "linux" && arch == "aarch64" && env_flag_enabled(AARCH64_NEOVERSE_512TVB_ENV) { cc_builder.flag("-mcpu=neoverse-512tvb"); } @@ -48,3 +52,7 @@ fn main() -> Result<(), Box> { Ok(()) } + +fn env_flag_enabled(name: &str) -> bool { + env::var(name).is_ok_and(|value| value == "1" || value.eq_ignore_ascii_case("true")) +} diff --git a/lore-server/DOCKER.md b/lore-server/DOCKER.md index 688565dd..75ae212d 100644 --- a/lore-server/DOCKER.md +++ b/lore-server/DOCKER.md @@ -6,15 +6,13 @@ telemetry integration, or replication is configured. ## Prerequisites - Docker with BuildKit support -- On Apple Silicon (M-series Macs), builds must target `linux/amd64` due to Graviton-specific - compiler flags in `.cargo/config.toml` for `aarch64-unknown-linux-gnu` ## Building From the repository root: ```sh -docker build --platform linux/amd64 -f lore-server/Dockerfile -t loreserver . +docker build -f lore-server/Dockerfile -t loreserver . ``` The build compiles the `loreserver` binary and generates self-signed TLS certificates for QUIC