Skip to content

Extend minicore with intrinsics and use it to replace #[rustc_intrinsic] in tests #140037

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

hbina
Copy link
Contributor

@hbina hbina commented Apr 19, 2025

Fixes #139918

@rustbot
Copy link
Collaborator

rustbot commented Apr 19, 2025

r? @Mark-Simulacrum

rustbot has assigned @Mark-Simulacrum.
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

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Apr 19, 2025
@hbina hbina changed the title Forgot to add the stubs Extend minicore with intrinsics and use it to replace #[rustc_intrinsic] in tests Apr 19, 2025
@hbina
Copy link
Contributor Author

hbina commented Apr 19, 2025

I am getting this issue

hbina085@DESKTOP-PGERPVO ~/g/rustlang (hbina-update-use-minicore) [1]> reset && python x.py test /home/hbina085/git/rustlang/tests/assembly/rust-abi-arg-attr.rs
Building bootstrap
    Finished `dev` profile [unoptimized] target(s) in 0.05s
Building stage0 library artifacts (x86_64-unknown-linux-gnu)
    Finished `release` profile [optimized + debuginfo] target(s) in 0.05s
Building compiler artifacts (stage0 -> stage1, x86_64-unknown-linux-gnu)
    Finished `release` profile [optimized + debuginfo] target(s) in 0.25s
Creating a sysroot for stage1 compiler (use `rustup toolchain link 'name' build/host/stage1`)
Building stage0 tool lld-wrapper (x86_64-unknown-linux-gnu)
    Finished `release` profile [optimized + debuginfo] target(s) in 0.09s
Building stage1 library artifacts (x86_64-unknown-linux-gnu)
    Finished `release` profile [optimized + debuginfo] target(s) in 0.02s
Building stage0 tool compiletest (x86_64-unknown-linux-gnu)
    Finished `release` profile [optimized + debuginfo] target(s) in 0.16s
Testing stage1 compiletest suite=assembly mode=assembly (x86_64-unknown-linux-gnu)

running 539 tests
iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii  88/539
ii.iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii 176/539
iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii 264/539
iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii 352/539
iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii 440/539
iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii 528/539
iiiiiiii
[assembly] tests/assembly/rust-abi-arg-attr.rs#loongarch64 ... F

[assembly] tests/assembly/rust-abi-arg-attr.rs#riscv64-zbb ... F

[assembly] tests/assembly/rust-abi-arg-attr.rs#riscv64 ... F


failures:

---- [assembly] tests/assembly/rust-abi-arg-attr.rs#loongarch64 stdout ----

error in revision `loongarch64`: verification with 'FileCheck' failed
status: exit status: 1
command: "/home/hbina085/git/rustlang/build/x86_64-unknown-linux-gnu/ci-llvm/bin/FileCheck" "--input-file" "/home/hbina085/git/rustlang/build/x86_64-unknown-linux-gnu/test/assembly/rust-abi-arg-attr.loongarch64/rust-abi-arg-attr.s" "/home/hbina085/git/rustlang/tests/assembly/rust-abi-arg-attr.rs" "--check-prefix=CHECK" "--check-prefix" "loongarch64" "--allow-unused-prefixes" "--dump-input-context" "100"
stdout: none
--- stderr -------------------------------
/home/hbina085/git/rustlang/tests/assembly/rust-abi-arg-attr.rs:34:17: error: CHECK-NEXT: expected string not found in input
 // CHECK-NEXT: .cfi_startproc
                ^
/home/hbina085/git/rustlang/build/x86_64-unknown-linux-gnu/test/assembly/rust-abi-arg-attr.loongarch64/rust-abi-arg-attr.s:6:18: note: scanning from here
issue_114508_u32:
                 ^
/home/hbina085/git/rustlang/build/x86_64-unknown-linux-gnu/test/assembly/rust-abi-arg-attr.loongarch64/rust-abi-arg-attr.s:15:30: note: possible intended match here
 .section .text.issue_114508_i32,"ax",@progbits
                             ^
