* [PATCH 5.4 0/2] Fix kselftest builds when specifying an output dir
@ 2023-01-06 22:08 Tyler Hicks
2023-01-06 22:08 ` [PATCH 5.4 1/2] selftests: Fix kselftest O=objdir build from cluttering top level objdir Tyler Hicks
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Tyler Hicks @ 2023-01-06 22:08 UTC (permalink / raw)
To: stable; +Cc: Shuah Khan, Muhammad Usama Anjum, Tyler Hicks
From: "Tyler Hicks" <code@tyhicks.com>
When attempting to build kselftests with a separate output directory, a
number of the tests fail to build.
For example,
$ rm -rf build && \
make INSTALL_HDR_PATH=build/usr headers_install > /dev/null && \
make O=build FORCE_TARGETS=1 TARGETS=breakpoints -C tools/testing/selftests > /dev/null
/usr/bin/ld: cannot open output file
build/kselftest/breakpoints/step_after_suspend_test: No such file or directory
collect2: error: ld returned 1 exit status
make[1]: *** [../lib.mk:146: build/kselftest/breakpoints/step_after_suspend_test] Error 1
make: *** [Makefile:163: all] Error 2
This has already been addressed upstream with v5.18 commit 5ad51ab618de
("selftests: set the BUILD variable to absolute path"). It does not
cleanly cherry pick to the linux-5.4.y branch without v5.7 commit
29e911ef7b70 ("selftests: Fix kselftest O=objdir build from cluttering
top level objdir"). Commit 5ad51ab618de was written in a way that
assumes that the kselftests aren't build in the top level objdir so it
makes sense to bring the pre-req commit back but it does represent a
slight change in behavior since the kselftests will now be built in a
subdir of the specified objdir (O=).
Tyler
Muhammad Usama Anjum (1):
selftests: set the BUILD variable to absolute path
Shuah Khan (1):
selftests: Fix kselftest O=objdir build from cluttering top level
objdir
tools/testing/selftests/Makefile | 28 ++++++++++++++++++----------
1 file changed, 18 insertions(+), 10 deletions(-)
--
2.34.1
^ permalink raw reply [flat|nested] 4+ messages in thread* [PATCH 5.4 1/2] selftests: Fix kselftest O=objdir build from cluttering top level objdir
2023-01-06 22:08 [PATCH 5.4 0/2] Fix kselftest builds when specifying an output dir Tyler Hicks
@ 2023-01-06 22:08 ` Tyler Hicks
2023-01-06 22:08 ` [PATCH 5.4 2/2] selftests: set the BUILD variable to absolute path Tyler Hicks
2023-01-12 12:49 ` [PATCH 5.4 0/2] Fix kselftest builds when specifying an output dir Greg KH
2 siblings, 0 replies; 4+ messages in thread
From: Tyler Hicks @ 2023-01-06 22:08 UTC (permalink / raw)
To: stable; +Cc: Shuah Khan, Muhammad Usama Anjum, Tyler Hicks
From: Shuah Khan <skhan@linuxfoundation.org>
commit 29e911ef7b706215caf02a82b0d3076611d6abe8 upstream.
make kselftest-all O=objdir builds create generated objects in objdir.
This clutters the top level directory with kselftest objects. Fix it
to create sub-directory under objdir for kselftest objects.
Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
Signed-off-by: Tyler Hicks (Microsoft) <code@tyhicks.com>
---
tools/testing/selftests/Makefile | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/tools/testing/selftests/Makefile b/tools/testing/selftests/Makefile
index 612f6757015d..0eb5567bb94a 100644
--- a/tools/testing/selftests/Makefile
+++ b/tools/testing/selftests/Makefile
@@ -78,7 +78,7 @@ override LDFLAGS =
override MAKEFLAGS =
endif
-# Append kselftest to KBUILD_OUTPUT to avoid cluttering
+# Append kselftest to KBUILD_OUTPUT and O to avoid cluttering
# KBUILD_OUTPUT with selftest objects and headers installed
# by selftests Makefile or lib.mk.
ifdef building_out_of_srctree
@@ -86,7 +86,7 @@ override LDFLAGS =
endif
ifneq ($(O),)
- BUILD := $(O)
+ BUILD := $(O)/kselftest
else
ifneq ($(KBUILD_OUTPUT),)
BUILD := $(KBUILD_OUTPUT)/kselftest
--
2.34.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 5.4 2/2] selftests: set the BUILD variable to absolute path
2023-01-06 22:08 [PATCH 5.4 0/2] Fix kselftest builds when specifying an output dir Tyler Hicks
2023-01-06 22:08 ` [PATCH 5.4 1/2] selftests: Fix kselftest O=objdir build from cluttering top level objdir Tyler Hicks
@ 2023-01-06 22:08 ` Tyler Hicks
2023-01-12 12:49 ` [PATCH 5.4 0/2] Fix kselftest builds when specifying an output dir Greg KH
2 siblings, 0 replies; 4+ messages in thread
From: Tyler Hicks @ 2023-01-06 22:08 UTC (permalink / raw)
To: stable; +Cc: Shuah Khan, Muhammad Usama Anjum, Tyler Hicks
From: Muhammad Usama Anjum <usama.anjum@collabora.com>
commit 5ad51ab618de5d05f4e692ebabeb6fe6289aaa57 upstream.
The build of kselftests fails if relative path is specified through
KBUILD_OUTPUT or O=<path> method. BUILD variable is used to determine
the path of the output objects. When make is run from other directories
with relative paths, the exact path of the build objects is ambiguous
and build fails.
make[1]: Entering directory '/home/usama/repos/kernel/linux_mainline2/tools/testing/selftests/alsa'
gcc mixer-test.c -L/usr/lib/x86_64-linux-gnu -lasound -o build/kselftest/alsa/mixer-test
/usr/bin/ld: cannot open output file build/kselftest/alsa/mixer-test
Set the BUILD variable to the absolute path of the output directory.
Make the logic readable and easy to follow. Use spaces instead of tabs
for indentation as if with tab indentation is considered recipe in make.
Signed-off-by: Muhammad Usama Anjum <usama.anjum@collabora.com>
Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
Signed-off-by: Tyler Hicks (Microsoft) <code@tyhicks.com>
---
tools/testing/selftests/Makefile | 26 +++++++++++++++++---------
1 file changed, 17 insertions(+), 9 deletions(-)
diff --git a/tools/testing/selftests/Makefile b/tools/testing/selftests/Makefile
index 0eb5567bb94a..40ee6f57af78 100644
--- a/tools/testing/selftests/Makefile
+++ b/tools/testing/selftests/Makefile
@@ -85,19 +85,27 @@ ifdef building_out_of_srctree
override LDFLAGS =
endif
-ifneq ($(O),)
- BUILD := $(O)/kselftest
+top_srcdir ?= ../../..
+
+ifeq ("$(origin O)", "command line")
+ KBUILD_OUTPUT := $(O)
+endif
+
+ifneq ($(KBUILD_OUTPUT),)
+ # Make's built-in functions such as $(abspath ...), $(realpath ...) cannot
+ # expand a shell special character '~'. We use a somewhat tedious way here.
+ abs_objtree := $(shell cd $(top_srcdir) && mkdir -p $(KBUILD_OUTPUT) && cd $(KBUILD_OUTPUT) && pwd)
+ $(if $(abs_objtree),, \
+ $(error failed to create output directory "$(KBUILD_OUTPUT)"))
+ # $(realpath ...) resolves symlinks
+ abs_objtree := $(realpath $(abs_objtree))
+ BUILD := $(abs_objtree)/kselftest
else
- ifneq ($(KBUILD_OUTPUT),)
- BUILD := $(KBUILD_OUTPUT)/kselftest
- else
- BUILD := $(shell pwd)
- DEFAULT_INSTALL_HDR_PATH := 1
- endif
+ BUILD := $(CURDIR)
+ DEFAULT_INSTALL_HDR_PATH := 1
endif
# Prepare for headers install
-top_srcdir ?= ../../..
include $(top_srcdir)/scripts/subarch.include
ARCH ?= $(SUBARCH)
export KSFT_KHDR_INSTALL_DONE := 1
--
2.34.1
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [PATCH 5.4 0/2] Fix kselftest builds when specifying an output dir
2023-01-06 22:08 [PATCH 5.4 0/2] Fix kselftest builds when specifying an output dir Tyler Hicks
2023-01-06 22:08 ` [PATCH 5.4 1/2] selftests: Fix kselftest O=objdir build from cluttering top level objdir Tyler Hicks
2023-01-06 22:08 ` [PATCH 5.4 2/2] selftests: set the BUILD variable to absolute path Tyler Hicks
@ 2023-01-12 12:49 ` Greg KH
2 siblings, 0 replies; 4+ messages in thread
From: Greg KH @ 2023-01-12 12:49 UTC (permalink / raw)
To: Tyler Hicks; +Cc: stable, Shuah Khan, Muhammad Usama Anjum
On Fri, Jan 06, 2023 at 04:08:42PM -0600, Tyler Hicks wrote:
> From: "Tyler Hicks" <code@tyhicks.com>
>
> When attempting to build kselftests with a separate output directory, a
> number of the tests fail to build.
>
> For example,
>
> $ rm -rf build && \
> make INSTALL_HDR_PATH=build/usr headers_install > /dev/null && \
> make O=build FORCE_TARGETS=1 TARGETS=breakpoints -C tools/testing/selftests > /dev/null
> /usr/bin/ld: cannot open output file
> build/kselftest/breakpoints/step_after_suspend_test: No such file or directory
> collect2: error: ld returned 1 exit status
> make[1]: *** [../lib.mk:146: build/kselftest/breakpoints/step_after_suspend_test] Error 1
> make: *** [Makefile:163: all] Error 2
>
> This has already been addressed upstream with v5.18 commit 5ad51ab618de
> ("selftests: set the BUILD variable to absolute path"). It does not
> cleanly cherry pick to the linux-5.4.y branch without v5.7 commit
> 29e911ef7b70 ("selftests: Fix kselftest O=objdir build from cluttering
> top level objdir"). Commit 5ad51ab618de was written in a way that
> assumes that the kselftests aren't build in the top level objdir so it
> makes sense to bring the pre-req commit back but it does represent a
> slight change in behavior since the kselftests will now be built in a
> subdir of the specified objdir (O=).
>
> Tyler
>
> Muhammad Usama Anjum (1):
> selftests: set the BUILD variable to absolute path
>
> Shuah Khan (1):
> selftests: Fix kselftest O=objdir build from cluttering top level
> objdir
>
> tools/testing/selftests/Makefile | 28 ++++++++++++++++++----------
> 1 file changed, 18 insertions(+), 10 deletions(-)
>
> --
> 2.34.1
>
Now queued up, thanks.
greg k-h
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2023-01-12 12:49 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-01-06 22:08 [PATCH 5.4 0/2] Fix kselftest builds when specifying an output dir Tyler Hicks
2023-01-06 22:08 ` [PATCH 5.4 1/2] selftests: Fix kselftest O=objdir build from cluttering top level objdir Tyler Hicks
2023-01-06 22:08 ` [PATCH 5.4 2/2] selftests: set the BUILD variable to absolute path Tyler Hicks
2023-01-12 12:49 ` [PATCH 5.4 0/2] Fix kselftest builds when specifying an output dir Greg KH
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.