Repository navigation
Run one compiler order everywhere, and find llvm-config only in the compiler's Homebrew prefix - #78
Merged
crimson-knight merged 3 commits intoNov 26, 2026
Conversation
…rew's keg-only llvm beside the compiler
…compiler's Homebrew prefix Every Amber tool now runs the compiler named by CRYSTAL (stripped of surrounding whitespace) when it is set, otherwise crystal-alpha, otherwise stock crystal: - amber db seed, amber watch's default build and the default watch config run the compiler from Amber::CLI.crystal_compiler_command, quoted. - The agent loop resolver and the generated agent hook read CRYSTAL instead of CRYSTAL_ALPHA and drop the acrystal alias; the hook version moves to 7 so `amber doctor` asks existing projects to rerun setup. - amber-lsp's default compiler uses the same resolver. amber-lsp's llvm-config search no longer walks every directory above the compiler. FindLLVMConfigForCompiler tries opt/llvm@N in the Homebrew prefix that holds the compiler (the parent of Cellar, or of bin / opt/<formula>/bin, when that prefix has a Cellar folder), then the standard Homebrew prefixes, then PATH, and matches LLVM major.minor as whole version components, so 21.10.x no longer matches 21.1. A spec plants an llvm-config in a project's opt/ folder and proves it is never run.
…rch the unversioned llvm keg The opt/<formula>/bin rule fired for /opt/homebrew/bin/crystal-alpha (the folder two levels above bin is /opt) and returned no prefix. Each layout now proposes a candidate, and the first candidate that holds a Cellar folder is the prefix. FindLLVMConfigForCompiler also tries opt/llvm beside opt/llvm@N; the version check rejects either when its LLVM does not match.
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.
Two changes for the agent-crystal Homebrew line (Amber V2).
One compiler order everywhere. Every Amber tool runs the command in
CRYSTALwhen it is set (surrounding whitespace stripped), otherwisecrystal-alpha, otherwise stockcrystal.amber generate(route and plug insertion),amber exec,amber db seed,amber watch's default build and the default watch config runAmber::CLI.crystal_compiler_command, quoted withProcess.quote.ResolveCrystalCompilerCommandtakes the variable and a PATH lookup, so its spec covers each branch without touching the environment.ResolveCompilerForAgentLoopand the generated.amber/amber-agent-hook) readsCRYSTALinstead ofCRYSTAL_ALPHAand drops theacrystalalias. The hook version moves to 7, soamber doctorasks existing projects to rerunamber setup:agent.Lookup.default_compiler_commanduses the same resolver.llvm-config only from the compiler's Homebrew prefix. The stdlib API layer of
amber-lsp lookupneedsllvm-configto buildsrc/docs_main.cr.FindLLVMConfigForCompiler(its own file) searches, in order:opt/llvm@N/bin/llvm-config, thenopt/llvm/bin/llvm-config, in the Homebrew prefix that holds the compiler (ListHomebrewPrefixesAroundCompiler). Each layout proposes a candidate: the parent ofCellarfor<prefix>/Cellar/<formula>/<version>/bin/<compiler>, the parent ofoptforopt/<formula>/bin, and the parent ofbin. The first candidate that holds aCellarfolder is the prefix. This covers/opt/homebrew, Linuxbrew (/home/linuxbrew/.linuxbrew) and custom prefixes./opt/homebrewand/usr/local.llvm-config-N.M,llvm-config-Nandllvm-configon PATH.A compiler outside a Homebrew prefix contributes no search path, so nothing above an arbitrary compiler (a project folder, a home folder) is ever run; a spec plants an
llvm-configin a project'sopt/folder and proves it never runs. The version must match LLVMmajor.minoras whole components, so21.10.xdoes not match21.1.Known separate issue, not fixed here: with agent-crystal 1.22.3-incremental-2 and -3,
crystal-alpha docs src/docs_main.crfails becauserequire "./compress/**"loads bothcompress/deflate/lib_z/reader.crandcompress/deflate/mica/reader.cr. That makes the stdlib layer unavailable with an empty cache, sobuild_layered_api_index_spec.crand twolookup_command_spec.crexamples fail locally on that toolchain (they fail identically at this PR's first commit); CI on stock Crystal runs them.Local:
crystal-alpha specgives 812 examples, 3 failures (the three above), 0 errors.