Received: by 2002:a25:b323:0:0:0:0:0 with SMTP id l35csp240393ybj; Thu, 19 Sep 2019 13:39:33 -0700 (PDT) X-Google-Smtp-Source: APXvYqzbWdegbpnhUcHNecfJ3JH1OKKKcNNbfIbULCttY1t9pafOIF/Atfq8SIs/QHx+uO1+NFfc X-Received: by 2002:a17:906:6848:: with SMTP id a8mr16426141ejs.104.1568925573479; Thu, 19 Sep 2019 13:39:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1568925573; cv=none; d=google.com; s=arc-20160816; b=vZEy8feH+ew2qDMnQELu0B7PkxatxXUDeGp++Jmg1xpj2/xzFy2VOJYgAT90wHbj9D HwYUKGexttnx8Qh+ue/4nuzlO/a8/deidsC60/vaUQYp66cxGgKMWXcK/uxg2vXW4v8k ChmTPnvbvpPhjgRx3gFDMkqjAjh5/MG0aZel7+gpRsIcpOXtx1Q3Lk+S8gqSe8Gnemrm KMkni7aI1mHG/FYQwA+38pvWVOwMdCx94WC+j75JO8hfibAO0IqEYLyryw3SvCaekwmD k96AF5lPXDXkaXjvDgfbs1S1BbNgvhjZQbIpglsxvIdLT45lt7+IFv1dhp8OtE/gZyuw 1hig== 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=VJcWMgQlBXCDJq+mIxTwVnwKjmA/FYBDYBWzdA4+waM=; b=mn21HHRslZWoAHmraJ1RLuV2/vHSU078BdQ6XCRQzOGzYYVnQ56hTrRsBAVw6ooAu7 Fy3NkI7cYHKIoSfXzTCFzUchWpfGeXZFczu/R9nQgatkvBRy9T11+a8/OkSC4Dbg2EOo gGetWWIMj+spGutbMEMEPAoDysVkRNGhiQZHZLl1agKf/YauHrh4/cgTFHtDkpPZWnf5 fDcu1WOSyjY8b3nbcLkTl60UwGPebffxG5JUY3e7tZ9rLjYUGqJvxVyG5TyNUW06s2/y 6ygj3NmuPbng7mAxxzt4W+caIHOUo1b9DCAvFuSvZx7nLglh4PxdBUnuPxQbit9Btpgb Bs6w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Ue2ocIOy; 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 g14si5621526edm.407.2019.09.19.13.39.06; Thu, 19 Sep 2019 13:39:33 -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=Ue2ocIOy; 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 S2389596AbfISOS5 (ORCPT + 99 others); Thu, 19 Sep 2019 10:18:57 -0400 Received: from mail-lf1-f65.google.com ([209.85.167.65]:43257 "EHLO mail-lf1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388006AbfISOS5 (ORCPT ); Thu, 19 Sep 2019 10:18:57 -0400 Received: by mail-lf1-f65.google.com with SMTP id u3so2485940lfl.10 for ; Thu, 19 Sep 2019 07:18:55 -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=VJcWMgQlBXCDJq+mIxTwVnwKjmA/FYBDYBWzdA4+waM=; b=Ue2ocIOyWscRCt7ZzCTi01c0gL7F7vMVAGP9yIEGYKpEYohfx/PwMKCvSdrtlzdPYK BUht9dlkdUgnz/lwVucsdrAvl5byjMtVldpfPt9guguIxcbNz4SFJOHcYVK+1BiYwvNe 7DuwgnRk82njueUCROP8jC8sMCF0EJrc49hkHVFvhTE4Bp3o+Q85DuhPxSlM/vTG26Nu CQ6tS1ewupHReyrLiQCexCiPBVGy5oIcGB/rLj/GtSYvVxZkjonoQgHZA1zmA7kWgQO1 tBGOWhOzQKBPw8V7d9iQI2UgQVnQN7Osy+Chy72rqp+xsMyXSmOKfZvFWJ1OpljK4fFB 95mQ== 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=VJcWMgQlBXCDJq+mIxTwVnwKjmA/FYBDYBWzdA4+waM=; b=jx3joRnBZbqD7EpZrzRSXmc7WerOYgywzs4jvSN7HaPXX7ALxy0Mu5zwh+MyqYqNMs qCbhLU5LiNATSVm844Vs8eG7wXQHXfNGXTfnn7+yyNlTyb9f+E5Ipov/4Uts+NieYNrL Kn6WyCK8Em0/wpOWxbhfIuRWxxfkYLbz510tfT8W3/7UKzDA2LHWFDgy8Y2yDaZCLBz8 8LuAGnQRdscOzcmHIzxqWg8RGi0JUYmTdz61/NMmRWRiVTJAe4x6VOS5QDkXrxYZTJkU LlyUrv101QT/RywJ5aNeLvxSORhTa3bhYDOZTRiGKRhpgltV7WnNberY5EwsDNb0kxxe I34A== X-Gm-Message-State: APjAAAUh7w1XaSWYuT2urS0RVSkIWQT2WQN8Z6MCOBiLF39TDNkvhVji j1SVHJVS6iGq4rdukXb6YI4qaw== X-Received: by 2002:a19:d6:: with SMTP id 205mr5444406lfa.144.1568902734233; Thu, 19 Sep 2019 07:18:54 -0700 (PDT) Received: from khorivan (168-200-94-178.pool.ukrtel.net. [178.94.200.168]) by smtp.gmail.com with ESMTPSA id d25sm1582984lfj.15.2019.09.19.07.18.52 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 19 Sep 2019 07:18:53 -0700 (PDT) Date: Thu, 19 Sep 2019 17:18:50 +0300 From: Ivan Khoronzhuk To: Andrii Nakryiko Cc: Alexei Starovoitov , Daniel Borkmann , Yonghong Song , "David S. Miller" , Jakub Kicinski , Jesper Dangaard Brouer , john fastabend , open list , Networking , bpf , clang-built-linux@googlegroups.com, sergei.shtylyov@cogentembedded.com Subject: Re: [PATCH v3 bpf-next 09/14] samples: bpf: makefile: use own flags but not host when cross compile Message-ID: <20190919141848.GA8870@khorivan> Mail-Followup-To: Andrii Nakryiko , Alexei Starovoitov , Daniel Borkmann , Yonghong Song , "David S. Miller" , Jakub Kicinski , Jesper Dangaard Brouer , john fastabend , open list , Networking , bpf , clang-built-linux@googlegroups.com, sergei.shtylyov@cogentembedded.com References: <20190916105433.11404-1-ivan.khoronzhuk@linaro.org> <20190916105433.11404-10-ivan.khoronzhuk@linaro.org> <20190918103508.GC2908@khorivan> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline In-Reply-To: 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 Wed, Sep 18, 2019 at 02:29:53PM -0700, Andrii Nakryiko wrote: >On Wed, Sep 18, 2019 at 3:35 AM Ivan Khoronzhuk > wrote: >> >> On Tue, Sep 17, 2019 at 04:42:07PM -0700, Andrii Nakryiko wrote: >> >On Mon, Sep 16, 2019 at 3:59 AM Ivan Khoronzhuk >> > wrote: >> >> >> >> While compile natively, the hosts cflags and ldflags are equal to ones >> >> used from HOSTCFLAGS and HOSTLDFLAGS. When cross compiling it should >> >> have own, used for target arch. While verification, for arm, arm64 and >> >> x86_64 the following flags were used alsways: >> >> >> >> -Wall >> >> -O2 >> >> -fomit-frame-pointer >> >> -Wmissing-prototypes >> >> -Wstrict-prototypes >> >> >> >> So, add them as they were verified and used before adding >> >> Makefile.target, but anyway limit it only for cross compile options as >> >> for host can be some configurations when another options can be used, >> >> So, for host arch samples left all as is, it allows to avoid potential >> >> option mistmatches for existent environments. >> >> >> >> Signed-off-by: Ivan Khoronzhuk >> >> --- >> >> samples/bpf/Makefile | 9 +++++++++ >> >> 1 file changed, 9 insertions(+) >> >> >> >> diff --git a/samples/bpf/Makefile b/samples/bpf/Makefile >> >> index 1579cc16a1c2..b5c87a8b8b51 100644 >> >> --- a/samples/bpf/Makefile >> >> +++ b/samples/bpf/Makefile >> >> @@ -178,8 +178,17 @@ CLANG_EXTRA_CFLAGS := $(ARM_ARCH_SELECTOR) >> >> TPROGS_CFLAGS += $(ARM_ARCH_SELECTOR) >> >> endif >> >> >> >> +ifdef CROSS_COMPILE >> >> +TPROGS_CFLAGS += -Wall >> >> +TPROGS_CFLAGS += -O2 >> > >> >Specifying one arg per line seems like overkill, put them in one line? >> Will combine. >> >> > >> >> +TPROGS_CFLAGS += -fomit-frame-pointer >> > >> >Why this one? >> I've explained in commit msg. The logic is to have as much as close options >> to have smiliar binaries. As those options are used before for hosts and kinda >> cross builds - better follow same way. > >I'm just asking why omit frame pointers and make it harder to do stuff >like profiling? What performance benefits are we seeking for in BPF >samples? > >> >> > >> >> +TPROGS_CFLAGS += -Wmissing-prototypes >> >> +TPROGS_CFLAGS += -Wstrict-prototypes >> > >> >Are these in some way special that we want them in cross-compile mode only? >> > >> >All of those flags seem useful regardless of cross-compilation or not, >> >shouldn't they be common? I'm a bit lost about the intent here... >> They are common but split is needed to expose it at least. Also host for >> different arches can have some own opts already used that shouldn't be present >> for cross, better not mix it for safety. > >We want -Wmissing-prototypes and -Wstrict-prototypes for cross-compile >and non-cross-compile cases, right? So let's specify them as common >set of options, instead of relying on KBUILD_HOSTCFLAGS or >HOST_EXTRACFLAGS to have them. Otherwise we'll be getting extra >warnings for just cross-compile case, which is not good. If you are >worrying about having duplicate -W flags, seems like it's handled by >GCC already, so shouldn't be a problem. Ok, lets drop omit-frame-pointer. But then, lets do more radical step and drop KBUILD_HOSTCFLAGS & HOST_EXTRACFLAG in this patch: -ifdef CROSS_COMPILE +TPROGS_CFLAGS += -Wall -O2 +TPROGS_CFLAGS += -Wmissing-prototypes +TPROGS_CFLAGS += -Wstrict-prototypes -else -TPROGS_LDLIBS := $(KBUILD_HOSTLDLIBS) -TPROGS_CFLAGS += $(KBUILD_HOSTCFLAGS) $(HOST_EXTRACFLAGS) -endif At least it allows to use same options always for both, native and cross. I verified on native x86_64, arm64 and arm and cross for arm and arm64, but should work for others, at least it can be tuned explicitly and no need to depend on KBUILD and use "cross" fork here. -- Regards, Ivan Khoronzhuk