From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pf1-f174.google.com (mail-pf1-f174.google.com [209.85.210.174]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 06F0218C33C for ; Thu, 5 Dec 2024 06:27:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.174 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733380063; cv=none; b=CBbvVYlL8YRiXiRqwMLmHx0/OOnnepoZU71b+a/uOADE0DsnwtcqqYta7F0H1R7xdRTuQoXixjWKwN0I2Rs2pwA5szUB5modE9Vcds2exJ31DRBes66aW4MN9yaGK+nXrPQg3j3cgUrI+wVGCmdUi680eb/eIOWBDzEOUdI2YLQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733380063; c=relaxed/simple; bh=qS1NPBabbYXkSV9uKTFXDZ1+1kaI8qyGYql2iCfXsR0=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=pYJsRW3uRdnldVyWNns+at2Z8pLGZCztSplxZDCRS10ByAmC0YlxLmi4DvMmoZN93JqK01CSe3HADQXxUdp1WyHAOjcmahbRZvcZihFHjb9rzCPP0QqXcGwHRfs1Wb3l83JV6lcXJ+uLGS3OHYIDsjV5Bu4ORaoejiV0qIDw+fI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=rivosinc.com; spf=pass smtp.mailfrom=rivosinc.com; dkim=pass (2048-bit key) header.d=rivosinc-com.20230601.gappssmtp.com header.i=@rivosinc-com.20230601.gappssmtp.com header.b=Z37L6G7Q; arc=none smtp.client-ip=209.85.210.174 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=rivosinc.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=rivosinc.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=rivosinc-com.20230601.gappssmtp.com header.i=@rivosinc-com.20230601.gappssmtp.com header.b="Z37L6G7Q" Received: by mail-pf1-f174.google.com with SMTP id d2e1a72fcca58-723f37dd76cso536359b3a.0 for ; Wed, 04 Dec 2024 22:27:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20230601.gappssmtp.com; s=20230601; t=1733380059; x=1733984859; darn=vger.kernel.org; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date:from:to :cc:subject:date:message-id:reply-to; bh=XCYS6iztL10oOLNtRWs25ZswwaRh2arrdQMGB4nuP3Q=; b=Z37L6G7Q9O3J/jIe9bXpu/w8sGyS3ep1x0k9Ni7TooVNPkTmYSxF7XdacrJv5sDCdP Zfc7KdMK3SyuH3ehmGPjRHjub4rE2Of/uRpqGPOp2Y19X8CNsYyl7yYWlZlkvAouOVjI oLfrGlf1KVu2OTBV3bAppsdoyjn3QqHtv9kyGlsn5jR1+69cqf7j0rQuNDNWOoM09gGX wITdjy3c/Wht771j6ILxHs/aFUmxc/u5IMubuRTexsSMoPl0YiEdmd5DHLIK5UrJMQRY T0ERtzBUmkPkPhxU9DwwTjKcrGJLorRHTjKaWZZgLm5sEeFMJAnVqFqeIEvfS7vSjsiY d9Uw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733380059; x=1733984859; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=XCYS6iztL10oOLNtRWs25ZswwaRh2arrdQMGB4nuP3Q=; b=duImfx+m7Jd/mDQGvbLOvuM/2T//T/9/IPcm/QOF3S0NxcZ11e7m5yt3N3Pi4Lj9T+ osX+LZnfWgDSPowvxwxJIQ/Hp5jBo/rC30Xm3QHJpkxygNgjPRyFIKMmy1vPyKv2UwMX M0vcS7Be+4zlvfAp6nA+KwkKQWZj/OiUEv9TiW91DZaXRzm+wAFUwUMzh7JszOP9lj/W i0r2dG2Wn9bAJH9ENRhFeRMzVSDJhux/W2fq6MVJsiVlFar9GDjG4E6+OezYOGfF2bzU bY97zPdOsgz0HpcNKZxukUufoR/FV4gQ1W/B40KWBLxHjRqrhdP/2IkR2featCnfOQ7k KMdg== X-Forwarded-Encrypted: i=1; AJvYcCU6DjBgI8A4QlTnTDcNXI91GPCpFndweym7jCSQ3uzt6JmtOvoN3NbceFZ9mSSKnjgQXS4zux4wErPIooM=@vger.kernel.org X-Gm-Message-State: AOJu0YxdJFYCiajTBBVJFL9ceuuxiPL9i9XTKjvIjgsz932i2jpskEWP fHHFySJqKEN9nsUVk67uUrICHjePSRJXBe2CgdKlRXwvOfXIqpluvxKk8Xmgf1o= X-Gm-Gg: ASbGncvq9kV5XMCXx++HlpoMupsorEJFcN+hC6dLysNfF+2rwlYvxlJWus7jAKMZsA8 VX+ND4SdIpCWjW/o2bLlHD6QgkgwVPZiK7UYf6/gXIZ3RKH6C+kdGS1yLf1/nEQDIc6nw1a9DsK Po7Fm/lEACUdjNUMwnjnk9TUj+9uq8aFCGxVyPHXOQI+FyfjXbIVd7lodPqUAMMWuaIc9S6g2Mv bCKt25yUX8iVokPZqK1/XDnulIf+Bkhbfa/JXUNPYzR X-Google-Smtp-Source: AGHT+IFPvyQvWZJgFv3tZ7dxjDrDJ/Mpj5QRafpwVa5PN4Od6vrWdyy5rrj1mByFq7QDEWqX+uF9Gw== X-Received: by 2002:a05:6a00:2789:b0:725:9cc4:2354 with SMTP id d2e1a72fcca58-7259cc423b6mr4370890b3a.10.1733380057829; Wed, 04 Dec 2024 22:27:37 -0800 (PST) Received: from ghost ([2601:647:6700:64d0:f7b6:61d:746e:a663]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-7fd157dd329sm569747a12.85.2024.12.04.22.27.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Dec 2024 22:27:37 -0800 (PST) Date: Wed, 4 Dec 2024 22:27:34 -0800 From: Charlie Jenkins To: Masahiro Yamada Cc: linux-kbuild@vger.kernel.org, linux-kernel@vger.kernel.org, rust-for-linux@vger.kernel.org, cocci@inria.fr Subject: Re: [PATCH v2 05/11] kbuild: change working directory to external module directory with M= Message-ID: References: <20241110013649.34903-1-masahiroy@kernel.org> <20241110013649.34903-6-masahiroy@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: On Thu, Dec 05, 2024 at 11:48:08AM +0900, Masahiro Yamada wrote: > On Thu, Dec 5, 2024 at 8:35 AM Charlie Jenkins wrote: > > > > On Sun, Nov 10, 2024 at 10:34:33AM +0900, Masahiro Yamada wrote: > > > Currently, Kbuild always operates in the output directory of the kernel, > > > even when building external modules. This increases the risk of external > > > module Makefiles attempting to write to the kernel directory. > > > > > > This commit switches the working directory to the external module > > > directory, allowing the removal of the $(KBUILD_EXTMOD)/ prefix from > > > some build artifacts. > > > > > > The command for building external modules maintains backward > > > compatibility, but Makefiles that rely on working in the kernel > > > directory may break. In such cases, $(objtree) and $(srctree) should > > > be used to refer to the output and source directories of the kernel. > > > > > > The appearance of the build log will change as follows: > > > > > > [Before] > > > > > > $ make -C /path/to/my/linux M=/path/to/my/externel/module > > > make: Entering directory '/path/to/my/linux' > > > CC [M] /path/to/my/externel/module/helloworld.o > > > MODPOST /path/to/my/externel/module/Module.symvers > > > CC [M] /path/to/my/externel/module/helloworld.mod.o > > > CC [M] /path/to/my/externel/module/.module-common.o > > > LD [M] /path/to/my/externel/module/helloworld.ko > > > make: Leaving directory '/path/to/my/linux' > > > > > > [After] > > > > > > $ make -C /path/to/my/linux M=/path/to/my/externel/module > > > make: Entering directory '/path/to/my/linux' > > > make[1]: Entering directory '/path/to/my/externel/module' > > > CC [M] helloworld.o > > > MODPOST Module.symvers > > > CC [M] helloworld.mod.o > > > CC [M] .module-common.o > > > LD [M] helloworld.ko > > > make[1]: Leaving directory '/path/to/my/externel/module' > > > make: Leaving directory '/path/to/my/linux' > > > > > > Printing "Entering directory" twice is cumbersome. This will be > > > addressed later. > > > > This change has caused O= to fail. > > > > For example: > > > > make O=build defconfig > > make -j$(nproc) V=1 O=build bindeb-pkg > > > > outputs: > > > > make ARCH=x86 KERNELRELEASE=6.13.0-rc1 KBUILD_BUILD_VERSION=3 run-command KBUILD_RUN_COMMAND='+$(srctree)/scripts/package/builddeb linux-libc-dev' > > dh_installchangelogs -plinux-image-6.13.0-rc1 > > ../scripts/package/builddeb linux-headers-6.13.0-rc1 > > dh_compress -plinux-image-6.13.0-rc1 > > dh_fixperms -plinux-image-6.13.0-rc1 > > dh_gencontrol -plinux-image-6.13.0-rc1 -- -fdebian/image.files > > Rebuilding host programs with x86_64-linux-gnu-gcc... > > make[6]: Entering directory '/scratch/kernels/linux/build' > > /scratch/kernels/linux/Makefile:190: *** specified kernel directory "build" does not exist. Stop. > > > > It is stepping into this directory and then trying to find the directory > > it just stepped into so $(realpath $(KBUILD_OUTPUT)) returns an empty > > string. > > > > Using an absolute directory resolves this problem, but I believe it > > shouldn't be necessary. > > > Agree. > > I will apply the following fixup unless I have a better idea. > > > > > diff --git a/scripts/package/install-extmod-build > b/scripts/package/install-extmod-build > index 64d958ee45f3..85af1573db31 100755 > --- a/scripts/package/install-extmod-build > +++ b/scripts/package/install-extmod-build > @@ -69,7 +69,7 @@ if [ "${CC}" != "${HOSTCC}" ]; then > # > # Use the single-target build to avoid the modpost invocation, which > # would overwrite Module.symvers. > - "${MAKE}" HOSTCC="${CC}" KBUILD_EXTMOD="${destdir}" scripts/ > + "${MAKE}" O=. HOSTCC="${CC}" KBUILD_EXTMOD="${destdir}" scripts/ > > cat <<-'EOF' > "${destdir}/scripts/Kbuild" > subdir-y := basic > @@ -78,7 +78,7 @@ if [ "${CC}" != "${HOSTCC}" ]; then > EOF > > # Run once again to rebuild scripts/basic/ and scripts/mod/modpost. > - "${MAKE}" HOSTCC="${CC}" KBUILD_EXTMOD="${destdir}" scripts/ > + "${MAKE}" O=. HOSTCC="${CC}" KBUILD_EXTMOD="${destdir}" scripts/ > > rm -f "${destdir}/Kbuild" "${destdir}/scripts/Kbuild" > fi > Looks fine to me :) If this is what you decide on, feel free to add my tags. Tested-by: Charlie Jenkins Reviewed-by: Charlie Jenkins > > > -- > Best Regards > Masahiro Yamada