From nobody Fri Apr 3 06:26:51 2026 Received: from mail-wm1-f53.google.com (mail-wm1-f53.google.com [209.85.128.53]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8BF412BDC0A for ; Wed, 18 Feb 2026 15:48:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.53 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771429689; cv=none; b=kFUXQLLyNunre630jvIQXFZeapMDFuhbBF764lDMU0BCbIRg+zv3Uw+1E+vuvoJa2C3uUtFK28J2QoDWECVuBWjta+U4fcHf/I6BsdlrtzT1fvZu5yXg3oVkiHuWurXHgd49lJvw9S/puBNwE7s0MgLJuonvHXSUs373dQWnrmw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771429689; c=relaxed/simple; bh=zpyqzpFOHppQVJAb1owM5FRBK9bKCVLDsQ7J3h9lQ88=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=kIKURgrpgUFcUmsLgHcdYmFzphxMqYDrvFGSZkajKw0KaBdAlA949q5VUtl9EviIW03fNY/IB4oRy8vXY0FANscGPcq6pyq8tAhwvCOZAla9JmjoxHHEDgG/jczYADMshyzFhmM2Dz7Hs1JLu8uv+xWR0XlVQh+uNMPYNpA/nQs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=PM/JryG+; arc=none smtp.client-ip=209.85.128.53 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="PM/JryG+" Received: by mail-wm1-f53.google.com with SMTP id 5b1f17b1804b1-480706554beso53940425e9.1 for ; Wed, 18 Feb 2026 07:48:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1771429686; x=1772034486; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=xj239r5RLCKwLTm1AZYnx5SxtOGhPSVfSA9B5DKaX3Y=; b=PM/JryG+eIlWviqiLmGcbTXff7DUuNtisx+oUhskRu+ivkgzPMdfgV52ErI1yss4B2 /1tosHoiVOre/afT6jaKL/eLwjbqxBj5s2kMTyyLhhxjsLaNw1aR9qPcdM2ykEbEmGlB +41n9TUWG5idCfLViP4Mq1M+O5Cq4cpPdVgbZnlGMaVjnrUHwX4SmSoPypED+nyY4btb dzx2CrRkb3vwWLvEBb1Ae2dLeiha+Wo6wxC4hrcu4INyphAb6VMaRrqb+vrzwWM8c0Tm wpDyr8OQAJylvNhL2iyj0rbeiMW80KPlAr/02AQTLKMZnT5hcjSzUzikbvo1hWrgc7l6 g5hA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1771429686; x=1772034486; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=xj239r5RLCKwLTm1AZYnx5SxtOGhPSVfSA9B5DKaX3Y=; b=nP1rCiPFmJnexFD0k55Q9d/fcX668rXIS55KwMx3EAURDDhj4W46GwC4Q1sslNL7IV fHZrm498hfser6L0qLDavKqskviign6DeYamI5xpVW53otvJqH6seefGCdxaoR912e5P /C9bKE81NHaIgeS86RDqSIgeJTn3Hz2tUWNKU7moN/7Hv7+pEjYCq41OQmKDfbkZH32A OjICLvNUwpaIFzSImaHVkmzNCJbaK3yHlGx9P6z/gBeZCIkWn7iShqvZ83Xzv9ZCWzlf T+yxLndW5Yj1eGYft2/7NcHQ0mdD7euIGZ49/yf8O81aqc7nxTSSDPuIE1n8tMA2G/YP W5OA== X-Forwarded-Encrypted: i=1; AJvYcCWc7/5bOCGDS+AKxi96dFVdobJ0+ej3+DIN3pTYcfEkcmDHvgAQp2h8Zo2YDBx05T36SZWuhRVS7Qd7/8s=@vger.kernel.org X-Gm-Message-State: AOJu0Yx/REgKoUDVGWjnqFWhcqih3JqmaJsm0wT8cWxpkXoYff05z91w LLi3wMAUnXO5x7Lx1egu77dP2fGv8NTf4WfzK2xDXH92KTZQO+SIzAa2 X-Gm-Gg: AZuq6aIByRNLKAxv4pesuVC+lBem4sp8nz5lp4fNCYbZgqfdmgWlRSxlEJKINh5FIxf pkVgsefMrzpmJGW1wFFR+JjOxsz8T4k3rYtJHqZJN1BHMChG7CevvWtDQtzp8ljtufjcO9JkRaO MBetN8ztZ8YTQYtXpI3rw7HkwTUBgC9m8huR1MPDjzqaymrTIoZAcxWk84rJXB5egjvWR4Zwe5t fhV3yE1URdPJ9YYk859I6VYiYz2M/vvzNDt8S+Nl0tURr+Omy37hudlFWHuvQ0iCNz8S2bN2VD1 cu+1IKnHO6Tay9H+aVtFbhllcMlqLUuuCaoVj1X7TeT+EPPKZGHhZSMJNW6KWjE5ZQ0hpr0UUUw wDGXJqETSvv9RWP02yq5KF2S77S8q8dKHN1KG7AkW4UkIiEGyn6N+BOW9Y1+9Qb5ujXiGUgxFo1 p5djxQvMCYcA467Ln2EflRC5wiWqVS6rJuVINLnocaooH9MjQ0iAnLlpwMK/x/dT/EEj5srb8I2 Qo/av7Gy5DS/1pI8l/kdsESEFr+sDnIKSMuo/N6MM7k/U4= X-Received: by 2002:a05:600c:c491:b0:475:dd89:acb with SMTP id 5b1f17b1804b1-48379be8253mr257859815e9.22.1771429685657; Wed, 18 Feb 2026 07:48:05 -0800 (PST) Received: from ddolgov-thinkpadt14sgen1.rmtde.csb (dslb-002-207-075-089.002.207.pools.vodafone-ip.de. [2.207.75.89]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4837e565f5esm428352325e9.10.2026.02.18.07.48.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Feb 2026 07:48:05 -0800 (PST) From: Dmitrii Dolgov <9erthalion6@gmail.com> To: linux-perf-users@vger.kernel.org, Ian Rogers , Arnaldo Carvalho de Melo , Miguel Ojeda , Levi Zim Cc: Namhyung Kim , Linux Kernel Mailing List , Linux Kbuild mailing list , rust-for-linux , Nathan Chancellor , Nicolas Schier , Dmitrii Dolgov <9erthalion6@gmail.com> Subject: [PATCH v4] tools build: Fix rust cross compilation Date: Wed, 18 Feb 2026 16:47:53 +0100 Message-ID: <20260218154800.367720-1-9erthalion6@gmail.com> X-Mailer: git-send-email 2.52.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Currently no target is specified to compile rust code when needed, which breaks cross compilation. E.g. for arm64: LD /tmp/build/tests/workloads/perf-test-in.o aarch64-linux-gnu-ld: /tmp/build/tests/workloads/code_with_type.a(code_= with_type.code_with_type.d12f4324cb53c560-cgu.0.rcgu.o): Relocations in gen= eric ELF (EM: 62) aarch64-linux-gnu-ld: /tmp/build/tests/workloads/code_with_type.a(code_= with_type.code_with_type.d12f4324cb53c560-cgu.0.rcgu.o): Relocations in gen= eric ELF (EM: 62) [...repeated...] aarch64-linux-gnu-ld: /tmp/build/tests/workloads/code_with_type.a(code_= with_type.code_with_type.d12f4324cb53c560-cgu.0.rcgu.o): Relocations in gen= eric ELF (EM: 62) aarch64-linux-gnu-ld: /tmp/build/tests/workloads/code_with_type.a(code_= with_type.code_with_type.d12f4324cb53c560-cgu.0.rcgu.o): Relocations in gen= eric ELF (EM: 62) aarch64-linux-gnu-ld: /tmp/build/tests/workloads/code_with_type.a: erro= r adding symbols: file in wrong format make[5]: *** [/perf/tools/build/Makefile.build:162: /tmp/build/tests/wo= rkloads/perf-test-in.o] Error 1 make[4]: *** [/perf/tools/build/Makefile.build:156: workloads] Error 2 make[3]: *** [/perf/tools/build/Makefile.build:156: tests] Error 2 make[2]: *** [Makefile.perf:785: /tmp/build/perf-test-in.o] Error 2 make[2]: *** Waiting for unfinished jobs.... make[1]: *** [Makefile.perf:289: sub-make] Error 2 make: *** [Makefile:76: all] Error 2 Detect required target and pass it via rust_flags to the compiler. Note that CROSS_COMPILE might be different from what rust compiler expects, since it may omit the target vendor value, e.g. "aarch64-linux-gnu" instead of "aarch64-unknown-linux-gnu". Thus explicitly map supported CROSS_COMPILE values to corresponding Rust versions, as suggested by Miguel Ojeda. Tested using arm64 cross-compilation example from [1]. Fixes: 2e05bb52a12 ("perf test workload: Add code_with_type test workload") Link: https://perfwiki.github.io/main/arm64-cross-compilation-dockerfile/ [= 1] Signed-off-by: Dmitrii Dolgov <9erthalion6@gmail.com> Reviewed-by: Ian Rogers --- Changes in v4 - Fixed incorrect target name for riscv Changes in v3 - Improved commit message, add an example of the compilation failure Changes in v2: - Map supported CROSS_COMPILE values to corresponding Rust targets tools/build/Build.include | 9 +++++++++ tools/perf/Makefile.config | 14 ++++++++++++++ tools/perf/Makefile.perf | 2 +- 3 files changed, 24 insertions(+), 1 deletion(-) diff --git a/tools/build/Build.include b/tools/build/Build.include index e45b2eb0d24..cd0baa7a168 100644 --- a/tools/build/Build.include +++ b/tools/build/Build.include @@ -98,6 +98,15 @@ c_flags_2 =3D $(filter-out $(CFLAGS_REMOVE_$(basetarget)= .o), $(c_flags_1)) c_flags =3D $(filter-out $(CFLAGS_REMOVE_$(obj)), $(c_flags_2)) cxx_flags =3D -Wp,-MD,$(depfile) -Wp,-MT,$@ $(CXXFLAGS) -D"BUILD_STR(s)=3D= \#s" $(CXXFLAGS_$(basetarget).o) $(CXXFLAGS_$(obj)) =20 +### +# Rust flags to be used on rule definition, includes: +# - global $(RUST_FLAGS) +# - per target Rust flags +# - per object Rust flags +rust_flags_1 =3D $(RUST_FLAGS) $(RUST_FLAGS_$(basetarget).o) $(RUST_FLAGS_= $(obj)) +rust_flags_2 =3D $(filter-out $(RUST_FLAGS_REMOVE_$(basetarget).o), $(rust= _flags_1)) +rust_flags =3D $(filter-out $(RUST_FLAGS_REMOVE_$(obj)), $(rust_flags_2)) + ### ## HOSTCC C flags =20 diff --git a/tools/perf/Makefile.config b/tools/perf/Makefile.config index a8dc72cfe48..214d8f6d9b8 100644 --- a/tools/perf/Makefile.config +++ b/tools/perf/Makefile.config @@ -1163,6 +1163,20 @@ ifndef NO_RUST CFLAGS +=3D -DHAVE_RUST_SUPPORT $(call detected,CONFIG_RUST_SUPPORT) endif + + ifneq ($(CROSS_COMPILE),) + RUST_TARGET_FLAGS_arm :=3D arm-unknown-linux-gnueabi + RUST_TARGET_FLAGS_arm64 :=3D aarch64-unknown-linux-gnu + RUST_TARGET_FLAGS_m68k :=3D m68k-unknown-linux-gnu + RUST_TARGET_FLAGS_mips :=3D mipsel-unknown-linux-gnu + RUST_TARGET_FLAGS_powerpc :=3D powerpc64le-unknown-linux-gnu + RUST_TARGET_FLAGS_riscv :=3D riscv64gc-unknown-linux-gnu + RUST_TARGET_FLAGS_s390 :=3D s390x-unknown-linux-gnu + RUST_TARGET_FLAGS_x86 :=3D x86_64-unknown-linux-gnu + RUST_TARGET_FLAGS_x86_64 :=3D x86_64-unknown-linux-gnu + + RUST_FLAGS +=3D --target=3D$(RUST_TARGET_FLAGS_$(ARCH)) + endif endif =20 # Among the variables below, these: diff --git a/tools/perf/Makefile.perf b/tools/perf/Makefile.perf index 11b63bafdb2..f7b936deeaa 100644 --- a/tools/perf/Makefile.perf +++ b/tools/perf/Makefile.perf @@ -274,7 +274,7 @@ ifeq ($(PYLINT),1) PYLINT :=3D $(shell which pylint 2> /dev/null) endif =20 -export srctree OUTPUT RM CC CXX RUSTC LD AR CFLAGS CXXFLAGS V BISON FLEX A= WK +export srctree OUTPUT RM CC CXX RUSTC LD AR CFLAGS CXXFLAGS RUST_FLAGS V B= ISON FLEX AWK export HOSTCC HOSTLD HOSTAR HOSTCFLAGS SHELLCHECK MYPY PYLINT =20 include $(srctree)/tools/build/Makefile.include base-commit: dbf0108347bdb5d4ccef8910555b16c1f1a505f8 --=20 2.52.0