Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp644152pxb; Thu, 21 Jan 2021 16:36:30 -0800 (PST) X-Google-Smtp-Source: ABdhPJwdXQHIkfhwMCMa7rbRlYAmeKH5NcsJaI4/9u2W4E2cUkYP/+chXcw/Foex7Jtx8CtDihR3 X-Received: by 2002:a17:906:39d0:: with SMTP id i16mr1336226eje.18.1611275790537; Thu, 21 Jan 2021 16:36:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1611275790; cv=none; d=google.com; s=arc-20160816; b=0Hye8r8fR0kkXzH9mQHGlzR8QgP40n4NwSMYw5lCRRE4yFKce7dnu/H6RZBq/98tw7 1ZD+2mh7FzgkI7quWyYzZIXFBjgQo4+nmahiZkrm5fy/rowin+rfZ0hvl/84RJph41H3 Z59uJrLSuQI2A8H/U2iYLdcVno6NMIIH95gr3ma3Yd7XMSWX+ZMWPpGUfA8QpmLV1Dpp dWGjJn/+94CXqHfcBmeBJVJOVVr+Y70DbOkrjpon5tyMvpQuv6TA4V0/QEb4UXvEkySG hnoID+h2dzveCDX6YNBLbBcqIJCIw6uq5EQCnDecOxM5jPVIXogfI7HAdRA4KdsgTO4o g0lg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:to:from:dkim-signature; bh=nIwDL815WbM3BXQJbXvq/f398/RbftQTQcC+LW4e8Cw=; b=1Lq4OzwV00r4iQdTKqBiPtZma0QwtMgO7sAmCNgcHekDmXsYSrxBs1nGVQfnOHn0ii jSh9UG6KjVodTX6f/XkzSfJa28qgDxpINu07EjfKQdUrZ8+lLlFsYExRAB2vrs2r2NY5 OpOSzEZOLZXuou2qT8a23/IjokOhvEP1a5kOy26wdEKnSkgxVmZ8XBlZElwGsYEJ6Edg orexVV359mMlwhfSg+0aOS/eLhP7w+6RIx4cTl/hBviBeefykX+Bd0RJU6QVDjRZj+wj 5pC8+MORwkVnNSTGOrC5w/hea4e4eC4CnbNVCf1gC9+8trS37m+vLtjH5pYk0ryM/mhl vYeA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="Lf/QJ4FC"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id do4si2302486ejc.295.2021.01.21.16.36.06; Thu, 21 Jan 2021 16:36:30 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="Lf/QJ4FC"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726435AbhAVAdi (ORCPT + 99 others); Thu, 21 Jan 2021 19:33:38 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41700 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726222AbhAVAda (ORCPT ); Thu, 21 Jan 2021 19:33:30 -0500 Received: from mail-ed1-x533.google.com (mail-ed1-x533.google.com [IPv6:2a00:1450:4864:20::533]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B77B0C06174A; Thu, 21 Jan 2021 16:32:49 -0800 (PST) Received: by mail-ed1-x533.google.com with SMTP id d22so4687895edy.1; Thu, 21 Jan 2021 16:32:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=nIwDL815WbM3BXQJbXvq/f398/RbftQTQcC+LW4e8Cw=; b=Lf/QJ4FCE4pP1A+ZNAiTRm3qOKQYC01QPyQkp2uTVS6NmtGP++27MYD9iyJe+aOVKS 46nqbLOgI7Cj8J/vlpRXGknrWIjebEM4jnRHe/7/OjiHUchWuyB367+MhbeQBzwlccVG KmQjfOuDr5nABogQoKLmROIDJjX7KdGxnPwR5omDwIV9wwPK8U0qtR1fgSYSkkS/Tnq8 rdsp+jEy4lFlhAv8N5R4MOoe/rfWNU2YbrY1UAVnhpBxXsctWEuCP7rFWJZbMwGAPOEL uHF8P/s33TgiJDeSENFPdma629195dAJErOrWrI+OYJbgE44QNyWfpdX3tDCTXyZUuJ1 ZnkQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=nIwDL815WbM3BXQJbXvq/f398/RbftQTQcC+LW4e8Cw=; b=apI8gj9x071p2B9DKhCRbta8mq5OCuJT/TDDurQSlrAuW2Oqd4R3Jji+oKwVUzZn64 JDTs9i8DOZHGP2GBxblKt80vEGErEJo/oaNEVleHKHFDFECqC/Lx6Ubg9nCPTWbGW+VN gAowPVInVWDWLow9v0vGgF4I4MB++UoSWu4zpdmSyk12tlBV+qF8yF6aMAr8JUQvoebg LLkbdZgA9v+9aXn7oBbzm5QVS2NbUvTfGC2z0hiVscRvh0WPyRtKlXrI3Sh3ePXURxUH 04mMuQo4UpJWyov9ALFaYmEAiKr+NJEMGkHOickmPfSJ6Md56pAQj8s26eDnyWgWIUfO rUpA== X-Gm-Message-State: AOAM530qPg2NV101ugSOrowvDaS43GBTjIGztdL2hbISXUAX5Qh0QXpt LAaqp5Yo0ppdDJylFxBy0G4= X-Received: by 2002:a05:6402:104e:: with SMTP id e14mr1334004edu.316.1611275568372; Thu, 21 Jan 2021 16:32:48 -0800 (PST) Received: from localhost.localdomain (ip-109-40-66-206.web.vodafone.de. [109.40.66.206]) by smtp.gmail.com with ESMTPSA id f17sm3741870edu.25.2021.01.21.16.32.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Jan 2021 16:32:47 -0800 (PST) From: Sedat Dilek To: Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Martin KaFai Lau , Song Liu , Yonghong Song , John Fastabend , KP Singh , Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Shuah Khan , Nathan Chancellor , Nick Desaulniers , Quentin Monnet , Jean-Philippe Brucker , Tobias Klauser , Ilya Leoshkevich , Andrey Ignatov , Sedat Dilek , Stephane Eranian , "Frank Ch. Eigler" , Thomas Hebb , Masami Hiramatsu , Briana Oursler , "David S. Miller" , Davide Caratti , netdev@vger.kernel.org, bpf@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, clang-built-linux@googlegroups.com Subject: [PATCH RFC v2] tools: Factor Clang, LLC and LLVM utils definitions Date: Fri, 22 Jan 2021 01:32:25 +0100 Message-Id: <20210122003235.77246-1-sedat.dilek@gmail.com> X-Mailer: git-send-email 2.30.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org When dealing with BPF/BTF/pahole and DWARF v5 I wanted to build bpftool. While looking into the source code I found duplicate assignments in misc tools for the LLVM eco system, e.g. clang and llvm-objcopy. Move the Clang, LLC and/or LLVM utils definitions to tools/scripts/Makefile.include file and add missing includes where needed. Honestly, I was inspired by commit c8a950d0d3b9 ("tools: Factor HOSTCC, HOSTLD, HOSTAR definitions"). I tested with bpftool and perf on Debian/testing AMD64 and LLVM/Clang v11.1.0-rc1. Build instructions: [ make and make-options ] MAKE="make V=1" MAKE_OPTS="HOSTCC=clang HOSTCXX=clang++ HOSTLD=ld.lld CC=clang LD=ld.lld LLVM=1 LLVM_IAS=1" MAKE_OPTS="$MAKE_OPTS PAHOLE=/opt/pahole/bin/pahole" [ clean-up ] $MAKE $MAKE_OPTS -C tools/ clean [ bpftool ] $MAKE $MAKE_OPTS -C tools/bpf/bpftool/ [ perf ] PYTHON=python3 $MAKE $MAKE_OPTS -C tools/perf/ I was careful with respecting the user's wish to override custom compiler, linker, GNU/binutils and/or LLVM utils settings. Some personal notes: 1. I have NOT tested with cross-toolchain for other archs (cross compiler/linker etc.). 2. This patch is on top of Linux v5.11-rc4. I hope to get some feedback from especially Linux-bpf folks. Acked-by: Jiri Olsa # tools/build and tools/perf Signed-off-by: Sedat Dilek --- Changelog RFC v1->v2: - Add Jiri's ACK - Adapt to fit Linux v5.11-rc4 tools/bpf/bpftool/Makefile | 2 -- tools/bpf/runqslower/Makefile | 3 --- tools/build/feature/Makefile | 4 ++-- tools/perf/Makefile.perf | 1 - tools/scripts/Makefile.include | 7 +++++++ tools/testing/selftests/bpf/Makefile | 3 +-- tools/testing/selftests/tc-testing/Makefile | 3 +-- 7 files changed, 11 insertions(+), 12 deletions(-) diff --git a/tools/bpf/bpftool/Makefile b/tools/bpf/bpftool/Makefile index f897cb5fb12d..71c14efa6e91 100644 --- a/tools/bpf/bpftool/Makefile +++ b/tools/bpf/bpftool/Makefile @@ -75,8 +75,6 @@ endif INSTALL ?= install RM ?= rm -f -CLANG ?= clang -LLVM_STRIP ?= llvm-strip FEATURE_USER = .bpftool FEATURE_TESTS = libbfd disassembler-four-args reallocarray zlib libcap \ diff --git a/tools/bpf/runqslower/Makefile b/tools/bpf/runqslower/Makefile index 4d5ca54fcd4c..9d9fb6209be1 100644 --- a/tools/bpf/runqslower/Makefile +++ b/tools/bpf/runqslower/Makefile @@ -3,9 +3,6 @@ include ../../scripts/Makefile.include OUTPUT ?= $(abspath .output)/ -CLANG ?= clang -LLC ?= llc -LLVM_STRIP ?= llvm-strip BPFTOOL_OUTPUT := $(OUTPUT)bpftool/ DEFAULT_BPFTOOL := $(BPFTOOL_OUTPUT)bpftool BPFTOOL ?= $(DEFAULT_BPFTOOL) diff --git a/tools/build/feature/Makefile b/tools/build/feature/Makefile index 89ba522e377d..3e55edb3ea54 100644 --- a/tools/build/feature/Makefile +++ b/tools/build/feature/Makefile @@ -1,4 +1,6 @@ # SPDX-License-Identifier: GPL-2.0 +include ../../scripts/Makefile.include + FILES= \ test-all.bin \ test-backtrace.bin \ @@ -76,8 +78,6 @@ FILES= \ FILES := $(addprefix $(OUTPUT),$(FILES)) PKG_CONFIG ?= $(CROSS_COMPILE)pkg-config -LLVM_CONFIG ?= llvm-config -CLANG ?= clang all: $(FILES) diff --git a/tools/perf/Makefile.perf b/tools/perf/Makefile.perf index 62f3deb1d3a8..f4df7534026d 100644 --- a/tools/perf/Makefile.perf +++ b/tools/perf/Makefile.perf @@ -176,7 +176,6 @@ endef LD += $(EXTRA_LDFLAGS) PKG_CONFIG = $(CROSS_COMPILE)pkg-config -LLVM_CONFIG ?= llvm-config RM = rm -f LN = ln -f diff --git a/tools/scripts/Makefile.include b/tools/scripts/Makefile.include index 1358e89cdf7d..4255e71f72b7 100644 --- a/tools/scripts/Makefile.include +++ b/tools/scripts/Makefile.include @@ -69,6 +69,13 @@ HOSTCC ?= gcc HOSTLD ?= ld endif +# Some tools require Clang, LLC and/or LLVM utils +CLANG ?= clang +LLC ?= llc +LLVM_CONFIG ?= llvm-config +LLVM_OBJCOPY ?= llvm-objcopy +LLVM_STRIP ?= llvm-strip + ifeq ($(CC_NO_CLANG), 1) EXTRA_WARNINGS += -Wstrict-aliasing=3 endif diff --git a/tools/testing/selftests/bpf/Makefile b/tools/testing/selftests/bpf/Makefile index c51df6b91bef..952e2bc5f3bc 100644 --- a/tools/testing/selftests/bpf/Makefile +++ b/tools/testing/selftests/bpf/Makefile @@ -1,6 +1,7 @@ # SPDX-License-Identifier: GPL-2.0 include ../../../../scripts/Kbuild.include include ../../../scripts/Makefile.arch +include ../../../scripts/Makefile.include CXX ?= $(CROSS_COMPILE)g++ @@ -18,8 +19,6 @@ ifneq ($(wildcard $(GENHDR)),) GENFLAGS := -DHAVE_GENHDR endif -CLANG ?= clang -LLVM_OBJCOPY ?= llvm-objcopy BPF_GCC ?= $(shell command -v bpf-gcc;) SAN_CFLAGS ?= CFLAGS += -g -rdynamic -Wall -O2 $(GENFLAGS) $(SAN_CFLAGS) \ diff --git a/tools/testing/selftests/tc-testing/Makefile b/tools/testing/selftests/tc-testing/Makefile index 91fee5c43274..4d639279f41e 100644 --- a/tools/testing/selftests/tc-testing/Makefile +++ b/tools/testing/selftests/tc-testing/Makefile @@ -1,4 +1,5 @@ # SPDX-License-Identifier: GPL-2.0 +include ../../../scripts/Makefile.include top_srcdir = $(abspath ../../../..) APIDIR := $(top_scrdir)/include/uapi @@ -7,8 +8,6 @@ TEST_GEN_FILES = action.o KSFT_KHDR_INSTALL := 1 include ../lib.mk -CLANG ?= clang -LLC ?= llc PROBE := $(shell $(LLC) -march=bpf -mcpu=probe -filetype=null /dev/null 2>&1) ifeq ($(PROBE),) -- 2.30.0