Skip to contentSkip to conversation

tools/dma: fix building from the top level with O=

PATCH Applied Sasha Levin 4 participants 5 messages Oct 11 – Oct 13

Subsystems (3)
lore
Share & tools
lore

Sasha Levin

author maintainer
#0 lore raw

PATCH 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>'").

Fixes f74ee32963f1b ("tools/dma: move dma_map_benchmark from selftests to tools/dma")
Assisted-by LLM
---
 tools/dma/Makefile | 6 ++++++
 1 file changed, 6 insertions(+)
tools/dma/Makefile +6 -0
index 0c239a6b9eae5..20ae7f09cd206 100644
@@ -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
#1 lore raw
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 --

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
index e4abf37bf020c..b5fe6e2625eef 100644
@@ -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
author maintainer
#2 lore raw
Quoted 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/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
index e4abf37bf020c..b5fe6e2625eef 100644
@@ -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?

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
maintainer Acked-by on v1 1/1
#3 lore raw
In reply to Sasha Levin
Quoted 28 lines · Sasha Levin

"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>'").

Fixes f74ee32963f1b ("tools/dma: move dma_map_benchmark from selftests to tools/dma")
Assisted-by LLM
---
  tools/dma/Makefile | 6 ++++++
  1 file changed, 6 insertions(+)
tools/dma/Makefile +0 -0
index 0c239a6b9eae5..20ae7f09cd206 100644
@@ -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
#4 lore raw
In reply to Sasha Levin
Quoted 8 lines · Sasha Levin

"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.

Quoted 8 lines

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>'").

Fixes f74ee32963f1b ("tools/dma: move dma_map_benchmark from selftests to tools/dma")
Assisted-by LLM

Applied to dma-mapping-for-next. Thanks!

Best regards

Signature · 2 lines
Marek Szyprowski, PhD
Samsung R&D Institute Poland