From: alban.moizan@smile.fr
To: openembedded-core@lists.openembedded.org
Subject: Re: [PATCH v2 08/15] kernel-yocto.bbclass: Disable ccache when rust-kernel is enabled
Date: Wed, 14 Jan 2026 07:41:30 -0800 [thread overview]
Message-ID: <659490.1768405290403118898@lists.openembedded.org> (raw)
In-Reply-To: <20251230141540.1974380-9-Harish.Sadineni@windriver.com>
[-- Attachment #1: Type: text/plain, Size: 3956 bytes --]
Excuse me for the double mail, I was not yet subscribing to the mailing list, so my mail was hidden.
--------------------------
Hi everyone,
I've been investigating the issue when enabling `ccache` for kernel builds that involve Rust.
First of all, as documented in the `ccache` issue tracker [1], `ccache` is not directly compatible with Rust.
Therefore the current goal is to keep `ccache` enabled for the C portions of the kernel while bypassing it for Rust.
While an alternative like `sccache` [2], compatible with both C and Rust exists, you will see below that the underlying issue is the same, so just replacing `ccache` by `sccache` will change nothing here.
The issue (commit 235e6d49e5888ad04416219e10b6df91a738661a + this patch):
When `ccache` is enabled, `${CC}` to `${CCACHE}{CC}`, ex: `gcc` to `ccache gcc`
Then, when compiling the kernel, `scripts/Makefile.host` will give it to `rustc` with `-Clinker=$(HOSTCC)` [3], but the shell expands `$(HOSTCC)` to two words, therefore `rustc` takes `gcc` as another parameters, and it errors out.
I attempted to resolve it by modifying the incriminated Makefile in the following ways:
Trial 1: Quoting HOSTCC in Kernel Makefile
Modify `scripts/Makefile.host` to wrap `HOSTCC` in quotes to ensure it is passed as a single string parameter:
Replace `-Clinker=$(HOSTCC)` to `-Clinker='$(HOSTCC)'`
Result: Failure, `rustc` looks for a binary path literally named `ccache gcc`, which does not exist, indeed, `-Clinker` argument value is treated by `rustc` as a real path, and not a command [4].
Trial 2: Splitting HOSTCC into Linker and Pre-link Args
Modified `scripts/Makefile.host` to force the linker to the first word of `HOSTCC` and pass subsequent words to `-Zpre-link-args`:
Replace `-Clinker=$(HOSTCC)` by `-Clinker=$(firstword $(HOSTCC)) -Zpre-link-args='$(wordlist 2,$(words $(HOSTCC)),$(HOSTCC))'`
Result: Failure, `rustc` executes the command as: "ccache" "-m64" "gcc" ....
This is invalid because in `rustc`, the target-specific pre-link arguments (from `compiler/rustc_target/src/spec/targets/x86_64_unknown_linux_gnu.rs`) are added before our custom args, placing `-m64` before the `gcc` executable [5] .
Proposed Solutions
1. Kernel + Rust Patch (A): Patch the kernel Makefile (like the Trial 1) and patch `rustc` to accept a command string (with arguments) for `-Clinker` instead of a strict Path.
2. Kernel + Rust Patch (B): Patch the kernel Makefile (like the Trial 2) and patch `rustc` to use `post_link_args` instead of `pre_link_args` for target-specific values, ensuring the executable stays at the end of the command.
3. Shell Wrappers: Implement shell wrappers for CC, CXX, etc. This would allow `rustc` to call a single wrapper script, hiding `ccache` from it.
4. Kernel only: Patch the kernel Makefile to filter out `ccache` from CC (works in practice but not generic for a possible other wrapper in the future).
5. Leave as-is: disable `ccache` when rust is enabled .
Risks and Considerations
- Upstreamability: Patching rust and the kernel at the same time could take time.
- Maintainability: While the shell wrapper approach is more flexible and solves the issue for other tools with similar limitations, it might make debugging in Yocto more difficult and requires significant changes.
I'm leaning towards the 1st or the 3rd approach, but I'd appreciate the maintainers' thoughts on which path fits the OE architecture best.
[1] https://github.com/ccache/ccache/issues/364
[2] https://github.com/mozilla/sccache
[3] https://git.yoctoproject.org/linux-yocto/tree/scripts/Makefile.host?h=v6.18.1#n94
[4] https://github.com/rust-lang/rust/blob/4931e09e3ac3182d2a00f38cccfdf68e8e385e1c/compiler/rustc_codegen_ssa/src/back/link.rs#L1419
[5] https://github.com/rust-lang/rust/blob/4931e09e3ac3182d2a00f38cccfdf68e8e385e1c/compiler/rustc_codegen_ssa/src/back/link.rs#L1870
Best regards,
Alban Moizan
[-- Attachment #2: Type: text/html, Size: 5166 bytes --]
next prev parent reply other threads:[~2026-01-14 15:41 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-12-30 14:15 [PATCH v2 00/15] Enable rust support for linux kernel Harish.Sadineni
2025-12-30 14:15 ` [PATCH v2 01/15] bindgen-cli: extend BBCLASSEXTEND to include nativesdk Harish.Sadineni
2026-01-12 0:10 ` [OE-core] " Alistair Francis
2025-12-30 14:15 ` [PATCH v2 02/15] linux-yocto: conditionally add clang/rust/bindgen-cli-native to DEPENDS Harish.Sadineni
2026-01-12 0:12 ` [OE-core] " Alistair Francis
2025-12-30 14:15 ` [PATCH v2 03/15] rust: install Rust library sources for 'make rustavailable' support Harish.Sadineni
2025-12-30 15:58 ` [OE-core] " Richard Purdie
2026-01-05 16:24 ` Harish Sadineni
2026-01-06 18:59 ` Randy MacLeod
2026-01-07 16:34 ` Harish Sadineni
2026-01-07 18:21 ` Randy MacLeod
2026-01-07 19:03 ` Richard Purdie
2026-01-12 0:42 ` Alistair Francis
2026-01-13 12:14 ` Harish Sadineni
2025-12-30 14:15 ` [PATCH v2 04/15] bitbake.conf: Include "rust-kernel" in native/nativesdk feature filters Harish.Sadineni
2025-12-30 14:15 ` [PATCH v2 05/15] kernel-yocto: enable Rust kernel support via rustavailable and staged rustlib sources Harish.Sadineni
2025-12-30 14:15 ` [PATCH v2 06/15] linux-yocto: enable Rust support in kernel configuration Harish.Sadineni
2025-12-30 14:15 ` [PATCH v2 07/15] kernel-yocto: Fix for buildpaths errors when rust is enabled for kernel Harish.Sadineni
2025-12-30 14:15 ` [PATCH v2 08/15] kernel-yocto.bbclass: Disable ccache when rust-kernel is enabled Harish.Sadineni
2026-01-14 15:41 ` alban.moizan [this message]
2025-12-30 14:15 ` [PATCH v2 09/15] kernel-devsrc: copying rust-kernel source to $kerneldir/build Harish.Sadineni
2025-12-30 14:15 ` [PATCH v2 10/15] selftest/cases/runtime_test: Add test for Linux Rust sample Harish.Sadineni
2026-01-05 9:32 ` [OE-core] " Mathieu Dubois-Briand
2026-01-08 9:39 ` Yoann Congal
2025-12-30 14:15 ` [PATCH v2 11/15] kernel.bbclass: Copy include/config/auto.conf in STAGING_KERNEL_BUILDDIR Harish.Sadineni
2025-12-30 14:15 ` [PATCH v2 12/15] kernel.bbclass: Export artifacts needed for out-of-tree Rust compilation Harish.Sadineni
2025-12-30 14:15 ` [PATCH v2 13/15] module.bbclass: Prepare out-of-tree rust module compilation Harish.Sadineni
2025-12-30 14:15 ` [PATCH v2 14/15] meta-skeleton: Add rust-out-of-tree-module recipe Harish.Sadineni
2025-12-30 14:15 ` [PATCH v2 15/15] runtime_test: Add rust-out-of-tree selftest Harish.Sadineni
-- strict thread matches above, loose matches on Subject: below --
2026-01-14 14:57 [PATCH v2 08/15] kernel-yocto.bbclass: Disable ccache when rust-kernel is enabled Alban MOIZAN
2026-01-14 15:40 ` Bruce Ashfield
2026-01-14 17:05 ` Alban MOIZAN
2026-01-15 8:58 ` El Mehdi YOUNES
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=659490.1768405290403118898@lists.openembedded.org \
--to=alban.moizan@smile.fr \
--cc=openembedded-core@lists.openembedded.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox