Skip to content
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

Disables frame pointers for sgx target #121637

Closed
wants to merge 1 commit into from

Conversation

nshyrei
Copy link
Contributor

@nshyrei nshyrei commented Feb 26, 2024

Fixes an sgx-related test failure intorduced by PR https://github.com/rust-lang/rust/pull/121203`. The frame pointer feature from the PR in question adds unexpected assembly instructions for a function unw_getcontext which is checked in test rust/tests/run-make/x86_64-fortanix-unknown-sgx-lvi .

The test failure looks like this:

rust/tests/run-make/x86_64-fortanix-unknown-sgx-lvi/unw_getcontext.checks:2:8: error: CHECK: expected string not found in input
CHECK: lfence
       ^
rust/build/x86_64-unknown-linux-gnu/test/run-make/x86_64-fortanix-unknown-sgx-lvi/x86_64-fortanix-unknown-sgx-lvi/tmp.D32LVJN8Jw:6:33: note: scanning from here
0000000000030781 <unw_getcontext>:
                                ^
rust/build/x86_64-unknown-linux-gnu/test/run-make/x86_64-fortanix-unknown-sgx-lvi/x86_64-fortanix-unknown-sgx-lvi/tmp.D32LVJN8Jw:7:19: note: possible intended match here
 30781: f3 0f 1e fa endbr64
                  ^

Input file: rust/build/x86_64-unknown-linux-gnu/test/run-make/x86_64-fortanix-unknown-sgx-lvi/x86_64-fortanix-unknown-sgx-lvi/tmp.D32LVJN8Jw
Check file: rust/tests/run-make/x86_64-fortanix-unknown-sgx-lvi/unw_getcontext.checks

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

Input was:
<<<<<<
           1:  
           2: rust/build/x86_64-unknown-linux-gnu/test/run-make/x86_64-fortanix-unknown-sgx-lvi/x86_64-fortanix-unknown-sgx-lvi/enclave/target/x86_64-fortanix-unknown-sgx/debug/enclave: file format elf64-x86-64 
           3:  
           4: Disassembly of section .text: 
           5:  
           6: 0000000000030781 <unw_getcontext>: 
check:2'0                                     X~~ error: no match found
           7:  30781: f3 0f 1e fa endbr64 
check:2'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
check:2'1                       ?          possible intended match
           8:  30785: 48 89 07 movq %rax, (%rdi) 
check:2'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
           9:  30788: 48 89 5f 08 movq %rbx, 0x8(%rdi) 
check:2'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
          10:  3078c: 48 89 4f 10 movq %rcx, 0x10(%rdi) 
check:2'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
          11:  30790: 48 89 57 18 movq %rdx, 0x18(%rdi) 
check:2'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
          12:  30794: 48 89 7f 20 movq %rdi, 0x20(%rdi) 
check:2'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


failures:
    [run-make] tests/run-make/x86_64-fortanix-unknown-sgx-lvi

Command used to build the compiler and run the tests looks like this

export AR_x86_64_fortanix_unknown_sgx=ar
export CC_x86_64_fortanix_unknown_sgx=clang-11
export CFLAGS_x86_64_fortanix_unknown_sgx="-D__ELF__ -isystem/usr/include/x86_64-linux-gnu -mlvi-hardening -mllvm -x86-experimental-lvi-inline-asm-hardening"
export CXX_x86_64_fortanix_unknown_sgx=clang++-11
export CXXFLAGS_x86_64_fortanix_unknown_sgx="-D__ELF__ -isystem/usr/include/x86_64-linux-gnu -mlvi-hardening -mllvm -x86-experimental-lvi-inline-asm-hardening"
export CC_x86_64_unknown_linux_gnu=clang-11
export CXX_x86_64_unknown_linux_gnu=clang++-11
git submodule foreach --recursive git reset --hard
git submodule update --init --recursive
git submodule foreach --recursive git fetch --depth=2147483647 origin '+refs/heads/*:refs/remotes/origin/*'
rm -f config.toml
./configure --enable-lld --disable-rpath --set llvm.ninja=false --set rust.verbose-tests=true --set profile=compiler
TF_BUILD=True RUST_TEST_THREADS=1 ./x.py test --stage 1 "library/std" tests/assembly tests/run-make --target=x86_64-fortanix-unknown-sgx --no-doc --exclude src/tools/linkchecker --exclude src/tools/rust-demangler --no-fail-fast

Test is fixed by not setting the compiler flag -Cforce-frame-pointers=true if the host target is x86_64-fortanix-unknown-sgx

@rustbot
Copy link
Collaborator

rustbot commented Feb 26, 2024

r? @onur-ozkan

rustbot has assigned @onur-ozkan.
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-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) labels Feb 26, 2024
@Nilstrieb
Copy link
Member

can the test be fixed instead?

Copy link
Member

@onur-ozkan onur-ozkan left a comment

Choose a reason for hiding this comment

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

Thank you for the PR.

Test is fixed by not setting the compiler flag -Cforce-frame-pointers=true if the host target is x86_64-fortanix-unknown-sgx

I would expect fixing the actual problem rather than hiding it. And instead of applying this patch, you could simply disable it in the build configuration (config.toml) anyway.

@onur-ozkan onur-ozkan 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 Feb 26, 2024
@nshyrei
Copy link
Contributor Author

nshyrei commented Mar 4, 2024

@onur-ozkan The issue will be properly fixed in #121683. I am closing this one.

@nshyrei nshyrei closed this Mar 4, 2024
@nshyrei nshyrei deleted the no_frame_pointers_on_sgx branch March 4, 2024 10:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants