Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp8833785ybl; Fri, 17 Jan 2020 01:50:56 -0800 (PST) X-Google-Smtp-Source: APXvYqwRCwrMmcdubbBDwgn2Ihb0qF5psknRm9+F+ZaqIcB1zXKpbCyFO1TdmNBexz3bmSK/JLno X-Received: by 2002:a9d:6a41:: with SMTP id h1mr5222683otn.279.1579254656406; Fri, 17 Jan 2020 01:50:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1579254656; cv=none; d=google.com; s=arc-20160816; b=mjl8sMigd2DxXXe+EJ+PBXaE+NYGxcHxNV0cZxoyAm7GPn7cGsZutW7J4eONuRCEt9 gRQwjoxe0vo7WqvXWEdjj3lb3TFtJy+rK7LkEINpyfwfMfooMsQLvSsLBhhjEa/AEX4b sMpxaP22CFQUw1jsCIXFqCbg2/OJH2GY0BcgZa5P8XRiUcKeK16P/zHt6/mRTX00AIjC blJq8Zp8sLvD5IkwT6NXFU8nMg/xyW2e9VNl81Gf15CdDXral2BKrQt45oy60zATTsHJ ii9Rfc20bANai+m3Ale6UFZX1J/5nhKPDjZ3swy/E3CxIh1PWUzJeXkWlZRJkOA1uxO5 uWkA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:references:in-reply-to:subject:cc:to:from :dkim-signature; bh=2DEmJ5gzdkN5fJt0y4FiCUVkAhDydkqj1OLIvLy08AQ=; b=ah7GNEoxOXWQv/pXkB0qs2rIiLphUsQkPZY/XeL3PQikn/cCqKldlgUdQ6bPz40tzR 8ef0juO5vkVLPXC9umM/0vWwnWgILmtDkqOoKnXZHVtwrFRVESnNUy2WpDR/91OYc5xF lFgn9R0LEtQUk63dRVvzBUlFeQVoYsTJcKI0+YWY3pdTxYinoj5DoLrv4L7YLS7zChn1 FEoaoOd6UcLizsUWNMP8KO3gXTr/SSemLQ2m/8qX4SebIXdnU1hC6Pvf6mNJBIpnPeR3 OXyvcjBdyN4pa/59bbhYfNcI4ltSYwN/tqNBcXHJnQeu2aEkRnZf8f1GwiUHzjTpAFOZ 7oNw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=KOF5uLIu; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i6si14032798oth.182.2020.01.17.01.50.44; Fri, 17 Jan 2020 01:50:56 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=KOF5uLIu; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728982AbgAQJtq (ORCPT + 99 others); Fri, 17 Jan 2020 04:49:46 -0500 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:28730 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727665AbgAQJto (ORCPT ); Fri, 17 Jan 2020 04:49:44 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1579254583; 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=2DEmJ5gzdkN5fJt0y4FiCUVkAhDydkqj1OLIvLy08AQ=; b=KOF5uLIuL8EQoMcmV/0PLGJxqH0RLZO0MXYE2gk81Znld+Ne/pxwybiwRfuY27hxPsqWBY YAPwhQeaew1skfJ6C+NLxErF3vtkfIyNp7CGYPHBwSJKwfsDMU6dFfr2NLwi2oYJ9MyoCU 9V9bps9pXPynlkSe8e86fBKp186mInA= Received: from mail-lj1-f200.google.com (mail-lj1-f200.google.com [209.85.208.200]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-105-TaQJBqswMQKrbwh0H6qgxQ-1; Fri, 17 Jan 2020 04:49:40 -0500 X-MC-Unique: TaQJBqswMQKrbwh0H6qgxQ-1 Received: by mail-lj1-f200.google.com with SMTP id b15so6027814ljp.7 for ; Fri, 17 Jan 2020 01:49:40 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:in-reply-to:references:date :message-id:mime-version:content-transfer-encoding; bh=2DEmJ5gzdkN5fJt0y4FiCUVkAhDydkqj1OLIvLy08AQ=; b=HnLkAe8jOjVCkSxUYqp/Zy0UTYc+/q0tCP1xIpQS//NhjtxJIHnkpRQLfVO1WU4jr8 MpgesgJKZxI8RlSXXnl7I1a9OyLEYJ3BqPUBcsDWM5HEalQ300gFtYrgEY0oZQ1b7a6X I1zXiaWvXWhRdLOB38GFtZtZapNiynzhgKfnWUaskIAfl2WWZJI1KzNXvdJ7r5OWGAg0 Q5xxAIAV1DKP8U9+DroUY0+fy0YYmf34Ps3gA2TI/b/PQr5HnlO2ju0qoVkspDhZiR/8 eP0VIBhUej7c8CGzcPdKbiMs1PiD8k8jUyC4Z9NKj7GPue0gBOpTI5CEieYCzWVOipLK QcuA== X-Gm-Message-State: APjAAAVCQM/61oAa5dlVnzxuGDHk1hAwAvfJJCFSnWndwZWLdbvSKOVN 6I/XwB0SlPnpwsvhDdVD/Lf3iWUowF5D3uKcSzKE3UqxEguKQmCEpEYM366eUVar7bRLELCJdYA 23d7J1oJXPVJpVY6sHM/2fT7R X-Received: by 2002:a2e:5357:: with SMTP id t23mr5182972ljd.227.1579254578785; Fri, 17 Jan 2020 01:49:38 -0800 (PST) X-Received: by 2002:a2e:5357:: with SMTP id t23mr5182947ljd.227.1579254578524; Fri, 17 Jan 2020 01:49:38 -0800 (PST) Received: from alrua-x1.borgediget.toke.dk ([2a0c:4d80:42:443::2]) by smtp.gmail.com with ESMTPSA id r9sm13683623lfc.72.2020.01.17.01.49.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Jan 2020 01:49:37 -0800 (PST) Received: by alrua-x1.borgediget.toke.dk (Postfix, from userid 1000) id C6AC21804D6; Fri, 17 Jan 2020 10:49:36 +0100 (CET) From: Toke =?utf-8?Q?H=C3=B8iland-J=C3=B8rgensen?= To: Andrii Nakryiko Cc: Alexei Starovoitov , Daniel Borkmann , Martin KaFai Lau , Song Liu , Yonghong Song , Andrii Nakryiko , Doug Ledford , Jason Gunthorpe , "David S. Miller" , Jakub Kicinski , Jesper Dangaard Brouer , John Fastabend , Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Shuah Khan , Networking , bpf , open list , linux-rdma@vger.kernel.org, "open list\:KERNEL SELFTEST FRAMEWORK" , clang-built-linux@googlegroups.com Subject: Re: [PATCH bpf-next v3 09/11] selftests: Remove tools/lib/bpf from include path In-Reply-To: References: <157918093154.1357254.7616059374996162336.stgit@toke.dk> <157918094179.1357254.14428494370073273452.stgit@toke.dk> X-Clacks-Overhead: GNU Terry Pratchett Date: Fri, 17 Jan 2020 10:49:36 +0100 Message-ID: <87r1zyquof.fsf@toke.dk> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Andrii Nakryiko writes: > On Thu, Jan 16, 2020 at 5:28 AM Toke H=C3=B8iland-J=C3=B8rgensen wrote: >> >> From: Toke H=C3=B8iland-J=C3=B8rgensen >> >> To make sure no new files are introduced that doesn't include the bpf/ >> prefix in its #include, remove tools/lib/bpf from the include path >> entirely. >> >> Instead, we introduce a new header files directory under the scratch too= ls/ >> dir, and add a rule to run the 'install_headers' rule from libbpf to hav= e a >> full set of consistent libbpf headers in $(OUTPUT)/tools/include/bpf, and >> then use $(OUTPUT)/tools/include as the include path for selftests. >> >> For consistency we also make sure we put all the scratch build files from >> other bpftool and libbpf into tools/build/, so everything stays within >> selftests/. >> >> Signed-off-by: Toke H=C3=B8iland-J=C3=B8rgensen >> --- >> tools/testing/selftests/bpf/.gitignore | 1 + >> tools/testing/selftests/bpf/Makefile | 50 +++++++++++++++++++------= ------- >> 2 files changed, 31 insertions(+), 20 deletions(-) >> >> diff --git a/tools/testing/selftests/bpf/.gitignore b/tools/testing/self= tests/bpf/.gitignore >> index 1d14e3ab70be..849be9990ad2 100644 >> --- a/tools/testing/selftests/bpf/.gitignore >> +++ b/tools/testing/selftests/bpf/.gitignore >> @@ -40,3 +40,4 @@ test_cpp >> /bpf_gcc >> /tools >> bpf_helper_defs.h >> +/include/bpf > > Isn't the real path (within selftests/bpf) a tools/include/bpf, which > is already ignored through /tools rule? Yeah, you're correct. I started out with having it in include/bpf, but ended up moving it, and guess I forgot to remove the .gitignore. Will fix. >> diff --git a/tools/testing/selftests/bpf/Makefile b/tools/testing/selfte= sts/bpf/Makefile >> index 1fd7da49bd56..c3fa695bb028 100644 >> --- a/tools/testing/selftests/bpf/Makefile >> +++ b/tools/testing/selftests/bpf/Makefile >> @@ -20,8 +20,8 @@ CLANG ?=3D clang >> LLC ?=3D llc >> LLVM_OBJCOPY ?=3D llvm-objcopy >> BPF_GCC ?=3D $(shell command -v bpf-gcc;) >> -CFLAGS +=3D -g -Wall -O2 $(GENFLAGS) -I$(CURDIR) -I$(APIDIR) -I$(LIBDIR= ) \ >> - -I$(BPFDIR) -I$(GENDIR) -I$(TOOLSINCDIR) \ >> +CFLAGS +=3D -g -Wall -O2 $(GENFLAGS) -I$(CURDIR) -I$(APIDIR) = \ >> + -I$(INCLUDE_DIR) -I$(GENDIR) -I$(LIBDIR) -I$(TOOLSINCDIR) \ >> -Dbpf_prog_load=3Dbpf_prog_test_load = \ >> -Dbpf_load_program=3Dbpf_test_load_program >> LDLIBS +=3D -lcap -lelf -lz -lrt -lpthread >> @@ -97,11 +97,15 @@ OVERRIDE_TARGETS :=3D 1 >> override define CLEAN >> $(call msg,CLEAN) >> $(RM) -r $(TEST_GEN_PROGS) $(TEST_GEN_PROGS_EXTENDED) $(TEST_GEN= _FILES) $(EXTRA_CLEAN) >> - $(MAKE) -C $(BPFDIR) OUTPUT=3D$(OUTPUT)/ clean >> endef >> >> include ../lib.mk >> >> +SCRATCH_DIR :=3D $(OUTPUT)/tools >> +BUILD_DIR :=3D $(SCRATCH_DIR)/build >> +INCLUDE_DIR :=3D $(SCRATCH_DIR)/include >> +INCLUDE_BPF :=3D $(INCLUDE_DIR)/bpf/bpf.h >> + >> # Define simple and short `make test_progs`, `make test_sysctl`, etc ta= rgets >> # to build individual tests. >> # NOTE: Semicolon at the end is critical to override lib.mk's default s= tatic >> @@ -120,7 +124,7 @@ $(OUTPUT)/urandom_read: urandom_read.c >> $(call msg,BINARY,,$@) >> $(CC) -o $@ $< -Wl,--build-id >> >> -$(OUTPUT)/test_stub.o: test_stub.c >> +$(OUTPUT)/test_stub.o: test_stub.c $(INCLUDE_BPF) >> $(call msg,CC,,$@) >> $(CC) -c $(CFLAGS) -o $@ $< >> >> @@ -129,7 +133,7 @@ $(OUTPUT)/runqslower: force >> $(Q)$(MAKE) $(submake_extras) -C $(TOOLSDIR)/bpf/runqslower = \ >> OUTPUT=3D$(CURDIR)/tools/ VMLINUX_BTF=3D$(abspath ..= /../../../vmlinux) >> >> -BPFOBJ :=3D $(OUTPUT)/libbpf.a >> +BPFOBJ :=3D $(BUILD_DIR)/libbpf/libbpf.a >> >> $(TEST_GEN_PROGS) $(TEST_GEN_PROGS_EXTENDED): $(OUTPUT)/test_stub.o $(B= PFOBJ) >> >> @@ -155,17 +159,23 @@ force: >> DEFAULT_BPFTOOL :=3D $(OUTPUT)/tools/sbin/bpftool >> BPFTOOL ?=3D $(DEFAULT_BPFTOOL) >> >> -$(DEFAULT_BPFTOOL): force >> - $(Q)$(MAKE) $(submake_extras) -C $(BPFTOOLDIR) = \ >> +$(BUILD_DIR)/libbpf $(BUILD_DIR)/bpftool $(INCLUDE_DIR): >> + $(call msg,MKDIR,,$@) >> + mkdir -p $@ >> + >> +$(DEFAULT_BPFTOOL): force $(BUILD_DIR)/bpftool > > directories should be included as order-only dependencies (after | ) OK. >> + $(Q)$(MAKE) $(submake_extras) -C $(BPFTOOLDIR) \ >> + OUTPUT=3D$(BUILD_DIR)/bpftool/ = \ >> prefix=3D DESTDIR=3D$(OUTPUT)/tools/ install >> >> -$(BPFOBJ): force >> - $(Q)$(MAKE) $(submake_extras) -C $(BPFDIR) OUTPUT=3D$(OUTPUT)/ >> +$(BPFOBJ): force $(BUILD_DIR)/libbpf > > same > >> + $(Q)$(MAKE) $(submake_extras) -C $(BPFDIR) \ >> + OUTPUT=3D$(BUILD_DIR)/libbpf/ >> >> -BPF_HELPERS :=3D $(OUTPUT)/bpf_helper_defs.h $(wildcard $(BPFDIR)/bpf_*= .h) >> -$(OUTPUT)/bpf_helper_defs.h: $(BPFOBJ) >> - $(Q)$(MAKE) $(submake_extras) -C $(BPFDIR) = \ >> - OUTPUT=3D$(OUTPUT)/ $(OUTPUT)/bpf_helper_defs.h >> +BPF_HELPERS :=3D $(wildcard $(BPFDIR)/bpf_*.h) $(INCLUDE_BPF) > > Shouldn't all BPF_HELPERS come from $(INCLUDE_DIR)/bpf now? > >> +$(INCLUDE_BPF): force $(BPFOBJ) > > And this can be more properly a $(BPF_HELPERS): force $(BPFOBJ)? > >> + $(Q)$(MAKE) $(submake_extras) -C $(BPFDIR) install_headers \ >> + OUTPUT=3D$(BUILD_DIR)/libbpf/ DESTDIR=3D$(SCRATCH_DIR) p= refix=3D >> >> # Get Clang's default includes on this system, as opposed to those seen= by >> # '-target bpf'. This fixes "missing" files on some architectures/distr= os, >> @@ -185,8 +195,8 @@ MENDIAN=3D$(if $(IS_LITTLE_ENDIAN),-mlittle-endian,-= mbig-endian) >> >> CLANG_SYS_INCLUDES =3D $(call get_sys_includes,$(CLANG)) >> BPF_CFLAGS =3D -g -D__TARGET_ARCH_$(SRCARCH) $(MENDIAN) = \ >> - -I$(OUTPUT) -I$(CURDIR) -I$(CURDIR)/include/uapi \ >> - -I$(APIDIR) -I$(LIBDIR) -I$(BPFDIR) -I$(abspath $(OUTPUT)/.= ./usr/include) >> + -I$(INCLUDE_DIR) -I$(CURDIR) -I$(CURDIR)/include/uapi \ >> + -I$(APIDIR) -I$(abspath $(OUTPUT)/../usr/include) >> >> CLANG_CFLAGS =3D $(CLANG_SYS_INCLUDES) \ >> -Wno-compare-distinct-pointer-types >> @@ -306,7 +316,7 @@ $(TRUNNER_TEST_OBJS): $(TRUNNER_OUTPUT)/%.test.o: = \ >> $(TRUNNER_EXTRA_HDRS) \ >> $(TRUNNER_BPF_OBJS) \ >> $(TRUNNER_BPF_SKELS) \ >> - $$(BPFOBJ) | $(TRUNNER_OUTPUT) >> + $$(BPFOBJ) $$(INCLUDE_BPF) | $(TRUNNER_OUTPUT) > > singling out $(INCLUDE_BPF) looks weird? But I think $(BPFOBJ) > achieves the same effect, so this change can be probably dropped? Same > below. I was having some trouble getting the dependency order right here. $(INCLUDE_BPF) depends on $(BPFOBJ), not the other way around. May be fixable though, I'll take another look. -Toke