From nobody Wed Dec 17 13:56:57 2025 Received: from mail-pl1-f170.google.com (mail-pl1-f170.google.com [209.85.214.170]) (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 2452E187855 for ; Tue, 9 Jul 2024 20:42:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.170 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720557776; cv=none; b=mHpEZn9cTmAjF2FkRt8Kn84QxVJnHyquvsmXR0tAHFOguVRGqzc0w24xRdVkaxD0ENldLZcWMNw/rKw1fRievAzvZxpy2xn310JIHUQROLOT6cI4lv5+yqW2QojhGZrqk0/1hccR0rKvhGNNXzBOAyqNkcsKt5aKquJ6w+G8jAU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720557776; c=relaxed/simple; bh=m43Go+o+Pj5R7eJEh0tWSFmc/0HGU7llEtpxq/+VOrs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=u0ARwanS2lq55upeXsuqcNS9neFQvQEz7L0OVfJXP711u/q29WZFWCAXKjVtT+aBS1EThigTJSVqaQ1qQu7CwQu2fz2O8JucRZNUCkjbp+prOzJOyIxqPn6AI4PSk38Q2nfZ1D62j3TuEK1OAigqW/Ire7uDAcHYMKvdfVdqv64= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org; spf=pass smtp.mailfrom=chromium.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b=EL8ihX/j; arc=none smtp.client-ip=209.85.214.170 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=chromium.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="EL8ihX/j" Received: by mail-pl1-f170.google.com with SMTP id d9443c01a7336-1fb53bfb6easo25519915ad.2 for ; Tue, 09 Jul 2024 13:42:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1720557771; x=1721162571; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=75e49adwmjRLWz6oRihBwJMsEfi0gMyYpXT0nKz58WE=; b=EL8ihX/jl4OIlf1HxUi9iBPD48LC0Kv9qEkhwTIF6ZxSaWpjaIa86pV8VePJ0n/Nr7 pk+RwUi1GQ3l6mI+PO9hAdbMSg8AjWpx7K4z846YCpX7GfBhYcjzSejYgTUNwo2DCRUR qAXYxApCwPZaH+oj5yw2uHsK2B7rv2RDtEKWA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720557771; x=1721162571; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=75e49adwmjRLWz6oRihBwJMsEfi0gMyYpXT0nKz58WE=; b=BpKG537CWv2qtVmie6Z/hYZ02tglALGgeSQj1aLcfh1qU3wbsXkqygaCjZw2awgt8F wq5Kee1irbl3cPLPA1ZCwDeV16vA5qe46jUaXb97uo2NAai7VA0nDPPrgfhgfAIpLTHF BlJeqXYxV2k9rD8K1Xex/86yeSRcJzgEIoSZSBkiJoukKucjWvgsvmChpO2eiY1shXrS TPg3bxsCG8fh+TX/ENpc3RccLRvk6i0a+2STPThonRxTlu/14rS+ach3VILzyBSLVA9X Y8YDgHF9jGFRKrOzUAbFf1RrD1Spe0ksbfxdqiyd47PyJI3ExVM6IlrPGhwx+3sWyU3Q LwYA== X-Forwarded-Encrypted: i=1; AJvYcCXmhIMsjLtLs8ob7+7jHsRr+RXNvMl8ONthsR6i2UPPRSpGruovw8l1jtT/dxdVZz7vZ60spvlfDFvLvWSe3OEaRcz0IujWpiKNCG5N X-Gm-Message-State: AOJu0YxJPcD+xvpyuNvIzMZ7jTGrllOOMVJDXT0RaGErIrD/d6YfucTH WUqkCFSHpgJ4mf7qw6kDpMkxwMgdGQaj5g0o+ppTVvNMPNuN+ppNuqutoo/wkzjCv7dDvpPiWWY = X-Google-Smtp-Source: AGHT+IHq8Lmie4abV8IlHVeSZdomvTKvmBTUZFcQoOFOag8g4wqstmW7lVGP15ODIy8EDSDtff8HYA== X-Received: by 2002:a17:902:e74b:b0:1fb:4a8e:7673 with SMTP id d9443c01a7336-1fbb6ec4f06mr30123935ad.68.1720557771337; Tue, 09 Jul 2024 13:42:51 -0700 (PDT) Received: from localhost ([2620:15c:9d:2:4d59:98c6:8095:9b12]) by smtp.gmail.com with UTF8SMTPSA id d9443c01a7336-1fbb6ad52d1sm20204195ad.305.2024.07.09.13.42.50 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 09 Jul 2024 13:42:51 -0700 (PDT) From: Brian Norris To: Arnaldo Carvalho de Melo , Namhyung Kim , Ian Rogers , Thomas Richter , Josh Poimboeuf , Peter Zijlstra Cc: linux-kbuild@vger.kernel.org, linux-kernel@vger.kernel.org, bpf@vger.kernel.org, Masahiro Yamada , Brian Norris , Jiri Olsa Subject: [PATCH v3 1/3] tools build: Correct libsubcmd fixdep dependencies Date: Tue, 9 Jul 2024 13:41:51 -0700 Message-ID: <20240709204203.1481851-2-briannorris@chromium.org> X-Mailer: git-send-email 2.45.2.803.g4e1b14247a-goog In-Reply-To: <20240709204203.1481851-1-briannorris@chromium.org> References: <20240709204203.1481851-1-briannorris@chromium.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" All built targets need fixdep to be built first, before handling object dependencies [1]. We're missing one such dependency before the libsubcmd target. This resolves .cmd file generation issues such that the following sequence produces many fewer results: $ git clean -xfd tools/ $ make tools/objtool $ grep "cannot find fixdep" $(find tools/objtool -name '*.cmd') In particular, only a buggy tools/objtool/libsubcmd/.fixdep.o.cmd remains, due to circular dependencies of fixdep on itself. Such incomplete .cmd files don't usually cause a direct problem, since they're designed to fail "open", but they can cause some subtle problems that would otherwise be handled by proper fixdep'd dependency files. [2] [1] This problem is better described in commit abb26210a395 ("perf tools: Force fixdep compilation at the start of the build"). I don't apply its solution here, because additional recursive make can be a bit of overkill. [2] Example failure case: cp -arl linux-src linux-src2 cd linux-src2 make O=3D/path/to/out cd ../linux-src rm -rf ../linux-src2 make O=3D/path/to/out Previously, we'd see errors like: make[6]: *** No rule to make target '/path/to/linux-src2/tools/include/linux/compiler.h', needed by '/path/to/out/tools/bpf/resolve_btfids/libsubcmd/exec-cmd.o'. Stop. Now, the properly-fixdep'd .cmd files will ignore a missing /path/to/linux-src2/... Link: https://lore.kernel.org/all/ZGVi9HbI43R5trN8@bhelgaas/ Link: https://lore.kernel.org/all/Zk-C5Eg84yt6_nml@google.com/ Signed-off-by: Brian Norris Acked-by: Jiri Olsa --- Changes in v3: - update notes about failure cases - add Jiri's Acked-by tools/lib/subcmd/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/lib/subcmd/Makefile b/tools/lib/subcmd/Makefile index b87213263a5e..59b09f280e49 100644 --- a/tools/lib/subcmd/Makefile +++ b/tools/lib/subcmd/Makefile @@ -76,7 +76,7 @@ include $(srctree)/tools/build/Makefile.include =20 all: fixdep $(LIBFILE) =20 -$(SUBCMD_IN): FORCE +$(SUBCMD_IN): fixdep FORCE @$(MAKE) $(build)=3Dlibsubcmd =20 $(LIBFILE): $(SUBCMD_IN) --=20 2.45.2.803.g4e1b14247a-goog From nobody Wed Dec 17 13:56:57 2025 Received: from mail-pf1-f169.google.com (mail-pf1-f169.google.com [209.85.210.169]) (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 9A1FB18787D for ; Tue, 9 Jul 2024 20:42:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.169 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720557775; cv=none; b=gK8RBx/Byo+g1idare2PR8MuejVt/5PzWnZsYyIxE4pS3yLvDBLjpSARLtQag5aMTf90CL5hS5TFuO/Ls7Gj4FK54OVAkBNd49v5EzpOsjVswJ1tDoqKG9zq/bIVY90T1f6/388WFVuAvgn2cnxRmS4m1rbS4FmvzKmokcNKalE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720557775; c=relaxed/simple; bh=b4hwpR7FcvZtkKTELzGynXekzYR0PusjIfDe9l3TwMQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=mzhhKc/0/Ntd8Yzco91kV7VQdYskIImYbcBVeSxarrBZTtFcx2JGxQsxySlRDhfEG4IWA5O9u816s/p51vVOWU/DZsUSdIyJTfUvIGMK71UcDnJ1ccPkRI/kuji+O07EsI2t82KOq60DMoIaqslP2yDczTxI0L/mMRMrHsK18M4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org; spf=pass smtp.mailfrom=chromium.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b=SsYLTYTl; arc=none smtp.client-ip=209.85.210.169 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=chromium.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="SsYLTYTl" Received: by mail-pf1-f169.google.com with SMTP id d2e1a72fcca58-706524adf91so4488197b3a.2 for ; Tue, 09 Jul 2024 13:42:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1720557773; x=1721162573; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=LiALKlxZPNYSJmF/lhWQ3NpiYNOoFr+vLFcM3ThUmi4=; b=SsYLTYTltLo7sJqvf+mGn6scBSv7f/iHv0jysYQvIsYm+u9Rvhy+4I9birjmvY7mzH lNzOZCAknKmPnhQdwaWmJDsOkt41/G2vp+Uyluy43CvcvTF28v4T+xDUfo5au5hnBRmz Mhkzp+OKA1tuexMSnT6395/rAJMHod35VL+44= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720557773; x=1721162573; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=LiALKlxZPNYSJmF/lhWQ3NpiYNOoFr+vLFcM3ThUmi4=; b=Pzj2af3WI0b+mhhNul67Bha6VxyE70Sfdk1JbNfXvpVYtDQIpLOGxNKI8196UYdhKu DgybWhkDA/uGLmKMYGqM8tJsJgHEgP7dYv2CyEAQvu0A0TRVt5fYPOL3C14hfnejInYK 4r0/SPwACxrnL4Im/ED68fZcEoE/LCF0ba6qxP/7Y8rw38y4+oOsw1RTsbAAoFa+fjTU qSqZnDC+Q7+mWqnHTWkMbFWxzEUD5hA040joP1UtQphfrbfI4g8HzoHc8BFe3kozOaln vde0aOlvL/noaKP+jzHlAgxLcfo/SIKY46T1wfN+emNEUw+04VXd1Zu9qIN5eVHmVGM/ eltw== X-Forwarded-Encrypted: i=1; AJvYcCUpRNDeT4yvXpKIfPsxjz1ruqJAu6Hpchgu6w22C7TDptfk3LJCGW1Tm1wrpUyLcZFmbTCNHuaVeqrwGezA4JQl/HlGInLERaESGVlf X-Gm-Message-State: AOJu0YzHl4KO+nahgVJecBMduyIUVlN4Co/NBzzKtER30uhoJTmYG6+A au4IIj0MdNa+pv09etrfNv5CLx+1bk+ez1hOVBZvdFczCU2zuzATBktXXkiS/A== X-Google-Smtp-Source: AGHT+IFk1ZoJ/7py9bvsFpMRs4pPRa9BdumrqhYcFo1TH7FtyYfUYmo7l+dHmIHLVhnPJz5rO/9wdA== X-Received: by 2002:a05:6a20:6a0f:b0:1be:c4bb:6f31 with SMTP id adf61e73a8af0-1c2982233cdmr4577298637.18.1720557772993; Tue, 09 Jul 2024 13:42:52 -0700 (PDT) Received: from localhost ([2620:15c:9d:2:4d59:98c6:8095:9b12]) by smtp.gmail.com with UTF8SMTPSA id d2e1a72fcca58-70b4389c175sm2345131b3a.12.2024.07.09.13.42.52 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 09 Jul 2024 13:42:52 -0700 (PDT) From: Brian Norris To: Arnaldo Carvalho de Melo , Namhyung Kim , Ian Rogers , Thomas Richter , Josh Poimboeuf , Peter Zijlstra Cc: linux-kbuild@vger.kernel.org, linux-kernel@vger.kernel.org, bpf@vger.kernel.org, Masahiro Yamada , Brian Norris Subject: [PATCH v3 2/3] tools build: Avoid circular .fixdep-in.o.cmd issues Date: Tue, 9 Jul 2024 13:41:52 -0700 Message-ID: <20240709204203.1481851-3-briannorris@chromium.org> X-Mailer: git-send-email 2.45.2.803.g4e1b14247a-goog In-Reply-To: <20240709204203.1481851-1-briannorris@chromium.org> References: <20240709204203.1481851-1-briannorris@chromium.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The 'fixdep' tool is used to post-process dependency files for various reasons, and it runs after every object file generation command. This even includes 'fixdep' itself. In Kbuild, this isn't actually a problem, because it uses a single command to generate fixdep (a compile-and-link command on fixdep.c), and afterward runs the fixdep command on the accompanying .fixdep.cmd file. In tools/ builds (which notably is maintained separately from Kbuild), fixdep is generated in several phases: 1. fixdep.c -> fixdep-in.o 2. fixdep-in.o -> fixdep Thus, fixdep is not available in the post-processing for step 1, and instead, we generate .cmd files that look like: ## from tools/objtool/libsubcmd/.fixdep.o.cmd # cannot find fixdep (/path/to/linux/tools/objtool/libsubcmd//fixdep) [...] These invalid .cmd files are benign in some respects, but cause problems in others (such as the linked reports). Because the tools/ build system is rather complicated in its own right (and pointedly different than Kbuild), I choose to simply open-code the rule for building fixdep, and avoid the recursive-make indirection that produces the problem in the first place. Link: https://lore.kernel.org/all/Zk-C5Eg84yt6_nml@google.com/ Signed-off-by: Brian Norris --- Changes in v3: - Drop unnecessary tools/build/Build tools/build/Build | 3 --- tools/build/Makefile | 11 ++--------- 2 files changed, 2 insertions(+), 12 deletions(-) delete mode 100644 tools/build/Build diff --git a/tools/build/Build b/tools/build/Build deleted file mode 100644 index 76d1a4960973..000000000000 --- a/tools/build/Build +++ /dev/null @@ -1,3 +0,0 @@ -hostprogs :=3D fixdep - -fixdep-y :=3D fixdep.o diff --git a/tools/build/Makefile b/tools/build/Makefile index 17cdf01e29a0..fea3cf647f5b 100644 --- a/tools/build/Makefile +++ b/tools/build/Makefile @@ -43,12 +43,5 @@ ifneq ($(wildcard $(TMP_O)),) $(Q)$(MAKE) -C feature OUTPUT=3D$(TMP_O) clean >/dev/null endif =20 -$(OUTPUT)fixdep-in.o: FORCE - $(Q)$(MAKE) $(build)=3Dfixdep - -$(OUTPUT)fixdep: $(OUTPUT)fixdep-in.o - $(QUIET_LINK)$(HOSTCC) $(KBUILD_HOSTLDFLAGS) -o $@ $< - -FORCE: - -.PHONY: FORCE +$(OUTPUT)fixdep: $(srctree)/tools/build/fixdep.c + $(QUIET_CC)$(HOSTCC) $(KBUILD_HOSTLDFLAGS) -o $@ $< --=20 2.45.2.803.g4e1b14247a-goog From nobody Wed Dec 17 13:56:57 2025 Received: from mail-pl1-f173.google.com (mail-pl1-f173.google.com [209.85.214.173]) (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 50201189F46 for ; Tue, 9 Jul 2024 20:42:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.173 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720557777; cv=none; b=qQTouuL/jnp02gtOo+l6uN/fuikNg+LC9gatFx+HbZvWvwdZrm92LK7HnNd9lPMPVUm1nxkohvxVMLM5eJ0FeA25j8/kte3fIJ3+1sB5VnjTDL/ERRTNvvXmBmocMjBHGmnH3fqXmlhZ679swnySCtiZGWAQs7kUHdk9uM4+TJA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720557777; c=relaxed/simple; bh=5hJtb8O8aGVuCzIkuDaH1C7eL8jW1PgUZ7H/z2BPSw8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=gv/FqmR41Uc5cd/6LabiTBOJl7kafX9n3vwCaRk03DkuMyvzXm7lVTQFMe2alog3w6WTIK1LwYEIzHA2Nk3qgIBTi/2yjG/SieZO1zO4I/nufDamRn75BWqVZK5EuTSHnpUEZAxXAOPI+X26YjXa4dr/9Dx4eK1QKSEXypDfnjw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org; spf=pass smtp.mailfrom=chromium.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b=V/rDWky3; arc=none smtp.client-ip=209.85.214.173 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=chromium.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="V/rDWky3" Received: by mail-pl1-f173.google.com with SMTP id d9443c01a7336-1fb4a332622so21915345ad.2 for ; Tue, 09 Jul 2024 13:42:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1720557775; x=1721162575; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=b2jCXrLvZIYGuyX7wwzQt98iRS81M5D6rZNTDsiflt0=; b=V/rDWky3NVcNl9fX2hZ8HBmQQ5e2kwGhsheuKWUkN5k1uj+eVyIxQBD0YSRh/NH3yx OCWOp7aqImTKs3Io0bdpAkOu7fsPPKWqcrAhGKSXQ157Imf2QrFFcNlkqPxpdyVylnfL /rvFYkwo2j31mpHwdasyzpwb9r+fXyqNdewe0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720557775; x=1721162575; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=b2jCXrLvZIYGuyX7wwzQt98iRS81M5D6rZNTDsiflt0=; b=BBKQUB/+10/otM59ZptExoq2T7YjJO9FyamvrC1k7VxS+UQREaEQ/Nurr7U+Uz8pTT 855f140s7174oBKbL6FPPx8qEBddzugDA5iMsGru73/vZuw/GT0+8zu+aIk7SgM+gykQ v49bguLwuOVHmmMoDdl/E2oR5UYufNdvO7zDH7Pcq8ZAuN9Z+TK3Ter7Bbu6BlzvFbdu PfpYHnz6sxgtMfqR8EGbSTiJNohUzNBqJEsk4BZyznB5gxWdgCPsaMWWashjwhYtvRTJ nvddNFSl6bF0fowC9CyM5+z/olQJfG2ScoTX0x19vEtOUKCGVDb3uWYW1gnJyU7TvsTR 6Hzg== X-Forwarded-Encrypted: i=1; AJvYcCUhyyJ5wE3Z0XKLWESWlxbAqN+dyauDmbjHWUCQ5xi4eU9pRCvOS4uswcen2BGLF1Fo2kOHNsrHqBTN32VMWmXSpFdnVXAoA+/iKFln X-Gm-Message-State: AOJu0Yznao3ZebezAd6ueh1ennanVW830VOVZN3OdLLqoqvCNus10ypc /xQ8p2xDvt+/JfdUyB1ldnxiCKVW+Q2CXFjwd9rBJsmBg3I7Iz3ABj1JjYfO3g== X-Google-Smtp-Source: AGHT+IHjK3RExiQOmuK3iDTX/Upl24GWjmDes7leC1u1b1/8tRoqtQUBfMBlLxfOsmft2g4mqCkU8A== X-Received: by 2002:a17:903:11ce:b0:1fb:365:5e0 with SMTP id d9443c01a7336-1fbb6d25264mr29004165ad.14.1720557774614; Tue, 09 Jul 2024 13:42:54 -0700 (PDT) Received: from localhost ([2620:15c:9d:2:4d59:98c6:8095:9b12]) by smtp.gmail.com with UTF8SMTPSA id d9443c01a7336-1fbb6ab6c53sm20318625ad.153.2024.07.09.13.42.53 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 09 Jul 2024 13:42:54 -0700 (PDT) From: Brian Norris To: Arnaldo Carvalho de Melo , Namhyung Kim , Ian Rogers , Thomas Richter , Josh Poimboeuf , Peter Zijlstra Cc: linux-kbuild@vger.kernel.org, linux-kernel@vger.kernel.org, bpf@vger.kernel.org, Masahiro Yamada , Brian Norris , Jiri Olsa Subject: [PATCH v3 3/3] tools build: Correct bpf fixdep dependencies Date: Tue, 9 Jul 2024 13:41:53 -0700 Message-ID: <20240709204203.1481851-4-briannorris@chromium.org> X-Mailer: git-send-email 2.45.2.803.g4e1b14247a-goog In-Reply-To: <20240709204203.1481851-1-briannorris@chromium.org> References: <20240709204203.1481851-1-briannorris@chromium.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The dependencies in tools/lib/bpf/Makefile are incorrect. Before we recurse to build $(BPF_IN_STATIC), we need to build its 'fixdep' executable. I can't use the usual shortcut from Makefile.include: : fixdep because its 'fixdep' target relies on $(OUTPUT), and $(OUTPUT) differs in the parent 'make' versus the child 'make' -- so I imitate it via open-coding. I tweak a few $(MAKE) invocations while I'm at it, because 1. I'm adding a new recursive make; and 2. these recursive 'make's print spurious lines about files that are "up to date" (which isn't normally a feature in Kbuild subtargets) or "jobserver not available" (see [1]) I also need to tweak the assignment of the OUTPUT variable, so that relative path builds work. For example, for 'make tools/lib/bpf', OUTPUT is unset, and is usually treated as "cwd" -- but recursive make will change cwd and so OUTPUT has a new meaning. For consistency, I ensure OUTPUT is always an absolute path. And $(Q) gets a backup definition in tools/build/Makefile.include, because Makefile.include is sometimes included without tools/build/Makefile, so the "quiet command" stuff doesn't actually work consistently without it. After this change, top-level builds result in an empty grep result from: $ grep 'cannot find fixdep' $(find tools/ -name '*.cmd') [1] https://www.gnu.org/software/make/manual/html_node/MAKE-Variable.html If we're not using $(MAKE) directly, then we need to use more '+'. Signed-off-by: Brian Norris Acked-by: Jiri Olsa --- Changes in v3: - add Jiri's Acked-by Changes in v2: - also fix libbpf shared library rules - ensure OUTPUT is always set, and always an absolute path - add backup $(Q) definition in tools/build/Makefile.include tools/build/Makefile.include | 12 +++++++++++- tools/lib/bpf/Makefile | 14 ++++++++++++-- 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/tools/build/Makefile.include b/tools/build/Makefile.include index 8dadaa0fbb43..0e4de83400ac 100644 --- a/tools/build/Makefile.include +++ b/tools/build/Makefile.include @@ -1,8 +1,18 @@ # SPDX-License-Identifier: GPL-2.0-only build :=3D -f $(srctree)/tools/build/Makefile.build dir=3D. obj =20 +# More than just $(Q), we sometimes want to suppress all command output fr= om a +# recursive make -- even the 'up to date' printout. +ifeq ($(V),1) + Q ?=3D + SILENT_MAKE =3D +$(Q)$(MAKE) +else + Q ?=3D @ + SILENT_MAKE =3D +$(Q)$(MAKE) --silent +endif + fixdep: - $(Q)$(MAKE) -C $(srctree)/tools/build CFLAGS=3D LDFLAGS=3D $(OUTPUT)fixdep + $(SILENT_MAKE) -C $(srctree)/tools/build CFLAGS=3D LDFLAGS=3D $(OUTPUT)fi= xdep =20 fixdep-clean: $(Q)$(MAKE) -C $(srctree)/tools/build clean diff --git a/tools/lib/bpf/Makefile b/tools/lib/bpf/Makefile index 2cf892774346..630369c0091e 100644 --- a/tools/lib/bpf/Makefile +++ b/tools/lib/bpf/Makefile @@ -108,6 +108,8 @@ MAKEOVERRIDES=3D =20 all: =20 +OUTPUT ?=3D ./ +OUTPUT :=3D $(abspath $(OUTPUT))/ export srctree OUTPUT CC LD CFLAGS V include $(srctree)/tools/build/Makefile.include =20 @@ -141,7 +143,13 @@ all: fixdep =20 all_cmd: $(CMD_TARGETS) check =20 -$(BPF_IN_SHARED): force $(BPF_GENERATED) +$(SHARED_OBJDIR): + $(Q)mkdir -p $@ + +$(STATIC_OBJDIR): + $(Q)mkdir -p $@ + +$(BPF_IN_SHARED): force $(BPF_GENERATED) | $(SHARED_OBJDIR) @(test -f ../../include/uapi/linux/bpf.h -a -f ../../../include/uapi/linu= x/bpf.h && ( \ (diff -B ../../include/uapi/linux/bpf.h ../../../include/uapi/linux/bpf.h= >/dev/null) || \ echo "Warning: Kernel ABI header at 'tools/include/uapi/linux/bpf.h' diff= ers from latest version at 'include/uapi/linux/bpf.h'" >&2 )) || true @@ -151,9 +159,11 @@ $(BPF_IN_SHARED): force $(BPF_GENERATED) @(test -f ../../include/uapi/linux/if_xdp.h -a -f ../../../include/uapi/l= inux/if_xdp.h && ( \ (diff -B ../../include/uapi/linux/if_xdp.h ../../../include/uapi/linux/if= _xdp.h >/dev/null) || \ echo "Warning: Kernel ABI header at 'tools/include/uapi/linux/if_xdp.h' d= iffers from latest version at 'include/uapi/linux/if_xdp.h'" >&2 )) || true + $(SILENT_MAKE) -C $(srctree)/tools/build CFLAGS=3D LDFLAGS=3D OUTPUT=3D$(= SHARED_OBJDIR) $(SHARED_OBJDIR)fixdep $(Q)$(MAKE) $(build)=3Dlibbpf OUTPUT=3D$(SHARED_OBJDIR) CFLAGS=3D"$(CFLAG= S) $(SHLIB_FLAGS)" =20 -$(BPF_IN_STATIC): force $(BPF_GENERATED) +$(BPF_IN_STATIC): force $(BPF_GENERATED) | $(STATIC_OBJDIR) + $(SILENT_MAKE) -C $(srctree)/tools/build CFLAGS=3D LDFLAGS=3D OUTPUT=3D$(= STATIC_OBJDIR) $(STATIC_OBJDIR)fixdep $(Q)$(MAKE) $(build)=3Dlibbpf OUTPUT=3D$(STATIC_OBJDIR) =20 $(BPF_HELPER_DEFS): $(srctree)/tools/include/uapi/linux/bpf.h --=20 2.45.2.803.g4e1b14247a-goog