You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
make: let user-provided options win over target defaults - #972
Target-specific assignments in arch.mk/options.mk/board.mk used hard '=', silently clobbering values the user set via command line, environment, or a sourced .config (e.g. LSCRIPT_IN from PR #958 was defeated on every target with a dedicated script).
Convert the target-default assignments to '?=' (first-set wins) and, for LSCRIPT_IN, capture the user value before the target files are parsed so the last-resort default (hal/$(TARGET).ld) and the ARMClang .sct default only apply when the user provided nothing.
CMake: WOLFBOOT_LSCRIPT_TEMPLATE had the same flaw (plain set() over a user -D value); guard it with NOT DEFINED and let test-app use an absolute user template as-is.
Document LSCRIPT_IN as a user option in docs/compile.md.
The reason will be displayed to describe this comment to others. Learn more.
🟡 Changes recommended
Critical make assignment and linker-script selection errors can break builds, use incorrect memory layouts, overwrite custom templates, and leave ChaCha code in flash when encrypted self-updates require it in RAM.
This PR adjusts wolfBoot’s Make and CMake configuration so user-provided options take precedence over target defaults, extending the custom linker-script support introduced in #958.
Changes:
Converts target defaults to conditional assignments and defers the Make linker-script fallback.
Preserves CMake linker-template overrides and supports absolute template paths.
Documents the LSCRIPT_IN option and its usage.
File
Description
tools/config.mk
Makes the multi-sector erase default conditional.
test-app/CMakeLists.txt
Handles absolute bootloader template paths.
options.mk
Makes the ChaCha RAM linker-script selection conditional.
Makefile
Captures user script selection and defers fallback defaults.
hal/boards/stm32wba55cg_nucleo/board.mk
Makes the board linker-script default conditional.
hal/boards/stm32wb_nucleo/board.mk
Makes the board linker-script default conditional.
docs/compile.md
Documents custom linker-script configuration.
CMakeLists.txt
Guards linker-template defaults against user overrides.
arch.mk
Converts architecture-specific linker-script defaults to conditional assignments.
The reason will be displayed to describe this comment to others. Learn more.
🟡 Changes recommended
Active moderate findings remain in configuration persistence, stage1 override handling, and CMake path quoting, so the change is not ready for approval.
LSCRIPT_IN is documented as a .config option, but config/Makefile regenerates .config exclusively from CONFIG_VARS, and that list does not contain LSCRIPT_IN. Therefore make config silently deletes a custom linker-script path before this capture runs, and the next build falls back to the target default. Add LSCRIPT_IN to the persisted configuration variables.
Quote linker-template paths in CMake arguments
test-app/CMakeLists.txt:114
This new path is intended to accept an arbitrary absolute user template, but the unquoted expansion is split into multiple CMake arguments when the path contains whitespace. That makes IS_ABSOLUTE (and then configure_file) fail for valid user paths such as /work trees/custom.ld; quote the template, resolved source, and destination arguments.
Persist FLASH_MULTI_SECTOR_ERASE in generated config
tools/config.mk:105
Changing this to ?= only preserves a value while it is present in .config; config/Makefile rebuilds that file from CONFIG_VARS, which omits FLASH_MULTI_SECTOR_ERASE. A user setting from a generated configuration is consequently discarded and this default becomes 0 again, defeating the precedence change. Add FLASH_MULTI_SECTOR_ERASE to CONFIG_VARS as well.
Target-specific assignments in arch.mk/options.mk/board.mk used hard
'=', silently clobbering values the user set via command line,
environment, or a sourced .config (e.g. LSCRIPT_IN from PR wolfSSL#958 was
defeated on every target with a dedicated script).
Convert the target-default assignments to '?=' (first-set wins) and,
for LSCRIPT_IN, capture the user value before the target files are
parsed so the last-resort default (hal/$(TARGET).ld) and the ARMClang
.sct default only apply when the user provided nothing.
CMake: WOLFBOOT_LSCRIPT_TEMPLATE had the same flaw (plain set() over a
user -D value); guard it with NOT DEFINED and let test-app use an
absolute user template as-is.
Document LSCRIPT_IN as a user option in docs/compile.md.
The x86 FSP TGL boards (kontron_vx3060_s2, nai_68int6) share
hal/x86_fsp_tgl_stage1.ld; arch.mk selects it via 'LSCRIPT_IN ?=', but
the hard default here ran first, so the stage1 build of those boards
looked for a non-existent hal/kontron_vx3060_s2_stage1.ld (CI:
'kontron_vx3060_s2 build test', red on master).
The reason will be displayed to describe this comment to others. Learn more.
🟡 Changes recommended
Two moderate active issues remain: generated configuration drops LSCRIPT_IN, and root-invoked stage1 builds resolve user-supplied relative linker-script paths from the wrong directory.
Copilot review follow-ups:
- tools/config.mk: add LSCRIPT_IN to CONFIG_VARS so 'make config'
persists it; it was documented as a .config option but the
regeneration silently dropped it
- Makefile: pass a user-provided LSCRIPT_IN to the recursive stage1
build as an absolute path (abspath), since the sub-make resolves
relative paths from stage1/ while the top-level link resolves them
from the repo root; target-derived stage1 defaults are untouched
The reason will be displayed to describe this comment to others. Learn more.
🟡 Changes recommended
Critical linker-script configuration bugs leave empty values from make config and mishandle absolute custom paths, causing normal and x86 FSP builds to fail until defaults and user-provided scripts are handled correctly.
Copilot review follow-ups:
- config/Makefile: skip emitting a variable whose value is empty, so
'make config' with a blank LSCRIPT_IN prompt no longer persists a
defined-but-empty 'LSCRIPT_IN?=' (quoted test -n: unquoted, bash's
test returns true for a missing operand)
- Makefile: the last-resort hal/$(TARGET).ld default now keys on
strip(LSCRIPT_IN) being empty, so a persisted empty value falls
back correctly
- stage1/x86_fsp.mk: the .ld.in generation rule only applies to the
target-derived script; a user-provided LSCRIPT_IN is used as-is
(it previously produced a bogus hal/<abs path>.in prerequisite)
The reason will be displayed to describe this comment to others. Learn more.
🟡 Changes recommended
An active moderate Makefile issue causes empty LSCRIPT_IN values to bypass the intended target-specific linker-script selection, so changes are required.
Copilot review follow-up: ?= considers a defined-but-empty LSCRIPT_IN
(stale LSCRIPT_IN?= line in .config, exported empty env var) already
set, so it skipped every target-specific default and fell through to
the last-resort hal/$(TARGET).ld - e.g. TARGET=stm32l5 TZEN=0 lost its
hal/stm32l5-ns.ld layout. The strip-based last-resort check only fixed
that one line, not the 32 target sites.
Add the LSCRIPT_IN_DEFAULT helper in tools/config.mk (assigns only when
LSCRIPT_IN is undefined or empty) and convert all 29 arch.mk, 2
board.mk and 1 stage1/Makefile sites to it.
The reason will be displayed to describe this comment to others. Learn more.
🔵 Needs a closer look
Human assessment is needed because moderate hidden findings reveal a shared command-line precedence issue in fallback linker-script assignments, making the documented empty-value behavior unreliable across targets.
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
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.
Target-specific assignments in arch.mk/options.mk/board.mk used hard '=', silently clobbering values the user set via command line, environment, or a sourced .config (e.g. LSCRIPT_IN from PR #958 was defeated on every target with a dedicated script).
Convert the target-default assignments to '?=' (first-set wins) and, for LSCRIPT_IN, capture the user value before the target files are parsed so the last-resort default (hal/$(TARGET).ld) and the ARMClang .sct default only apply when the user provided nothing.
CMake: WOLFBOOT_LSCRIPT_TEMPLATE had the same flaw (plain set() over a user -D value); guard it with NOT DEFINED and let test-app use an absolute user template as-is.
Document LSCRIPT_IN as a user option in docs/compile.md.