/home/hbina085/git/rustlang/tests/assembly/rust-abi-arg-attr.rs:54:17: error: CHECK-NEXT: expected string not found in input
 // CHECK-NEXT: .cfi_startproc
                ^
/home/hbina085/git/rustlang/build/x86_64-unknown-linux-gnu/test/assembly/rust-abi-arg-attr.loongarch64/rust-abi-arg-attr.s:19:18: note: scanning from here
issue_114508_i32:
                 ^
/home/hbina085/git/rustlang/build/x86_64-unknown-linux-gnu/test/assembly/rust-abi-arg-attr.loongarch64/rust-abi-arg-attr.s:29:17: note: possible intended match here
 .section ".note.GNU-stack","",@progbits
                ^

Input file: /home/hbina085/git/rustlang/build/x86_64-unknown-linux-gnu/test/assembly/rust-abi-arg-attr.loongarch64/rust-abi-arg-attr.s
Check file: /home/hbina085/git/rustlang/tests/assembly/rust-abi-arg-attr.rs

-dump-input=help explains the following input dump.

Input was:
<<<<<<
           1:  .file "rust_abi_arg_attr.eff6563d25fa939-cgu.0" 
           2:  .section .text.issue_114508_u32,"ax",@progbits 
           3:  .globl issue_114508_u32 
           4:  .p2align 5 
           5:  .type issue_114508_u32,@function 
           6: issue_114508_u32: 
next:34'0                      X error: no match found
           7:  sltu $a2, $a1, $a0 
next:34'0     ~~~~~~~~~~~~~~~~~~~~
           8:  masknez $a1, $a1, $a2 
next:34'0     ~~~~~~~~~~~~~~~~~~~~~~~
           9:  maskeqz $a0, $a0, $a2 
next:34'0     ~~~~~~~~~~~~~~~~~~~~~~~
          10:  or $a0, $a0, $a1 
next:34'0     ~~~~~~~~~~~~~~~~~~
          11:  ret 
next:34'0     ~~~~~
          12: .Lfunc_end0: 
next:34'0     ~~~~~~~~~~~~~
          13:  .size issue_114508_u32, .Lfunc_end0-issue_114508_u32 
next:34'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
          14:  
next:34'0     ~
          15:  .section .text.issue_114508_i32,"ax",@progbits 
next:34'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
next:34'1                                  ?                   possible intended match
          16:  .globl issue_114508_i32 
next:34'0     ~~~~~~~~~~~~~~~~~~~~~~~~~
          17:  .p2align 5 
next:34'0     ~~~~~~~~~~~~
          18:  .type issue_114508_i32,@function 
next:34'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
          19: issue_114508_i32: 
next:34'0     ~~~~~~~~~~~~~~~~~
next:54'0                      X error: no match found
          20:  slt $a2, $a1, $a0 
next:54'0     ~~~~~~~~~~~~~~~~~~~
          21:  masknez $a1, $a1, $a2 
next:54'0     ~~~~~~~~~~~~~~~~~~~~~~~
          22:  maskeqz $a0, $a0, $a2 
next:54'0     ~~~~~~~~~~~~~~~~~~~~~~~
          23:  or $a0, $a0, $a1 
next:54'0     ~~~~~~~~~~~~~~~~~~
          24:  ret 
next:54'0     ~~~~~
          25: .Lfunc_end1: 
next:54'0     ~~~~~~~~~~~~~
          26:  .size issue_114508_i32, .Lfunc_end1-issue_114508_i32 
next:54'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
          27:  
next:54'0     ~
          28:  .ident "rustc version 1.88.0-dev" 
next:54'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
          29:  .section ".note.GNU-stack","",@progbits 
next:54'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
next:54'1                     ?                         possible intended match
>>>>>>
------------------------------------------


---- [assembly] tests/assembly/rust-abi-arg-attr.rs#riscv64-zbb stdout ----

