All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Ian Rogers" <irogers@google.com>,
	"Peter Zijlstra" <peterz@infradead.org>,
	"Ingo Molnar" <mingo@redhat.com>,
	"Arnaldo Carvalho de Melo" <acme@kernel.org>,
	"Namhyung Kim" <namhyung@kernel.org>,
	"Jiri Olsa" <jolsa@kernel.org>,
	"Adrian Hunter" <adrian.hunter@intel.com>,
	"Quentin Monnet" <qmo@kernel.org>,
	"Miguel Ojeda" <ojeda@kernel.org>,
	"Nathan Chancellor" <nathan@kernel.org>,
	"Nicolas Schier" <nsc@kernel.org>
Cc: "Boqun Feng" <boqun@kernel.org>, "Gary Guo" <gary@garyguo.net>,
	"Björn Roy Baron" <bjorn3_gh@protonmail.com>,
	"Benno Lossin" <lossin@kernel.org>,
	"Andreas Hindborg" <a.hindborg@kernel.org>,
	"Alice Ryhl" <aliceryhl@google.com>,
	"Trevor Gross" <tmgross@umich.edu>,
	"Danilo Krummrich" <dakr@kernel.org>,
	"Nick Desaulniers" <ndesaulniers@google.com>,
	"Bill Wendling" <morbo@google.com>,
	"Justin Stitt" <justinstitt@google.com>,
	linux-perf-users@vger.kernel.org, bpf@vger.kernel.org,
	linux-kbuild@vger.kernel.org
Subject: Re: [RFC PATCH v3 1/3] tools build: Add Rust library build infrastructure and zlib-rs feature test
Date: Thu, 05 Nov 2026 18:30:53 +0000	[thread overview]
Message-ID: <sashiko-outbox-199770@kernel.org> (raw)
In-Reply-To: <20261105180923.3441359-2-irogers@google.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] tools build: feature_check_code passes CLANG_CROSS_FLAGS to g++ in CXXFLAGS
--

commit b53b88b2adbac2b7788068d159976b5144e79923
Author: Ian Rogers <irogers@google.com>

tools build: Add Rust library build infrastructure and zlib-rs feature test

This commit adds shared Rust library build and feature detection rules under
tools/build/Makefile.rust, along with cross-compilation target mappings and a
feature test for zlib-rs.

> diff --git a/tools/build/Makefile.feature b/tools/build/Makefile.feature
> index 4d37d11f674c5..ecf27626d493e 100644
> --- a/tools/build/Makefile.feature
> +++ b/tools/build/Makefile.feature
> @@ -5,10 +5,11 @@ ifneq ($(OUTPUT),)
>    OUTPUT_FEATURES = $(OUTPUT)feature/
>    $(shell mkdir -p $(OUTPUT_FEATURES))
>  endif
> +RUST_OUTPUT ?= $(abspath $(or $(OUTPUT),$(CURDIR)))/
>  
>  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) RUST_OUTPUT="$(RUST_OUTPUT)" CC="$(CC)" CXX="$(CXX)" CARGO="$(CARGO)" RUSTC="$(RUSTC)" $(if $(PKG_CONFIG),PKG_CONFIG="$(PKG_CONFIG)") CFLAGS="$(CLANG_CROSS_FLAGS) $(EXTRA_CFLAGS) $(FEATURE_CHECK_CFLAGS-$(1))" CXXFLAGS="$(CLANG_CROSS_FLAGS) $(EXTRA_CXXFLAGS) $(FEATURE_CHECK_CXXFLAGS-$(1))" RUST_FLAGS="$(RUST_FLAGS)" LDFLAGS="$(LDFLAGS) $(FEATURE_CHECK_LDFLAGS-$(1))" -C $(feature_dir) $(OUTPUT_FEATURES)test-$1.bin >/dev/null 2>/dev/null && echo 1 || echo 0)
>  endef

[Severity: Medium]
Does prepending $(CLANG_CROSS_FLAGS) to CXXFLAGS in feature_check_code break
C++ feature detection (such as cxa-demangle, llvm, and llvm-perf) when
cross-compiling with CC=clang and the default CXX=$(CROSS_COMPILE)g++?

