Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp6058738ybl; Sun, 22 Dec 2019 22:14:34 -0800 (PST) X-Google-Smtp-Source: APXvYqx+8r1BmMd6Vidf+RUf5/NbpN86vVe/EATb+UoLdQWSw0LwlHwn486gOqYcm48MOmlF9zP6 X-Received: by 2002:a05:6830:124b:: with SMTP id s11mr30242364otp.333.1577081674494; Sun, 22 Dec 2019 22:14:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1577081674; cv=none; d=google.com; s=arc-20160816; b=w6PrfaDPFYEbzmT9Jt9qRwfQI0EBGtI0wv6I6asIcQECSJSIbEitwEOMTDIjfBhojg MKBNilqIlrx3BtqMljv2YmH/E9fnw+TuOKOGRUUpr7/tpHvgtcPr/GP7d6F5g2cw9mVB IiwdIqDO78jHffoVVOHXjg1IfqP8jOKWj+80EV4zpWdXhdtb+80LM6AEt8okK7UBaA+m FOVm61vtEWLTpWCGUZreUC/m0PAPHj4m64x4RddLVHLBF0D+V1LzuIWcA6i5Y3EjqYkO 4ZkJ17kK5YWCQhi/SjlvavHbm1zf/mK/5zJxuCD8JXNIPfegFK3TxzoxcTRnmrU6iPXr TCnQ== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=FzLLXgScNK2NFx9W8K4Xo6N6LSZ1F5SXbeG183QdbNg=; b=toWnTWaGI7Pd9EXR08rEDWYTFZa9rBpXts3QVrdxgN4b11E5F2fNvnIvDaTKrmVhDi jCAsE0HhLeDKihUsfz1rAUH4BNYkGaXemFkwoKX2dE7jwIueH5vGBsd/Odl82xkrzOZD 9g4wEByvwm/t2hw69g0DmYch5nUItKl1u7ezmLA7UxdwzW/SD3uQN7Kh48xE6AZbP5Ig T1xJcXDZEt01e5ltgNkXqIfJTpU+l16TioOpOelfbsNIeXxW/NRwG1fTfqggNX+9dbD9 keKYBl9EgyJxwh9MOBBCtIPDvcrND/3qr/7tai7O9LuzMBI/tYegopatWhf5ThhOGUIg P6CQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=Yp3Wht3A; 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=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m24si9730120otn.67.2019.12.22.22.14.22; Sun, 22 Dec 2019 22:14:34 -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=fail header.i=@gmail.com header.s=20161025 header.b=Yp3Wht3A; 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=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726096AbfLWGNq (ORCPT + 99 others); Mon, 23 Dec 2019 01:13:46 -0500 Received: from mail-pf1-f194.google.com ([209.85.210.194]:41996 "EHLO mail-pf1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725811AbfLWGNp (ORCPT ); Mon, 23 Dec 2019 01:13:45 -0500 Received: by mail-pf1-f194.google.com with SMTP id 4so8653058pfz.9; Sun, 22 Dec 2019 22:13:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=FzLLXgScNK2NFx9W8K4Xo6N6LSZ1F5SXbeG183QdbNg=; b=Yp3Wht3Ac9Yt2DIxrFs7shTnzEQKcWgBYSx9P94e5PpDHmBuDYREbTmuRLkgFXP+37 IVavDSNpKCaXRSF1HHEq4J6LgdCPmeC6QTHy7sxI+d0BRstHXjNWLbgHV+FAI4ELSjnh L8tvlfwbVZ5NVT3KI0TTyMuyoKBixjkpzGwnogm1c/5Fax58Xr080AID7cookuQ/0xo3 KHQ8ezLSZi1FxTOT/DLUrennQyGeGy+x+5pqTqD1WdNfoGBt5cOXM7itrHNMfpq84zsm rYEVFx4U+pfckXxmIQSzb40VMMSbtaCkNU2fO/08vGT0Fd+j/tleH1U2XoCDnSTbskG1 Rf5A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=FzLLXgScNK2NFx9W8K4Xo6N6LSZ1F5SXbeG183QdbNg=; b=aMPyYoM9gSOA+SiQfgOsem4cn/csfW03TdqJ3cBBKZYV0zYEW3bBFpgd1iwqp8Snbn ScbD76wvbfRIENQWFO8FikHCfU23ml8LDynAu/uII7r8DpcKaMbb/dBoXT5ADCsffKME I3YJ2GUILb6Wsy4wlXp1YtG+q7a1ivlrXy+auojga7bXAZjj0Jxw0J/7KvcYWRGSWa61 fuzKZilQt7QQSzW3X/m35pQ1gcVYfcTKjNMzTqw97M+gtHqm3EuDFqlNwpQEcbWSZ+Is 5TbstaUB11mZL9KVK/uztw8mH+hmcpqBIf+p2/T72CSk0ICBSBVJXaIyekG+9nwPymUU ERkA== X-Gm-Message-State: APjAAAX0jeME0Al2UQZMuZBB10qAFxa/wELaKae4/YBX205g0pAKSYRz SrjMhpQtMEQ9ZmyOAgC+ft4= X-Received: by 2002:a63:d40d:: with SMTP id a13mr15949396pgh.9.1577081624762; Sun, 22 Dec 2019 22:13:44 -0800 (PST) Received: from gaurie.seo.corp.google.com ([2401:fa00:d:1:4eb0:a5ef:3975:7440]) by smtp.gmail.com with ESMTPSA id u7sm21622191pfh.128.2019.12.22.22.13.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 22 Dec 2019 22:13:44 -0800 (PST) From: Namhyung Kim To: Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko Cc: Martin KaFai Lau , Song Liu , Yonghong Song , bpf@vger.kernel.org, Arnaldo Carvalho de Melo , Jiri Olsa , LKML , Shuah Khan , linux-kselftest@vger.kernel.org, netdev@vger.kernel.org, linux-perf-users@vger.kernel.org Subject: [PATCH bpf v3] libbpf: Fix build on read-only filesystems Date: Mon, 23 Dec 2019 15:13:26 +0900 Message-Id: <20191223061326.843366-1-namhyung@kernel.org> X-Mailer: git-send-email 2.24.1.735.g03f4e72817-goog In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org I got the following error when I tried to build perf on a read-only filesystem with O=dir option. $ cd /some/where/ro/linux/tools/perf $ make O=$HOME/build/perf ... CC /home/namhyung/build/perf/lib.o /bin/sh: bpf_helper_defs.h: Read-only file system make[3]: *** [Makefile:184: bpf_helper_defs.h] Error 1 make[2]: *** [Makefile.perf:778: /home/namhyung/build/perf/libbpf.a] Error 2 make[2]: *** Waiting for unfinished jobs.... LD /home/namhyung/build/perf/libperf-in.o AR /home/namhyung/build/perf/libperf.a PERF_VERSION = 5.4.0 make[1]: *** [Makefile.perf:225: sub-make] Error 2 make: *** [Makefile:70: all] Error 2 It was becaused bpf_helper_defs.h was generated in current directory. Move it to OUTPUT directory. Tested-by: Andrii Nakryiko Acked-by: Andrii Nakryiko Signed-off-by: Namhyung Kim --- tools/lib/bpf/Makefile | 15 ++++++++------- tools/testing/selftests/bpf/.gitignore | 1 + tools/testing/selftests/bpf/Makefile | 6 +++--- 3 files changed, 12 insertions(+), 10 deletions(-) diff --git a/tools/lib/bpf/Makefile b/tools/lib/bpf/Makefile index defae23a0169..97830e46d1a0 100644 --- a/tools/lib/bpf/Makefile +++ b/tools/lib/bpf/Makefile @@ -138,6 +138,7 @@ STATIC_OBJDIR := $(OUTPUT)staticobjs/ BPF_IN_SHARED := $(SHARED_OBJDIR)libbpf-in.o BPF_IN_STATIC := $(STATIC_OBJDIR)libbpf-in.o VERSION_SCRIPT := libbpf.map +BPF_HELPER_DEFS := $(OUTPUT)bpf_helper_defs.h LIB_TARGET := $(addprefix $(OUTPUT),$(LIB_TARGET)) LIB_FILE := $(addprefix $(OUTPUT),$(LIB_FILE)) @@ -159,7 +160,7 @@ all: fixdep all_cmd: $(CMD_TARGETS) check -$(BPF_IN_SHARED): force elfdep bpfdep bpf_helper_defs.h +$(BPF_IN_SHARED): force elfdep bpfdep $(BPF_HELPER_DEFS) @(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 @@ -177,12 +178,12 @@ $(BPF_IN_SHARED): force elfdep bpfdep bpf_helper_defs.h 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 $(Q)$(MAKE) $(build)=libbpf OUTPUT=$(SHARED_OBJDIR) CFLAGS="$(CFLAGS) $(SHLIB_FLAGS)" -$(BPF_IN_STATIC): force elfdep bpfdep bpf_helper_defs.h +$(BPF_IN_STATIC): force elfdep bpfdep $(BPF_HELPER_DEFS) $(Q)$(MAKE) $(build)=libbpf OUTPUT=$(STATIC_OBJDIR) -bpf_helper_defs.h: $(srctree)/tools/include/uapi/linux/bpf.h +$(BPF_HELPER_DEFS): $(srctree)/tools/include/uapi/linux/bpf.h $(Q)$(srctree)/scripts/bpf_helpers_doc.py --header \ - --file $(srctree)/tools/include/uapi/linux/bpf.h > bpf_helper_defs.h + --file $(srctree)/tools/include/uapi/linux/bpf.h > $(BPF_HELPER_DEFS) $(OUTPUT)libbpf.so: $(OUTPUT)libbpf.so.$(LIBBPF_VERSION) @@ -243,7 +244,7 @@ install_lib: all_cmd $(call do_install_mkdir,$(libdir_SQ)); \ cp -fpR $(LIB_FILE) $(DESTDIR)$(libdir_SQ) -install_headers: bpf_helper_defs.h +install_headers: $(BPF_HELPER_DEFS) $(call QUIET_INSTALL, headers) \ $(call do_install,bpf.h,$(prefix)/include/bpf,644); \ $(call do_install,libbpf.h,$(prefix)/include/bpf,644); \ @@ -251,7 +252,7 @@ install_headers: bpf_helper_defs.h $(call do_install,libbpf_util.h,$(prefix)/include/bpf,644); \ $(call do_install,xsk.h,$(prefix)/include/bpf,644); \ $(call do_install,bpf_helpers.h,$(prefix)/include/bpf,644); \ - $(call do_install,bpf_helper_defs.h,$(prefix)/include/bpf,644); \ + $(call do_install,$(BPF_HELPER_DEFS),$(prefix)/include/bpf,644); \ $(call do_install,bpf_tracing.h,$(prefix)/include/bpf,644); \ $(call do_install,bpf_endian.h,$(prefix)/include/bpf,644); \ $(call do_install,bpf_core_read.h,$(prefix)/include/bpf,644); @@ -271,7 +272,7 @@ install: install_lib install_pkgconfig clean: $(call QUIET_CLEAN, libbpf) $(RM) -rf $(CMD_TARGETS) \ *.o *~ *.a *.so *.so.$(LIBBPF_MAJOR_VERSION) .*.d .*.cmd \ - *.pc LIBBPF-CFLAGS bpf_helper_defs.h \ + *.pc LIBBPF-CFLAGS $(BPF_HELPER_DEFS) \ $(SHARED_OBJDIR) $(STATIC_OBJDIR) $(call QUIET_CLEAN, core-gen) $(RM) $(OUTPUT)FEATURE-DUMP.libbpf diff --git a/tools/testing/selftests/bpf/.gitignore b/tools/testing/selftests/bpf/.gitignore index 419652458da4..1ff0a9f49c01 100644 --- a/tools/testing/selftests/bpf/.gitignore +++ b/tools/testing/selftests/bpf/.gitignore @@ -40,3 +40,4 @@ xdping test_cpp /no_alu32 /bpf_gcc +bpf_helper_defs.h diff --git a/tools/testing/selftests/bpf/Makefile b/tools/testing/selftests/bpf/Makefile index e0fe01d9ec33..e2fd6f8d579c 100644 --- a/tools/testing/selftests/bpf/Makefile +++ b/tools/testing/selftests/bpf/Makefile @@ -120,9 +120,9 @@ $(OUTPUT)/test_cgroup_attach: cgroup_helpers.c $(BPFOBJ): force $(MAKE) -C $(BPFDIR) OUTPUT=$(OUTPUT)/ -BPF_HELPERS := $(BPFDIR)/bpf_helper_defs.h $(wildcard $(BPFDIR)/bpf_*.h) -$(BPFDIR)/bpf_helper_defs.h: - $(MAKE) -C $(BPFDIR) OUTPUT=$(OUTPUT)/ bpf_helper_defs.h +BPF_HELPERS := $(OUTPUT)/bpf_helper_defs.h $(wildcard $(BPFDIR)/bpf_*.h) +$(OUTPUT)/bpf_helper_defs.h: + $(MAKE) -C $(BPFDIR) OUTPUT=$(OUTPUT)/ $(OUTPUT)/bpf_helper_defs.h # Get Clang's default includes on this system, as opposed to those seen by # '-target bpf'. This fixes "missing" files on some architectures/distros, -- 2.24.1.735.g03f4e72817-goog