error in revision `riscv64-zbb`: verification with 'FileCheck' failed
status: exit status: 1
command: "/home/hbina085/git/rustlang/build/x86_64-unknown-linux-gnu/ci-llvm/bin/FileCheck" "--input-file" "/home/hbina085/git/rustlang/build/x86_64-unknown-linux-gnu/test/assembly/rust-abi-arg-attr.riscv64-zbb/rust-abi-arg-attr.s" "/home/hbina085/git/rustlang/tests/assembly/rust-abi-arg-attr.rs" "--check-prefix=CHECK" "--check-prefix" "riscv64-zbb" "--allow-unused-prefixes" "--dump-input-context" "100"
stdout: none
--- stderr -------------------------------
/home/hbina085/git/rustlang/tests/assembly/rust-abi-arg-attr.rs:34:17: error: CHECK-NEXT: expected string not found in input
 // CHECK-NEXT: .cfi_startproc
                ^
/home/hbina085/git/rustlang/build/x86_64-unknown-linux-gnu/test/assembly/rust-abi-arg-attr.riscv64-zbb/rust-abi-arg-attr.s:8:18: note: scanning from here
issue_114508_u32:
                 ^
/home/hbina085/git/rustlang/build/x86_64-unknown-linux-gnu/test/assembly/rust-abi-arg-attr.riscv64-zbb/rust-abi-arg-attr.s:14:30: note: possible intended match here
 .section .text.issue_114508_i32,"ax",@progbits
                             ^
/home/hbina085/git/rustlang/tests/assembly/rust-abi-arg-attr.rs:54:17: error: CHECK-NEXT: expected string not found in input
 // CHECK-NEXT: .cfi_startproc
                ^
/home/hbina085/git/rustlang/build/x86_64-unknown-linux-gnu/test/assembly/rust-abi-arg-attr.riscv64-zbb/rust-abi-arg-attr.s:18:18: note: scanning from here
issue_114508_i32:
                 ^
/home/hbina085/git/rustlang/build/x86_64-unknown-linux-gnu/test/assembly/rust-abi-arg-attr.riscv64-zbb/rust-abi-arg-attr.s:25:17: note: possible intended match here
 .section ".note.GNU-stack","",@progbits
                ^

Input file: /home/hbina085/git/rustlang/build/x86_64-unknown-linux-gnu/test/assembly/rust-abi-arg-attr.riscv64-zbb/rust-abi-arg-attr.s
Check file: /home/hbina085/git/rustlang/tests/assembly/rust-abi-arg-attr.rs

-dump-input=help explains the following input dump.

Input was:
<<<<<<
           1:  .attribute 4, 16 
           2:  .attribute 5, "rv64i2p1_m2p0_a2p1_f2p2_d2p2_c2p0_zicsr2p0_zifencei2p0_zmmul1p0_zaamo1p0_zalrsc1p0_zbb1p0" 
           3:  .file "rust_abi_arg_attr.eff6563d25fa939-cgu.0" 
           4:  .section .text.issue_114508_u32,"ax",@progbits 
           5:  .globl issue_114508_u32 
           6:  .p2align 1 
           7:  .type issue_114508_u32,@function 
           8: issue_114508_u32: 
next:34'0                      X error: no match found
           9:  maxu a0, a0, a1 
next:34'0     ~~~~~~~~~~~~~~~~~
          10:  ret 
next:34'0     ~~~~~
          11: .Lfunc_end0: 
next:34'0     ~~~~~~~~~~~~~
          12:  .size issue_114508_u32, .Lfunc_end0-issue_114508_u32 
next:34'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
          13:  
next:34'0     ~
          14:  .section .text.issue_114508_i32,"ax",@progbits 
next:34'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
next:34'1                                  ?                   possible intended match
          15:  .globl issue_114508_i32 
next:34'0     ~~~~~~~~~~~~~~~~~~~~~~~~~
          16:  .p2align 1 
next:34'0     ~~~~~~~~~~~~
          17:  .type issue_114508_i32,@function 
next:34'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
          18: issue_114508_i32: 