In tools/scripts/Makefile.include, CLANG_CROSS_FLAGS is populated whenever
CC_NO_CLANG is 0 and CROSS_COMPILE is set, and is only appended to CFLAGS and
AFLAGS while CXX defaults to $(CROSS_COMPILE)g++ (unless LLVM is set or CXX is
explicitly overridden):

tools/scripts/Makefile.include:
    $(call allow-override,CC,$(CROSS_COMPILE)gcc)
    ...
    $(call allow-override,CXX,$(CROSS_COMPILE)g++)
    ...
    CLANG_CROSS_FLAGS := --target=$(CLANG_TARGET)
    GCC_TOOLCHAIN_DIR := $(dir $(shell which $(CROSS_COMPILE)gcc 2>/dev/null))
    ifneq ($(GCC_TOOLCHAIN_DIR),)
    CLANG_CROSS_FLAGS += --prefix=$(GCC_TOOLCHAIN_DIR)$(notdir $(CROSS_COMPILE))
    CLANG_CROSS_FLAGS += --sysroot=$(shell $(CROSS_COMPILE)gcc -print-sysroot)
    CLANG_CROSS_FLAGS += --gcc-toolchain=$(realpath $(GCC_TOOLCHAIN_DIR)/..)
    endif # GCC_TOOLCHAIN_DIR
    endif # CLANG_CROSS_FLAGS
    CFLAGS += $(CLANG_CROSS_FLAGS)
    AFLAGS += $(CLANG_CROSS_FLAGS)

As noted in tools/perf/Makefile.config (commit c8592f8da838 ("perf build: Fix
CXX clang flag injection when only CC=clang is set")), CC being clang does not
imply CXX is clang++. When $(CROSS_COMPILE)g++ is invoked for a C++ feature
check via $(BUILDXX), it rejects Clang-only flags in CLANG_CROSS_FLAGS such as
--target=... and --gcc-toolchain=..., causing the feature check to fail.

Also, this change to CFLAGS and CXXFLAGS in tools/build/Makefile.feature is
not mentioned in the commit message. Should CLANG_CROSS_FLAGS only be passed
in CXXFLAGS when CXX is actually clang++, or is this change intended for a
separate patch?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261105180923.3441359-1-irogers@google.com?part=1

  reply	other threads:[~2026-11-05 18:30 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-05 18:09 [RFC PATCH v3 0/3] tools: Add Rust library build infrastructure and prefer zlib-rs Ian Rogers
2026-11-05 18:09 ` [RFC PATCH v3 1/3] tools build: Add Rust library build infrastructure and zlib-rs feature test Ian Rogers
2026-11-05 18:30   ` sashiko-bot [this message]
2026-11-05 18:53   ` bot+bpf-ci
2026-11-05 18:09 ` [RFC PATCH v3 2/3] perf build: Prefer zlib-rs over zlib when available Ian Rogers
2026-11-05 18:26   ` sashiko-bot
2026-11-05 18:53   ` bot+bpf-ci
2026-11-05 18:09 ` [RFC PATCH v3 3/3] bpftool: " Ian Rogers
2026-11-05 18:15   ` sashiko-bot
2026-11-05 18:53   ` bot+bpf-ci

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=sashiko-outbox-199770@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=a.hindborg@kernel.org \
    --cc=acme@kernel.org \
    --cc=adrian.hunter@intel.com \
    --cc=aliceryhl@google.com \
    --cc=bjorn3_gh@protonmail.com \
    --cc=boqun@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=dakr@kernel.org \
    --cc=gary@garyguo.net \
    --cc=irogers@google.com \
    --cc=jolsa@kernel.org \
    --cc=justinstitt@google.com \
    --cc=linux-kbuild@vger.kernel.org \
    --cc=linux-perf-users@vger.kernel.org \
    --cc=lossin@kernel.org \
    --cc=mingo@redhat.com \
    --cc=morbo@google.com \
    --cc=namhyung@kernel.org \
    --cc=nathan@kernel.org \
    --cc=ndesaulniers@google.com \
    --cc=nsc@kernel.org \
    --cc=ojeda@kernel.org \
    --cc=peterz@infradead.org \
    --cc=qmo@kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=tmgross@umich.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.