Skip to content

Port rust-lang/backtrace's cpp_smoke_test to rust-lang/rust test suite #136695

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

Closed
wants to merge 2 commits into from

Conversation

jieyouxu
Copy link
Member

@jieyouxu jieyouxu commented Feb 7, 2025

Ports https://github.com/rust-lang/backtrace-rs/tree/e33eaac8caf46d0d3cc57f8d152529e8b7ae1b78/crates/cpp_smoke_test to the main repo.

I can't say I'm 100% convinced by the value of this test living in the main repo for several reasons:

  1. This test (or at least the actual cpp_smoke_test.rs is extremely fragile. It's sensitive to debuginfo levels AND optimizations. On x86_64-unknown-linux-gnu, the C++ file must be compiled with exactly -O1. No more, no less, or else the backtrace symbol names do not line up in symbol count or name.
  2. I could not get this test to work on Windows MSVC, no matter which combination of debuginfo levels and optimization levels I tried.
  3. This test also exercises backtrace-the-submodule, and does not actually exercise through the std::backtrace interfaces (as std::backtrace is missing some key APIs to make this test possible).

Note that I have not tried other targets, e.g. Apple friends, which may fail for yet other reasons.

Possibly supersedes #136182.

r? @ChrisDenton (or @workingjubilee)

try-job: x86_64-apple-1
try-job: aarch64-apple

jieyouxu and others added 2 commits February 8, 2025 00:54
These should eventually be cleaned up, but let's add a helper for the
immediate need of porting the `cpp_smoke_test` test.
This test exercises the `backtrace` submodule included under the
`library/` tree, which should be the `backtrace` that is used and thus
transitively shipped with the standard library.

The `cpp_smoke_test` was disabled in the `backtrace` repo many years
ago. This is seemingly because the test failed years ago due to C++
symbol demangling troubles in `cpp_demangle` (which are now fixed; see
<gimli-rs/cpp_demangle#73>).

Note that this test is disabled on Windows MSVC because I couldn't get
it to work locally:

- At MSVC `-O1`, the test fails because there are no backtrace symbols.
- At MSVC `-O0`, the test fails because both the C++ templated
  trampolined symbol has a different signature (w/ a `__cdecl`) and also
  `cpp_trampoline` is missing.

Co-authored-by: Pyrode <[email protected]>
@rustbot rustbot added A-run-make Area: port run-make Makefiles to rmake.rs 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 Feb 7, 2025
@jieyouxu jieyouxu added S-experimental Status: Ongoing experiment that does not require reviewing and won't be merged in its current state. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Feb 7, 2025
@jieyouxu
Copy link
Member Author

jieyouxu commented Feb 7, 2025

Tagging S-experimental for now, mostly opened for discussion.

@jieyouxu jieyouxu marked this pull request as draft February 7, 2025 17:05
@jieyouxu
Copy link
Member Author

jieyouxu commented Feb 7, 2025

@bors try

@jieyouxu
Copy link
Member Author

jieyouxu commented Feb 7, 2025

In all honesty, maybe smoke this test even over at rust-lang/backtrace lmao

bors added a commit to rust-lang-ci/rust that referenced this pull request Feb 7, 2025
Port `rust-lang/backtrace`'s `cpp_smoke_test` to `rust-lang/rust` test suite

Ports https://github.com/rust-lang/backtrace-rs/tree/e33eaac8caf46d0d3cc57f8d152529e8b7ae1b78/crates/cpp_smoke_test to the main repo.

I can't say I'm 100% convinced by the value of this test living in the main repo for several reasons:

1. This test (or at least the actual `cpp_smoke_test.rs` is **extremely** fragile. It's sensitive to debuginfo levels AND optimizations. On `x86_64-unknown-linux-gnu`, the C++ file **must** be compiled with **exactly** `-O1`. No more, no less, or else the backtrace symbol names do not line up in symbol count or name.
2. I could not get this test to work on Windows MSVC, no matter which combination of debuginfo levels and optimization levels I tried.

Note that I have not tried other targets, e.g. Apple friends, which may fail for yet other reasons.

Possibly supersedes rust-lang#136182.

r? `@ChrisDenton` (or `@workingjubilee)`

try-job: x86_64-apple-1
try-job: aarch64-apple
@bors
Copy link
Collaborator

bors commented Feb 7, 2025

⌛ Trying commit 7bb88c2 with merge 896b013...

@jieyouxu jieyouxu added A-backtrace Area: Backtraces A-testsuite Area: The testsuite used to check the correctness of rustc labels Feb 7, 2025
@rust-log-analyzer
Copy link
Collaborator

The job aarch64-apple failed! Check out the build log: (web) (plain)

Click to see the possible cause of the failure (guessed by this bot)
Updating files:  98% (50845/51882)
Updating files:  99% (51364/51882)
Updating files: 100% (51882/51882)
Updating files: 100% (51882/51882), done.
Switched to a new branch 'try'
branch 'try' set up to track 'origin/try'.
[command]/opt/homebrew/bin/git log -1 --format=%H
896b0137bf91fe20dedfe706efbc086a6cc0725e
##[group]Run src/ci/scripts/setup-environment.sh
src/ci/scripts/setup-environment.sh
---
file:.git/config remote.origin.url=https://github.com/rust-lang-ci/rust
file:.git/config remote.origin.fetch=+refs/heads/*:refs/remotes/origin/*
file:.git/config gc.auto=0
file:.git/config http.https://github.com/.extraheader=AUTHORIZATION: basic ***
file:.git/config branch.try.remote=origin
file:.git/config branch.try.merge=refs/heads/try
file:.git/config remote.upstream.fetch=+refs/heads/*:refs/remotes/upstream/*
file:.git/config submodule.library/backtrace.active=true
file:.git/config submodule.library/backtrace.url=https://github.com/rust-lang/backtrace-rs.git
file:.git/config submodule.library/stdarch.active=true
---
---- [run-make] tests/run-make/cpp-smoke-test stdout ----

error: rmake recipe failed to complete
status: exit status: 1
command: cd "/Users/runner/work/rust/rust/build/aarch64-apple-darwin/test/run-make/cpp-smoke-test/rmake_out" && env -u RUSTFLAGS AR="ar" BUILD_ROOT="/Users/runner/work/rust/rust/build/aarch64-apple-darwin" CARGO="/Users/runner/work/rust/rust/build/aarch64-apple-darwin/stage1-tools-bin/cargo" CC="/Applications/Xcode_15.4.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang" CC_DEFAULT_FLAGS="-ffunction-sections -fdata-sections -fPIC --target=arm64-apple-macosx11 -isysroot /Applications/Xcode_15.4.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.5.sdk" CXX="/Applications/Xcode_15.4.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++" CXX_DEFAULT_FLAGS="-ffunction-sections -fdata-sections -fPIC --target=arm64-apple-macosx11 -isysroot /Applications/Xcode_15.4.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.5.sdk -stdlib=libc++" DYLD_LIBRARY_PATH="/Users/runner/work/rust/rust/build/aarch64-apple-darwin/stage0-bootstrap-tools/aarch64-apple-darwin/release/deps:/Users/runner/work/rust/rust/build/aarch64-apple-darwin/stage0/lib:/Users/runner/work/rust/rust/build/aarch64-apple-darwin/stage2-tools-bin:/Users/runner/work/rust/rust/build/aarch64-apple-darwin/stage2/lib/rustlib/aarch64-apple-darwin/lib" HOST_RPATH_DIR="/Users/runner/work/rust/rust/build/aarch64-apple-darwin/stage2/lib" LD_LIB_PATH_ENVVAR="DYLD_LIBRARY_PATH" LLVM_BIN_DIR="/Users/runner/work/rust/rust/build/aarch64-apple-darwin/ci-llvm/bin" LLVM_COMPONENTS="aarch64 aarch64asmparser aarch64codegen aarch64desc aarch64disassembler aarch64info aarch64utils aggressiveinstcombine all all-targets analysis arm armasmparser armcodegen armdesc armdisassembler arminfo armutils asmparser asmprinter avr avrasmparser avrcodegen avrdesc avrdisassembler avrinfo binaryformat bitreader bitstreamreader bitwriter bpf bpfasmparser bpfcodegen bpfdesc bpfdisassembler bpfinfo cfguard codegen codegendata codegentypes core coroutines coverage csky cskyasmparser cskycodegen cskydesc cskydisassembler cskyinfo debuginfobtf debuginfocodeview debuginfodwarf debuginfogsym debuginfologicalview debuginfomsf debuginfopdb demangle dlltooldriver dwarflinker dwarflinkerclassic dwarflinkerparallel dwp engine executionengine extensions filecheck frontenddriver frontendhlsl frontendoffloading frontendopenacc frontendopenmp fuzzercli fuzzmutate globalisel hexagon hexagonasmparser hexagoncodegen hexagondesc hexagondisassembler hexagoninfo hipstdpar instcombine instrumentation interfacestub interpreter ipo irprinter irreader jitlink libdriver lineeditor linker loongarch loongarchasmparser loongarchcodegen loongarchdesc loongarchdisassembler loongarchinfo lto m68k m68kasmparser m68kcodegen m68kdesc m68kdisassembler m68kinfo mc mca mcdisassembler mcjit mcparser mips mipsasmparser mipscodegen mipsdesc mipsdisassembler mipsinfo mirparser msp430 msp430asmparser msp430codegen msp430desc msp430disassembler msp430info native nativecodegen nvptx nvptxcodegen nvptxdesc nvptxinfo objcarcopts objcopy object objectyaml option orcdebugging orcjit orcshared orctargetprocess passes powerpc powerpcasmparser powerpccodegen powerpcdesc powerpcdisassembler powerpcinfo profiledata remarks riscv riscvasmparser riscvcodegen riscvdesc riscvdisassembler riscvinfo riscvtargetmca runtimedyld sandboxir scalaropts selectiondag sparc sparcasmparser sparccodegen sparcdesc sparcdisassembler sparcinfo support symbolize systemz systemzasmparser systemzcodegen systemzdesc systemzdisassembler systemzinfo tablegen target targetparser textapi textapibinaryreader transformutils vectorize webassembly webassemblyasmparser webassemblycodegen webassemblydesc webassemblydisassembler webassemblyinfo webassemblyutils windowsdriver windowsmanifest x86 x86asmparser x86codegen x86desc x86disassembler x86info x86targetmca xray xtensa xtensaasmparser xtensacodegen xtensadesc xtensadisassembler xtensainfo" LLVM_FILECHECK="/Users/runner/work/rust/rust/build/aarch64-apple-darwin/ci-llvm/bin/FileCheck" NODE="/opt/homebrew/bin/node" PYTHON="/usr/bin/python3" RUSTC="/Users/runner/work/rust/rust/build/aarch64-apple-darwin/stage2/bin/rustc" RUSTDOC="/Users/runner/work/rust/rust/build/aarch64-apple-darwin/stage2/bin/rustdoc" SOURCE_ROOT="/Users/runner/work/rust/rust" TARGET="aarch64-apple-darwin" TARGET_RPATH_DIR="/Users/runner/work/rust/rust/build/aarch64-apple-darwin/stage2/lib/rustlib/aarch64-apple-darwin/lib" TARGET_RPATH_ENV="/Users/runner/work/rust/rust/build/aarch64-apple-darwin/test/run-make/cpp-smoke-test/rmake_out:/Users/runner/work/rust/rust/build/aarch64-apple-darwin/stage0-bootstrap-tools/aarch64-apple-darwin/release/deps:/Users/runner/work/rust/rust/build/aarch64-apple-darwin/stage0/lib" "/Users/runner/work/rust/rust/build/aarch64-apple-darwin/test/run-make/cpp-smoke-test/rmake"
--- stderr -------------------------------
command failed at line 64
command failed at line 64
Command { cmd: DYLD_LIBRARY_PATH="/Users/runner/work/rust/rust/build/aarch64-apple-darwin/test/run-make/cpp-smoke-test/rmake_out:/Users/runner/work/rust/rust/build/aarch64-apple-darwin/test/run-make/cpp-smoke-test/rmake_out:/Users/runner/work/rust/rust/build/aarch64-apple-darwin/stage0-bootstrap-tools/aarch64-apple-darwin/release/deps:/Users/runner/work/rust/rust/build/aarch64-apple-darwin/stage0/lib:/Users/runner/work/rust/rust/build/aarch64-apple-darwin/stage0-bootstrap-tools/aarch64-apple-darwin/release/deps:/Users/runner/work/rust/rust/build/aarch64-apple-darwin/stage0/lib:/Users/runner/work/rust/rust/build/aarch64-apple-darwin/stage2-tools-bin:/Users/runner/work/rust/rust/build/aarch64-apple-darwin/stage2/lib/rustlib/aarch64-apple-darwin/lib" LC_ALL="C" "/Users/runner/work/rust/rust/build/aarch64-apple-darwin/test/run-make/cpp-smoke-test/rmake_out/cpp_smoke_test", stdin_buf: None, stdin: None, stdout: None, stderr: None, drop_bomb: DropBomb { command: "/Users/runner/work/rust/rust/build/aarch64-apple-darwin/test/run-make/cpp-smoke-test/rmake_out/cpp_smoke_test", defused: true, armed_location: Location { file: "/Users/runner/work/rust/rust/tests/run-make/cpp-smoke-test/rmake.rs", line: 64, col: 5 } }, already_executed: true }
output status: `signal: 6 (SIGABRT)`
=== STDOUT ===
expected names = [
expected names = [
    "void space::templated_trampoline<void (*)()>(void (*)())",
    "cpp_trampoline",



=== STDERR ===
---
   5:        0x102aaf668 - std::panicking::default_hook::ha5209877de15da4e
   6:        0x102ab035c - std::panicking::rust_panic_with_hook::h61c817b43e6241f3
   7:        0x102aaff00 - std::panicking::begin_panic_handler::{{closure}}::hc1446ff5a36c75e0
   8:        0x102aaefc4 - std::sys::backtrace::__rust_end_short_backtrace::h2e4d9af37b7b1990
   9:        0x102aafbe0 - _rust_begin_unwind
  10:        0x102ac9790 - core::panicking::panic_nounwind_fmt::h27d77e578f56034f
  11:        0x102ac9808 - core::panicking::panic_nounwind::h3fed6c4430767e75
  12:        0x102ac98e4 - core::panicking::panic_cannot_unwind::h308d7afe61de7625
  13:        0x102982c44 - cpp_smoke_test::main::assert_cpp_frames::he750c2a453af0c5c
                               at /Users/runner/work/rust/rust/build/aarch64-apple-darwin/test/run-make/cpp-smoke-test/rmake_out/cpp_smoke_test.rs:12:5
  14:        0x102982750 - cpp_smoke_test::main::hf215d54d19a0425e
                               at /Users/runner/work/rust/rust/build/aarch64-apple-darwin/test/run-make/cpp-smoke-test/rmake_out/cpp_smoke_test.rs:69:9
                               at /Users/runner/work/rust/rust/library/core/src/ops/function.rs:250:5
  16:        0x10297e900 - std::sys::backtrace::__rust_begin_short_backtrace::h4fe1a90e5cfaeb2c
                               at /Users/runner/work/rust/rust/library/std/src/sys/backtrace.rs:152:18
  17:        0x10297e8d0 - std::rt::lang_start::{{closure}}::h35556602ff29c270

@bors
Copy link
Collaborator

bors commented Feb 7, 2025

💔 Test failed - checks-actions

@bors bors added the S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. label Feb 7, 2025
@jieyouxu jieyouxu closed this Feb 8, 2025
@jieyouxu jieyouxu deleted the cpp_smoke_test branch February 8, 2025 08:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-backtrace Area: Backtraces A-run-make Area: port run-make Makefiles to rmake.rs A-testsuite Area: The testsuite used to check the correctness of rustc S-experimental Status: Ongoing experiment that does not require reviewing and won't be merged in its current state. 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.

5 participants