next:34'0     ~~~~~~~~~~~~~~~~~
next:54'0                      X error: no match found
          19:  max a0, a0, a1 
next:54'0     ~~~~~~~~~~~~~~~~
          20:  ret 
next:54'0     ~~~~~
          21: .Lfunc_end1: 
next:54'0     ~~~~~~~~~~~~~
          22:  .size issue_114508_i32, .Lfunc_end1-issue_114508_i32 
next:54'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
          23:  
next:54'0     ~
          24:  .ident "rustc version 1.88.0-dev" 
next:54'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
          25:  .section ".note.GNU-stack","",@progbits 
next:54'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
next:54'1                     ?                         possible intended match
>>>>>>
------------------------------------------


---- [assembly] tests/assembly/rust-abi-arg-attr.rs#riscv64 stdout ----

error in revision `riscv64`: verification with 'FileCheck' failed
status: exit status: 1
command: "/home/hbina085/git/rustlang/build/x86_64-unknown-linux-gnu/ci-llvm/bin/FileCheck" "--input-file" "/home/hbina085/git/rustlang/build/x86_64-unknown-linux-gnu/test/assembly/rust-abi-arg-attr.riscv64/rust-abi-arg-attr.s" "/home/hbina085/git/rustlang/tests/assembly/rust-abi-arg-attr.rs" "--check-prefix=CHECK" "--check-prefix" "riscv64" "--allow-unused-prefixes" "--dump-input-context" "100"
stdout: none
--- stderr -------------------------------
/home/hbina085/git/rustlang/tests/assembly/rust-abi-arg-attr.rs:34:17: error: CHECK-NEXT: expected string not found in input
 // CHECK-NEXT: .cfi_startproc
                ^
/home/hbina085/git/rustlang/build/x86_64-unknown-linux-gnu/test/assembly/rust-abi-arg-attr.riscv64/rust-abi-arg-attr.s:8:18: note: scanning from here
issue_114508_u32:
                 ^
/home/hbina085/git/rustlang/build/x86_64-unknown-linux-gnu/test/assembly/rust-abi-arg-attr.riscv64/rust-abi-arg-attr.s:16:30: note: possible intended match here
 .section .text.issue_114508_i32,"ax",@progbits
                             ^
/home/hbina085/git/rustlang/tests/assembly/rust-abi-arg-attr.rs:54:17: error: CHECK-NEXT: expected string not found in input
 // CHECK-NEXT: .cfi_startproc
                ^
/home/hbina085/git/rustlang/build/x86_64-unknown-linux-gnu/test/assembly/rust-abi-arg-attr.riscv64/rust-abi-arg-attr.s:20:18: note: scanning from here
issue_114508_i32:
                 ^
/home/hbina085/git/rustlang/build/x86_64-unknown-linux-gnu/test/assembly/rust-abi-arg-attr.riscv64/rust-abi-arg-attr.s:29:17: note: possible intended match here
 .section ".note.GNU-stack","",@progbits
                ^

Input file: /home/hbina085/git/rustlang/build/x86_64-unknown-linux-gnu/test/assembly/rust-abi-arg-attr.riscv64/rust-abi-arg-attr.s
Check file: /home/hbina085/git/rustlang/tests/assembly/rust-abi-arg-attr.rs

-dump-input=help explains the following input dump.

Input was:
<<<<<<
           1:  .attribute 4, 16 
           2:  .attribute 5, "rv64i2p1_m2p0_a2p1_f2p2_d2p2_c2p0_zicsr2p0_zifencei2p0_zmmul1p0_zaamo1p0_zalrsc1p0" 
           3:  .file "rust_abi_arg_attr.eff6563d25fa939-cgu.0" 
           4:  .section .text.issue_114508_u32,"ax",@progbits 
           5:  .globl issue_114508_u32 
           6:  .p2align 1 
           7:  .type issue_114508_u32,@function 
           8: issue_114508_u32: 
next:34'0                      X error: no match found
           9:  bltu a1, a0, .LBB0_2 
