From mboxrd@z Thu Jan 1 00:00:00 1970 From: Yonghong Song Subject: [PATCH bpf-next] bpf: fix a compilation error when CONFIG_BPF_SYSCALL is not defined Date: Tue, 20 Nov 2018 13:48:23 -0800 Message-ID: <20181120214823.1699338-1-yhs@fb.com> Mime-Version: 1.0 Content-Type: text/plain Cc: , Martin KaFai Lau To: , , , Return-path: Received: from mx0b-00082601.pphosted.com ([67.231.153.30]:33360 "EHLO mx0b-00082601.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725887AbeKUIUK (ORCPT ); Wed, 21 Nov 2018 03:20:10 -0500 Received: from pps.filterd (m0109332.ppops.net [127.0.0.1]) by mx0a-00082601.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id wAKLiRdR003232 for ; Tue, 20 Nov 2018 13:48:53 -0800 Received: from mail.thefacebook.com ([199.201.64.23]) by mx0a-00082601.pphosted.com with ESMTP id 2nvrftrffr-14 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT) for ; Tue, 20 Nov 2018 13:48:53 -0800 Sender: netdev-owner@vger.kernel.org List-ID: Kernel test robot (lkp@intel.com) reports a compilation error at https://www.spinics.net/lists/netdev/msg534913.html introduced by commit 838e96904ff3 ("bpf: Introduce bpf_func_info"). If CONFIG_BPF is defined and CONFIG_BPF_SYSCALL is not defined, the following error will appear: kernel/bpf/core.c:414: undefined reference to `btf_type_by_id' kernel/bpf/core.c:415: undefined reference to `btf_name_by_offset' When CONFIG_BPF_SYSCALL is not defined, let us define stub inline functions for btf_type_by_id() and btf_name_by_offset() in include/linux/btf.h. This way, the compilation failure can be avoided. Fixes: 838e96904ff3 ("bpf: Introduce bpf_func_info") Reported-by: kbuild test robot Cc: Martin KaFai Lau Signed-off-by: Yonghong Song --- include/linux/btf.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/include/linux/btf.h b/include/linux/btf.h index 7f2c0a4a45ea..a5e893071861 100644 --- a/include/linux/btf.h +++ b/include/linux/btf.h @@ -46,7 +46,19 @@ void btf_type_seq_show(const struct btf *btf, u32 type_id, void *obj, struct seq_file *m); int btf_get_fd_by_id(u32 id); u32 btf_id(const struct btf *btf); + +#ifdef CONFIG_BPF_SYSCALL const struct btf_type *btf_type_by_id(const struct btf *btf, u32 type_id); const char *btf_name_by_offset(const struct btf *btf, u32 offset); +#else +const struct btf_type *btf_type_by_id(const struct btf *btf, u32 type_id) +{ + return NULL; +} +const char *btf_name_by_offset(const struct btf *btf, u32 offset) +{ + return NULL; +} +#endif #endif -- 2.17.1