lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <dd2c9072-e95e-4906-a5cb-cb9ba862dd36@fujitsu.com>
Date: Mon, 23 Dec 2024 01:00:25 +0000
From: "Zhijian Li (Fujitsu)" <lizhijian@...itsu.com>
To: Quentin Monnet <qmo@...n.net>, "linux-kbuild@...r.kernel.org"
	<linux-kbuild@...r.kernel.org>
CC: Masahiro Yamada <masahiroy@...nel.org>, Nathan Chancellor
	<nathan@...nel.org>, Nicolas Schier <nicolas@...sle.eu>,
	"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
	"bpf@...r.kernel.org" <bpf@...r.kernel.org>, Shuah Khan <shuah@...nel.org>,
	"linux-kselftest@...r.kernel.org" <linux-kselftest@...r.kernel.org>
Subject: Re: [PATCH RFC] Makefile: Export absolute srctree path for
 out-of-tree builds



On 21/12/2024 01:14, Quentin Monnet wrote:
> 2024-12-17 11:10 UTC+0800 ~ Li Zhijian <lizhijian@...itsu.com>
>> Fixes an issue where out-of-tree kselftest builds fail when building
>> the BPF and bpftools components. The failure occurs because the top-level
>> Makefile passes a relative srctree path ('..') to its sub-Makefiles, which
>> leads to errors in locating necessary files.
>>
>> For example, the following error is encountered:
>>
>> ```
>> $ make V=1 O=$build/ TARGETS=hid kselftest-all
>> ...
>> make -C ../tools/testing/selftests all
>> make[4]: Entering directory '/path/to/linux/tools/testing/selftests/hid'
>> make  -C /path/to/linux/tools/testing/selftests/../../../tools/lib/bpf OUTPUT=/path/to/linux/O/kselftest/hid/tools/build/libbpf/ \
>>              EXTRA_CFLAGS='-g -O0'                                      \
>>              DESTDIR=/path/to/linux/O/kselftest/hid/tools prefix= all install_headers
>> make[5]: Entering directory '/path/to/linux/tools/lib/bpf'
>> ...
>> make[5]: Entering directory '/path/to/linux/tools/bpf/bpftool'
>> Makefile:127: ../tools/build/Makefile.feature: No such file or directory
>> make[5]: *** No rule to make target '../tools/build/Makefile.feature'.  Stop.
>> ```
> 
> 
> Another condition to reproduce the failure above is to have have
> $(srcroot) in the Makefile set to "." or "..", for example when your
> $build is located right under the root of the repo [0].
> 
> [0] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Makefile?h=v6.13-rc3#n273
> 
> 
>> To resolve this, the srctree is exported as an absolute path (abs_srctree)
>> when performing an out-of-tree build. This ensures that all sub-Makefiles
>> have the correct path to the source tree, preventing directory resolution
>> errors.
>>
>> Signed-off-by: Li Zhijian <lizhijian@...itsu.com>
>> ---
>> Request for Additional Testing
>>
>> We welcome all contributors and CI systems to test this change thoroughly.
>> In theory, this change should not affect in-tree builds. However, to ensure
>> stability and compatibility, we encourage testing across different
>> configurations.
>>
>> What has been tested?
>> - out-of-tree kernel build
>> - out-of-tree kselftest-all
>> ---
>>   Makefile | 3 ++-
>>   1 file changed, 2 insertions(+), 1 deletion(-)
>>
>> diff --git a/Makefile b/Makefile
>> index e5b8a8832c0c..36e65806bb5e 100644
>> --- a/Makefile
>> +++ b/Makefile
>> @@ -275,7 +275,8 @@ else ifeq ($(srcroot)/,$(dir $(CURDIR)))
>>       srcroot := ..
>>   endif
>>   
>> -export srctree := $(if $(KBUILD_EXTMOD),$(abs_srctree),$(srcroot))
>> +srctree := $(if $(KBUILD_EXTMOD),$(abs_srctree),$(srcroot))
>> +export srctree := $(if $(building_out_of_srctree),$(abs_srctree),$(srctree))
>>   
>>   ifdef building_out_of_srctree
>>   export VPATH := $(srcroot)
> 
> 
> The patch does fix the issue in the case you reported.
> 
> Maybe I'd write the change differently, though; rather than potentially
> overwriting $(srctree) before exporting it, let's unroll with ifdef's to
> make it clearer?

Yes, your code looks better.
However, this "absolute source tree" approach was not approved.:)

Thank you!!



> 
> 	ifdef building_out_of_srctree
> 	    srctree := $(abs_srctree)
> 	else ifdef KBUILD_EXTMOD
> 	    srctree := $(abs_srctree)
> 	else
> 	    srctree := $(srcroot)
> 	endif
> 	export srctree
> 
> (not tested)
> 
> Thanks,
> Quentin

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