Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp1070555pxu; Thu, 17 Dec 2020 01:09:07 -0800 (PST) X-Google-Smtp-Source: ABdhPJwWCk+I+7P21wUbV13QUBPzw29UNXTkXMLRNRiLbuOH9DUHnlAqXHibkX5LxS1eqJ8VgFvV X-Received: by 2002:a17:906:1a19:: with SMTP id i25mr33618187ejf.206.1608196147184; Thu, 17 Dec 2020 01:09:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1608196147; cv=none; d=google.com; s=arc-20160816; b=I7UR18wXEhepmJUYBzh+WJL+0YiuLB7Ok8gnqCoOn8qV2zJko5xoiItdWPVVHuSxOB Kwn3MxYAKimTsB/j/uGw1hHxJfIeEmQc39Xf8zYJA3YpX51NcwFRgcGHiCRPjCQdSL8X emw2DiVL75psWaJ+wpwnAtM6w9THkGAx3TirkcGidVekprec/23EgMWjBHWicDeEfKRa 2K56cReqqerYCyx2hvn2irV8LXpSvbIFTK2L1HPq11B083ZViQiHvHIjSl3LoEpYg2Hy Qozh+iIHDMh7T19IaV0g6DfZQ536XQB0k8sE0f3f4N8YJt1+4ebtSYUuHRR9EO87KJew sCRA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=vAO/2/47mbhlLw+965PNTisNKeQzGGv2Q/ZDNBlq8ho=; b=doEvKqyMUW2ojLS6SaW8UaoXMEJyR9Prp8EyzVWMCSCEMAW/4P2JHBpuTXXnO1NVgG zSN4CdSixFQG0U1rjQ0OiK6LRC+tNQAhXMKnE25lv527szz7CtvaYaViRnPGGE+hHnk0 Wv+EV+NfbZ28GX5pfO2yFPAnH8AewM8fdeACOVA86GA3dCo8Ri79OmwhPvhSEcXvErIW +bK4EJrAil1ZDP1Psp7R0Yxw0qA7KwSWNorLnhLvz7TXZzRZWPcwJ1nGngurrDGihhIH pWm6s7vcGkuUoSLQexPL//sdf/Ul3O9ymXd6X0KY9kDe9lNtAXLRW2AnZGBKXojwXyIL sOGg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b="ug3HU0/B"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id c12si2241634ejb.751.2020.12.17.01.08.43; Thu, 17 Dec 2020 01:09:07 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b="ug3HU0/B"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725871AbgLQJG4 (ORCPT + 99 others); Thu, 17 Dec 2020 04:06:56 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42974 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726259AbgLQJGz (ORCPT ); Thu, 17 Dec 2020 04:06:55 -0500 Received: from mail-lf1-x135.google.com (mail-lf1-x135.google.com [IPv6:2a00:1450:4864:20::135]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9B534C061282 for ; Thu, 17 Dec 2020 01:06:14 -0800 (PST) Received: by mail-lf1-x135.google.com with SMTP id h205so11967745lfd.5 for ; Thu, 17 Dec 2020 01:06:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=vAO/2/47mbhlLw+965PNTisNKeQzGGv2Q/ZDNBlq8ho=; b=ug3HU0/BD5jHUI6DBI3tUcGDLe5Vi0dADf7CQjmuw/ZLMEvO78n6LoGbJVJ9/LH/oY 02XfSpETFlVPf2/TuFtgteUxWs4gqgZd8XpPPXZqFJ+3W7fYS2Mo4+z/BVYuNpus6vtz pyZo35hXAxYxPKHwOWQEa28G/ws1llfu1/sO/dgTA2sCj2CHq+PjFNtbH5wP9b92HQTt CUhhGqnd82VO3vyy5jObExl/xwXUQsiT+DVOkAQGGLq1JmbCb+tOKMnYVsNUdxnvshLX AD/iJCQ8RHOTiwU9+j7lRaeJCvbkpPvketTDkElKJfk82Cv9xmcLl4GgDQXxLVZm4TIP EXfw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=vAO/2/47mbhlLw+965PNTisNKeQzGGv2Q/ZDNBlq8ho=; b=J50nZRO2wu1ijKnZV3SffQmCYlfQ8y8OY+nsS8GRpMBp2N6MSYaDEr89LT1NUJb1mu iNVSvsXcHz7o7NmqcXyyKMcKV8LXqKGwIgtCa1knGldIkPgHk2TOKs7pq3IJRM6Rp5JG 9jnxeyn81eeR8wRGD/0CqZ4wJYqztheEU2lem2xd9eh+LDJ5AiRfNonA1XzxYOPobTsh 2nPt959BDL0aFXldn/0HDhCuP64xatTF+WQ3Hh88euJv+P3Tz2/SfaZhmH92A9rycwlP YwR4MUEKuTlpDfs7dODvMQCKv5UXb0w8Snm1wVZn8bCHr12X+7n97yr9d9noTAxB0YKA 5LZA== X-Gm-Message-State: AOAM530JuSW3t8JBfXpv70dnABUwu8yg8CScMOEP3qg0PwQIpyHR6Y/6 0x5sGOpCrqaEWupHKdHmvlxOJb6CIagtKeQ7KKi9Pw== X-Received: by 2002:a05:6512:30a:: with SMTP id t10mr911692lfp.124.1608195972094; Thu, 17 Dec 2020 01:06:12 -0800 (PST) MIME-Version: 1.0 References: <20201119085022.3606135-1-davidgow@google.com> <3678c6eb-3815-a360-f495-fc246513f0f5@isovalent.com> In-Reply-To: <3678c6eb-3815-a360-f495-fc246513f0f5@isovalent.com> From: David Gow Date: Thu, 17 Dec 2020 17:05:59 +0800 Message-ID: Subject: Re: [RFC PATCH] bpf: preload: Fix build error when O= is set To: Quentin Monnet Cc: Andrii Nakryiko , Alexei Starovoitov , Daniel Borkmann , =?UTF-8?B?VG9rZSBIw7hpbGFuZC1Kw7hyZ2Vuc2Vu?= , Networking , bpf , open list , Brendan Higgins , Masami Hiramatsu , linux-um Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Dec 16, 2020 at 10:53 PM Quentin Monnet wrote: > > 2020-11-21 17:48 UTC+0800 ~ David Gow > > On Sat, Nov 21, 2020 at 3:38 PM Andrii Nakryiko > > wrote: > >> > >> On Thu, Nov 19, 2020 at 12:51 AM David Gow wrote: > >>> > >>> If BPF_PRELOAD is enabled, and an out-of-tree build is requested with > >>> make O=, compilation seems to fail with: > >>> > >>> tools/scripts/Makefile.include:4: *** O=.kunit does not exist. Stop. > >>> make[4]: *** [../kernel/bpf/preload/Makefile:8: kernel/bpf/preload/libbpf.a] Error 2 > >>> make[3]: *** [../scripts/Makefile.build:500: kernel/bpf/preload] Error 2 > >>> make[2]: *** [../scripts/Makefile.build:500: kernel/bpf] Error 2 > >>> make[2]: *** Waiting for unfinished jobs.... > >>> make[1]: *** [.../Makefile:1799: kernel] Error 2 > >>> make[1]: *** Waiting for unfinished jobs.... > >>> make: *** [Makefile:185: __sub-make] Error 2 > >>> > >>> By the looks of things, this is because the (relative path) O= passed on > >>> the command line is being passed to the libbpf Makefile, which then > >>> can't find the directory. Given OUTPUT= is being passed anyway, we can > >>> work around this by explicitly setting an empty O=, which will be > >>> ignored in favour of OUTPUT= in tools/scripts/Makefile.include. > >> > >> Strange, but I can't repro it. I use make O= all the > >> time with no issues. I just tried specifically with a make O=.build, > >> where .build is inside Linux repo, and it still worked fine. See also > >> be40920fbf10 ("tools: Let O= makes handle a relative path with -C > >> option") which was supposed to address such an issue. So I'm wondering > >> what exactly is causing this problem. > >> > > [+ linux-um list] > > > > Hmm... From a quick check, I can't reproduce this on x86, so it's > > possibly a UML-specific issue. > > > > The problem here seems to be that $PWD is, for whatever reason, equal > > to the srcdir on x86, but not on UML. In general, $PWD behaves pretty > > weirdly -- I don't fully understand it -- but if I add a tactical "PWD > > := $(shell pwd)" or use $(CURDIR) instead, the issue shows up on x86 > > as well. I guess this is because PWD only gets updated when set by a > > shell or something, and UML does this somewhere? > > > > Thoughts? > > > > Cheers, > > -- David > > Hi David, Andrii, > > David, did you use a different command for building for UML and x86? I'm > asking because I reproduce on x86, but only for some targets, in > particular when I tried bindeb-pkg. I just ran "make ARCH={x86,um} O=.bpftest", with defconfig + enabling BPF_PRELOAD and its dependencies. UML fails, x86 works. (Though I can reproduce the failure if I make bindeb-pkg on x86). (It also shows up when building UML with the allyesconfig-based KUnit alltests option by running "./tools/testing/kunit/kunit.py run --alltests", though this understandably takes a long time and is less obvious) > > With "make O=.build vmlinux", I have: > - $(O) for "dummy" check in tools/scripts/Makefile.include set to > /linux/.build > - $(PWD) for same check set to /linux/tools > - Since $(O) is an absolute path, the "dummy" check passes > > With "make O=.build bindeb-pkg", I have instead: > - $(O) set to .build (relative path) > - $(PWD) set to /linux/.build > - "dummy" check changes to /linux/.build and searches for .build in it, > which fails and aborts the build > > (tools/scripts/Makefile.include is included from libbpf's Makefile, > called from kernel/bpf/preload/Makefile.) > > I'm not sure how exactly the bindeb-pkg target ends up passing these values. Yeah: I haven't been able to find where uml is changing them either: I'm assuming there's something which changes directory and/or spawns a shell/recursive make to change $(PWD) or something. > For what it's worth, I have been solving this (before finding this > thread) with a fix close to yours, I pass "O=$(abspath .)" on the > command line for building libbpf in kernel/bpf/preload/Makefile. It > looked consistent to me with the "tools/:" target from the main > Makefile, where "O=$(abspath $(objtree))" is passed (and $(objtree) is "."). Given that there are several targets being broken here, it's probably worth having a fix like this which overrides O= rather than trying to hunt down every target which could change $(PWD). I don't particularly mind whether we use O= or O=$(abspath .), both are working in the UML usecase as well. Does anyone object to basically accepting either this patch as-is, or using O=$(abspath .)? Cheers, -- David