Repository navigation
Add amber build with --target-tier for a known deploy CPU - #80
Merged
Merged
Conversation
amber build compiles the first shard.yml target into bin/ with crystal-alpha in release mode, after compiling app/assets. The default tier, portable, keeps the compiler's own target; named tiers (x86-64-v2/v3/v4, neoverse-v1/n2/v2, apple-m1/m4) pass --mcpu. The tier table is one constant, AmberCLI::TARGET_TIERS, printed by --list-target-tiers. A tier may also come from build.target_tier in .amber.yml.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this adds
amber buildbuilds the app's release binary with crystal-alpha (firsttargets:entry inshard.ymlintobin/,--release, after compilingapp/assets/), with a--target-tier NAMEoption for owners who know their deploy machine.portable: crystal-alpha's own default target, so one binary runs on every supported chip and picks per-chip kernels at startup.--mcpu:x86-64-v2,x86-64-v3,x86-64-v4,neoverse-v1(Graviton3),neoverse-n2(Azure Cobalt 100),neoverse-v2(Graviton4),apple-m1,apple-m4.AmberCLI::TARGET_TIERS(src/amber_cli/core/target_tier.cr), each entry with a one-line description;amber build --list-target-tiersprints it..amber.yml(build: target_tier: ...);--target-tieroverrides it.shard.ymlis read only for itstargets:.--dry-runprints the compiler command without running it.Every CPU name was checked against crystal-alpha 1.22.3 / LLVM 21.1.8: Linux tiers by
--cross-compile --target x86_64-linux-gnu|aarch64-linux-gnu --mcpu ...producing an ELF object with no "not a recognized processor" warning, Apple tiers by a native build that runs.Note:
neoverse-n2is Armv9 with SVE2, which Graviton3 (Neoverse V1) lacks, so Graviton3 gets its ownneoverse-v1tier.Proof
crystal spec spec/commands/build_command_spec.cr: option parsing, the tier table, the exact compiler command line per tier, the.amber.ymlfallback and override, unknown-tier and wrong-architecture errors.amber new tier_demo -d sqliteapp built withamber buildand withamber build --target-tier apple-m1(crystal-alpha build src/tier_demo.cr -o bin/tier_demo --release --mcpu apple-m1); both serve HTTP 200, andotool -Llists only/usr/lib/libsqlite3.dyliband/usr/lib/libSystem.B.dylib.Ships in the next amber_cli release; this PR makes no release.