From patchwork Tue Jul 2 21:58:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Brian Norris X-Patchwork-Id: 13720366 Received: from mail-pl1-f172.google.com (mail-pl1-f172.google.com [209.85.214.172]) (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 E14611B11EE for ; Tue, 2 Jul 2024 21:59:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719957544; cv=none; b=aoubYRVoWdg77adA46ohrmx/vGgrLPx1TqHHQJMG+Ad4rpSZrz5GFKnBOk7OgwQzZZXtKxhw22QeeG5JXgTbbxgrO/D3KKrK99Jc1NV8MHR13sqfmxDErk7xDCHnV9pqKAS+l7BXAstNjw+bHEsRugenWzADzZ0zkaIkqfijOaI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719957544; c=relaxed/simple; bh=hRx/V3N1tOC03q/ejC+f/u6Teuj3+AZz0SNmbH3aP+Q=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=aaSpNSzIvlMwSMMh564wsxOTVw5hbNnciw83SOE/Vn+/oRbEf7DpAqntyMssRAOhdlwmuhFMkR5VfTMTFwmAHigmiUxvLWbwH6+/coJ03nFLNTPbnkOU1+qe7+MS9ZRhTz3C8Q85A2aREYDOqc//KHr8dM0J3Rt4U/rUpi8mmIU= 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=P61IpjSp; arc=none smtp.client-ip=209.85.214.172 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="P61IpjSp" Received: by mail-pl1-f172.google.com with SMTP id d9443c01a7336-1f480624d10so35394185ad.1 for ; Tue, 02 Jul 2024 14:59:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1719957542; x=1720562342; 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=MS62etFpIYNGMrGCK000i0PIRfNlj81mNm/Gs9qD5BY=; b=P61IpjSpNrFO4Mhe/vSPn+HYxWf9wzZff49NXuEIUmGW8tYmt6z7T1ohloU+Dpcz2J P0trfgxN/r38uwvtDsJiLTdvgssqJahaJV3tCi9neHYRY3gyTPhve2SsCXivLBnJJRSu HnVKMUrzsSdDkh5ORdc/9HLXWyaOOXjY2wa1k= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719957542; x=1720562342; 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=MS62etFpIYNGMrGCK000i0PIRfNlj81mNm/Gs9qD5BY=; b=rCSNQH5u8zhdj7BV6SNabiIOXvC/biHI6Uh1F1i0AhbmdGZ4QSKSUa8OJmmNo8qW0o HfVpT20EEObiEq4n610QZgyOMqQIzBh6Gu4CMw1kO8L5H7nmZJ6jZGI9SJyJCMrBM7QH SE7vGBTYsB2aKVpZqKLveNoKPiZ/4j16mf31/zmYRIUARLRKT5FVebsIphc+zccUeD0/ 3a4hOX0WYohXWlP6g4LuQsczY9kCGyAwFMMbwrf9b7rMDz8EvByRY9YFAZsv+xb+2S23 Zrmvgo0j8V/lQ8O8Vh07s+I67032j/J6Oo/XGjdpTs2kJcM0Y7BiOQBG51hMso40fKp3 XQag== X-Forwarded-Encrypted: i=1; AJvYcCVrE+OjHLfqn1N2dEsAGf03vgIuNaaQSvq8AuuzvB47DEabjR/EvkiE9Qg+3e+y62JoGahMF5atuPVZTcx6KPJDZ/NG X-Gm-Message-State: AOJu0YyAvPzr4ILc5IN3S9r3EAyaKxCIIJCoZP4Fn/5X7fkJQh0RXhhY ekg+APUEFJbBkePp6T6swYy844e5PC5hMt8Dv2FF9UVofIYBzKvVejOJPjX1bg== X-Google-Smtp-Source: AGHT+IGhBHTd3UcyBZmHUjgYyT7fXHIhXEIAs1XDCCOIAV7kEK6DLojlLX7aVDeHN+pn1Pb84Pk4hA== X-Received: by 2002:a17:903:11c4:b0:1fa:ff88:8914 with SMTP id d9443c01a7336-1faff8890ccmr18873025ad.35.1719957542207; Tue, 02 Jul 2024 14:59:02 -0700 (PDT) Received: from localhost ([2620:15c:9d:2:5fa9:4b10:46fe:4740]) by smtp.gmail.com with UTF8SMTPSA id d9443c01a7336-1fac10d1498sm89565205ad.8.2024.07.02.14.59.01 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 02 Jul 2024 14:59:01 -0700 (PDT) From: Brian Norris To: Arnaldo Carvalho de Melo , Namhyung Kim , Ian Rogers , Thomas Richter , Josh Poimboeuf , Peter Zijlstra Cc: Masahiro Yamada , bpf@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kbuild@vger.kernel.org, Brian Norris Subject: [PATCH v2 1/3] tools build: Correct libsubcmd fixdep dependencies Date: Tue, 2 Jul 2024 14:58:37 -0700 Message-ID: <20240702215854.408532-2-briannorris@chromium.org> X-Mailer: git-send-email 2.45.2.803.g4e1b14247a-goog In-Reply-To: <20240702215854.408532-1-briannorris@chromium.org> References: <20240702215854.408532-1-briannorris@chromium.org> Precedence: bulk X-Mailing-List: bpf@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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. [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. 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 --- (no changes since v1) 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 all: fixdep $(LIBFILE) -$(SUBCMD_IN): FORCE +$(SUBCMD_IN): fixdep FORCE @$(MAKE) $(build)=libsubcmd $(LIBFILE): $(SUBCMD_IN) From patchwork Tue Jul 2 21:58:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Brian Norris X-Patchwork-Id: 13720367 Received: from mail-pl1-f177.google.com (mail-pl1-f177.google.com [209.85.214.177]) (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 8B5B020FAB1 for ; Tue, 2 Jul 2024 21:59:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.177 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719957546; cv=none; b=X6xyJJAzDkEMxYc6yDfP97FUJNrfKCXveuBEn1WBe0fxj9glbOksCVnC3w5mu29G+CUm1H0KInCPIUsBOKyS3exnLBDSaChVkKahq4iaRTKlozrgbLEU1yzVz7AiKJcRHOatH23Q9jv077ypgqEXUOxV20Lq1E9EIcY+vtP7fFA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719957546; c=relaxed/simple; bh=Yzpg2+WaoEbAF5iByFWp49UVOXwrxjOWqhpGJSHXybE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=W0pgGtl3FyF7aOVDVsS3ncmsrM++qpmATGYCmNZO7wflm/otpNgbuBtu9scCptHi891M9WC0Mr2RI4vHmEw5xlxCfJUR2xxHp8Wf9YF3400XjUGjE+p+o6YR6qJCXoH4KUsp2Nsz2vMokKjPTfIyKcHF5op7r6txlIGqeNv+6+o= 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=O21kfWY4; arc=none smtp.client-ip=209.85.214.177 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="O21kfWY4" Received: by mail-pl1-f177.google.com with SMTP id d9443c01a7336-1fa3bdd91c1so35844895ad.2 for ; Tue, 02 Jul 2024 14:59:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1719957544; x=1720562344; 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=Gsj73O3sDeXJFSaK3K7S5NYYn9jtEt42KkD9vbFcQHE=; b=O21kfWY4z6hOwUJq1WjZjgGCw2SBMJ8S3uXQf4t8bptDEYBOLqpcstscPA0o5g9C04 hl35t6CKwAwfiX2yOF2rVgdN48hDrQSn9cmOHKunlwQt07aQVeFbhGgrdBEDBkBIP/4m mpvEKXuBJStmGaigIel0nPgjtLgyrHUE60JXk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719957544; x=1720562344; 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=Gsj73O3sDeXJFSaK3K7S5NYYn9jtEt42KkD9vbFcQHE=; b=XXYiIBsjYhCVxlAXCa9t1+8qhS4le5e4omset4YQDCR81WKBwKbr20FGbRDwzCNAH1 8b/+23BtMpIS2BzE85ykJ5YfMtrJLIH0vCaP97/1AARh+Ew70yCW7oL3VaFzxQXO5wod ioyjFpR6MJfH/u3ANPHvn0OOI1nZG4bP8FfdkCetx80uMdpaNukMDRAqsJsXsl++KM6J /bbbdXORyUVjbjZo/B/44BDDjLk2gutw2psOaYNaOIKcNbpybwQCVIThcSc88mpU3wG2 A+UzQ2dnb9u857nSzw3Oh3bgVtD1woE1ljGk/9saOPyQlqxOzuvmtVSKrEKS/+hNozHy /3VQ== X-Forwarded-Encrypted: i=1; AJvYcCUmbTTvvUCE14j7e8IX2wTE5NwfJb3C4OOj6+Y86ytb/G7lvPsAbaPNDryQMZluD/ionHwh5LRvb1Tg+m6l/BuagyNd X-Gm-Message-State: AOJu0Yw/V8zvGHLFuJyb1Eq2fhccr+xK2NmiKPObxHOiLw5c6QWrmBMm YyMnGWzi53sYVNtEql7YFOie8scPPxrS9CLRMfmQTHhK09GIjv3+0FzWn1vOTw== X-Google-Smtp-Source: AGHT+IFcvyCQMP70a54FiUECjL3zy54tvMT4fzePzLGfeDFAcPS+TNQEst+rANMcYK6YnMwgQVENjA== X-Received: by 2002:a17:902:c942:b0:1fa:d319:e0ae with SMTP id d9443c01a7336-1fadbce6a64mr115401435ad.51.1719957543897; Tue, 02 Jul 2024 14:59:03 -0700 (PDT) Received: from localhost ([2620:15c:9d:2:5fa9:4b10:46fe:4740]) by smtp.gmail.com with UTF8SMTPSA id d9443c01a7336-1fb14faa1ddsm946665ad.17.2024.07.02.14.59.02 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 02 Jul 2024 14:59:03 -0700 (PDT) From: Brian Norris To: Arnaldo Carvalho de Melo , Namhyung Kim , Ian Rogers , Thomas Richter , Josh Poimboeuf , Peter Zijlstra Cc: Masahiro Yamada , bpf@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kbuild@vger.kernel.org, Brian Norris Subject: [PATCH v2 2/3] tools build: Avoid circular .fixdep-in.o.cmd issues Date: Tue, 2 Jul 2024 14:58:38 -0700 Message-ID: <20240702215854.408532-3-briannorris@chromium.org> X-Mailer: git-send-email 2.45.2.803.g4e1b14247a-goog In-Reply-To: <20240702215854.408532-1-briannorris@chromium.org> References: <20240702215854.408532-1-briannorris@chromium.org> Precedence: bulk X-Mailing-List: bpf@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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 --- (no changes since v1) tools/build/Makefile | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) 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=$(TMP_O) clean >/dev/null endif -$(OUTPUT)fixdep-in.o: FORCE - $(Q)$(MAKE) $(build)=fixdep - -$(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 $@ $< From patchwork Tue Jul 2 21:58:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Brian Norris X-Patchwork-Id: 13720368 X-Patchwork-Delegate: bpf@iogearbox.net Received: from mail-pg1-f180.google.com (mail-pg1-f180.google.com [209.85.215.180]) (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 ABF0E1C0939 for ; Tue, 2 Jul 2024 21:59:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.180 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719957548; cv=none; b=Mna1aiqZDK5WjMGgwLWjqc/5k1j3wm3MlwxZOaVe1fQRNZt4Ejt0nygr9BZIKtW75RJ1g9lqXOG+yNkdtmOopJmq4Ilg9OFXalXiTkAyv7640S5KhyWFxHK8MF9VgT6+DqkAdUBkNhoC11qtdp+i8jvubEfjSjSi6pbQRfB7XFE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719957548; c=relaxed/simple; bh=KS6v5h2TMxV5p5idCDDKxL5D9ipXivXxl0yGY6wRk5k=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=agLAbvxPU9FXaYRPIbJxyOJO0E7U3nSVbFzvmDKNbU6EB99rnMYBZnxrNBew2wlEOPFEOWbnNETyswe+xuFGFl+TjLjMqGPIVm6k8Mth4sKhRKDfC0vyRGP3cXMWkAXOyq3+SDTHlQmg3LJNpDE6ubFclWPfecPlmCGvCyosTXo= 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=llkhDD92; arc=none smtp.client-ip=209.85.215.180 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="llkhDD92" Received: by mail-pg1-f180.google.com with SMTP id 41be03b00d2f7-7276c331f78so17762a12.0 for ; Tue, 02 Jul 2024 14:59:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1719957546; x=1720562346; 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=XaROXC68GNyaX4Dj5ZGqXjQP0U0kBkL9jho+BZ7xcjY=; b=llkhDD9289OvZvEm6UOR8hFnxssZxsWHbMXwCUkB50MMIAmep75hkV/Hd6bpKKG9sj s/MaPzqE4E7upg5DEG3Pq7BgHfQSf+AC++DtO1+wu4+RBHfjyYoblOJNWlpzw8xqmxRc NV8I6xtY4oKkYfsX7+tl6BKxagL1b+ozroIDA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719957546; x=1720562346; 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=XaROXC68GNyaX4Dj5ZGqXjQP0U0kBkL9jho+BZ7xcjY=; b=aAAr6S5/8K2RBumf4+zwofkTXq+vY3I6+dFyXCWOom3Ci2DsVUiDBPmZCnk60+HRAM g5MGhBTyV7ChsQGexLOx70PjYdydfFFf8Qit2cZ9fnHs5NT/vJUb/acMQfjHWXLu5pIn YBXhPynKEVJEdb3xUHz+I/vExoSz0smQifDoK6a9ApdaMy9HAfua4VuausumsRHGEs7s 41PCNkVCz6Ww8WqRqbV56GHzu6h+KHfdrbeHc1B1jpzqddjR487aQj6d7LQ+MAGN51jX ZCj/eajemjgx16wXvo+H9z6NlW4J6y9fb3ZfNuFHo/8lf5/NWbAiZlO7fYAeJWFWHGar nDpQ== X-Forwarded-Encrypted: i=1; AJvYcCWwB0HnFa4Nwo+Qi6dVRj1PFDTLNqYcDfiUL1uxkVxEzScwAe8GCcQqJq3jatD94AeyPSOFKTzL2Nq1ZHzYTM5TXKcr X-Gm-Message-State: AOJu0YxuSnPuWazWzl5+ncn1gzwO/FL5DkSkxvpLkfcTp9IjDgS51xPY ESyjCguDxXtRRSAuE5Y/f7pNGK6vdlejFPnO6vgoFj1EWIz8hdl9F+DgdClTyQ== X-Google-Smtp-Source: AGHT+IH2/m6EIFOLSLhgMDsvvUV/sVJEQ8WwfSylFVNaQ8sawGIDNdYdzlJnCUgCZbHRviLXsCiLow== X-Received: by 2002:a17:90a:c912:b0:2c9:36bf:ba6f with SMTP id 98e67ed59e1d1-2c93d186753mr15586471a91.3.1719957545989; Tue, 02 Jul 2024 14:59:05 -0700 (PDT) Received: from localhost ([2620:15c:9d:2:5fa9:4b10:46fe:4740]) by smtp.gmail.com with UTF8SMTPSA id 98e67ed59e1d1-2c91c7df8b0sm9517429a91.0.2024.07.02.14.59.04 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 02 Jul 2024 14:59:05 -0700 (PDT) From: Brian Norris To: Arnaldo Carvalho de Melo , Namhyung Kim , Ian Rogers , Thomas Richter , Josh Poimboeuf , Peter Zijlstra Cc: Masahiro Yamada , bpf@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kbuild@vger.kernel.org, Brian Norris Subject: [PATCH v2 3/3] tools build: Correct bpf fixdep dependencies Date: Tue, 2 Jul 2024 14:58:39 -0700 Message-ID: <20240702215854.408532-4-briannorris@chromium.org> X-Mailer: git-send-email 2.45.2.803.g4e1b14247a-goog In-Reply-To: <20240702215854.408532-1-briannorris@chromium.org> References: <20240702215854.408532-1-briannorris@chromium.org> Precedence: bulk X-Mailing-List: bpf@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: bpf@iogearbox.net 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 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 := -f $(srctree)/tools/build/Makefile.build dir=. obj +# More than just $(Q), we sometimes want to suppress all command output from a +# recursive make -- even the 'up to date' printout. +ifeq ($(V),1) + Q ?= + SILENT_MAKE = +$(Q)$(MAKE) +else + Q ?= @ + SILENT_MAKE = +$(Q)$(MAKE) --silent +endif + fixdep: - $(Q)$(MAKE) -C $(srctree)/tools/build CFLAGS= LDFLAGS= $(OUTPUT)fixdep + $(SILENT_MAKE) -C $(srctree)/tools/build CFLAGS= LDFLAGS= $(OUTPUT)fixdep 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= all: +OUTPUT ?= ./ +OUTPUT := $(abspath $(OUTPUT))/ export srctree OUTPUT CC LD CFLAGS V include $(srctree)/tools/build/Makefile.include @@ -141,7 +143,13 @@ all: fixdep all_cmd: $(CMD_TARGETS) check -$(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/linux/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' differs 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/linux/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' differs from latest version at 'include/uapi/linux/if_xdp.h'" >&2 )) || true + $(SILENT_MAKE) -C $(srctree)/tools/build CFLAGS= LDFLAGS= OUTPUT=$(SHARED_OBJDIR) $(SHARED_OBJDIR)fixdep $(Q)$(MAKE) $(build)=libbpf OUTPUT=$(SHARED_OBJDIR) CFLAGS="$(CFLAGS) $(SHLIB_FLAGS)" -$(BPF_IN_STATIC): force $(BPF_GENERATED) +$(BPF_IN_STATIC): force $(BPF_GENERATED) | $(STATIC_OBJDIR) + $(SILENT_MAKE) -C $(srctree)/tools/build CFLAGS= LDFLAGS= OUTPUT=$(STATIC_OBJDIR) $(STATIC_OBJDIR)fixdep $(Q)$(MAKE) $(build)=libbpf OUTPUT=$(STATIC_OBJDIR) $(BPF_HELPER_DEFS): $(srctree)/tools/include/uapi/linux/bpf.h