Skip to content

build: keep TARGET out of Buildroot's environment - #2795

Merged
openipc-ai merged 1 commit into
masterfrom
build-target-env
Nov 8, 2026
Merged

openipc-ai merged 1 commit into
masterfrom
build-target-env

Conversation

@openipc-ai

Copy link
Copy Markdown
Collaborator

Fixes #2794.

Symptom

make BOARD=<board> TARGET=$(PWD)/output-<board> fails in host-libffi on any board that pulls in host-python3. CLAUDE.md recommends this pattern for building more than one board locally. Reported by DeathCamel58 in #2793.

Cause

A variable set on the make command line is exported to every recipe and passed to sub-makes through MAKEFLAGS. So our TARGET reached Buildroot and every package's configure. host-libffi is autoreconf'd, and its AX_ENABLE_BUILDDIR reads $TARGET as the name of a build subdirectory: it creates it, cds in, and re-runs ../../…/configure, which isn't there for an absolute path.

Fix

MAKEOVERRIDES := $(filter-out TARGET=%,$(MAKEOVERRIDES)) and unexport TARGET, right after TARGET ?=. Our Makefile still uses TARGET as before. Buildroot is told where to build by O=$(TARGET), and the one recursive call into this file that needs TARGET (repack-final) already passes it explicitly. Nothing under general/ or .github/scripts/ reads TARGET from the environment.

Evidence

make BOARD=s3l_ultimate TARGET=<dir> br-host-libffi from a clean output directory, with the same BR2_DL_DIR:

master Makefile:

continue configure in default builddir ".//tmp/.../out-before"
/bin/bash: ../../../../../../.././configure: No such file or directory
make[2]: *** [package/pkg-generic.mk:273: .../out-before/build/host-libffi-3.4.4/.stamp_configured] Error 127

This branch: exit 0. host-libffi-3.4.4 reaches .stamp_configured, .stamp_built and .stamp_host_installed.

A probe sub-make shows the propagation directly. On master, make TARGET=/x/output-board gives the sub-make MAKEFLAGS=[... BOARD=s3l_ultimate TARGET=/x/output-board] and env TARGET=/x/output-board. With this change, both are gone. The same holds when TARGET comes from the environment rather than the command line.

Scope

Build system only. CI runs plain make BOARD=..., where TARGET comes from ?= and was never exported, so CI builds see no difference, and image contents can't change from this. Nothing here runs on a camera, so there's no hardware evidence to give. ci-matrix.py --self-test passes. The selector builds every board for a Makefile change, as it should.

`make TARGET=...` exported TARGET to every recipe and passed it to
sub-makes through MAKEFLAGS, so it reached each package's configure.
host-libffi's AX_ENABLE_BUILDDIR treats $TARGET as a build subdirectory,
then re-runs ../../configure from inside it and fails with exit 127.
That broke the multi-board pattern CLAUDE.md recommends for any board
that pulls in host-python3.

Buildroot already gets O=$(TARGET), and repack-final passes TARGET
explicitly, so drop it from MAKEOVERRIDES and unexport it.

Fixes #2794
@qodo-free-for-open-source-projects

Copy link
Copy Markdown

PR Summary by Qodo

Prevent TARGET from leaking into Buildroot builds

🐞 Bug fix 🕐 Less than 10 minutes

Grey Divider

AI Description

• Stop the output-directory variable from reaching Buildroot packages through the environment or
 sub-make overrides.
• Preserve the selected output directory through Buildroot’s O argument and an explicit repack
 argument.
• Fix host-libffi configuration failures during multi-board builds.
Diagram

graph TD
  A["make TARGET=..."] --> B["Top-level Makefile"] --> C["Block TARGET propagation"] --> D["Buildroot via O"] --> E["Package configure"]
  B --> F["Repack sub-make"]
Loading
High-Level Assessment

Keep the targeted Makefile fix. Renaming TARGET throughout the build would be more disruptive, while unexporting it alone would not address propagation through MAKEFLAGS. Buildroot already receives the output path through O.

Files changed (1) +9 / -0

Bug fix (1) +9 / -0
MakefilePrevent TARGET from propagating into Buildroot +9/-0

Prevent TARGET from propagating into Buildroot

• Filters TARGET assignments from MAKEOVERRIDES and unexports TARGET after its default is set. This preserves local output-path selection while preventing host-libffi from interpreting the path as a configure build directory.

Makefile

@qodo-free-for-open-source-projects

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (0) 📘 Rule violations (0) 📎 Requirement gaps (0)

Grey Divider

Great, no issues found!

Qodo reviewed your code and found no material issues that require review

Grey Divider

Tip of the day
💡 Did you know, you can pick a display mode instead of tweaking every Display option by hand

More tips ↗ | Customize Qodo ↗ | Qodo docs ↗

Grey Divider

Qodo Logo

@openipc-ai
openipc-ai merged commit ea8aac3 into master Nov 8, 2026
278 of 286 checks passed
@openipc-ai
openipc-ai deleted the build-target-env branch November 8, 2026 12:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

build: TARGET= on the make command line breaks host-libffi's configure

1 participant