From patchwork Tue Sep 10 10:38:24 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ivan Khoronzhuk X-Patchwork-Id: 173500 Delivered-To: patch@linaro.org Received: by 2002:a05:6e02:ce:0:0:0:0 with SMTP id r14csp5609716ilq; Tue, 10 Sep 2019 03:38:49 -0700 (PDT) X-Google-Smtp-Source: APXvYqwKo5nMca3YQMXId0FM6/M/UAHd3WHhO/EXwNU5IbYbEX9+9G/EpcDGYR4J9PgXN0S1mgnK X-Received: by 2002:a17:906:5393:: with SMTP id g19mr13593294ejo.256.1568111929747; Tue, 10 Sep 2019 03:38:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1568111929; cv=none; d=google.com; s=arc-20160816; b=p4+Z7jgGd9Y4ef0SPG/XjshQD+ek/xvVT3SXV4GR3zUI/JPafjpoplIkZDRDCrGBTN Ump+fZIzd+YtOJ7ruMIzQmueI4A1ADctRZysuY4ZCdBHdLEJTy69GO9BG+DRe79YyDzg 1YbvwX31gOZHNeILXF6PPI4+k0Xa3bldMZHdBjFhtqdhUWEfYBxsiTEHJmp7aiUuDCMj ewCFKeDmhWQIE19PELJ1H7/PuV7yx706+jzNsOdanGagcFaSzdW7O1u8ZUvOV4duxdRm WfTO1eKnmNrj8C5vlNc539ulBsfUCWXJbe/V9YFsrEfgr1fUDNeIKzeMmXtdoLmN5RU7 S08A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=2CISuDOqpRrytITzE2bzjW1/55vOTPEJWp8ToeKeR/s=; b=nClb81qx4fF61T6EoD0KV9rIk+57ORczQgJtbtS5mPkzeFRGD+VU/dQfVyMaiLtMiB Nhfs/WuqPaBO07cRZzU1K/mN0EbaMwQSjciS1RLC2tqNf088pIseWZmUM8oHJtyjTh39 1+3XWL0qckj/Ze11880gm8qKHDuAT7qnqrXS5qYcuOFBKbcfw2Kdcru2BPVJ3tYsOqFH BJUnnhlqve7q7Q+WlrMoLKwKwVPcD4QrRPns4WLCc+7Vdz9Cpse32Mk3UEotZ2Ql8eqT HKa2KVgR5TraKQGWUylOcq0NI21PzCk7brmy851KjOZf2OfogRfc+goLkCTKSfu8r7+i impg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=P7UfO+FT; 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 y9si8966603ejb.5.2019.09.10.03.38.49; Tue, 10 Sep 2019 03:38:49 -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=P7UfO+FT; 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 S2436559AbfIJKir (ORCPT + 27 others); Tue, 10 Sep 2019 06:38:47 -0400 Received: from mail-lf1-f66.google.com ([209.85.167.66]:45123 "EHLO mail-lf1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2406052AbfIJKip (ORCPT ); Tue, 10 Sep 2019 06:38:45 -0400 Received: by mail-lf1-f66.google.com with SMTP id r134so13001641lff.12 for ; Tue, 10 Sep 2019 03:38:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=2CISuDOqpRrytITzE2bzjW1/55vOTPEJWp8ToeKeR/s=; b=P7UfO+FTl1bnzu58ITbd2c6ZsAqQrt8Qa1tZHEKjiRiiGqt4NsWRiu1jKrm7bdxgfl ORiWhKn4HTpMA7X/BlerAFmJfDj66KexpV3883rEICKB3oibNnHNbMTriwzuasJhOwhd 6U5eZvYvHKZgO3w6I4GkuD+ksR0NvR+5nMNkTwqMzO6QQF+QyIKbyxt8DPDSgk4ELsis hJxSS1nCRfzKd2XnW/zsh1U5A0kDPAUV2sEDRbeyjjB7JiOZsE6gxdVD5RVR5LrE2XNf d7CAthgXfH5bWJ5MBh3D+HX10ChBb/Sobj2KWiGwXwVb086DHwlDeknb9+lb07r3Ec3D PktQ== 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:date:message-id:in-reply-to :references; bh=2CISuDOqpRrytITzE2bzjW1/55vOTPEJWp8ToeKeR/s=; b=DbR194JWppXOEDgkib4t5ygrJbN5aqen4r+afVySCU1RzKKvj9fdycqEy1J0RS659o g0IWHlW5NZmKhTd3WBxyvpEvGdm8oXNlf/yiCQ7R4eQliAuGGDtmeLdnIyu+GtDjPA4e qir6Z4meD4yuHhi/0JFz13zUtf8VD8bGC5ElGJfpwVtGritnW8Bn6CO6Naj1dW+gkpXt YOMAAYfhwWDz7zGXiYzQXJ39V+MqRLYAxOhiLyjkhgqcY1vEvlG13LRSlb9uC5dEKJqq Loabl4l6VOXf2WAkgUSvwIjkm/M35ONWBkW0Wl+lhtjONhNo4vjrccUq4aVvtKBTo3g3 Bf/w== X-Gm-Message-State: APjAAAXrQJNGPEhj2lsqoALvmw+hVhhEyIzT2E61csdUezWRW1FlP6zL wv0aevkVSJhMPzVmuBiTZsBCSQ== X-Received: by 2002:a19:381a:: with SMTP id f26mr19784105lfa.168.1568111923667; Tue, 10 Sep 2019 03:38:43 -0700 (PDT) Received: from localhost.localdomain (168-200-94-178.pool.ukrtel.net. [178.94.200.168]) by smtp.gmail.com with ESMTPSA id g5sm4005563lfh.2.2019.09.10.03.38.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Sep 2019 03:38:43 -0700 (PDT) From: Ivan Khoronzhuk To: ast@kernel.org, daniel@iogearbox.net, yhs@fb.com, davem@davemloft.net, jakub.kicinski@netronome.com, hawk@kernel.org, john.fastabend@gmail.com Cc: linux-kernel@vger.kernel.org, netdev@vger.kernel.org, bpf@vger.kernel.org, clang-built-linux@googlegroups.com, Ivan Khoronzhuk Subject: [PATCH bpf-next 05/11] samples: bpf: makefile: use D vars from KBUILD_CFLAGS to handle headers Date: Tue, 10 Sep 2019 13:38:24 +0300 Message-Id: <20190910103830.20794-6-ivan.khoronzhuk@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190910103830.20794-1-ivan.khoronzhuk@linaro.org> References: <20190910103830.20794-1-ivan.khoronzhuk@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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(+) -- 2.17.1 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 + # 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