rust_for_linux: -Zregparm=<N> commandline flag for X86 (#116972)
Command line flag -Zregparm=<N> for X86 (32-bit) for rust-for-linux: https://github.com/rust-lang/rust/issues/116972
Implemented in the similar way as fastcall/vectorcall support (args are marked InReg if fit).
r? @pnkfelix
rustbot has assigned @pnkfelix. They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.
Use r? to explicitly pick a reviewer
The job mingw-check-tidy failed! Check out the build log: (web) (plain)
Click to see the possible cause of the failure (guessed by this bot)
COPY host-x86_64/mingw-check/validate-toolstate.sh /scripts/
COPY host-x86_64/mingw-check/validate-error-codes.sh /scripts/
# NOTE: intentionally uses python2 for x.py so we can test it still works.
# validate-toolstate only runs in our CI, so it's ok for it to only support python3.
ENV SCRIPT TIDY_PRINT_DIFF=1 python2.7 ../x.py test \
--stage 0 src/tools/tidy tidyselftest --extra-checks=py:lint,cpp:fmt
# This file is autogenerated by pip-compile with Python 3.10
# by the following command:
#
# pip-compile --allow-unsafe --generate-hashes reuse-requirements.in
---
#13 2.804 Building wheels for collected packages: reuse
#13 2.805 Building wheel for reuse (pyproject.toml): started
#13 3.049 Building wheel for reuse (pyproject.toml): finished with status 'done'
#13 3.050 Created wheel for reuse: filename=reuse-4.0.3-cp310-cp310-manylinux_2_35_x86_64.whl size=132715 sha256=dfa09868353292d98f811d3efdb0d54d07389e808efc71d68e3b93c514bf8bec
#13 3.050 Stored in directory: /tmp/pip-ephem-wheel-cache-ie5l4p94/wheels/3d/8d/0a/e0fc6aba4494b28a967ab5eaf951c121d9c677958714e34532
#13 3.053 Installing collected packages: boolean-py, binaryornot, tomlkit, reuse, python-debian, markupsafe, license-expression, jinja2, chardet, attrs
#13 3.441 Successfully installed attrs-23.2.0 binaryornot-0.4.4 boolean-py-4.0 chardet-5.2.0 jinja2-3.1.4 license-expression-30.3.0 markupsafe-2.1.5 python-debian-0.1.49 reuse-4.0.3 tomlkit-0.13.0
#13 3.441 WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv
#13 3.966 Collecting virtualenv
#13 3.966 Collecting virtualenv
#13 4.011 Downloading virtualenv-20.26.4-py3-none-any.whl (6.0 MB)
#13 4.226 ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 6.0/6.0 MB 28.3 MB/s eta 0:00:00
#13 4.269 Collecting distlib<1,>=0.3.7
#13 4.276 Downloading distlib-0.3.8-py2.py3-none-any.whl (468 kB)
#13 4.286 ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 468.9/468.9 KB 59.5 MB/s eta 0:00:00
#13 4.323 Collecting filelock<4,>=3.12.2
#13 4.330 Downloading filelock-3.16.0-py3-none-any.whl (16 kB)
#13 4.362 Collecting platformdirs<5,>=3.9.1
#13 4.369 Downloading platformdirs-4.3.3-py3-none-any.whl (18 kB)
#13 4.449 Installing collected packages: distlib, platformdirs, filelock, virtualenv
#13 4.635 Successfully installed distlib-0.3.8 filelock-3.16.0 platformdirs-4.3.3 virtualenv-20.26.4
#13 DONE 4.7s
#14 [7/8] COPY host-x86_64/mingw-check/validate-toolstate.sh /scripts/
#14 DONE 0.0s
---
DirectMap4k: 225216 kB
DirectMap2M: 9211904 kB
DirectMap1G: 9437184 kB
##[endgroup]
Executing TIDY_PRINT_DIFF=1 python2.7 ../x.py test --stage 0 src/tools/tidy tidyselftest --extra-checks=py:lint,cpp:fmt
+ TIDY_PRINT_DIFF=1 python2.7 ../x.py test --stage 0 src/tools/tidy tidyselftest --extra-checks=py:lint,cpp:fmt
Finished `dev` profile [unoptimized] target(s) in 0.04s
##[endgroup]
downloading https://ci-artifacts.rust-lang.org/rustc-builds-alt/13b5a4e43b92cf738acad403ea56900947f9d37b/rust-dev-nightly-x86_64-unknown-linux-gnu.tar.xz
extracting /checkout/obj/build/cache/llvm-13b5a4e43b92cf738acad403ea56900947f9d37b-true/rust-dev-nightly-x86_64-unknown-linux-gnu.tar.xz to /checkout/obj/build/x86_64-unknown-linux-gnu/ci-llvm
---
Diff in /checkout/compiler/rustc_middle/src/ty/layout.rs:19:
use rustc_target::abi::*;
use rustc_target::spec::abi::Abi as SpecAbi;
use rustc_target::spec::{
- HasTargetSpec, HasWasmCAbiOpt, HasX86AbiOpt, PanicStrategy, Target, WasmCAbi, X86Abi
+ HasTargetSpec, HasWasmCAbiOpt, HasX86AbiOpt, PanicStrategy, Target, WasmCAbi, X86Abi,
use tracing::debug;
Diff in /checkout/compiler/rustc_middle/src/ty/layout.rs:545:
impl<'tcx> HasX86AbiOpt for TyCtxt<'tcx> {
fn x86_abi_opt(&self) -> X86Abi {
- X86Abi {
- regparm: self.sess.opts.unstable_opts.regparm
- }
+ X86Abi { regparm: self.sess.opts.unstable_opts.regparm }
}
fmt error: Running `"/checkout/obj/build/x86_64-unknown-linux-gnu/rustfmt/bin/rustfmt" "--config-path" "/checkout" "--edition" "2021" "--unstable-features" "--skip-children" "--check" "/checkout/compiler/rustc_mir_build/src/build/expr/stmt.rs" "/checkout/compiler/rustc_mir_build/src/build/expr/mod.rs" "/checkout/compiler/rustc_mir_build/src/build/expr/as_rvalue.rs" "/checkout/compiler/rustc_mir_build/src/build/expr/as_constant.rs" "/checkout/compiler/rustc_mir_build/src/build/coverageinfo.rs" "/checkout/compiler/rustc_mir_build/src/build/custom/parse/instruction.rs" "/checkout/compiler/rustc_mir_build/src/build/custom/parse.rs" "/checkout/compiler/rustc_mir_build/src/build/custom/mod.rs" "/checkout/compiler/rustc_mir_build/src/build/matches/simplify.rs" "/checkout/compiler/rustc_mir_build/src/build/matches/match_pair.rs" "/checkout/compiler/rustc_mir_build/src/build/matches/util.rs" "/checkout/compiler/rustc_mir_build/src/build/matches/mod.rs" "/checkout/compiler/rustc_mir_build/src/build/matches/test.rs" "/checkout/compiler/rustc_mir_build/src/build/mod.rs" "/checkout/compiler/rustc_mir_build/src/build/block.rs" "/checkout/compiler/rustc_mir_build/src/build/scope.rs" "/checkout/compiler/rustc_middle/src/tests.rs" "/checkout/compiler/rustc_middle/src/infer/canonical.rs" "/checkout/compiler/rustc_middle/src/infer/mod.rs" "/checkout/compiler/rustc_middle/src/infer/unify_key.rs" "/checkout/compiler/rustc_middle/src/thir.rs" "/checkout/compiler/rustc_middle/src/metadata.rs" "/checkout/compiler/rustc_middle/src/error.rs" "/checkout/compiler/rustc_middle/src/query/keys.rs" "/checkout/compiler/rustc_middle/src/query/plumbing.rs" "/checkout/compiler/rustc_middle/src/query/on_disk_cache.rs" "/checkout/compiler/rustc_middle/src/query/mod.rs" "/checkout/compiler/rustc_middle/src/query/erase.rs" "/checkout/compiler/rustc_middle/src/macros.rs" "/checkout/compiler/rustc_middle/src/traits/select.rs" "/checkout/compiler/rustc_middle/src/traits/specialization_graph.rs" "/checkout/compiler/rustc_middle/src/traits/structural_impls.rs" "/checkout/compiler/rustc_middle/src/traits/query.rs" "/checkout/compiler/rustc_middle/src/traits/mod.rs" "/checkout/compiler/rustc_middle/src/traits/solve.rs" "/checkout/compiler/rustc_middle/src/ty/predicate.rs" "/checkout/compiler/rustc_middle/src/ty/normalize_erasing_regions.rs" "/checkout/compiler/rustc_middle/src/ty/instance.rs" "/checkout/compiler/rustc_middle/src/ty/opaque_types.rs" "/checkout/compiler/rustc_middle/src/ty/typeck_results.rs" "/checkout/compiler/rustc_middle/src/ty/flags.rs" "/checkout/compiler/rustc_middle/src/ty/adjustment.rs" "/checkout/compiler/rustc_middle/src/ty/consts/kind.rs" "/checkout/compiler/rustc_middle/src/ty/consts/valtree.rs" "/checkout/compiler/rustc_middle/src/ty/consts/int.rs" "/checkout/compiler/rustc_middle/src/ty/error.rs" "/checkout/compiler/rustc_middle/src/ty/consts.rs" "/checkout/compiler/rustc_middle/src/ty/print/pretty.rs" "/checkout/compiler/rustc_middle/src/ty/print/mod.rs" "/checkout/compiler/rustc_middle/src/ty/erase_regions.rs" "/checkout/compiler/rustc_middle/src/ty/adt.rs" "/checkout/compiler/rustc_middle/src/ty/elaborate_impl.rs" "/checkout/compiler/rustc_middle/src/ty/intrinsic.rs" "/checkout/compiler/rustc_middle/src/ty/layout.rs" "/checkout/compiler/rustc_middle/src/ty/rvalue_scopes.rs" "/checkout/compiler/rustc_middle/src/ty/inhabitedness/inhabited_predicate.rs" "/checkout/compiler/rustc_middle/src/ty/inhabitedness/mod.rs" "/checkout/compiler/rustc_middle/src/ty/context/tls.rs" "/checkout/compiler/rustc_middle/src/ty/visit.rs" "/checkout/compiler/rustc_middle/src/ty/structural_impls.rs" "/checkout/compiler/rustc_middle/src/ty/context.rs" "/checkout/compiler/rustc_middle/src/ty/vtable.rs" "/checkout/compiler/rustc_middle/src/ty/abstract_const.rs" "/checkout/compiler/rustc_mir_build/src/build/expr/as_place.rs"` failed.
If you're running `tidy`, try again with `--bless`. Or, if you just want to format code, run `./x.py fmt` instead.
local time: Mon Sep 16 15:08:19 UTC 2024
network time: Mon, 16 Sep 2024 15:08:19 GMT
##[error]Process completed with exit code 1.
Post job cleanup.
The job mingw-check failed! Check out the build log: (web) (plain)
Click to see the possible cause of the failure (guessed by this bot)
#16 2.905 Building wheels for collected packages: reuse
#16 2.906 Building wheel for reuse (pyproject.toml): started
#16 3.155 Building wheel for reuse (pyproject.toml): finished with status 'done'
#16 3.156 Created wheel for reuse: filename=reuse-4.0.3-cp310-cp310-manylinux_2_35_x86_64.whl size=132715 sha256=dfa09868353292d98f811d3efdb0d54d07389e808efc71d68e3b93c514bf8bec
#16 3.156 Stored in directory: /tmp/pip-ephem-wheel-cache-ulsqfri_/wheels/3d/8d/0a/e0fc6aba4494b28a967ab5eaf951c121d9c677958714e34532
#16 3.159 Installing collected packages: boolean-py, binaryornot, tomlkit, reuse, python-debian, markupsafe, license-expression, jinja2, chardet, attrs
#16 3.555 Successfully installed attrs-23.2.0 binaryornot-0.4.4 boolean-py-4.0 chardet-5.2.0 jinja2-3.1.4 license-expression-30.3.0 markupsafe-2.1.5 python-debian-0.1.49 reuse-4.0.3 tomlkit-0.13.0
#16 3.555 WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv
#16 DONE 3.6s
---
Compiling libc v0.2.150
Checking gccjit_sys v0.2.0
Checking gccjit v2.1.0
Checking rustc_codegen_gcc v0.1.0 (/checkout/compiler/rustc_codegen_gcc)
error[E0405]: cannot find trait `X86AbiOpt` in this scope
|
|
576 | impl<'gcc, 'tcx> X86AbiOpt for CodegenCx<'gcc, 'tcx> {
| ^^^^^^^^^ help: a trait with a similar name exists: `HasX86AbiOpt`
::: /checkout/compiler/rustc_target/src/spec/mod.rs:2061:1
|
|
2061 | pub trait HasX86AbiOpt {
| ---------------------- similarly named trait `HasX86AbiOpt` defined here
error: unused import: `HasX86AbiOpt`
|
|
24 | HasTargetSpec, HasWasmCAbiOpt, HasX86AbiOpt, Target, TlsModel, WasmCAbi, X86Abi,
|
= note: `-D unused-imports` implied by `-D warnings`
= help: to override `-D warnings` add `#[allow(unused_imports)]`
The job x86_64-gnu-llvm-17 failed! Check out the build log: (web) (plain)
Click to see the possible cause of the failure (guessed by this bot)
------
> importing cache manifest from ghcr.io/rust-lang/rust-ci-cache:fb97a1d6377f6cf2227825318ca4bbde3889e0c420746f5a03ba46a07e9a862725c26a09b9fc49a0d129ebd75935d3f6cd19acf41cc4267a6846fd4aa574b12c:
------
##[endgroup]
Setting extra environment values for docker: --env ENABLE_GCC_CODEGEN=1 --env GCC_EXEC_PREFIX=/usr/lib/gcc/
[CI_JOB_NAME=x86_64-gnu-llvm-17]
---
sccache: Starting the server...
##[group]Configure the build
configure: processing command line
configure:
configure: build.configure-args := ['--build=x86_64-unknown-linux-gnu', '--llvm-root=/usr/lib/llvm-17', '--enable-llvm-link-shared', '--set', 'rust.randomize-layout=true', '--set', 'rust.thin-lto-import-instr-limit=10', '--set', 'change-id=99999999', '--enable-verbose-configure', '--enable-sccache', '--disable-manage-submodules', '--enable-locked-deps', '--enable-cargo-native-static', '--set', 'rust.codegen-units-std=1', '--set', 'dist.compression-profile=balanced', '--dist-compression-formats=xz', '--set', 'rust.lld=false', '--disable-dist-src', '--release-channel=nightly', '--enable-debug-assertions', '--enable-overflow-checks', '--enable-llvm-assertions', '--set', 'rust.verify-llvm-ir', '--set', 'rust.codegen-backends=llvm,cranelift,gcc', '--set', 'llvm.static-libstdcpp', '--enable-new-symbol-mangling']
configure: target.x86_64-unknown-linux-gnu.llvm-config := /usr/lib/llvm-17/bin/llvm-config
configure: llvm.link-shared := True
configure: rust.randomize-layout := True
configure: rust.thin-lto-import-instr-limit := 10
---
failures:
---- [codegen] tests/codegen/regparm-inreg.rs stdout ----
error: verification with 'FileCheck' failed
status: exit status: 1
command: "/usr/lib/llvm-17/bin/FileCheck" "--input-file" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/codegen/regparm-inreg/regparm-inreg.ll" "/checkout/tests/codegen/regparm-inreg.rs" "--check-prefix=CHECK" "--check-prefix" "NONMSVC" "--allow-unused-prefixes" "--dump-input-context" "100"
--- stderr -------------------------------
/checkout/tests/codegen/regparm-inreg.rs:24:12: error: CHECK: expected string not found in input
/checkout/tests/codegen/regparm-inreg.rs:24:12: error: CHECK: expected string not found in input
// CHECK: @f2(ptr noundef %_1, ptr noundef %_2, ptr noundef %_3)
^
/checkout/obj/build/x86_64-unknown-linux-gnu/test/codegen/regparm-inreg/regparm-inreg.ll:7:94: note: scanning from here
define x86_fastcallcc void @f1(i32 inreg noundef %_1, i32 inreg noundef %_2, i32 noundef %_3) unnamed_addr #0 {
^
/checkout/obj/build/x86_64-unknown-linux-gnu/test/codegen/regparm-inreg/regparm-inreg.ll:13:13: note: possible intended match here
define void @f2(i32 noundef %_1, i32 noundef %_2, i32 noundef %_3) unnamed_addr #1 {
Input file: /checkout/obj/build/x86_64-unknown-linux-gnu/test/codegen/regparm-inreg/regparm-inreg.ll
Check file: /checkout/tests/codegen/regparm-inreg.rs
-dump-input=help explains the following input dump.
Input was:
<<<<<<
<<<<<<
1: ; ModuleID = 'regparm_inreg.9bc7252c0826ffa9-cgu.0'
2: source_filename = "regparm_inreg.9bc7252c0826ffa9-cgu.0"
3: target datalayout = "e-m:e-p:32:32-p270:32:32-p271:32:32-p272:64:64-f64:32:64-f80:32-n8:16:32-S128"
4: target triple = "i686-unknown-linux-gnu"
5:
6: ; Function Attrs: nounwind uwtable
7: define x86_fastcallcc void @f1(i32 inreg noundef %_1, i32 inreg noundef %_2, i32 noundef %_3) unnamed_addr #0 {
check:24'0 X~~~~~~~~~~~~~~~~~~ error: no match found
check:24'0 ~~~~~~~
9: ret void
check:24'0 ~~~~~~~~~~
10: }
10: }
check:24'0 ~~
11:
check:24'0 ~
12: ; Function Attrs: uwtable
check:24'0 ~~~~~~~~~~~~~~~~~~~~~~~~~~
13: define void @f2(i32 noundef %_1, i32 noundef %_2, i32 noundef %_3) unnamed_addr #1 {
check:24'0 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
check:24'1 ? possible intended match
check:24'0 ~~~~~~~
15: ret void
check:24'0 ~~~~~~~~~~
16: }
16: }
check:24'0 ~~
17:
check:24'0 ~
18: ; Function Attrs: nounwind uwtable
check:24'0 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
19: define void @f3(i32 inreg noundef %_1, i32 inreg noundef %_2, i32 inreg noundef %_3) unnamed_addr #0 {
check:24'0 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
check:24'0 ~~~~~~~
21: ret void
check:24'0 ~~~~~~~~~~
22: }
22: }
check:24'0 ~~
23:
check:24'0 ~
24: ; Function Attrs: nounwind uwtable
check:24'0 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
25: define void @f4(i32 inreg noundef %_1, i32 inreg noundef %_2, i32 inreg noundef %_3) unnamed_addr #0 {
check:24'0 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
check:24'0 ~~~~~~~
27: ret void
check:24'0 ~~~~~~~~~~
28: }
28: }
check:24'0 ~~
29:
check:24'0 ~
30: ; Function Attrs: nounwind uwtable
check:24'0 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
31: define x86_stdcallcc void @f5(i32 inreg noundef %_1, i32 inreg noundef %_2, i32 inreg noundef %_3) unnamed_addr #0 {
check:24'0 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
check:24'0 ~~~~~~~
33: ret void
check:24'0 ~~~~~~~~~~
34: }
34: }
check:24'0 ~~
35:
check:24'0 ~
36: ; Function Attrs: nounwind uwtable
check:24'0 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
37: define x86_thiscallcc void @f6(i32 noundef %_1, i32 noundef %_2, i32 noundef %_3) unnamed_addr #0 {
check:24'0 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
check:24'0 ~~~~~~~
39: ret void
check:24'0 ~~~~~~~~~~
40: }
40: }
check:24'0 ~~
41:
check:24'0 ~
42: attributes #0 = { nounwind uwtable "probe-stack"="inline-asm" "target-cpu"="pentium4" }
check:24'0 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
43: attributes #1 = { uwtable "probe-stack"="inline-asm" "target-cpu"="pentium4" }
check:24'0 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
check:24'0 ~
check:24'0 ~
45: !llvm.module.flags = !{!0}
check:24'0 ~~~~~~~~~~~~~~~~~~~~~~~~~~~
46: !llvm.ident = !{!1}
check:24'0 ~~~~~~~~~~~~~~~~~~~~
check:24'0 ~
check:24'0 ~
48: !0 = !{i32 8, !"PIC Level", i32 2}
check:24'0 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
49: !1 = !{!"rustc version 1.83.0-nightly (527212db2 2024-09-16)"}
check:24'0 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
------------------------------------------
The job mingw-check failed! Check out the build log: (web) (plain)
Click to see the possible cause of the failure (guessed by this bot)
#16 2.915 Building wheels for collected packages: reuse
#16 2.916 Building wheel for reuse (pyproject.toml): started
#16 3.161 Building wheel for reuse (pyproject.toml): finished with status 'done'
#16 3.162 Created wheel for reuse: filename=reuse-4.0.3-cp310-cp310-manylinux_2_35_x86_64.whl size=132715 sha256=dfa09868353292d98f811d3efdb0d54d07389e808efc71d68e3b93c514bf8bec
#16 3.163 Stored in directory: /tmp/pip-ephem-wheel-cache-o_hbwz6c/wheels/3d/8d/0a/e0fc6aba4494b28a967ab5eaf951c121d9c677958714e34532
#16 3.165 Installing collected packages: boolean-py, binaryornot, tomlkit, reuse, python-debian, markupsafe, license-expression, jinja2, chardet, attrs
#16 3.554 Successfully installed attrs-23.2.0 binaryornot-0.4.4 boolean-py-4.0 chardet-5.2.0 jinja2-3.1.4 license-expression-30.3.0 markupsafe-2.1.5 python-debian-0.1.49 reuse-4.0.3 tomlkit-0.13.0
#16 3.554 WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv
#16 DONE 3.6s
---
Documenting rustc_ast_pretty v0.0.0 (/checkout/compiler/rustc_ast_pretty)
error: unclosed HTML tag `N`
--> compiler/rustc_target/src/spec/mod.rs:2056:40
|
2056 | /// On x86-32 targets, the regparm <N> causes the compiler to pass arguments
|
= note: `-D rustdoc::invalid-html-tags` implied by `-D warnings`
= help: to override `-D warnings` add `#[allow(rustdoc::invalid_html_tags)]`
error: could not document `rustc_target`
warning: build failed, waiting for other jobs to finish...
Command has failed. Rerun with -v to see more details.
local time: Mon Sep 16 17:12:25 UTC 2024
network time: Mon, 16 Sep 2024 17:12:25 GMT
##[error]Process completed with exit code 1.
Post job cleanup.
The job x86_64-gnu-llvm-17 failed! Check out the build log: (web) (plain)
Click to see the possible cause of the failure (guessed by this bot)
------
> importing cache manifest from ghcr.io/rust-lang/rust-ci-cache:fb97a1d6377f6cf2227825318ca4bbde3889e0c420746f5a03ba46a07e9a862725c26a09b9fc49a0d129ebd75935d3f6cd19acf41cc4267a6846fd4aa574b12c:
------
##[endgroup]
Setting extra environment values for docker: --env ENABLE_GCC_CODEGEN=1 --env GCC_EXEC_PREFIX=/usr/lib/gcc/
[CI_JOB_NAME=x86_64-gnu-llvm-17]
---
sccache: Starting the server...
##[group]Configure the build
configure: processing command line
configure:
configure: build.configure-args := ['--build=x86_64-unknown-linux-gnu', '--llvm-root=/usr/lib/llvm-17', '--enable-llvm-link-shared', '--set', 'rust.randomize-layout=true', '--set', 'rust.thin-lto-import-instr-limit=10', '--set', 'change-id=99999999', '--enable-verbose-configure', '--enable-sccache', '--disable-manage-submodules', '--enable-locked-deps', '--enable-cargo-native-static', '--set', 'rust.codegen-units-std=1', '--set', 'dist.compression-profile=balanced', '--dist-compression-formats=xz', '--set', 'rust.lld=false', '--disable-dist-src', '--release-channel=nightly', '--enable-debug-assertions', '--enable-overflow-checks', '--enable-llvm-assertions', '--set', 'rust.verify-llvm-ir', '--set', 'rust.codegen-backends=llvm,cranelift,gcc', '--set', 'llvm.static-libstdcpp', '--enable-new-symbol-mangling']
configure: target.x86_64-unknown-linux-gnu.llvm-config := /usr/lib/llvm-17/bin/llvm-config
configure: llvm.link-shared := True
configure: rust.randomize-layout := True
configure: rust.thin-lto-import-instr-limit := 10
---
Downloaded boml v0.3.1
Compiling boml v0.3.1
Compiling y v0.1.0 (/checkout/compiler/rustc_codegen_gcc/build_system)
Finished `release` profile [optimized] target(s) in 3.68s
Running `/checkout/obj/build/x86_64-unknown-linux-gnu/stage1-codegen/x86_64-unknown-linux-gnu/release/y test --use-system-gcc --use-backend gcc --out-dir /checkout/obj/build/x86_64-unknown-linux-gnu/stage1-tools/cg_gcc --release --mini-tests --std-tests`
Using system GCC
[BUILD] example
[AOT] mini_core_hello_world
/checkout/obj/build/x86_64-unknown-linux-gnu/stage1-tools/cg_gcc/mini_core_hello_world
abc
:umbrella: The latest upstream changes (presumably #129970) made this pull request unmergeable. Please resolve the merge conflicts.
These commits modify compiler targets. (See the Target Tier Policy.)
Some changes occurred in compiler/rustc_codegen_gcc
cc @antoyo, @GuillaumeGomez
As this affects call ABI, doesn't this need to be a target option rather than compiler flag? Otherwise @RalfJung will be very sad.
As this affects call ABI, doesn't this need to be a target option rather than compiler flag? Otherwise @RalfJung will be very sad.
Am I understanding correctly that like -C soft-float, the problem that if this is a compiler flag, then it's easy to have code compiled with -Z regparam call code that is not -Z regparam even though they appear to be of the same concrete target, then dragons get summoned?
Yes, exactly.
As a nightly flag I don't mind having this experimentally, but the docs should call out very clearly that all code that is linked together needs to use the same value for this flag.
But this can't be stabilized in that form.
As a nightly flag I don't mind having this experimentally, but the docs should call out very clearly that all code that is linked together needs to use the same value for this flag.
Although IIRC target options don't have a stable format either, so we may as well make this part of target options and implement this the "correct" way to make using it correctly less footgunny from the get-go instead of having the flag that's asking for fireworks? Since I imagine if RfL wants this flag then surely they'll want to actually use it. Especially if this is limited to a specific target architecture(?).
Yeah if this can be made a target option that would probably be better. I just didn't want to block experimentation on these concerns.
Right, that's fair and fine by me as well.
@rustbot label A-rust-for-linux @rustbot label A-ABI
Cc @vincenzopalazzo who was interested in this.
The job mingw-check-tidy failed! Check out the build log: (web) (plain)
Click to see the possible cause of the failure (guessed by this bot)
COPY host-x86_64/mingw-check/validate-toolstate.sh /scripts/
COPY host-x86_64/mingw-check/validate-error-codes.sh /scripts/
# NOTE: intentionally uses python2 for x.py so we can test it still works.
# validate-toolstate only runs in our CI, so it's ok for it to only support python3.
ENV SCRIPT TIDY_PRINT_DIFF=1 python2.7 ../x.py test \
--stage 0 src/tools/tidy tidyselftest --extra-checks=py:lint,cpp:fmt
# This file is autogenerated by pip-compile with Python 3.10
# by the following command:
#
# pip-compile --allow-unsafe --generate-hashes reuse-requirements.in
---
#13 2.681 Building wheels for collected packages: reuse
#13 2.682 Building wheel for reuse (pyproject.toml): started
#13 2.926 Building wheel for reuse (pyproject.toml): finished with status 'done'
#13 2.928 Created wheel for reuse: filename=reuse-4.0.3-cp310-cp310-manylinux_2_35_x86_64.whl size=132715 sha256=dfa09868353292d98f811d3efdb0d54d07389e808efc71d68e3b93c514bf8bec
#13 2.928 Stored in directory: /tmp/pip-ephem-wheel-cache-9xmhisae/wheels/3d/8d/0a/e0fc6aba4494b28a967ab5eaf951c121d9c677958714e34532
#13 2.930 Installing collected packages: boolean-py, binaryornot, tomlkit, reuse, python-debian, markupsafe, license-expression, jinja2, chardet, attrs
#13 3.326 Successfully installed attrs-23.2.0 binaryornot-0.4.4 boolean-py-4.0 chardet-5.2.0 jinja2-3.1.4 license-expression-30.3.0 markupsafe-2.1.5 python-debian-0.1.49 reuse-4.0.3 tomlkit-0.13.0
#13 3.327 WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv
#13 3.851 Collecting virtualenv
#13 3.851 Collecting virtualenv
#13 3.891 Downloading virtualenv-20.26.6-py3-none-any.whl (6.0 MB)
#13 3.973 ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 6.0/6.0 MB 74.5 MB/s eta 0:00:00
#13 4.030 Collecting platformdirs<5,>=3.9.1
#13 4.034 Downloading platformdirs-4.3.6-py3-none-any.whl (18 kB)
#13 4.069 Collecting filelock<4,>=3.12.2
#13 4.090 Collecting distlib<1,>=0.3.7
#13 4.093 Downloading distlib-0.3.8-py2.py3-none-any.whl (468 kB)
#13 4.101 ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 468.9/468.9 KB 77.2 MB/s eta 0:00:00
#13 4.101 ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 468.9/468.9 KB 77.2 MB/s eta 0:00:00
#13 4.180 Installing collected packages: distlib, platformdirs, filelock, virtualenv
#13 4.367 Successfully installed distlib-0.3.8 filelock-3.16.1 platformdirs-4.3.6 virtualenv-20.26.6
#13 DONE 4.4s
#14 [7/8] COPY host-x86_64/mingw-check/validate-toolstate.sh /scripts/
#14 DONE 0.0s
---
DirectMap4k: 214976 kB
DirectMap2M: 9222144 kB
DirectMap1G: 9437184 kB
##[endgroup]
Executing TIDY_PRINT_DIFF=1 python2.7 ../x.py test --stage 0 src/tools/tidy tidyselftest --extra-checks=py:lint,cpp:fmt
+ TIDY_PRINT_DIFF=1 python2.7 ../x.py test --stage 0 src/tools/tidy tidyselftest --extra-checks=py:lint,cpp:fmt
Finished `dev` profile [unoptimized] target(s) in 0.04s
##[endgroup]
downloading https://static.rust-lang.org/dist/2024-09-22/rustfmt-nightly-x86_64-unknown-linux-gnu.tar.xz
extracting /checkout/obj/build/cache/2024-09-22/rustfmt-nightly-x86_64-unknown-linux-gnu.tar.xz to /checkout/obj/build/x86_64-unknown-linux-gnu/rustfmt
---
Compiling tidy v0.1.0 (/checkout/src/tools/tidy)
Finished `release` profile [optimized] target(s) in 30.59s
##[endgroup]
fmt check
Diff in /checkout/compiler/rustc_target/src/abi/call/mod.rs:974:
let spec = cx.target_spec();
match &spec.arch[..] {
"x86" => {
- x86::fill_inregs(
- cx,
- x86::X86Options {
- x86::X86Options {
- flavor: x86::Flavor::General,
- regparm: cx.x86_abi_opt().regparm,
- );
- );
+ x86::fill_inregs(cx, self, x86::X86Options {
+ flavor: x86::Flavor::General,
+ regparm: cx.x86_abi_opt().regparm,
}
_ => {}
}
}
fmt error: Running `"/checkout/obj/build/x86_64-unknown-linux-gnu/rustfmt/bin/rustfmt" "--config-path" "/checkout" "--edition" "2021" "--unstable-features" "--skip-children" "--check" "/checkout/tests/run-make/allocator-shim-circular-deps/rmake.rs" "/checkout/tests/run-make/allocator-shim-circular-deps/my_lib.rs" "/checkout/compiler/rustc_target/src/abi/call/avr.rs" "/checkout/compiler/rustc_target/src/abi/call/wasm.rs" "/checkout/compiler/rustc_target/src/abi/call/mod.rs" "/checkout/compiler/rustc_target/src/abi/call/bpf.rs" "/checkout/compiler/rustc_target/src/abi/call/powerpc64.rs" "/checkout/compiler/rustc_target/src/abi/call/powerpc.rs" "/checkout/compiler/rustc_target/src/abi/call/riscv.rs" "/checkout/compiler/rustc_target/src/abi/call/loongarch.rs" "/checkout/compiler/rustc_target/src/abi/call/nvptx64.rs" "/checkout/compiler/rustc_target/src/abi/call/hexagon.rs" "/checkout/compiler/rustc_target/src/abi/call/amdgpu.rs" "/checkout/compiler/rustc_target/src/abi/call/sparc64.rs" "/checkout/compiler/rustc_target/src/abi/call/arm.rs" "/checkout/compiler/rustc_target/src/abi/call/x86_64.rs" "/checkout/compiler/rustc_target/src/abi/call/m68k.rs" "/checkout/compiler/rustc_target/src/abi/call/x86.rs" "/checkout/compiler/rustc_target/src/abi/call/sparc.rs" "/checkout/compiler/rustc_target/src/abi/call/s390x.rs" "/checkout/compiler/rustc_target/src/abi/call/x86_win64.rs" "/checkout/compiler/rustc_target/src/abi/call/mips.rs" "/checkout/compiler/rustc_target/src/abi/call/xtensa.rs" "/checkout/compiler/rustc_target/src/abi/call/mips64.rs" "/checkout/compiler/rustc_target/src/abi/call/csky.rs" "/checkout/compiler/rustc_target/src/abi/call/msp430.rs" "/checkout/compiler/rustc_target/src/abi/call/aarch64.rs" "/checkout/compiler/rustc_target/src/json.rs" "/checkout/compiler/rustc_target/src/target_features.rs" "/checkout/compiler/rustc_target/src/lib.rs" "/checkout/tests/run-make/doctests-merge/doctest.rs" "/checkout/tests/run-make/doctests-merge/rmake.rs" "/checkout/tests/run-make/doctests-merge/doctest-standalone.rs" "/checkout/compiler/rustc_target/src/spec/mod.rs" "/checkout/compiler/rustc_target/src/spec/tests/tests_impl.rs" "/checkout/tests/run-make/native-link-modifier-bundle/bundled.rs" "/checkout/tests/run-make/native-link-modifier-bundle/cdylib-bundled.rs" "/checkout/tests/run-make/native-link-modifier-bundle/cdylib-non-bundled.rs" "/checkout/tests/run-make/native-link-modifier-bundle/rmake.rs" "/checkout/tests/run-make/native-link-modifier-bundle/non-bundled.rs" "/checkout/compiler/rustc_target/src/spec/abi/mod.rs" "/checkout/compiler/rustc_target/src/spec/abi/tests.rs" "/checkout/tests/run-make/run-in-tmpdir-self-test/rmake.rs" "/checkout/tests/run-make/rlib-format-packed-bundled-libs/rust_dep_up.rs" "/checkout/tests/run-make/rlib-format-packed-bundled-libs/main.rs" "/checkout/tests/run-make/rlib-format-packed-bundled-libs/rmake.rs" "/checkout/tests/run-make/rlib-format-packed-bundled-libs/rust_dep_local.rs" "/checkout/tests/run-make/print-target-list/rmake.rs" "/checkout/tests/run-make/staticlib-blank-lib/foo.rs" "/checkout/tests/run-make/staticlib-blank-lib/rmake.rs" "/checkout/tests/run-make/no-builtins-lto/no_builtins.rs" "/checkout/tests/run-make/no-builtins-lto/main.rs" "/checkout/tests/run-make/no-builtins-lto/rmake.rs" "/checkout/tests/run-make/prune-link-args/rmake.rs" "/checkout/tests/run-make/prune-link-args/empty.rs" "/checkout/tests/run-make/pass-linker-flags-from-dep/native_dep_2.rs" "/checkout/tests/run-make/pass-linker-flags-from-dep/main.rs" "/checkout/tests/run-make/pass-linker-flags-from-dep/rmake.rs" "/checkout/tests/run-make/pass-linker-flags-from-dep/rust_dep_attr.rs" "/checkout/tests/run-make/pass-linker-flags-from-dep/rust_dep_flag.rs" "/checkout/tests/run-make/pass-linker-flags-from-dep/native_dep_1.rs" "/checkout/compiler/rustc_target/src/spec/base/wasm.rs" "/checkout/compiler/rustc_target/src/spec/base/linux_uclibc.rs" "/checkout/tests/run-make/allocator-shim-circular-deps/main.rs"` failed.
If you're running `tidy`, try again with `--bless`. Or, if you just want to format code, run `./x.py fmt` instead.
local time: Wed Oct 2 18:36:30 UTC 2024
network time: Wed, 02 Oct 2024 18:36:31 GMT
##[error]Process completed with exit code 1.
Post job cleanup.
This seems fine to me as an experiment.
My only concern was similar to some raised above... I'll try to explain below.
People above raised question of whether -Z flag approach is okay here, versus making this a target option.
A related (maybe even strongly coupled) concern is from the way the code itself is architected: Is regparm truly an independent thing from the Abi flavor? Or should it be folded into that enum ...? (Which, I freely admit, does seem like it might be a bit of a pain to do...)
Overall I would r+, but I'm not sure I'm comfortable without getting buy in from someone else who actively maintains the code in adjust_for_foreign_abi: https://github.com/rust-lang/rust/blob/267cf8d3b20e98315c8e0ddf1d7020f60f664249/compiler/rustc_target/src/abi/call/mod.rs#L872-L900
@workingjubilee can I get a vibe check from you regarding this point here: https://github.com/rust-lang/rust/pull/130432#issuecomment-2394271280
r? workingjubilee
(just to make this clear: if I get a positive vibe check from @workingjubilee, or anyone else who has contributed to that rustc_target::abi module, then you can treat my comment above as an r=me.)
Hm? Yeah, I don't see why we're using a new trait for conjuring a new additional struct this instead of threading it through the usual data structures and CodegenCx, since this is ABI-affecting.
HasWasmCAbiOpt should not be used as a model because that code is a temporary hack slated for total destruction... there will not be two wasm C ABIs in the future, so it's fine if it exists in this weirdly "tacked on" state... but Miguel Ojeda will be very sad if we land all this code and then delete it later.
Just to be clear, Linux is always going to set this to either 3 or 0, right? And this flag doesn't have a practical effect (it might add the inreg annotation, but LLVM will look at that LLVMIR and do the same machine codegen, right?) if we get a value above 3?
It seems the VDSO is built with this set to 0. https://github.com/torvalds/linux/blob/ac308609567d31fe44be80ab757a5ddf062362ef/arch/x86/entry/vdso/Makefile#L131
I am not persuaded we want to accept -Zregparm=4 at all, but if we do, and it's supposed to not have an effect, then this needs an assembly test that verifies that -Zregparm=4 has the same ABI as -Zregparm=3.
For an extern "C fn, obviously.
@pnkfelix I think you're referring to FastcallOrVectorcall here? https://github.com/rust-lang/rust/blob/c39f318c5e734e7f254c6b2589205d6ed936443d/compiler/rustc_target/src/abi/call/x86.rs#L6-L9
Yeaaaaahhh this is... weird. They are in fact intimately related:
https://github.com/llvm/llvm-project/blob/72f38040ddc8c2eca712c29b86ea0209faab4d57/llvm/lib/Target/X86/X86CallingConv.td#L886-L908
Yeah, for clang an invalid regparm attribute, even just "too big" (which should have zero effect beyond the value given for -Zregparm=3) just gets rejected, so I don't see why we should accept an invalid regparm at the CLI: https://github.com/llvm/llvm-project/blob/dd0fe4fb7440182d8101135bfd694b2d84893c2e/clang/test/Sema/attr-regparm.c#L3-L7
Hm? Yeah, I don't see why we're using a new trait for conjuring a new additional struct this instead of threading it through the usual data structures and CodegenCx, since this is ABI-affecting.
HasWasmCAbiOptshould not be used as a model because that code is a temporary hack slated for total destruction... there will not be two wasm C ABIs in the future, so it's fine if it exists in this weirdly "tacked on" state... but Miguel Ojeda will be very sad if we land all this code and then delete it later.
Yes, I implemented HasX86AbiOpt using HasWasmCAbiOpt as an example. adjust_for_foreign_abi works with traits HasDataLayout + HasTargetSpec + HasWasmCAbiOpt, which are implemented by CodegenCx (operation_with_overflow in Builder) and by LayoutCx (fn_abi_new_uncached in rustc_ty_utils).
Could you, pls, recommend the right way to provide regparm & reg-struct-return flags for adjust_for_foreign_abi function?
CodegenCx should be provided instead of LayoutCx in fn_abi_new_uncached?
Yeah, for clang an invalid regparm attribute, even just "too big" (which should have zero effect beyond the value given for
-Zregparm=3) just gets rejected, so I don't see why we should accept an invalid regparm at the CLI: https://github.com/llvm/llvm-project/blob/dd0fe4fb7440182d8101135bfd694b2d84893c2e/clang/test/Sema/attr-regparm.c#L3-L7
I looked at https://github.com/rust-lang/llvm-project/blob/dd46457da782554454106d48ecd4f6b4c2f9af73/clang/test/CodeGen/regparm-flag.c test with -mregparm 4 supported too. But yes, probably limit 3 may be better.
I don't know why they'd accept it at the command line but reject the attribute? Back compat reasons? I hear clang once accepted -O9 or something like that without warning and people mistakenly believed that it actually applied more optimization than -O3. So, compatibility is a good reason for us to accept the same CLI name, but for anyone porting their C build from 20 years ago over to Rust, I think we can just give them the bad news that setting -mregparm=16 wasn't doing anything.
(Thanks everyone for taking a look and helping with this -- @azhogin when you think this is more or less ready I can give a try to building the kernel with these flags)