next:34'0     ~~~~~~~~~~~~~~~~~~~~~~
          10:  mv a0, a1 
next:34'0     ~~~~~~~~~~~
          11: .LBB0_2: 
next:34'0     ~~~~~~~~~
          12:  ret 
next:34'0     ~~~~~
          13: .Lfunc_end0: 
next:34'0     ~~~~~~~~~~~~~
          14:  .size issue_114508_u32, .Lfunc_end0-issue_114508_u32 
next:34'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
          15:  
next:34'0     ~
          16:  .section .text.issue_114508_i32,"ax",@progbits 
next:34'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
next:34'1                                  ?                   possible intended match
          17:  .globl issue_114508_i32 
next:34'0     ~~~~~~~~~~~~~~~~~~~~~~~~~
          18:  .p2align 1 
next:34'0     ~~~~~~~~~~~~
          19:  .type issue_114508_i32,@function 
next:34'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
          20: issue_114508_i32: 
next:34'0     ~~~~~~~~~~~~~~~~~
next:54'0                      X error: no match found
          21:  blt a1, a0, .LBB1_2 
next:54'0     ~~~~~~~~~~~~~~~~~~~~~
          22:  mv a0, a1 
next:54'0     ~~~~~~~~~~~
          23: .LBB1_2: 
next:54'0     ~~~~~~~~~
          24:  ret 
next:54'0     ~~~~~
          25: .Lfunc_end1: 
next:54'0     ~~~~~~~~~~~~~
          26:  .size issue_114508_i32, .Lfunc_end1-issue_114508_i32 
next:54'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
          27:  
next:54'0     ~
          28:  .ident "rustc version 1.88.0-dev" 
next:54'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
          29:  .section ".note.GNU-stack","",@progbits 
next:54'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
next:54'1                     ?                         possible intended match
>>>>>>
------------------------------------------



failures:
    [assembly] tests/assembly/rust-abi-arg-attr.rs#loongarch64
    [assembly] tests/assembly/rust-abi-arg-attr.rs#riscv64-zbb
    [assembly] tests/assembly/rust-abi-arg-attr.rs#riscv64

test result: FAILED. 1 passed; 3 failed; 535 ignored; 0 measured; 0 filtered out; finished in 102.37ms

Some tests failed in compiletest suite=assembly mode=assembly host=x86_64-unknown-linux-gnu target=x86_64-unknown-linux-gnu
help: ignored 497 up-to-date tests; use `--force-rerun` to prevent this

From what I can gather, the problem is that the compiler optimizes out the function?
It seems that Rust compiles crates as a separate thing so when the final test binary is built, the metadata is gone so the test here doesn't work anymore.

@rust-log-analyzer

This comment has been minimized.

@jieyouxu
Copy link
Member

jieyouxu commented Apr 19, 2025

From what I can gather, the problem is that the compiler optimizes out the function?

Not quite. From what I can tell, the key instructions are still present (i.e. if you comment out the .cfi* directive CHECK-NEXTs the test passes for me locally), but it's missing the CFI directives.

E.g. loongarch64 revision (this PR)

issue_114508_u32:
	sltu	$a2, $a1, $a0
	masknez	$a1, $a1, $a2
	maskeqz	$a0, $a0, $a2
	or	$a0, $a0, $a1
	ret
.Lfunc_end0:
	.size	issue_114508_u32, .Lfunc_end0-issue_114508_u32

	.section	.text.issue_114508_i32,"ax",@progbits
	.globl	issue_114508_i32
	.p2align	5
	.type	issue_114508_i32,@function
issue_114508_i32:
	slt	$a2, $a1, $a0
	masknez	$a1, $a1, $a2
	maskeqz	$a0, $a0, $a2
	or	$a0, $a0, $a1
	ret
.Lfunc_end1:
	.size	issue_114508_i32, .Lfunc_end1-issue_114508_i32

	.ident	"rustc version 1.88.0-dev"
	.section	".note.GNU-stack","",@progbits

on master:

