From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (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 6807933556D for ; Wed, 12 Aug 2026 07:03:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786518238; cv=none; b=puFfXx4Fx/Y2TQ3HzvzW64KL5ZQL2zBIErfavMz6zDpl0lsGUittIlcS7Up6GxU6x7Ia7S+bhizMQQnL5PToa46Imf2ac+b4sQvNfZOEgzE3rm78cKAqwashsochI1vKABqTFKkPZZ7pOggF9DuwKQkkJWJs5D7jCeRamG/BaZM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786518238; c=relaxed/simple; bh=GCkBXddSbeHCDvY1GzromperE2nmzYP3jL1SLw1+JJI=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=TB2J8oDeTy1l2PDBTzQj3uf7+jAVD+Hk037J/TIE+QeqmFcndEmL2W915wx+a3niQJEKfzI8BX1b7g/0egC9Bbjr9wmTrI6jDBN/+ElEYvhcPD9ttFXpsy7xEHK9CfMLoIv3eiRkeTWnFb3TqBWfw+nMz4N2SeI4DRDuzTXGmNU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=AwIq+J9d; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b=Ev1dWeJD; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="AwIq+J9d"; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b="Ev1dWeJD" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1786518235; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=GMSQFwJ3Pn8MGM6lOdOzrV1KHdix97IWR2KeUG/GEeU=; b=AwIq+J9dxpqYQWpI96V9rbgJb1hxlMkzj1AcQiN5/EmSzIHw/e9412XXmI/d+xqKPYWkRj 3vqiQWNr0UyzcChbdaQSDAR2AIOUV5EZjfVdMZRyCww5B50bvFclPeF00ElRiiUnECmX6d j14rpKS03OPNq1zt1uguIFbWWtPJLSw= Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-201-8pBTaFU8N0qgdbsV3cUU9Q-1; Wed, 12 Aug 2026 03:03:51 -0400 X-MC-Unique: 8pBTaFU8N0qgdbsV3cUU9Q-1 X-Mimecast-MFC-AGG-ID: 8pBTaFU8N0qgdbsV3cUU9Q_1786518230 Received: by mail-wm1-f72.google.com with SMTP id 5b1f17b1804b1-49808ea1b64so8059405e9.1 for ; Wed, 12 Aug 2026 00:03:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1786518230; x=1787123030; darn=vger.kernel.org; h=content-transfer-encoding:content-type:in-reply-to:content-language :from:references:cc:to:subject:user-agent:mime-version:date :message-id:from:to:cc:subject:date:message-id:reply-to:content-type; bh=GMSQFwJ3Pn8MGM6lOdOzrV1KHdix97IWR2KeUG/GEeU=; b=Ev1dWeJDxFoaQNmhLYJbp9fsbGub+dt+mEuTBmgw5FJw5eqynqKQW23zUK51Mn8H0h ckqLCQWkjx35JcE8pMug04kGM9hD4J65b2zorGV7GpkP0CSco7/R27sNzQ0S1pnX9jUB SudS4vZBWg/EtGmV7OOoeEHnxU+tFN5Spb3CqedePFrAnK7FTPk7ADnYRGxZoAyU0yH6 JA1ZBugPcZEPuPVEElN78/G1fXcYhHdDg5sd6XP4LMfFScKKvHa+4iVks7YLQLwXUrPt muyMR6dwi8ditKDQAbAhcTupYAOIFQgYJ1v956xnLMGGl2EH5Vl83SDY3P6I7m8l2m2W sNzQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1786518230; x=1787123030; h=content-transfer-encoding:content-type:in-reply-to:content-language :from:references:cc:to:subject:user-agent:mime-version:date :message-id:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=GMSQFwJ3Pn8MGM6lOdOzrV1KHdix97IWR2KeUG/GEeU=; b=S4mcEN2hE4g4fpm3bSubgraN5XVJYhmhG55coUnHL2Mf3by+4bKzMvCStq3UftrfbO CHo5xXAUrMWU0O8lVu/14a5AqZarjKgk3nR6KQub4CzzeAcsEsSiKELY419ud78TWhJW nhBGGee2Nve60cL53B5j/rqKe+9VzDFA/PC88H7Noc2gfQdxhYeR4s7uGmRNFSkb8zYA 2jQxxbFvUo2zIgRaBJgctqV8O4ON18xMYcCq0aWMzzc7o/1VU61Vmmznl5pmiVBDeyZt p7v5QaFHGAC+mdkk+AqTGAEBuIVeB4uwg6XNfuuOI1QQnKT0bDRKHLbrG44lkgpbiY+S Rsig== X-Forwarded-Encrypted: i=1; AHgh+Rq1LxaxFS8v4idfIRlWtoPuDx0vPZbDglNiN1pH4b552QTAUuMMaonrFe7wdvHD5sCkgY+NL/ehwkqhXmA=@vger.kernel.org X-Gm-Message-State: AOJu0Yy7YEttNi65dLCIO1kDM8M2AwVPM82zGJPMGdbcXRfRqC1jBoYJ 8RLYETt4eQtOMMtaMK3YG1Qt2AGzcZocKJNsIINjeoDfv43BpP4U5CacRHhXxPmvG/U1hc5aHJ/ Wm3qIgGhaF6l/jN4GFxdlMBw6Obzcnd3MMgMRXNo2TaAFeuQchZrDJDZWSckK4Xqw X-Gm-Gg: AR+sD12JH7r7BI+7t5UaI9Jneae37+SZte9sdjeSKwowOAEAE24b1vhzG4PfiVohEJq GDb3ftnLgT8BqcIqfkos1FRB7GQazpz6Qn90c0Fo8MB2EqgPr9YQY4DnP8SIozCoxZHTxD/rgpZ LQfj9S8rJdnViB2if2ndt6bHt5DIr8jm+T/Y5POXOPe8nlcYao4K+Xy6uIJ7+dR/0ERtQ3hqy5I s5asB1C9FhTCznh1DM7DbOcTWWp1JssLmLMivNjfWCMDcln2SeMwI/XAJSBFOTVgLQWigHRSyPj fk0ISGJT2no7C6iNvXVex1GoTvKVqx16LmOlhOcHCVRptp7r9SmY/pxwie7SgjfS0tPiJMVguDM Ro1jzJqf/MzEASPmXQZaN+/9eqzajqkZjHdo= X-Received: by 2002:a05:600c:138b:b0:495:5d6d:9cc1 with SMTP id 5b1f17b1804b1-4997c30b80fmr29456775e9.0.1786518229772; Wed, 12 Aug 2026 00:03:49 -0700 (PDT) X-Received: by 2002:a05:600c:138b:b0:495:5d6d:9cc1 with SMTP id 5b1f17b1804b1-4997c30b80fmr29455945e9.0.1786518229435; Wed, 12 Aug 2026 00:03:49 -0700 (PDT) Received: from [192.168.0.135] (185-219-167-205-static.vivo.cz. [185.219.167.205]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4997ada79a3sm46337885e9.1.2026.08.12.00.03.47 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 12 Aug 2026 00:03:48 -0700 (PDT) Message-ID: <02ce6b65-7670-4dac-ac9c-8875867d6ad3@redhat.com> Date: Wed, 12 Aug 2026 09:03:47 +0200 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v2 1/4] selftests: add shared lib.bpf.mk to build BPF progs and skeletons To: Ziyang Men Cc: Shuah Khan , Tejun Heo , Johannes Weiner , =?UTF-8?Q?Michal_Koutn=C3=BD?= , Jiri Kosina , Benjamin Tissoires , David Vernet , Eduard Zingerman , Andrea Righi , Changwoo Min , Michal Hocko , Roman Gushchin , Shakeel Butt , Muchun Song , Andrew Morton , JP Kobryn , Mykola Lysenko , Nathan Chancellor , linux-kselftest@vger.kernel.org, cgroups@vger.kernel.org, linux-input@vger.kernel.org, sched-ext@lists.linux.dev, linux-mm@kvack.org, kernel-team@meta.com, bpf@vger.kernel.org, llvm@lists.linux.dev, linux-kernel@vger.kernel.org References: <20260721174833.1232771-1-ziyang.meme@gmail.com> <20260721174833.1232771-2-ziyang.meme@gmail.com> From: Viktor Malik Content-Language: en-US In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit On 8/6/26 21:48, Ziyang Men wrote: > On Wed, Jul 22, 2026 at 08:50:06AM +0200, Viktor Malik wrote: [...] > Hi Viktor, > > Thanks for your suggestions! >> >> Looking at the same line in tools/testing/selftests/bpf/Makefile: >> >> EXTRA_CFLAGS='-g $(OPT_FLAGS) $(SAN_CFLAGS) $(EXTRA_CFLAGS)' \ >> >> is there a reason why this is not respected and -O0 and -fPIC are >> hard-coded? > Yes it is true that there is no good reason. I will fix it in the next version. > >> What if someone wants to build selftests (including libbpf) >> with -O2 and some additional flags? > I will add a flag such as OPT_FLAGS ?= $(if $(RELEASE),-O2,O0), which follows > the pattern in the bpf/Makefile:37. So if we run > $ make -> -g -O0 -fPIC (taget libbpf) and -g -O0 (host bpftool) > $ make RELEASE=1 -> -g -O2 -fPIC (taget libbpf) and -g -O2 (host bpftool) > >> Is that possible with the new >> lib.bpf.mk? It would be nice if it used at least EXTRA_CFLAGS or >> USERCFLAGS defined in lib.mk. > Good idea. I will add the EXTRA_CFLAGS for target libbpf, host libbpf and host > bpgtool. Such that: > $ make OPT_FLAGS=-O2 EXTRA_CFLAGS=-DFOO -> -g -O2 -fPIC -DFOO (for target > libbpf) and -g -O2 -DFOO (for host bpftool) I'm wondering if we could use USERCFLAGS (and USERLDFLAGS) instead. These seem to be the preferred way for all selftests, per tools/testing/selftests/lib.mk: # Enables to extend CFLAGS and LDFLAGS from command line, e.g. # make USERCFLAGS=-Werror USERLDFLAGS=-static CFLAGS += $(USERCFLAGS) LDFLAGS += $(USERLDFLAGS) At the time I was adding the extra flags to libbpf/bpftool sub-makes, I wasn't aware of USER*FLAGS so I used EXTRA_*FLAGS instead. But now, when someone wants to build multiple selftest collections with extra flags, they need to define both. For instance, building with PIE requires: make -C tools/testing/selftests TARGETS="bpf ..." \ USERCFLAGS=-fpie EXTRA_CFLAGS=-fpie \ USERLDFLAGS=-pie EXTRA_LDFLAGS=-pie \ Switching to USER*FLAGS for bpf selftests would simplify things a bit. Viktor > >> >> Same questions would apply to other rules for libbpf and bpftool below. > I would check it them as as well in next version. > >> Thanks! >> Viktor >> >> > Thanks for your time and reviewing. Please let me know your concerns. Thanks! > > Best, > Ziyang