tools/dma: fix building from the top level with O=
Subsystems (3)
Sasha Levin
maintainerPATCH 1/1 tools/dma: fix building from the top level with O=
"make O=<dir> tools/dma" fails:
Makefile:27: /tools/build/Makefile.include: No such file or directory
tools/Makefile clears srctree, and the dma Makefile only works it out again when building_out_of_srctree is not set, which the top-level Makefile sets for O= builds.
Also work out srctree when it is empty, as tools/bpf/Makefile does since commit a89b2cbf71d64 ("tools, bpf: Fix build for 'make -s tools/bpf O=<dir>'").
--- tools/dma/Makefile | 6 ++++++ 1 file changed, 6 insertions(+)
tools/dma/Makefile +6 -0
@@ -7,7 +7,13 @@ bindir ?= /usr/bin # isn't set and when invoked from selftests build, where srctree # is set to ".". building_out_of_srctree is undefined for in srctree # builds +ifeq ($(srctree),) +update_srctree := 1 +endif ifndef building_out_of_srctree +update_srctree := 1 +endif +ifeq ($(update_srctree),1) srctree := $(patsubst %/,%,$(dir $(CURDIR))) srctree := $(patsubst %/,%,$(dir $(srctree))) endif
Signature · 1 line
2.53.0
[email protected]
AI reviewThank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [Low] tools/dma: incomplete fix for out-of-tree (O=) builds --
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Low] tools/dma: incomplete fix for out-of-tree (O=) builds
--
commit f9ebfb989b6d469df7135b7ea719817656f0b606
Author: Sasha Levin <[email protected]>
tools/dma: fix building from the top level with O=
This commit attempts to fix the out-of-tree build for tools/dma when using O=<dir> by correctly setting the srctree variable. It ensures that srctree is worked out even when it is empty or when building_out_of_srctree is set.
Quoted 8 lines
tools/dma/Makefile +0
-0@@ -7,7 +7,13 @@ bindir ?= /usr/bin # isn't set and when invoked from selftests build, where srctree # is set to ".". building_out_of_srctree is undefined for in srctree # builds
tools/dma/Makefile bindir ?= /usr/bin · line 19
Quoted 10 lines
tools/dma/Makefile +6
-0+ifeq ($(srctree),) +update_srctree := 1 +endif ifndef building_out_of_srctree +update_srctree := 1 +endif +ifeq ($(update_srctree),1) srctree := $(patsubst %/,%,$(dir $(CURDIR))) srctree := $(patsubst %/,%,$(dir $(srctree))) endif
[Severity: Low]
Does this commit completely fix the out-of-tree (O=) builds?
While this resolves the srctree issue to successfully locate Makefile.include, an out-of-tree build via O=<dir> will still fail immediately afterwards.
The default all target depends on $(ALL_PROGRAMS), which correctly expands to include $(OUTPUT) (e.g., out/.../dma_map_benchmark). However, the explicit build rule for $(DMA_MAP_BENCHMARK) lacks the $(OUTPUT) prefix:
tools/dma/Makefile:
DMA_MAP_BENCHMARK = dma_map_benchmark
$(DMA_MAP_BENCHMARK): prepare FORCE
$(CC) $(CFLAGS) $(DMA_MAP_BENCHMARK).c -o $(DMA_MAP_BENCHMARK)As a result, Make will abort with a 'No rule to make target' error.
Furthermore, the compilation command places the resulting binary back in the source tree instead of the requested output directory.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
Sasha Levin
maintainerQuoted 35 lines · On Sun, Oct 11, 2026 at 10:43:33PM +0000, [email protected] wrote:
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Low]tools/dma: incomplete fix for out-of-tree (O=) builds
--commit
f9ebfb989b6d469df7135b7ea719817656f0b606
Author: Sasha Levin <[email protected]>
tools/dma: fix building from the top level with O=This commit attempts to fix the out-of-tree build for
tools/dmawhen using O=<dir> by correctly setting the srctree variable. It ensures that srctree is worked out even when it is empty or whenbuilding_out_of_srctreeis set.Quoted 8 lines
tools/dma/Makefile +0
-0@@ -7,7 +7,13 @@ bindir ?= /usr/bin # isn't set and when invoked from selftests build, where srctree # is set to ".". building_out_of_srctree is undefined for in srctree # buildstools/dma/Makefile bindir ?= /usr/bin · line 19
Quoted 10 lines
tools/dma/Makefile +6
-0+ifeq ($(srctree),) +update_srctree := 1 +endif ifndef building_out_of_srctree +update_srctree := 1 +endif +ifeq ($(update_srctree),1) srctree := $(patsubst %/,%,$(dir $(CURDIR))) srctree := $(patsubst %/,%,$(dir $(srctree))) endif[Severity: Low]
Does this commit completely fix the out-of-tree (O=) builds?
Quoted 2 lines
While this resolves the srctree issue to successfully locate Makefile.include, an out-of-tree build via O=<dir> will still fail immediately afterwards.
This was fixed in a different patch here: https://lore.kernel.org/r/[email protected]
Signature · 2 lines
Thanks, Sasha
Quoted 28 lines · Sasha Levin
"make O=<dir>
tools/dma" fails:Makefile:27: /tools/build/Makefile.include: No such file or directory
tools/Makefileclears srctree, and the dmaMakefileonly works it out again whenbuilding_out_of_srctreeis not set, which the top-levelMakefilesets for O= builds.Also work out srctree when it is empty, as
tools/bpf/Makefiledoes since commita89b2cbf71d64("tools, bpf: Fix build for 'make -stools/bpfO=<dir>'").Fixes f74ee32963f1b ("tools/dma: move dma_map_benchmark from selftests to tools/dma")Assisted-by LLMSigned-off-by Sasha Levin <[email protected]>--- tools/dma/Makefile | 6 ++++++ 1 file changed, 6 insertions(+)tools/dma/Makefile +0
-0@@ -7,7 +7,13 @@ bindir ?= /usr/bin # isn't set and when invoked from selftests build, where srctree # is set to ".". building_out_of_srctree is undefined for in srctree # builds
tools/dma/Makefile bindir ?= /usr/bin · line 19
Quoted 10 lines
tools/dma/Makefile +6
-0+ifeq ($(srctree),) +update_srctree := 1 +endif ifndef building_out_of_srctree +update_srctree := 1 +endif +ifeq ($(update_srctree),1) srctree := $(patsubst %/,%,$(dir $(CURDIR))) srctree := $(patsubst %/,%,$(dir $(srctree))) endif
Signature · 2 lines
Thanks, Qinxin
Marek Szyprowski
AppliedQuoted 8 lines · Sasha Levin
"make O=<dir>
tools/dma" fails:Makefile:27: /tools/build/Makefile.include: No such file or directory
tools/Makefileclears srctree, and the dmaMakefileonly works it out again whenbuilding_out_of_srctreeis not set, which the top-levelMakefilesets for O= builds.
Quoted 8 lines
Also work out srctree when it is empty, as
tools/bpf/Makefiledoes since commita89b2cbf71d64("tools, bpf: Fix build for 'make -stools/bpfO=<dir>'").Fixes f74ee32963f1b ("tools/dma: move dma_map_benchmark from selftests to tools/dma")Assisted-by LLMSigned-off-by Sasha Levin <[email protected]>
Applied to dma-mapping-for-next. Thanks!
Best regards
Signature · 2 lines
Marek Szyprowski, PhD Samsung R&D Institute Poland