Received: by 2002:a25:c593:0:0:0:0:0 with SMTP id v141csp1304681ybe; Fri, 13 Sep 2019 14:26:17 -0700 (PDT) X-Google-Smtp-Source: APXvYqwuXRh+XSPtLDUWV1utG8XNn82hyUWWs2jSWYi3DFb1qIeZrwJL6NvpXnI7ZmoFhOzg8FMs X-Received: by 2002:a50:95c1:: with SMTP id x1mr1841896eda.180.1568409977322; Fri, 13 Sep 2019 14:26:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1568409977; cv=none; d=google.com; s=arc-20160816; b=CqcrwRyhX0yX60SYO0vUWSNrSIs6QMFd+wntC68m5g2uA4bipAsMoriaPvepVXxgcO 1AsCEqd3T/MtqsZP7ku4UUSIAazQfz18lHAuBk0o58BzQmxSpp9Xzp15jFDsv9C+kLCV l/qK0ZidzBKBU2cgB5pmdDPs3tsOJK1PWsYkSfnvZLnERdvUTvJxnUQ0KJUhOZqq+uEg H/Yju7DHd/6j1J50wCHuYBMohXrMKlTbs2vkidKqtUOWLqomioUM4xLtuWwrUs44qcB7 i2HGtL8QHC8N1E+go3RJ9Iu1VOvOJeyqDbRg/mArPjdHEh+i7yukNyYAbOrKwvMK3jfo 3YkQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:mail-followup-to :message-id:subject:cc:to:from:date:dkim-signature; bh=M7RhwXkvx5UdXmM9G4lNP2WF3fIHiZECXKfzifEwcp4=; b=kRimlXy61t1ELwazOM/SfDtUSVVsrkQ5lpc7XPVA0Bi2V1tvcGg1JQgTTjMgK7S4us YJuAsLf84Qw/5J69n7MxM9IygWGqwACcpYpXJTUo03V9VwS0S/UlDAlzLnaNGW5DV71G TIqFZ+70YKIP3r0Rb8/e3Dp4HuGvLOm3sLxOUR2PsdjKvPquMKDAzc9oTQzoel+q62jC Ji9LXNQMZjQCcIMV5+ecn08QcA2s670eqXftBDj+ZosL1nsbtVDE7rKiMVxSxQmzA/Ik Aem5lzzmcamU3X+LhjkG3EyfPGkJ+jmlLex8tMbfF4bGEdnscFc8GQjGo+hj9dtUo1bd V2JA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=vXIy2wUt; 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=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z12si15201283eju.15.2019.09.13.14.25.53; Fri, 13 Sep 2019 14:26:17 -0700 (PDT) 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=@linaro.org header.s=google header.b=vXIy2wUt; 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=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388636AbfIMVYJ (ORCPT + 99 others); Fri, 13 Sep 2019 17:24:09 -0400 Received: from mail-lf1-f65.google.com ([209.85.167.65]:32863 "EHLO mail-lf1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731214AbfIMVYJ (ORCPT ); Fri, 13 Sep 2019 17:24:09 -0400 Received: by mail-lf1-f65.google.com with SMTP id d10so23166782lfi.0 for ; Fri, 13 Sep 2019 14:24:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:mail-followup-to:references :mime-version:content-disposition:in-reply-to:user-agent; bh=M7RhwXkvx5UdXmM9G4lNP2WF3fIHiZECXKfzifEwcp4=; b=vXIy2wUt6CHXoGo9KPMbdEWFr+4Ws+dQLZDXXickxOjGdu3VW2EHmmG5X71zL4Ew/2 mc1yYqRPVxOTrS1mjS9mO3DqGj2lneRbZuDyTEKfYxOizw/XJgcgxgUrYGTvqJYeBuJV ZEGU4RVBYG8GkE0kL2ee7rXMfkpO4MMQlBSd/pwcSBCULXbdkyy97eS5ZepJxd/E5FKY xBy5f3WSxa+qiw84F+Ue1OFUO/JAcKtlWa577IzduLR/cvVivD6r9GEyvtHJQHO1qInK 82j/HEJowx+BF5Q2Xgqq99Mb2/W/MN+huQjMXUjsOqV0V0csQV8NQWxF4+N0wE2BB4s4 2q+Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id :mail-followup-to:references:mime-version:content-disposition :in-reply-to:user-agent; bh=M7RhwXkvx5UdXmM9G4lNP2WF3fIHiZECXKfzifEwcp4=; b=XITf6N/2Bn3ImdKnswkE4wIiQlQQqX8pAV9mFiPaVYtZTv6XzoXab1gcDhX//vdlmW YZA7XUj+/IwLhyTs6Hv6AGi6DMuiqFWiSKa1AzWIQ2BfmDY8wDogpFx/xgnalCl8fUqH F6QcMJOtLuTtoPyKg7Z4OxKvtQZM22L+t4ePUTuw7INlKIm8zn7Sv2GV4zdQ6djGbZBE /77CMRkJ79oSL9HlYGN+s/t8faS/Od49abhkeu6NglMxt38dDzxmaDSbvUSy+Uz4c0hp eUyhpMDtphB05KTKljDVkYUyGQIA1QjhbD/lbgxhb8QUKy2TP1zC6Y/5u4ws8QKBFZ0h tE9w== X-Gm-Message-State: APjAAAX5q71oANnFl4SBKxwxLfZwBnuWsXWVwfiBwS2nihobpSNX0TvJ GLK1G/4lREhgr1zFMudGTuQ2Eh892wI= X-Received: by 2002:a19:4a10:: with SMTP id x16mr34910188lfa.126.1568409846959; Fri, 13 Sep 2019 14:24:06 -0700 (PDT) Received: from khorivan (168-200-94-178.pool.ukrtel.net. [178.94.200.168]) by smtp.gmail.com with ESMTPSA id p8sm6619563ljn.93.2019.09.13.14.24.05 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 13 Sep 2019 14:24:06 -0700 (PDT) Date: Sat, 14 Sep 2019 00:24:04 +0300 From: Ivan Khoronzhuk To: Yonghong Song Cc: "ast@kernel.org" , "daniel@iogearbox.net" , "davem@davemloft.net" , "jakub.kicinski@netronome.com" , "hawk@kernel.org" , "john.fastabend@gmail.com" , "linux-kernel@vger.kernel.org" , "netdev@vger.kernel.org" , "bpf@vger.kernel.org" , "clang-built-linux@googlegroups.com" Subject: Re: [PATCH bpf-next 05/11] samples: bpf: makefile: use D vars from KBUILD_CFLAGS to handle headers Message-ID: <20190913212402.GB26724@khorivan> Mail-Followup-To: Yonghong Song , "ast@kernel.org" , "daniel@iogearbox.net" , "davem@davemloft.net" , "jakub.kicinski@netronome.com" , "hawk@kernel.org" , "john.fastabend@gmail.com" , "linux-kernel@vger.kernel.org" , "netdev@vger.kernel.org" , "bpf@vger.kernel.org" , "clang-built-linux@googlegroups.com" References: <20190910103830.20794-1-ivan.khoronzhuk@linaro.org> <20190910103830.20794-6-ivan.khoronzhuk@linaro.org> <97ca4228-145a-2449-b4ba-8e79380a54f4@fb.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline In-Reply-To: <97ca4228-145a-2449-b4ba-8e79380a54f4@fb.com> User-Agent: Mutt/1.9.4 (2018-02-28) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Sep 13, 2019 at 09:12:01PM +0000, Yonghong Song wrote: > > >On 9/10/19 11:38 AM, Ivan Khoronzhuk wrote: >> The kernel headers are reused from samples bpf, and autoconf.h is not >> enough to reflect complete arch configuration for clang. But CLANG-bpf >> cmds are sensitive for assembler part taken from linux headers and -D >> vars, usually used in CFLAGS, should be carefully added for each arch. >> For that, for CLANG-bpf, lets filter them only for arm arch as it >> definitely requires __LINUX_ARM_ARCH__ to be set, but ignore for >> others till it's really needed. For arm, -D__LINUX_ARM_ARCH__ is min >> version used as instruction set selector. In another case errors >> like "SMP is not supported" for arm and bunch of other errors are >> issued resulting to incorrect final object. >> >> Later D_OPTIONS can be used for gcc part. >> --- >> samples/bpf/Makefile | 9 +++++++++ >> 1 file changed, 9 insertions(+) >> >> diff --git a/samples/bpf/Makefile b/samples/bpf/Makefile >> index 8ecc5d0c2d5b..6492b7e65c08 100644 >> --- a/samples/bpf/Makefile >> +++ b/samples/bpf/Makefile >> @@ -185,6 +185,15 @@ HOSTLDLIBS_map_perf_test += -lrt >> HOSTLDLIBS_test_overhead += -lrt >> HOSTLDLIBS_xdpsock += -pthread >> >> +# Strip all expet -D options needed to handle linux headers >> +# for arm it's __LINUX_ARM_ARCH__ and potentially others fork vars >> +D_OPTIONS = $(shell echo "$(KBUILD_CFLAGS) " | sed 's/[[:blank:]]/\n/g' | \ >> + sed '/^-D/!d' | tr '\n' ' ') >> + >> +ifeq ($(ARCH), arm) >> +CLANG_EXTRA_CFLAGS := $(D_OPTIONS) >> +endif > >Do you need this for native compilation? Yes, native "arm" also requires it. > >so arm64 compilation does not need this? yes, now only arm >If only -D__LINUX_ARM_ARCH__ is needed, maybe just >with > CLANG_EXTRA_CFLAGS := -D__LINUX_ARM_ARCH__ Value also needed: -D__LINUX_ARM_ARCH_=7 or -D__LINUX_ARM_ARCH_=6 So, need retrieve it. >Otherwise, people will wonder whether this is needed for >other architectures. Or just do > CLANG_EXTRA_CFLAGS := $(D_OPTIONS) >for all cross compilation? arm, cross and native requires it. Will do this: # Strip all expet -D options needed to handle linux headers # for arm it's __LINUX_ARM_ARCH__ and potentially others fork vars ifeq ($(ARCH), arm) D_OPTIONS = $(shell echo "$(KBUILD_CFLAGS) " | sed 's/[[:blank:]]/\n/g' | \ sed '/^-D/!d' | tr '\n' ' ') endif CLANG_EXTRA_CFLAGS := $(D_OPTIONS) > >> + >> # Allows pointing LLC/CLANG to a LLVM backend with bpf support, redefine on cmdline: >> # make samples/bpf/ LLC=~/git/llvm/build/bin/llc CLANG=~/git/llvm/build/bin/clang >> LLC ?= llc >> -- Regards, Ivan Khoronzhuk