issue_114508_u32:
	.cfi_startproc
	sltu	$a2, $a1, $a0
	masknez	$a1, $a1, $a2
	maskeqz	$a0, $a0, $a2
	or	$a0, $a0, $a1
	ret
.Lfunc_end0:
	.size	issue_114508_u32, .Lfunc_end0-issue_114508_u32
	.cfi_endproc

	.section	.text.issue_114508_i32,"ax",@progbits
	.globl	issue_114508_i32
	.p2align	5
	.type	issue_114508_i32,@function
issue_114508_i32:
	.cfi_startproc
	slt	$a2, $a1, $a0
	masknez	$a1, $a1, $a2
	maskeqz	$a0, $a0, $a2
	or	$a0, $a0, $a1
	ret
.Lfunc_end1:
	.size	issue_114508_i32, .Lfunc_end1-issue_114508_i32
	.cfi_endproc

	.ident	"rustc version 1.88.0-dev"
	.section	".note.GNU-stack","",@progbits

cc @rcvalle do you happen to know why the CFI directives might be missing? FWIW, minicore is built as an rlib + -Cpanic=abort and linked to the test crate via --extern minicore=/path/to/libminicore.rlib.

@jieyouxu
Copy link
Member

EDIT: bjorn3 told me

.cfi_startproc is expected whenever you compile with -Cpanic=unwind or with -Cpanic=abort + -Cforce-unwind-tables.

In this case I think it has to do with minicore being compiled with -Cpanic=abort, need to double-check how the assembly tests are built.

@RalfJung
Copy link
Member

In this case I think it has to do with minicore being compiled with -Cpanic=abort, need to double-check how the assembly tests are built.

Maybe we just need to add -Cforce-unwind-tables to the minicore build flags then?

@jieyouxu
Copy link
Member

Maybe we just need to add -Cforce-unwind-tables to the minicore build flags then?

That seems like a reasonable solution, I'll make that change separately and document these two preset flags in rdg.

@jieyouxu
Copy link
Member

jieyouxu commented Apr 23, 2025

#140194 will have //@ add-core-stubs also imply -Cforce-unwind-tables=yes when building the test (not minicore itself).

Zalathar added a commit to Zalathar/rust that referenced this pull request Apr 24, 2025
…les, r=bjorn3

minicore: Have `//@ add-core-stubs` also imply `-Cforce-unwind-tables=yes`

To preserve CFI directives in assembly tests, as `//@ add-core-stubs` already imply `-C panic=abort`.

This is a blocker for rust-lang#140037 (comment).

cc `@RalfJung`
r? `@bjorn3`
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Apr 24, 2025
…les, r=bjorn3

minicore: Have `//@ add-core-stubs` also imply `-Cforce-unwind-tables=yes`

To preserve CFI directives in assembly tests, as `//@ add-core-stubs` already imply `-C panic=abort`.

This is a blocker for rust-lang#140037 (comment).

cc ``@RalfJung``
r? ``@bjorn3``
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Apr 24, 2025
…les, r=bjorn3

minicore: Have `//@ add-core-stubs` also imply `-Cforce-unwind-tables=yes`

To preserve CFI directives in assembly tests, as `//@ add-core-stubs` already imply `-C panic=abort`.

This is a blocker for rust-lang#140037 (comment).

cc ```@RalfJung```
r? ```@bjorn3```
rust-timer added a commit to rust-lang-ci/rust that referenced this pull request Apr 24, 2025
Rollup merge of rust-lang#140194 - jieyouxu:minicore-force-unwind-tables, r=bjorn3

minicore: Have `//@ add-core-stubs` also imply `-Cforce-unwind-tables=yes`

To preserve CFI directives in assembly tests, as `//@ add-core-stubs` already imply `-C panic=abort`.

This is a blocker for rust-lang#140037 (comment).

cc ```@RalfJung```
r? ```@bjorn3```
github-actions bot pushed a commit to rust-lang/rustc-dev-guide that referenced this pull request Apr 28, 2025
…orn3

