evmar / n2

n2 ("into"), a ninja compatible build system

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

thread 'main' panicked at 'index out of bounds: the len is 4978 but the index is 4978', src/densemap.rs:25:10

petr-tik opened this issue · comments

Hey, thanks for the awesome project.

A friend/coworker of mine contributed recently and I wanted to try n2 on a decent-sized cpp project -
https://github.com/rr-debugger/rr/

Here is my repro for the bug in the issue title

Install n2 from git

~/Coding/rr $ cargo install --git https://github.com/evmar/n2
    Updating git repository `https://github.com/evmar/n2`
  Installing n2 v0.1.0 (https://github.com/evmar/n2#5754141e)
    Updating crates.io index
  Downloaded libc v0.2.122
  Downloaded 1 crate (577.4 KB) in 0.48s
   Compiling fs_extra v1.2.0
   Compiling libc v0.2.122
   Compiling cc v1.0.73
   Compiling anyhow v1.0.56
   Compiling unicode-width v0.1.9
   Compiling lazy_static v1.4.0
   Compiling getopts v0.2.21
   Compiling jemalloc-sys v0.3.2
   Compiling jemallocator v0.3.2
   Compiling n2 v0.1.0 (/home/petr_tik/.cargo/git/checkouts/n2-e6f499fa596a8a82/5754141)
    Finished release [optimized + debuginfo] target(s) in 29.26s
  Installing /home/petr_tik/.cargo/bin/n2
   Installed package `n2 v0.1.0 (https://github.com/evmar/n2#5754141e)` (executable `n2`)

Change to the dir with rr

Cd (or git clone from git clone https://github.com/rr-debugger/rr.git) and follow the build instructions from
https://github.com/rr-debugger/rr/wiki/Building-And-Installing#project-building

~/Coding/ $ git clone https://github.com/rr-debugger/rr.git && cd rr
~/Coding/rr $ git log --oneline -n1
4aca8b4d (HEAD, upstream/master, upstream/HEAD) Forward SIGTERM to detached tasks immediately
~/Coding/rr $ rm -rf build/
~/Coding/rr $ # follow this https://github.com/rr-debugger/rr/wiki/Building-And-Installing#project-building but call the build dir "build"

Tell cmake to generate build.ninja in the build dir

~/Coding/rr $ mkdir build && cd build && cmake -G Ninja ../
-- The C compiler identification is GNU 7.5.0
-- The CXX compiler identification is GNU 7.5.0
-- The ASM compiler identification is GNU
-- Found assembler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Performing Test SUPPORTS_CXX14
-- Performing Test SUPPORTS_CXX14 - Success
-- Found PkgConfig: /usr/bin/pkg-config (found version "0.29.1") 
-- Checking for module 'capnp'
--   Found capnp, version 0.6.1
-- Checking for module 'zlib'
--   Found zlib, version 1.2.11
-- Found PythonInterp: /usr/bin/python3 (found suitable version "3.6.12", minimum required is "3") 
You have called ADD_LIBRARY for library rrpage without any source files. This typically indicates a problem with your CMakeLists.txt file
You have called ADD_LIBRARY for library rrpreload without any source files. This typically indicates a problem with your CMakeLists.txt file
You have called ADD_LIBRARY for library rraudit without any source files. This typically indicates a problem with your CMakeLists.txt file
You have called ADD_LIBRARY for library rrpage_32 without any source files. This typically indicates a problem with your CMakeLists.txt file
You have called ADD_LIBRARY for library rrpreload_32 without any source files. This typically indicates a problem with your CMakeLists.txt file
You have called ADD_LIBRARY for library rraudit_32 without any source files. This typically indicates a problem with your CMakeLists.txt file
-- Configuring done
-- Generating done
-- Build files have been written to: /home/petr_tik/Coding/rr/build
~/Coding/rr/build $ cd ../

Check build.ninja and try building with n2

Check the number of lines in the build.ninja file and start a build with n2 until you get an error

~/Coding/rr $ wc -l build/build.ninja
44084 build/build.ninja
~/Coding/rr $ n2 -v -C build
thread 'main' panicked at 'index out of bounds: the len is 4978 but the index is 4978', src/densemap.rs:25:10
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

rerun n2 and get the full backtrace

~/Coding/rr $ RUST_BACKTRACE=full n2 -v -C build
thread 'main' panicked at 'index out of bounds: the len is 4978 but the index is 4978', src/densemap.rs:25:10
stack backtrace:
   0:     0x5615872ed76a - std::backtrace_rs::backtrace::libunwind::trace::h91c465e73bf6c785
                               at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/std/src/../../backtrace/src/backtrace/libunwind.rs:93:5
   1:     0x5615872ed76a - std::backtrace_rs::backtrace::trace_unsynchronized::hae9da36f5d58b5f3
                               at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x5615872ed76a - std::sys_common::backtrace::_print_fmt::h7f499fa126a7effb
                               at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/std/src/sys_common/backtrace.rs:67:5
   3:     0x5615872ed76a - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h3e2b509ce2ce6007
                               at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/std/src/sys_common/backtrace.rs:46:22
   4:     0x56158728dfcc - core::fmt::write::h753c7571fa063ecb
                               at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/core/src/fmt/mod.rs:1168:17
   5:     0x5615872c3e1f - std::io::Write::write_fmt::h2815c0519c99ba09
                               at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/std/src/io/mod.rs:1660:15
   6:     0x5615872ee802 - std::sys_common::backtrace::_print::h64941a6fc8b0ed9b
                               at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/std/src/sys_common/backtrace.rs:49:5
   7:     0x5615872ee802 - std::sys_common::backtrace::print::hcf25e43e1a9b0766
                               at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/std/src/sys_common/backtrace.rs:36:9
   8:     0x5615872ee802 - std::panicking::default_hook::{{closure}}::h78d3e6cf97fc623d
                               at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/std/src/panicking.rs:211:50
   9:     0x5615872ef5ee - std::panicking::default_hook::hda898f8d3ad1a5ae
                               at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/std/src/panicking.rs:228:9
  10:     0x5615872ef5ee - std::panicking::rust_panic_with_hook::h1a5ea2d6c23051aa
                               at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/std/src/panicking.rs:606:17
  11:     0x5615872ef0d8 - std::panicking::begin_panic_handler::{{closure}}::h07f549390938b73f
                               at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/std/src/panicking.rs:502:13
  12:     0x5615872ef056 - std::sys_common::backtrace::__rust_end_short_backtrace::h5ec3758a92cfb00d
                               at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/std/src/sys_common/backtrace.rs:139:18
  13:     0x5615872ef012 - rust_begin_unwind
                               at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/std/src/panicking.rs:498:5
  14:     0x561587286330 - core::panicking::panic_fmt::h3a79a6a99affe1d5
                               at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/core/src/panicking.rs:116:14
  15:     0x5615872862f1 - core::panicking::panic_bounds_check::h449d4ff4d992b84f
                               at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/core/src/panicking.rs:84:5
  16:     0x5615872b7b8d - <usize as core::slice::index::SliceIndex<[T]>>::index::h4157e3ec92048f2b
                               at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/core/src/slice/index.rs:189:10
  17:     0x5615872b7b8d - core::slice::index::<impl core::ops::index::Index<I> for [T]>::index::h67da73f717a04c6c
                               at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/core/src/slice/index.rs:15:9
  18:     0x5615872b7b8d - <alloc::vec::Vec<T,A> as core::ops::index::Index<I>>::index::h4d5671bbb1ca6714
                               at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/alloc/src/vec/mod.rs:2520:9
  19:     0x5615872b7b8d - n2::densemap::DenseMap<K,V>::get::h3cfc2bb3a9c6d350
                               at /home/petr_tik/.cargo/git/checkouts/n2-e6f499fa596a8a82/5754141/src/densemap.rs:25:10
  20:     0x5615872b7b8d - n2::graph::Graph::add_build::h1964147cca1ce967
                               at /home/petr_tik/.cargo/git/checkouts/n2-e6f499fa596a8a82/5754141/src/graph.rs:256:25
  21:     0x5615872b7b8d - n2::load::Loader::add_build::h08ca299dbe63baac
                               at /home/petr_tik/.cargo/git/checkouts/n2-e6f499fa596a8a82/5754141/src/load.rs:137:9
  22:     0x5615872b7b8d - n2::load::Loader::parse::h163c7ecc8e2b7ce5
                               at /home/petr_tik/.cargo/git/checkouts/n2-e6f499fa596a8a82/5754141/src/load.rs:171:44
  23:     0x5615872b7b8d - n2::load::Loader::read_file::hc4531311fe85d5d9
                               at /home/petr_tik/.cargo/git/checkouts/n2-e6f499fa596a8a82/5754141/src/load.rs:146:9
  24:     0x5615872a39fe - n2::trace::scope::hcd7c61c7107b5186
                               at /home/petr_tik/.cargo/git/checkouts/n2-e6f499fa596a8a82/5754141/src/trace.rs:116:21
  25:     0x5615872a39fe - n2::load::read::h697ad8d9a113c44c
                               at /home/petr_tik/.cargo/git/checkouts/n2-e6f499fa596a8a82/5754141/src/load.rs:193:5
  26:     0x5615872a39fe - n2::run::build::{{closure}}::hb2a3de0e31f57edb
                               at /home/petr_tik/.cargo/git/checkouts/n2-e6f499fa596a8a82/5754141/src/run.rs:33:51
  27:     0x5615872a1bf0 - n2::trace::scope::hae3aefe50621511a
                               at /home/petr_tik/.cargo/git/checkouts/n2-e6f499fa596a8a82/5754141/src/trace.rs:116:21
  28:     0x5615872a1bf0 - n2::run::build::h6dc9ded841a12ecc
                               at /home/petr_tik/.cargo/git/checkouts/n2-e6f499fa596a8a82/5754141/src/run.rs:33:21
  29:     0x56158729ed21 - n2::run::run_impl::h0bb597f9f5680885
                               at /home/petr_tik/.cargo/git/checkouts/n2-e6f499fa596a8a82/5754141/src/run.rs:209:22
  30:     0x56158728b380 - n2::run::run::hd21211266b0e6a0b
                               at /home/petr_tik/.cargo/git/checkouts/n2-e6f499fa596a8a82/5754141/src/run.rs:234:15
  31:     0x56158728b380 - n2::main::h4c022cd59e4f0615
                               at /home/petr_tik/.cargo/git/checkouts/n2-e6f499fa596a8a82/5754141/src/main.rs:4:27
  32:     0x56158728b6a3 - core::ops::function::FnOnce::call_once::h25e67c454c9b4a24
                               at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/core/src/ops/function.rs:227:5
  33:     0x56158728b6a3 - std::sys_common::backtrace::__rust_begin_short_backtrace::he1b68df33ad7ec41
                               at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/std/src/sys_common/backtrace.rs:123:18
  34:     0x56158728ba89 - main
  35:     0x7efddc4f1c87 - __libc_start_main
                               at /build/glibc-uZu3wS/glibc-2.27/csu/../csu/libc-start.c:310
  36:     0x56158728b28a - _start
  37:                0x0 - <unknown>

Start a build with ninja to smoke test that the build.ninja is valid enough to start building

~/Coding/rr $ ninja -C build
ninja: Entering directory `build'
ninja: warning: multiple rules generate ../src/preload/preload_interface.h. builds involving this target will not be correct; continuing anyway [-w dupbuild=warn]
ninja: warning: multiple rules generate ../src/preload/raw_syscall.S. builds involving this target will not be correct; continuing anyway [-w dupbuild=warn]
ninja: warning: multiple rules generate ../src/preload/rrcalls.h. builds involving this target will not be correct; continuing anyway [-w dupbuild=warn]
[1/2533] Building C object CMakeFiles/rr_exec_stub_32.dir/32/exec_stub.c.o
[2/2533] Building C object CMakeFiles/starvation_multithreaded.dir/src/chaos-test/starvation_multithreaded.c.o
[3/2533] Building C object CMakeFiles/brotli.dir/third-party/brotli/common/transform.c.o
[4/2533] Building C object CMakeFiles/core_count.dir/src/chaos-test/core_count.c.o
[5/2533] Building C object CMakeFiles/brotli.dir/third-party/brotli/dec/bit_reader.c.o
[6/2533] Building C object CMakeFiles/mmap_bits.dir/src/chaos-test/mmap_bits.c.o
[7/2533] Building C object CMakeFiles/starvation_singlethreaded.dir/src/chaos-test/starvation_singlethreaded.c.o
[8/2533] Linking C executable bin/rr_exec_stub_32
[9/2533] Building C object CMakeFiles/brotli.dir/third-party/brotli/dec/state.c.o
# Ctrl-C the process here

Hope this helps! Let me know if you need anything else.

Wow thanks for the extremely detailed bug report! Also rr is the coolest!

I don't have my Linux computer handy at the moment so I can't reproduce, but from the panic and trace: I think this is crashing when generating an error message, and the error message is saying that a given output file is already being built by something else. Looking at your Ninja log there's similarly a warning about possibly the same issue. Maybe there's something in the build files you could diagnose here? (I will endeavor to fix the panic as well, of course)

Possibly: one of these files like preload_interface.h is listed as an output of a single build rule multiple times.

I tried commenting enough out of CMakeLists.txt to get it to generate something on this Mac, but I could not reproduce this problem. Could you paste your build.ninja file somewhere?

This was closed by that PR but I am still interested in the answers to the above questions!

Thanks a lot for reviewing so swiftly. I installed the most recent version of n2 and it now gives a similar warning to ninja, however it still fails to build (with a new error this time).

I can create a new issue with the new error, if you want

install most recent n2 (sadly n2 doesn't have a version cli flag to print this easily)

~/Coding/rr $ n2 --version
n2: error: Unrecognized option: 'version'

in the rr directory (checked out at the same commit), clean the build dir and tell cmake to generate build.ninja again.

rm -rf build && mkdir build && cd build && cmake -G Ninja ../ && cd ..
-- The C compiler identification is GNU 7.5.0
-- The CXX compiler identification is GNU 7.5.0
-- The ASM compiler identification is GNU
-- Found assembler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Performing Test SUPPORTS_CXX14
-- Performing Test SUPPORTS_CXX14 - Success
-- Found PkgConfig: /usr/bin/pkg-config (found version "0.29.1") 
-- Checking for module 'capnp'
--   Found capnp, version 0.6.1
-- Checking for module 'zlib'
--   Found zlib, version 1.2.11
-- Found PythonInterp: /usr/bin/python3 (found suitable version "3.6.12", minimum required is "3") 
You have called ADD_LIBRARY for library rrpage without any source files. This typically indicates a problem with your CMakeLists.txt file
You have called ADD_LIBRARY for library rrpreload without any source files. This typically indicates a problem with your CMakeLists.txt file
You have called ADD_LIBRARY for library rraudit without any source files. This typically indicates a problem with your CMakeLists.txt file
You have called ADD_LIBRARY for library rrpage_32 without any source files. This typically indicates a problem with your CMakeLists.txt file
You have called ADD_LIBRARY for library rrpreload_32 without any source files. This typically indicates a problem with your CMakeLists.txt file
You have called ADD_LIBRARY for library rraudit_32 without any source files. This typically indicates a problem with your CMakeLists.txt file
-- Configuring done
-- Generating done
-- Build files have been written to: /home/petr_tik/Coding/rr/build

Fail to build with n2 but this time with warnings and a new error

~/Coding/rr $ RUST_BACKTRACE=full n2 -v -C build/
n2: warn: build.ninja:44074: "../src/preload/preload_interface.h" is repeated in output list
n2: warn: build.ninja:44074: "../src/preload/raw_syscall.S" is repeated in output list
n2: warn: build.ninja:44074: "../src/preload/rrcalls.h" is repeated in output list
thread 'main' panicked at 'expected no file state for ../src/preload/preload_interface.h', src/work.rs:575:17
stack backtrace:
   0:     0x561288ee083a - std::backtrace_rs::backtrace::libunwind::trace::h91c465e73bf6c785
                               at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/std/src/../../backtrace/src/backtrace/libunwind.rs:93:5
   1:     0x561288ee083a - std::backtrace_rs::backtrace::trace_unsynchronized::hae9da36f5d58b5f3
                               at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x561288ee083a - std::sys_common::backtrace::_print_fmt::h7f499fa126a7effb
                               at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/std/src/sys_common/backtrace.rs:67:5
   3:     0x561288ee083a - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h3e2b509ce2ce6007
                               at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/std/src/sys_common/backtrace.rs:46:22
   4:     0x561288e8101c - core::fmt::write::h753c7571fa063ecb
                               at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/core/src/fmt/mod.rs:1168:17
   5:     0x561288eb6eef - std::io::Write::write_fmt::h2815c0519c99ba09
                               at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/std/src/io/mod.rs:1660:15
   6:     0x561288ee18d2 - std::sys_common::backtrace::_print::h64941a6fc8b0ed9b
                               at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/std/src/sys_common/backtrace.rs:49:5
   7:     0x561288ee18d2 - std::sys_common::backtrace::print::hcf25e43e1a9b0766
                               at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/std/src/sys_common/backtrace.rs:36:9
   8:     0x561288ee18d2 - std::panicking::default_hook::{{closure}}::h78d3e6cf97fc623d
                               at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/std/src/panicking.rs:211:50
   9:     0x561288ee26be - std::panicking::default_hook::hda898f8d3ad1a5ae
                               at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/std/src/panicking.rs:228:9
  10:     0x561288ee26be - std::panicking::rust_panic_with_hook::h1a5ea2d6c23051aa
                               at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/std/src/panicking.rs:606:17
  11:     0x561288ee21a8 - std::panicking::begin_panic_handler::{{closure}}::h07f549390938b73f
                               at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/std/src/panicking.rs:502:13
  12:     0x561288ee2126 - std::sys_common::backtrace::__rust_end_short_backtrace::h5ec3758a92cfb00d
                               at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/std/src/sys_common/backtrace.rs:139:18
  13:     0x561288ee20e2 - rust_begin_unwind
                               at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/std/src/panicking.rs:498:5
  14:     0x561288e79380 - core::panicking::panic_fmt::h3a79a6a99affe1d5
                               at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/core/src/panicking.rs:116:14
  15:     0x561288e9b606 - n2::work::Work::check_build_files_missing::hf6446c2d294e5e8f
  16:     0x561288e9b606 - n2::work::Work::check_build_dirty::he52af68592e746be
                               at /home/petr_tik/.cargo/git/checkouts/n2-e6f499fa596a8a82/df0a27b/src/work.rs:590:28
  17:     0x561288e9b606 - n2::work::Work::run_without_cleanup::h19d1906faad45644
                               at /home/petr_tik/.cargo/git/checkouts/n2-e6f499fa596a8a82/df0a27b/src/work.rs:671:21
  18:     0x561288e953d5 - n2::work::Work::run::h249428d76b2080e1
                               at /home/petr_tik/.cargo/git/checkouts/n2-e6f499fa596a8a82/df0a27b/src/work.rs:741:22
  19:     0x561288e953d5 - n2::run::build::{{closure}}::h2daab0ddc1bd4e0c
                               at /home/petr_tik/.cargo/git/checkouts/n2-e6f499fa596a8a82/df0a27b/src/run.rs:49:47
  20:     0x561288e953d5 - n2::trace::scope::h2bf8a771a111bd3b
                               at /home/petr_tik/.cargo/git/checkouts/n2-e6f499fa596a8a82/df0a27b/src/trace.rs:116:21
  21:     0x561288e953d5 - n2::run::build::h6dc9ded841a12ecc
                               at /home/petr_tik/.cargo/git/checkouts/n2-e6f499fa596a8a82/df0a27b/src/run.rs:49:19
  22:     0x561288e91d71 - n2::run::run_impl::h0bb597f9f5680885
                               at /home/petr_tik/.cargo/git/checkouts/n2-e6f499fa596a8a82/df0a27b/src/run.rs:209:22
  23:     0x561288e7e3d0 - n2::run::run::hd21211266b0e6a0b
                               at /home/petr_tik/.cargo/git/checkouts/n2-e6f499fa596a8a82/df0a27b/src/run.rs:234:15
  24:     0x561288e7e3d0 - n2::main::h4c022cd59e4f0615
                               at /home/petr_tik/.cargo/git/checkouts/n2-e6f499fa596a8a82/df0a27b/src/main.rs:4:27
  25:     0x561288e7e6f3 - core::ops::function::FnOnce::call_once::h25e67c454c9b4a24
                               at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/core/src/ops/function.rs:227:5
  26:     0x561288e7e6f3 - std::sys_common::backtrace::__rust_begin_short_backtrace::he1b68df33ad7ec41
                               at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/std/src/sys_common/backtrace.rs:123:18
  27:     0x561288e7ead9 - main
  28:     0x7f30d8b8cc87 - __libc_start_main
                               at /build/glibc-uZu3wS/glibc-2.27/csu/../csu/libc-start.c:310
  29:     0x561288e7e2da - _start
  30:                0x0 - <unknown>

Start the build with ninja with same warnings!

~/Coding/rr $ ninja -C build/
ninja: Entering directory `build/'
ninja: warning: multiple rules generate ../src/preload/preload_interface.h. builds involving this target will not be correct; continuing anyway [-w dupbuild=warn]
ninja: warning: multiple rules generate ../src/preload/raw_syscall.S. builds involving this target will not be correct; continuing anyway [-w dupbuild=warn]
ninja: warning: multiple rules generate ../src/preload/rrcalls.h. builds involving this target will not be correct; continuing anyway [-w dupbuild=warn]
[1/2405] Linking C executable bin/shared_map_32
[2/2405] Linking C executable bin/strict_priorities_32
[3/2405] Linking C executable bin/segfault_32
ninja: build stopped: interrupted by user.

I tried commenting enough out of CMakeLists.txt to get it to generate something on this Mac, but I could not reproduce this problem. Could you paste your build.ninja file somewhere?

Is there anything I can do to minimise this and then open a PR with the failing minimal test case?

I think my test case reproduced the problem. I was more curious why CMake generated files like this.