machine files: add [compilers] section for hermetic toolchain configuration#15783
Open
Prince781 wants to merge 5 commits into
Open
machine files: add [compilers] section for hermetic toolchain configuration#15783Prince781 wants to merge 5 commits into
[compilers] section for hermetic toolchain configuration#15783Prince781 wants to merge 5 commits into
Conversation
Adds a new [compilers] section to native/cross machine files that allows declaring compiler type, binary, version, and toolchain configuration explicitly — without the user needing to know GCC-specific invocation flags or write wrapper scripts. Key features: - <lang>.type skip --version family detection, use declared type - <lang>.binary override [binaries] compiler path - <lang>.version skip --version parsing, use declared version - <lang>.ccache control ccache wrapping (default: true = auto-detect) - <lang>.subprocess-interpreter GCC: generate cc1/cc1plus/lto1 wrapper scripts in meson-private/compiler-wrappers/ so hermetic GCC subprograms can find their shared libraries without LD_LIBRARY_PATH or -wrapper - <lang>.sysroot, .no-default-includes, .system-include-dirs, .tool-search-paths parsed and stored; flag emission in follow-up The fast path in detect.py handles type='gcc' fully: generates subprocess wrappers before _get_gnu_compiler_defines() runs (which requires cc1), so hermetic builds succeed end-to-end. 17 unit tests cover: parsing, type/version/binary/ccache/flags, unknown key warnings, error paths (bad type, bad ccache type, missing dot). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
When [binaries] c already includes -B<libexec>, the GCC driver finds the real cc1 before reaching the generated wrapper directory that was appended last. Insert -B<wrapper_dir> right after the binary (index 0) so it is searched before any -B flags inherited from the compiler command. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Emit --sysroot, -nostdinc, -B, and -isystem flags directly from the [compilers] descriptor in the GCC fast path, so [binaries] c/cpp can be a bare binary path without any flags embedded. Also fix ccache auto-detection: when [binaries] has no ccache prefix but [compilers] ccache=true (the default), detect ccache automatically. Flag order: structured flags are appended after the binary, then _generate_subprocess_wrappers is called (so it has -B<libexec> available for --print-prog-name), then -B<wrapper_dir> is prepended before them. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
[compilers] section for hermetic toolchain configuration
Drop unused CompilerTable import, remove duplicate `c, cpp` and `linkers as lnk_mod` reimports inside the GCC fast path (the top-level imports already cover them), and fix an over-indented continuation line.
Two ways to specify the compiler binary (`[binaries].<lang>` and `[compilers].<lang>.binary`) is confusing and forces precedence rules. Drop `binary` entirely; the binary path lives only in `[binaries]`. The descriptor is still consulted in `_get_compilers()` for the ccache override, which fixes mesonbuild#12612 (a bare `[binaries] cpp = 'clang++'` losing ccache): with `[compilers] cpp.ccache = true` (the default), ccache is auto-detected on PATH. Also adjust the docs version tag to 1.12.0 and drop the fortran example.
|
You might want to take a look at #15462 and #14147 for other takes on a similar problem. From a brief skim, wouldn't it be nice to be able to download the SDK and compilers via a wrap file? That's what my proposal does: |
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.
Adds a new
[compilers]section to native and cross machine files that allows declaring compiler configuration explicitly, rather than relying on Meson to auto-detect it from a binary. This is primarily useful for hermetic toolchains where the compiler and its subprograms require a custom execution environment not present on the build host.When a language is declared in this section, the user can override compiler properties that Meson would infer by running
<compiler> --version.<lang>.typeallows controlling the compiler class.<lang>.versionis an optional override.The remaining keys --
sysroot,no-default-includes,system-include-dirs,tool-search-paths, andsubprocess-interpreter-- translate to compiler flags at setup time so that the binary entries stay clean:sysroot->--sysroot=<path>(GCC/Clang); ignored for MSVC-familyno-default-includes->-nostdinc//Xsystem-include-dirs->-isystem <dir>//imsvc <dir>tool-search-paths->-B <dir>(GCC/Clang)subprocess-interpreter-> GCC only: Meson generates thincc1/cc1plus/lto1wrapper scripts in the build scratch directory that invoke the real subprograms via the specified ELF interpreter, making the build fully cacheable by ccache without requiring-wrapperorLD_LIBRARY_PATH.Example for a self-contained GCC 12.2.0 bundled under
sdk/:Fixes #12612