minicore: Have `//@ add-core-stubs` also imply `-Cforce-unwind-tables=yes`

To preserve CFI directives in assembly tests, as `//@ add-core-stubs` already imply `-C panic=abort`.

This is a blocker for rust-lang/rust#140037 (comment).

cc ```@RalfJung```
r? ```@bjorn3```
@Mark-Simulacrum
Copy link
Member

@rustbot author

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels May 4, 2025
@rustbot
Copy link
Collaborator

rustbot commented May 4, 2025

Reminder, once the PR becomes ready for a review, use @rustbot ready.

@hbina hbina closed this May 5, 2025
@hbina hbina force-pushed the hbina-update-use-minicore branch from e480e1f to 54d024e Compare May 5, 2025 14:30
@hbina
Copy link
Contributor Author

hbina commented May 5, 2025

@rustbot ready

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels May 5, 2025
@hbina
Copy link
Contributor Author

hbina commented May 5, 2025

Trying to trigger the CI

@RalfJung
Copy link
Member

RalfJung commented May 5, 2025

You closed this PR so apparently it's not ready? CI gets triggered automatically on pushes.

Note that to reopen a PR it must be in the same state as when you closed it, i.e. you have to push it back to whatever the current commit was at that time. Closing and reopening indeed triggers CI but that is rarely ever necessary.

@RalfJung RalfJung removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label May 5, 2025
@RalfJung RalfJung added the S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. label May 5, 2025
@hbina
Copy link
Contributor Author

hbina commented May 5, 2025

Ah darn I force pushed :>

edit: I might have the branch in my backup...

@hbina hbina reopened this May 5, 2025
@rustbot rustbot added A-rustdoc-json Area: Rustdoc JSON backend A-test-infra-minicore Area: `minicore` test auxiliary and `//@ add-core-stubs` PG-exploit-mitigations Project group: Exploit mitigations labels May 5, 2025
@rust-log-analyzer

This comment has been minimized.

@hbina
Copy link
Contributor Author

hbina commented May 5, 2025

Ok, now this is the error that I am getting
https://pastebin.com/QGcAWUH4
No idea what it means tho, so any pointers are appreciated

Another question, can you implement Ordering like this?

#[lang = "Ordering"]
#[repr(i8)]
pub enum Ordering {
    Less = 0,
    Equal = 1,
    Greater = 1,
}

because I got this error when I use -1

error: requires `panic_const_neg_overflow` lang_item
  --> /home/hbina085/git/rust-lang/rust/tests/auxiliary/minicore.rs:210:21
   |
LL |                     -self
   |                     ^^^^^
...
LL | impl_neg_trait!(isize, i8, i16, i32, i64, i128,);
   | ------------------------------------------------ in this macro invocation
   |
   = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
   = note: this error originates in the macro `impl_neg_trait` (in Nightly builds, run with -Z macro-backtrace for more info)

And I can't find any usages of panic_const_neg_overflow...

hbina085@DESKTOP-PGERPVO ~/g/r/rust (hbina-update-use-minicore) [SIGINT]> rg 'panic_const_neg_overflow' --context 2 .                                                                                                        (base) 
./compiler/rustc_span/src/symbol.rs
1531-        panic_const_gen_fn_none_panic,
1532-        panic_const_mul_overflow,
1533:        panic_const_neg_overflow,
1534-        panic_const_rem_by_zero,
1535-        panic_const_rem_overflow,

./compiler/rustc_hir/src/lang_items.rs
297-    PanicDivOverflow,        sym::panic_const_div_overflow, panic_const_div_overflow, Target::Fn, GenericRequirement::None;
298-    PanicRemOverflow,        sym::panic_const_rem_overflow, panic_const_rem_overflow, Target::Fn, GenericRequirement::None;
299:    PanicNegOverflow,        sym::panic_const_neg_overflow, panic_const_neg_overflow, Target::Fn, GenericRequirement::None;
300-    PanicShrOverflow,        sym::panic_const_shr_overflow, panic_const_shr_overflow, Target::Fn, GenericRequirement::None;
301-    PanicShlOverflow,        sym::panic_const_shl_overflow, panic_const_shl_overflow, Target::Fn, GenericRequirement::None;

