Received: by 2002:a05:7412:b795:b0:e2:908c:2ebd with SMTP id iv21csp341140rdb; Thu, 2 Nov 2023 05:31:01 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHsJ6q7+KpevDRFhag3d7nXDZao7uxS8Fs99r8fpig+5f8HnN6HOETcBt4vgiGFgUsF1Tfh X-Received: by 2002:a17:90a:fb81:b0:280:3b2:d37a with SMTP id cp1-20020a17090afb8100b0028003b2d37amr14306238pjb.18.1698928261075; Thu, 02 Nov 2023 05:31:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698928261; cv=none; d=google.com; s=arc-20160816; b=Ffk9AawMSdBY44WO8n+ySKqSZfyS/FWBuOiT/fDva5KmNUXMJoAU+VkZtk301kRiMY r5gTq1VHWEhuBBBgRN3tBzN3CXMF3kZ9/iscpAcP+euHLlmE9SFKkhYI1mg0Kpu24r+L CYouUgcdYeMaW9LWXv8yXPYnYJLG8ZkzNOvaMKlsFC0eOxgqCWLCTjP+dsBSHQmgTicE elHD9gLUZ3cSKpMeMD8kJCaKNFitpla7achpH/YC1EAC7RHwVie1v5bc/MLhCqYNshFh +P3BIkWREnswUWBrkHBe1jl+PsCagXaGS2YK3/OSgVz2tHdPKS/DNMxeAIbNx+QWtet8 A8AQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:date:from:dkim-signature; bh=8ZqG4eXApU2XHK/8xC8VON8f1IHU1prc7SAhVA2sCKE=; fh=gCppFzgMEnLBBHEiboD7sm2ZASHJvLnYcS2wB511CNg=; b=htpVz+npLpbALJ7gSFqyAS6FYXDIu7vCUyrL0SLCZHrqUnFZ5FHmSQ7lgCFRgZRWFS +1UyaqOknumdOKQqcn7cVXTr/MU/M+MArSYDxY7PkBEW0xraHAqOLauRPLrzaXG0c7Ur ghAs/ESYYaziIdpbfn2ZhO2k/ag2LmqI9yfp8yQbN3744zAWyfC8GBdASCK5WCK1m56l BywYX8yoHX+IPv5K04q+/XNHYPVNfVHm+2SqWJb8XbVAHy9/+4CngPbBO8tSkfAOnahz YS+iYKr2zVz+G/uwf+xtorsflQGZkSn6bXIlhoi9qcz3BOwpgQPLq1fkJlK+FKUzzLKV uUOA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=MKkPDNGw; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 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 agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id rm14-20020a17090b3ece00b002800879f482si2988487pjb.87.2023.11.02.05.31.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Nov 2023 05:31:01 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) client-ip=2620:137:e000::3:2; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=MKkPDNGw; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id 4D7A6801BF61; Thu, 2 Nov 2023 05:30:58 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1376312AbjKBMav (ORCPT + 99 others); Thu, 2 Nov 2023 08:30:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43936 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347483AbjKBMat (ORCPT ); Thu, 2 Nov 2023 08:30:49 -0400 Received: from mail-wm1-x330.google.com (mail-wm1-x330.google.com [IPv6:2a00:1450:4864:20::330]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 03AFB18B; Thu, 2 Nov 2023 05:30:46 -0700 (PDT) Received: by mail-wm1-x330.google.com with SMTP id 5b1f17b1804b1-40839807e82so5594685e9.0; Thu, 02 Nov 2023 05:30:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1698928244; x=1699533044; darn=vger.kernel.org; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:date:from:from:to :cc:subject:date:message-id:reply-to; bh=8ZqG4eXApU2XHK/8xC8VON8f1IHU1prc7SAhVA2sCKE=; b=MKkPDNGw7eEYiNg6WG7KibnuO0xxEtIxH5tIuzLRKQh8GFrKAyYwyOq8Vyhph3hLHR wfhtuA/G+pWDgABog9MawOBVW6WoduEGItdxAD+VEplwBVV9Ket3GTHe9lKKsOPzHLYe gaoL+Z9DbPtCNpMRtr2JlqFeaVGJFWJz4D6a0yCdGQYmCktnqfyQoJqyiQpn2yDe+g6Q FD0Gb5al+GcSJeNX3LJ99SGHcEsWx4NHmCApJaogFxvESTB2gh3kAT7srNRYTGjacyMu IoZOG0gXS5USMxdQNr3edUctwiXEuQ5mdmkMwhyQ0Pi9TFsakXT/Egz13957GtzXckj9 7kZA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698928244; x=1699533044; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:date:from :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=8ZqG4eXApU2XHK/8xC8VON8f1IHU1prc7SAhVA2sCKE=; b=opUrei6cnSAUNpPg0ZccApaUMd5jJmRbQg/7BgXalN4evfVI1eKrFi/fXJZEk09Xbj PRR05/SPuee3FbnWVq3rX4TMXua1u99G/BsPcbGJwRV5w7V21UniK8fhs9qGLxs4GDlB i9A+TD0W9wJqT7b4zOlTnxHVgMRNV7bLuee3Wqf1G2oOrWEFbZvJYZZ8V9W4mH8JwzYu kbSc3YjzAjc474SoXQ378ZnXP9J8yeRAs5jQmTorzshJ7TkMkdWig8UNLPL6UQUUUwMU 3V6GL5ibk/0JwueV30ZzN6FNOQCdm6tUk5b/TY5JYDk1FRzFRyp+CvTSEP4br2/a7nPf v90Q== X-Gm-Message-State: AOJu0YwkyU/KMINOUhjXBZ1DSEEiJsWBhhbxu6JF9HxcYxzlFRf/LWnE cyK9KcZrfXMKKCA5eVqSZ71jm2ZR7qW1/g== X-Received: by 2002:a05:600c:2214:b0:408:33ba:569a with SMTP id z20-20020a05600c221400b0040833ba569amr6627963wml.8.1698928243923; Thu, 02 Nov 2023 05:30:43 -0700 (PDT) Received: from krava (2001-1ae9-1c2-4c00-726e-c10f-8833-ff22.ip6.tmcz.cz. [2001:1ae9:1c2:4c00:726e:c10f:8833:ff22]) by smtp.gmail.com with ESMTPSA id fm15-20020a05600c0c0f00b003fee6e170f9sm2768435wmb.45.2023.11.02.05.30.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Nov 2023 05:30:43 -0700 (PDT) From: Jiri Olsa X-Google-Original-From: Jiri Olsa Date: Thu, 2 Nov 2023 13:30:41 +0100 To: =?iso-8859-1?Q?Bj=F6rn_T=F6pel?= Cc: Arnaldo Carvalho de Melo , Jean-Philippe Brucker , linux-kernel@vger.kernel.org, =?iso-8859-1?Q?Bj=F6rn_T=F6pel?= , Nathan Chancellor , Nick Desaulniers , Tom Rix , bpf@vger.kernel.org, Anders Roxell , llvm@lists.linux.dev, Jiri Olsa Subject: Re: [PATCH v2] tools/build: Add clang cross-compilation flags to feature detection Message-ID: References: <20231102103252.247147-1-bjorn@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20231102103252.247147-1-bjorn@kernel.org> X-Spam-Status: No, score=-0.6 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Thu, 02 Nov 2023 05:30:58 -0700 (PDT) On Thu, Nov 02, 2023 at 11:32:52AM +0100, Bj?rn T?pel wrote: > From: Bj?rn T?pel > > When a tool cross-build has LLVM=1 set, the clang cross-compilation > flags are not passed to the feature detection build system. This > results in the host's features are detected instead of the targets. > > E.g, triggering a cross-build of bpftool: > > cd tools/bpf/bpftool > make ARCH=riscv CROSS_COMPILE=riscv64-linux-gnu- LLVM=1 > > would report the host's, and not the target's features. > > Correct the issue by passing the CLANG_CROSS_FLAGS variable to the > feature detection makefile. > > Fixes: cebdb7374577 ("tools: Help cross-building with clang") > Signed-off-by: Bj?rn T?pel Acked-by: Jiri Olsa jirka > --- > tools/build/Makefile.feature | 2 +- > tools/build/feature/Makefile | 12 ++++++------ > 2 files changed, 7 insertions(+), 7 deletions(-) > > diff --git a/tools/build/Makefile.feature b/tools/build/Makefile.feature > index 934e2777a2db..25b009a6c05f 100644 > --- a/tools/build/Makefile.feature > +++ b/tools/build/Makefile.feature > @@ -8,7 +8,7 @@ endif > > feature_check = $(eval $(feature_check_code)) > define feature_check_code > - feature-$(1) := $(shell $(MAKE) OUTPUT=$(OUTPUT_FEATURES) CC="$(CC)" CXX="$(CXX)" CFLAGS="$(EXTRA_CFLAGS) $(FEATURE_CHECK_CFLAGS-$(1))" CXXFLAGS="$(EXTRA_CXXFLAGS) $(FEATURE_CHECK_CXXFLAGS-$(1))" LDFLAGS="$(LDFLAGS) $(FEATURE_CHECK_LDFLAGS-$(1))" -C $(feature_dir) $(OUTPUT_FEATURES)test-$1.bin >/dev/null 2>/dev/null && echo 1 || echo 0) > + feature-$(1) := $(shell $(MAKE) OUTPUT=$(OUTPUT_FEATURES) CC="$(CC)" CXX="$(CXX)" CFLAGS="$(EXTRA_CFLAGS) $(FEATURE_CHECK_CFLAGS-$(1))" CXXFLAGS="$(EXTRA_CXXFLAGS) $(FEATURE_CHECK_CXXFLAGS-$(1))" LDFLAGS="$(LDFLAGS) $(FEATURE_CHECK_LDFLAGS-$(1))" CLANG_CROSS_FLAGS="$(CLANG_CROSS_FLAGS)" -C $(feature_dir) $(OUTPUT_FEATURES)test-$1.bin >/dev/null 2>/dev/null && echo 1 || echo 0) > endef > > feature_set = $(eval $(feature_set_code)) > diff --git a/tools/build/feature/Makefile b/tools/build/feature/Makefile > index dad79ede4e0a..c4458345e564 100644 > --- a/tools/build/feature/Makefile > +++ b/tools/build/feature/Makefile > @@ -84,12 +84,12 @@ PKG_CONFIG ?= $(CROSS_COMPILE)pkg-config > > all: $(FILES) > > -__BUILD = $(CC) $(CFLAGS) -MD -Wall -Werror -o $@ $(patsubst %.bin,%.c,$(@F)) $(LDFLAGS) > +__BUILD = $(CC) $(CFLAGS) $(CLANG_CROSS_FLAGS) -MD -Wall -Werror -o $@ $(patsubst %.bin,%.c,$(@F)) $(LDFLAGS) > BUILD = $(__BUILD) > $(@:.bin=.make.output) 2>&1 > BUILD_BFD = $(BUILD) -DPACKAGE='"perf"' -lbfd -ldl > BUILD_ALL = $(BUILD) -fstack-protector-all -O2 -D_FORTIFY_SOURCE=2 -ldw -lelf -lnuma -lelf -lslang $(FLAGS_PERL_EMBED) $(FLAGS_PYTHON_EMBED) -DPACKAGE='"perf"' -lbfd -ldl -lz -llzma -lzstd -lcap > > -__BUILDXX = $(CXX) $(CXXFLAGS) -MD -Wall -Werror -o $@ $(patsubst %.bin,%.cpp,$(@F)) $(LDFLAGS) > +__BUILDXX = $(CXX) $(CXXFLAGS) $(CLANG_CROSS_FLAGS) -MD -Wall -Werror -o $@ $(patsubst %.bin,%.cpp,$(@F)) $(LDFLAGS) > BUILDXX = $(__BUILDXX) > $(@:.bin=.make.output) 2>&1 > > ############################### > @@ -259,10 +259,10 @@ $(OUTPUT)test-reallocarray.bin: > $(BUILD) > > $(OUTPUT)test-libbfd-liberty.bin: > - $(CC) $(CFLAGS) -Wall -Werror -o $@ test-libbfd.c -DPACKAGE='"perf"' $(LDFLAGS) -lbfd -ldl -liberty > + $(CC) $(CFLAGS) $(CLANG_CROSS_FLAGS) -Wall -Werror -o $@ test-libbfd.c -DPACKAGE='"perf"' $(LDFLAGS) -lbfd -ldl -liberty > > $(OUTPUT)test-libbfd-liberty-z.bin: > - $(CC) $(CFLAGS) -Wall -Werror -o $@ test-libbfd.c -DPACKAGE='"perf"' $(LDFLAGS) -lbfd -ldl -liberty -lz > + $(CC) $(CFLAGS) $(CLANG_CROSS_FLAGS) -Wall -Werror -o $@ test-libbfd.c -DPACKAGE='"perf"' $(LDFLAGS) -lbfd -ldl -liberty -lz > > $(OUTPUT)test-cplus-demangle.bin: > $(BUILD) -liberty > @@ -283,10 +283,10 @@ $(OUTPUT)test-libbabeltrace.bin: > $(BUILD) # -lbabeltrace provided by $(FEATURE_CHECK_LDFLAGS-libbabeltrace) > > $(OUTPUT)test-compile-32.bin: > - $(CC) -m32 -o $@ test-compile.c > + $(CC) $(CLANG_CROSS_FLAGS) -m32 -o $@ test-compile.c > > $(OUTPUT)test-compile-x32.bin: > - $(CC) -mx32 -o $@ test-compile.c > + $(CC) $(CLANG_CROSS_FLAGS) -mx32 -o $@ test-compile.c > > $(OUTPUT)test-zlib.bin: > $(BUILD) -lz > > base-commit: 21e80f3841c01aeaf32d7aee7bbc87b3db1aa0c6 > -- > 2.40.1 >