Received: by 2002:ab2:1149:0:b0:1f3:1f8c:d0c6 with SMTP id z9csp2148085lqz; Tue, 2 Apr 2024 08:31:54 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVwMNsKabwtNLzYUFBt3G+fWioYIKjntfn2wLtjrbynCFDrwPlqlWQlbFyrYYFF/XILi3NnE/42BN0udGYjnpnKAtQkb39ICePhMyuWbg== X-Google-Smtp-Source: AGHT+IHKC6mPSK3FNLIYdbbhZ1P2we3bWR3bVIMVi1DcgAHmZZQVQB426r+NuIwcEinYUdzRneg8 X-Received: by 2002:a05:6808:1144:b0:3c3:dcfc:f694 with SMTP id u4-20020a056808114400b003c3dcfcf694mr16025107oiu.47.1712071914700; Tue, 02 Apr 2024 08:31:54 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712071914; cv=pass; d=google.com; s=arc-20160816; b=DgorOUMKOS+J1jLZIsm8uo7g8PRfmKsAIas9aDBm6LIUpqrR3G/KwDtVReBhN1MEnS 6a2KC+EMG20hcekNA/lTT8tgQI0zVQ5nroE0rR2nNEiGOrnlMEawZOchK3DsnggEMSEj BTkU8xqJXPHZ3xGDb27VsmRC0HM72od2FOqPlyyDZ40WxH7hItwrcoP49f0RNE6dSbQl tEP1UMlSbuz5xdtG+ieXgm/1ucqmfEpiuJGf5NfLaZz6udoM/0FH1kH5D6GylJTa6ktg GiIE0Rq3nHv/uNZweKvjHxgJzP8UpWtxjjzqRHT64O4V/x3SLTo6brjrmiCKWcjDqLzC +HKg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:ironport-hdrordr:ironport-data:dkim-signature; bh=+6buokSRXxD5AHfqji+FJX+U612BchLgn5C5OOcHDp8=; fh=OMdJb3gZkD/NmghFvqWc+lAo9XAPdBDZX6anzMPIhXI=; b=hgzwzi6OWa7m+O4Gd1QOAfBgfnt0fHiTVPY5wGDzUIHlL8rZ/SPb48rWAhDQ8OPkgk Ey6xQqpwciZsuCYP95JHdhw2gyrLTtlvoRIw3KVrAIHKX9j43Y3TjLjGyVhejcJxJesj jTZcF1KRtgIbFzbuIBdz+XVvW2/+iZQ7f2sst0yxcK1T19LfIjYbi9I8v2R/I3STj5V7 +YkNpaPcR4LiL3ihY8UGEQMQx8/2wMPwYmdLhMSmP2gHFrz32SIGECaPIf5jN29ahU/m Dtu8RYPbfwTD1k130TVu2PMXZulKk1cRV17U4JP66owwRdEHIJ85kOfFBcuwWBfMA5Vk DYvw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@cisco.com header.s=iport header.b=j2lpEUgL; arc=pass (i=1 spf=pass spfdomain=cisco.com dkim=pass dkdomain=cisco.com dmarc=pass fromdomain=cisco.com); spf=pass (google.com: domain of linux-kernel+bounces-128247-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-128247-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=NONE dis=NONE) header.from=cisco.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id b24-20020ab02398000000b007e0de0f7d21si1424061uan.26.2024.04.02.08.31.54 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Apr 2024 08:31:54 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-128247-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@cisco.com header.s=iport header.b=j2lpEUgL; arc=pass (i=1 spf=pass spfdomain=cisco.com dkim=pass dkdomain=cisco.com dmarc=pass fromdomain=cisco.com); spf=pass (google.com: domain of linux-kernel+bounces-128247-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-128247-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=NONE dis=NONE) header.from=cisco.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id BD64F1C2324C for ; Tue, 2 Apr 2024 15:31:53 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id F2398132C1E; Tue, 2 Apr 2024 15:31:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=cisco.com header.i=@cisco.com header.b="j2lpEUgL" Received: from alln-iport-1.cisco.com (alln-iport-1.cisco.com [173.37.142.88]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F23ED13118A; Tue, 2 Apr 2024 15:31:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=173.37.142.88 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712071900; cv=none; b=q1m103HGB5Y6cB9eCXj33OJv2Ae2L/tvTXXO5OblTpRVOE8TEsVkQtLYAl4kDyUNN0cXj9c3r2Rk710Fl0sh52XatpZt+Yj3ogpBorctoAlhj9Ac1G/tEWoig5eVxURcemgK1LN+BH6qDro9RCd+inMij1NyCgIAjmLwdCu4ZIQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712071900; c=relaxed/simple; bh=e69MTcmMVQRlw2pSk4NeN0iFCrZxVM43Fm6IIEyLoZA=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=W5W4bpK2diCPT/C7M39fkoA0fvwRKvEj2ApZZYjlUNZXJC6+Gi3yjNNKdCh7rtVTekJ2KGX/3aGnrbZcX82+7PdiB63Wy2B7boqihIbCBiEFaILIhqAmXm5SfFnKj7d+DjctYmAWbuyUARzqaQqpQVPXLIyP2HyBOrgjGy/tOWc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=cisco.com; spf=pass smtp.mailfrom=cisco.com; dkim=pass (1024-bit key) header.d=cisco.com header.i=@cisco.com header.b=j2lpEUgL; arc=none smtp.client-ip=173.37.142.88 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=cisco.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=cisco.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cisco.com; i=@cisco.com; l=2610; q=dns/txt; s=iport; t=1712071899; x=1713281499; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=+6buokSRXxD5AHfqji+FJX+U612BchLgn5C5OOcHDp8=; b=j2lpEUgLMF5U8UNjEAUELiasRz4r2QjOFg2yeNsxuJNMdxCxBDRU32AA vCLgwn+oj4cEnunlNABIqAfPgqz4uHLxuC01+qI4sc9v7NaDmAydZ3iR9 eLkwF/RvYQvyFwwul/582wo/fLz2Fme8bHbTNs3csebiyW732s89CGdon s=; X-CSE-ConnectionGUID: puciDyntTuO4io/BVrtvHQ== X-CSE-MsgGUID: 6/xQRmZbR+er6QTgIsyl1A== X-IPAS-Result: =?us-ascii?q?A0AwAQCYIwxmmIUNJK1aHgEBCxIMggQLgzVWQUiWPItzk?= =?us-ascii?q?heBJQNWDwEBAQ8xEwQBAYUGiAgCJjQJDgECBAEBAQEDAgMBAQEBAQEBAQYBA?= =?us-ascii?q?QUBAQECAQcFFAEBAQEBAQEBHhkFDhAnhW0Nhlw2AUaBPQESgwABgl8CAa8Wg?= =?us-ascii?q?iyBAbMygWoYgTCMe4VhJ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k2XtHmiXruvOmz7rHYEfDru18tZ0j1CJgG8eEhsbUR28u/bRokq/Xc9Pb k8e5ysqoYAs+0GxCNrwRRu1pDiDpBF0c9xRGOo+4RqlxKjd+AKUQGUZJhZHYcAmvckeRjEw0 FKN2dTzClRHtbSOQHKc7LCFhTC/Iy4YKSkFfyBscOcey9DnpId2hRXVQ5M6Sei+j8b+Hnf7x DXiQDUCa6s7ldMA1omq+0z7nhXwp5+OZDAv+hv3Zzfwhu9mX7KNa4ut4FndyP9PKoeFU1WM1 ETofeDAtYji6rnTzkSwrPUxIV2/2xqS3NThbbNHFp0l8XGm/GSuONkJpjp/P0xudM0DfFcFg XM/WysPuve/31PzMcebhr5d7exxlsAM8vy+CZjpgiJmOMQZSeN+1HgGibSs927silMwtqo0J I2Wd82hZV5DVv09lGfoHLlEjOZ3rszb+Y81bc2rp/hA+efPDEN5tZ9VWLdzRrlgs/Pa+lm9H yh3bpTSkn2zr9ESkgGMrNZMdgpVRZTKLZv3sMdQPvWSORZrHXppCvnah9scl39NwcxoehPz1 ijlACdwkQOn7VWecFniQi44MtvHA80gxU/XyARxZz5ELVB5P9b2hEreHrNqFYQaGBtLlqcuE qVeIpzZXpyiiF3volwgUHU0l6Q6HDzDuO5EF3HNjOQXF3K4ezH0xw== IronPort-HdrOrdr: A9a23:YNyNIa4SsDzk1dGpMAPXwMfXdLJyesId70hD6qm+c3Bom6uj5q KTdZsguyMc5Ax6ZJhCo6HiBED/exLhHPdOiOF7AV7IZmbbUQWTQb2KxLGSpgEIYxefygaYvp 0QFJSXz7bLfDxHsfo= X-Talos-CUID: =?us-ascii?q?9a23=3AEJzxFWh/v0hpVKjmWoBNZEK3YzJuamDWzVvBJVO?= =?us-ascii?q?EFEE1SbrSY2GK5L1Eqp87?= X-Talos-MUID: 9a23:QhcDEQkU6wznDguJOyzndno8c9dR2aGcAnpOnI9YgvWLFDdhP2602WE= X-IronPort-Anti-Spam-Filtered: true X-IronPort-AV: E=Sophos;i="6.07,175,1708387200"; d="scan'208";a="248631178" Received: from alln-core-11.cisco.com ([173.36.13.133]) by alln-iport-1.cisco.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Apr 2024 15:30:30 +0000 Received: from sjc-ads-1541.cisco.com (sjc-ads-1541.cisco.com [171.70.59.233]) by alln-core-11.cisco.com (8.15.2/8.15.2) with ESMTP id 432FUTlY029489; Tue, 2 Apr 2024 15:30:29 GMT From: Valerii Chernous To: Masahiro Yamada , Nathan Chancellor , Nicolas Schier Cc: xe-linux-external@cisco.com, linux-kbuild@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] Add MO(mod objs) variable to process ext modules with subdirs Date: Tue, 2 Apr 2024 08:30:27 -0700 Message-Id: <20240402153028.1378868-1-vchernou@cisco.com> X-Mailer: git-send-email 2.35.6 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Auto-Response-Suppress: DR, OOF, AutoReply X-Outbound-SMTP-Client: 171.70.59.233, sjc-ads-1541.cisco.com X-Outbound-Node: alln-core-11.cisco.com The change allow to build external modules with nested makefiles. With current unofficial way(using "src" variable) it is posible to build external(out of tree) kernel module with separating source and build artifacts dirs but with nested makefiles it doesn't work properly. Build system trap to recursion inside makefiles, articafts output dir path grow with each iteration until exceed max path len and build failed Providing "MO" variable and using "override" directive with declaring "src" variable solve the problem Usage example: make -C KERNEL_SOURCE_TREE MO=BUILD_OUT_DIR M=EXT_MOD_SRC_DIR modules Cc: xe-linux-external@cisco.com Cc: Valerii Chernous Signed-off-by: Valerii Chernous --- Makefile | 17 +++++++++++++++++ scripts/Makefile.build | 7 +++++++ 2 files changed, 24 insertions(+) diff --git a/Makefile b/Makefile index 4bef6323c47d..5858708d357c 100644 --- a/Makefile +++ b/Makefile @@ -142,6 +142,7 @@ ifeq ("$(origin M)", "command line") KBUILD_EXTMOD := $(M) endif +define kbuild_extmod_check_TEMPLATE $(if $(word 2, $(KBUILD_EXTMOD)), \ $(error building multiple external modules is not supported)) @@ -152,9 +153,25 @@ $(foreach x, % :, $(if $(findstring $x, $(KBUILD_EXTMOD)), \ ifneq ($(filter %/, $(KBUILD_EXTMOD)),) KBUILD_EXTMOD := $(shell dirname $(KBUILD_EXTMOD).) endif +endef +$(eval $(call kbuild_extmod_check_TEMPLATE)) export KBUILD_EXTMOD +# Use make M=src_dir MO=ko_dir or set the environment variables: +# KBUILD_EXTMOD_SRC, KBUILD_EXTMOD to specify separate directories of +# external module sources and build artifacts. +ifeq ("$(origin MO)", "command line") +ifeq (KBUILD_EXTMOD,) + $(error Ext module objects without module sources is not supported)) +endif +KBUILD_EXTMOD_SRC := $(KBUILD_EXTMOD) +KBUILD_EXTMOD := $(MO) +$(eval $(call kbuild_extmod_check_TEMPLATE)) +endif + +export KBUILD_EXTMOD_SRC + # backward compatibility KBUILD_EXTRA_WARN ?= $(KBUILD_ENABLE_EXTRA_GCC_CHECKS) diff --git a/scripts/Makefile.build b/scripts/Makefile.build index baf86c0880b6..a293950e2e07 100644 --- a/scripts/Makefile.build +++ b/scripts/Makefile.build @@ -3,7 +3,14 @@ # Building # ========================================================================== +ifeq ($(KBUILD_EXTMOD_SRC),) src := $(obj) +else ifeq ($(KBUILD_EXTMOD),$(obj)) +override src := $(KBUILD_EXTMOD_SRC) +else +src_subdir := $(patsubst $(KBUILD_EXTMOD)/%,%,$(obj)) +override src := $(KBUILD_EXTMOD_SRC)/$(src_subdir) +endif PHONY := $(obj)/ $(obj)/: -- 2.35.6