./compiler/rustc_codegen_cranelift/example/mini_core.rs
492-    panic_const_div_overflow = "attempt to divide with overflow",
493-    panic_const_rem_overflow = "attempt to calculate the remainder with overflow",
494:    panic_const_neg_overflow = "attempt to negate with overflow",
495-    panic_const_shr_overflow = "attempt to shift right with overflow",
496-    panic_const_shl_overflow = "attempt to shift left with overflow",

./compiler/rustc_codegen_gcc/example/mini_core.rs
496-    panic_const_div_overflow = "attempt to divide with overflow",
497-    panic_const_rem_overflow = "attempt to calculate the remainder with overflow",
498:    panic_const_neg_overflow = "attempt to negate with overflow",
499-    panic_const_shr_overflow = "attempt to shift right with overflow",
500-    panic_const_shl_overflow = "attempt to shift left with overflow",

./library/core/src/panicking.rs
191-        panic_const_div_overflow = "attempt to divide with overflow",
192-        panic_const_rem_overflow = "attempt to calculate the remainder with overflow",
193:        panic_const_neg_overflow = "attempt to negate with overflow",
194-        panic_const_shr_overflow = "attempt to shift right with overflow",
195-        panic_const_shl_overflow = "attempt to shift left with overflow",

@bors
Copy link
Collaborator

bors commented May 5, 2025

☔ The latest upstream changes (presumably #140664) made this pull request unmergeable. Please resolve the merge conflicts.

Copy link
Member

@RalfJung RalfJung May 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please don't reformat files you're not even changing in this PR. All of the Miri and Clippy changes should be undone.

@RalfJung
Copy link
Member

RalfJung commented May 6, 2025

And I can't find any usages of panic_const_neg_overflow...

Yeah, this is a lang item and it is inserted into the code by the compiler.

@RalfJung
Copy link
Member

RalfJung commented May 6, 2025

The errors that look like this

2025-05-05T15:24:16.9701876Z /checkout/tests/codegen/unwind-abis/win64-unwind-abi.rs:18:11: error: CHECK: expected string not found in input
2025-05-05T15:24:16.9702420Z // CHECK: @rust_item_that_can_unwind() unnamed_addr #1 {
2025-05-05T15:24:16.9702697Z           ^
2025-05-05T15:24:16.9703207Z /checkout/obj/build/x86_64-unknown-linux-gnu/test/codegen/unwind-abis/win64-unwind-abi/win64-unwind-abi.ll:7:70: note: scanning from here
2025-05-05T15:24:16.9703858Z define win64cc void @rust_item_that_cannot_unwind() unnamed_addr #0 {
2025-05-05T15:24:16.9704213Z                                                                      ^
2025-05-05T15:24:16.9704840Z /checkout/obj/build/x86_64-unknown-linux-gnu/test/codegen/unwind-abis/win64-unwind-abi/win64-unwind-abi.ll:13:21: note: possible intended match here
2025-05-05T15:24:16.9705595Z define win64cc void @rust_item_that_can_unwind() unnamed_addr #0 {

are caused by the attribute indices in the LLVM IR shifting around. I think it's possible to write codegen tests that are robust to such index shifts but I don't know how... the easiest fix is to just change the expected numbers in the test. Ensure to replace all occurrences of an index with the new one!

@RalfJung
Copy link
Member

RalfJung commented May 6, 2025

Given how many issues you are running into, I'd suggest reducing the scope of this PR to only change 1 or 2 files to use minicore. That'll make it much easier.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-rustdoc-json Area: Rustdoc JSON backend A-test-infra-minicore Area: `minicore` test auxiliary and `//@ add-core-stubs` PG-exploit-mitigations Project group: Exploit mitigations S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Extend minicore with intrinsics and use it to replace #[rustc_intrinsic] in tests
7 participants