From patchwork Mon Sep 16 10:54:19 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ivan Khoronzhuk X-Patchwork-Id: 173821 Delivered-To: patch@linaro.org Received: by 2002:a05:6e02:ce:0:0:0:0 with SMTP id r14csp3337716ilq; Mon, 16 Sep 2019 03:54:47 -0700 (PDT) X-Google-Smtp-Source: APXvYqykC9EOuDPS21cp6SAUNNX51RYBWWvhMb2adEaa4Rgq+lROxo8/cRxV/aX0naZHSn/vF9ps X-Received: by 2002:aa7:dd8e:: with SMTP id g14mr820312edv.233.1568631287695; Mon, 16 Sep 2019 03:54:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1568631287; cv=none; d=google.com; s=arc-20160816; b=QVVExy7+1/qHq9CMQSmDKxzKk0FQq2KjDPNNmg+2AzmmtZsaLWeGModfPp4lZA9LSZ sk5ffpVQT1bGyzOdWDGsIeQ5i7oKsJ9023FSGHxEfXKn5lNjmdegi7QYeGhIe63hX5E/ MnGAwEm+gfZ9GeobZt2B+lrmIJHMQ9sbHQSUe9suQLcqEl0Xq0ZeLYNydVSmP1nE4Ha5 9K180RJDdWMTLHa9NPtmG+A025WJm74SsiKPKeV08cu3amhTyDRFqOj0QHubqLxUYIxa C4x2NS37ZKprPZMftMcOiMnHA1kt15C1a25+4cXC7QhGl69X22G43ScOxz4GK7wowZHY O2pQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature; bh=nFwBnbJl1Pzb/az0iASSF7ufSzhkXpDlNpdyZZaDLco=; b=Tz0Si8Xv5R5U6UZsGPQO37WbmQIrJVGKcD190n5IVEuLLKyqCGLmOo3hs/MsQfm9AV U12ry3GmF+dQM0qLB0H3ziIWzc80z5N1qAX2GYLMs3yNv336jP+6yTwi3uU2FLwos+7u TTXLSMYY5RM7WB/FG10XbtkTnnuntGyo6NBZdhLTKdp93jiUhburUSWiYmIICuMaiKQR MO92hZl38ZyzbE7wGNJLJBRY8rzZ5f/1RIzMRjE6ZDElUbdoH+KNRMgfqQH4zhnhdQPh ScIFQOxclCFHgrexee4SsG9+JQpkxSKgrRYQZAx43PA5QrbH3kj0bES5Q2hciu+JV6Eb tSzA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Skv+nit2; 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 b13si21252224edt.403.2019.09.16.03.54.47; Mon, 16 Sep 2019 03:54:47 -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=Skv+nit2; 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 S1732429AbfIPKyn (ORCPT + 27 others); Mon, 16 Sep 2019 06:54:43 -0400 Received: from mail-lj1-f193.google.com ([209.85.208.193]:44121 "EHLO mail-lj1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725270AbfIPKym (ORCPT ); Mon, 16 Sep 2019 06:54:42 -0400 Received: by mail-lj1-f193.google.com with SMTP id m13so5320265ljj.11 for ; Mon, 16 Sep 2019 03:54:41 -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; bh=nFwBnbJl1Pzb/az0iASSF7ufSzhkXpDlNpdyZZaDLco=; b=Skv+nit2CnSd4bITeugcc5c8T6mSvVhLlXCqG/DpX+/QhEyrVs78DPqor1M91eVYOj 4cZtZWbiUEvN26GxmZJQ1kFcyW1ghVdkO0Xgu6Qeodc7Pdlaxe4PvchgOuyLH69FDRET ECcfeHUVKIg+pkJSrp259merQDwxatkV6avZvUP8F9vzlnRilkL8LR1oqKJ/paRZXht+ 6jZZjAZ0ppH+eWpHSK1L3JQvqTRAXxbMbMdGtMrel7DlBOTMaZNjs83kueiBBmDuEGgi 3opHDgVNMgkkZDAQD1o8hx5yQg40gl8h2J731huEbdUEnKawabyOpGco1+JNCbCeDjgl +54w== 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; bh=nFwBnbJl1Pzb/az0iASSF7ufSzhkXpDlNpdyZZaDLco=; b=i2h3I9e/HMiOSkWGA1goGsppA5HIOBA+A4Ylw0vALgjRBtU/o4pmIek0YXtOEw978l Kvw6EZDRdShkV05wsVw4o6/gkRoOdbhXD9tuRUlyTmJ1uLWMGPPdSdsXiNXO8WcgYXZj NMZOwWY+vmwbJfbAw1cfdbUUz0GM3VjeaDmECr9WFOAQurTmSkv84bG4PvnlXxaiyoW6 46FPkmR+6LTphNL4RhDh88AudnIofzkw9XEDitN9usbbMiK6C9lwZYKU3qCIhTR5EYgY XxDQGKz4/KPER7lV4Nn0YSTdGzs7WgQV2Eo/lOSRNUkFzdtl0QEOwX2Oi2zjYFjxQqCQ PXwg== X-Gm-Message-State: APjAAAWgiTjkTAIA1k9dQkG6XnyaY2PU0sdM+FVcFecZDDOJ3FSROzHO kIEur98LKhElqvGcIUFowauIZhoQWW8= X-Received: by 2002:a05:651c:282:: with SMTP id b2mr1654522ljo.121.1568631280219; Mon, 16 Sep 2019 03:54:40 -0700 (PDT) Received: from localhost.localdomain (168-200-94-178.pool.ukrtel.net. [178.94.200.168]) by smtp.gmail.com with ESMTPSA id v1sm8987737lfq.89.2019.09.16.03.54.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Sep 2019 03:54:39 -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, sergei.shtylyov@cogentembedded.com, Ivan Khoronzhuk Subject: [PATCH v3 bpf-next 00/14] samples: bpf: improve/fix cross-compilation Date: Mon, 16 Sep 2019 13:54:19 +0300 Message-Id: <20190916105433.11404-1-ivan.khoronzhuk@linaro.org> X-Mailer: git-send-email 2.17.1 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This series contains mainly fixes/improvements for cross-compilation but not only, tested for arm, arm64, but intended for any arch. Also verified on native build (not cross compilation) for x86_64 and arm. Initial RFC link: https://lkml.org/lkml/2019/8/29/1665 Prev. version: https://lkml.org/lkml/2019/9/10/331 Besides the patches given here, the RFC also contains couple patches related to llvm clang arm: include: asm: swab: mask rev16 instruction for clang arm: include: asm: unified: mask .syntax unified for clang They are necessarily to verify arm build. The change touches not only cross-compilation and can have impact on other archs and build environments, so might be good idea to verify it in order to add appropriate changes, some warn options could be tuned also. All is tested on x86-64 with clang installed (has to be built containing targets for arm, arm64..., see llc --version, usually it's present already) Instructions to test native on x86_64 ================================================= Native build on x86_64 is done in usual way and shouldn't have difference except HOSTCC is now printed as CC wile building the samples. Instructions to test cross compilation on arm64 ================================================= #Toolchain used for test: gcc version 8.3.0 (GNU Toolchain for the A-profile Architecture 8.3-2019.03 (arm-rel-8.36)) # Get some arm64 FS, containing at least libelf I've used sdk for TI am65x got here: http://downloads.ti.com/processor-sdk-linux/esd/AM65X/latest/exports/\ ti-processor-sdk-linux-am65xx-evm-06.00.00.07-Linux-x86-Install.bin # Install this binary to some dir, say "sdk". # Configure kernel (use defconfig as no matter), but clean everything # before. make ARCH=arm64 -C tools/ clean make ARCH=arm64 -C samples/bpf clean make ARCH=arm64 clean make ARCH=arm64 defconfig # The kernel version used in sdk doesn't correspond to checked one, # but for this verification only headers need to be syched, # so install them: make ARCH=arm64 headers_install # or on SDK if need keep them in sync (not necessarily to verify): make ARCH=arm64 INSTALL_HDR_PATH=/../sdk/\ ti-processor-sdk-linux-am65xx-evm-06.00.00.07/linux-devkit/sysroots/\ aarch64-linux/usr headers_install # Build samples make samples/bpf/ ARCH=arm64 CROSS_COMPILE="aarch64-linux-gnu-"\ SYSROOT="/../sdk/ti-processor-sdk-linux-am65xx-evm-06.00.00.07/\ linux-devkit/sysroots/aarch64-linux" Instructions to test cross compilation on arm ================================================= #Toolchains used for test: arm-linux-gnueabihf-gcc (Linaro GCC 7.2-2017.11) 7.2.1 20171011 or arm-linux-gnueabihf-gcc (GNU Toolchain for the A-profile Architecture 8.3-2019.03 \ (arm-rel-8.36)) 8.3.0 # Get some FS, I've used sdk for TI am52xx got here: http://downloads.ti.com/processor-sdk-linux/esd/AM57X/05_03_00_07/exports/\ ti-processor-sdk-linux-am57xx-evm-05.03.00.07-Linux-x86-Install.bin # Install this binary to some dir, say "sdk". # Configure kernel, but clean everything before. make ARCH=arm -C tools/ clean make ARCH=arm -C samples/bpf clean make ARCH=arm clean make ARCH=arm omap2plus_defconfig # The kernel version used in sdk doesn't correspond to checked one, but headers only should be synched, so install them: make ARCH=arm64 headers_install # or on SDK if need keep them in sync (not necessarily): make ARCH=arm INSTALL_HDR_PATH=/../sdk/\ ti-processor-sdk-linux-am57xx-evm-05.03.00.07/linux-devkit/sysroots/\ armv7ahf-neon-linux-gnueabi/usr headers_install # Build samples make samples/bpf/ ARCH=arm CROSS_COMPILE="arm-linux-gnueabihf-"\ SYSROOT="/../sdk/ti-processor-sdk-linux-am57xx-evm-05.03\ .00.07/linux-devkit/sysroots/armv7ahf-neon-linux-gnueabi" Based on bpf-next/master v3..v2: - renamed makefile.progs to makeifle.target, as more appropriate - left only __LINUX_ARM_ARCH__ for D options for arm - for host build - left options from KBUILD_HOST for compatibility reasons - split patch adding c/cxx/ld flags to libbpf by modules - moved readme change to separate patch - added patch setting options for cross-compile - fixed issue with option error for syscall_nrs.S, avoiding overlap for ccflags-y. v2..v1: - restructured patches order - split "samples: bpf: Makefile: base progs build on Makefile.progs" to make change more readable. It added couple nice extra patches. - removed redundant patch: "samples: bpf: Makefile: remove target for native build" - added fix: "samples: bpf: makefile: fix cookie_uid_helper_example obj build" - limited -D option filter only for arm - improved comments - added couple instructions to verify cross compilation for arm and arm64 arches based on TI am57xx and am65xx sdks. - corrected include a little order Ivan Khoronzhuk (14): samples: bpf: makefile: fix HDR_PROBE "echo" samples: bpf: makefile: fix cookie_uid_helper_example obj build samples: bpf: makefile: use --target from cross-compile samples: bpf: use own EXTRA_CFLAGS for clang commands samples: bpf: makefile: use __LINUX_ARM_ARCH__ selector for arm samples: bpf: makefile: drop unnecessarily inclusion for bpf_load samples: bpf: add makefile.target for separate CC target build samples: bpf: makefile: base target programs rules on Makefile.target samples: bpf: makefile: use own flags but not host when cross compile samples: bpf: makefile: use target CC environment for HDR_PROBE libbpf: makefile: add C/CXX/LDFLAGS to libbpf.so and test_libpf targets samples: bpf: makefile: provide C/CXX/LD flags to libbpf samples: bpf: makefile: add sysroot support samples: bpf: README: add preparation steps and sysroot info samples/bpf/Makefile | 179 +++++++++++++++++++++--------------- samples/bpf/Makefile.target | 75 +++++++++++++++ samples/bpf/README.rst | 41 ++++++++- tools/lib/bpf/Makefile | 11 ++- 4 files changed, 225 insertions(+), 81 deletions(-) create mode 100644 samples/bpf/Makefile.target -- 2.17.1 Acked-by: Andrii Nakryiko Acked-by: Andrii Nakryiko Acked-by: Andrii Nakryiko