Repository: rust
Issue: Tracking Issue for porting `run-make` tests to use Rust
Labels: A-testsuite,T-compiler,C-tracking-issue,A-run-make

We want to stop `run-make` tests from relying on `make`, and improve the `run-make` tests so that
they are more accessible to rustc contributors by allowing the tests to be written in Rust (see
#40713 for context). PR #113026 was merged to address this, and now we are able to write `run-make`
tests in Rust recipes. We would like your help to port over existing `run-make` tests still using
Makefiles to use Rust recipes instead.

If you would like to work on porting one of the `run-make` tests, please link to this issue in your
PR and leave a comment to claim the test (or multiple tests). If you are stuck, please don't hesitate to open a thread
on [Rust's Zulip](https://rust-lang.zulipchat.com/).

**`run-make` is the most flexible fallback test kind, but some `run-make` tests could be migrated to become e.g. ui tests instead. Please check if you can convert the `run-make` test into other test kinds before porting!**

When you try to port a test, also consider:

- Add some comments on *what* the test is trying to test.
- Add some comments on *how* the test tries to accomplish its goals if the test is non-trivial. This is especially true if you discovered that a test has platform/compiler/architecture/tooling-specific behavior that is a pain to debug.
- Any related issues? Any relevant links?
- Is the test still applicable? Has it become outdated? Is it duplicated?
- Can it be written in other test suites?

## Context: Rust recipes?

PR #113026 adds basic infrastructure support to write `run-make` tests using small Rust programs,
called *recipes*.

We aim to eliminate the dependency on make and Makefiles for building `run-make`-style tests. 
Makefiles are replaced by recipes (`rmake.rs`). The PR implements running `run-make` recipes in
3 steps:

1. We build the support library `run_make_support` which the `rmake.rs` recipes depend on as a tool
   lib.
2. We build the recipe `rmake.rs` and link in the support library.
3. We run the recipe to build and run the tests.

`rmake.rs` is basically a replacement for `Makefile`, and allows running arbitrary Rust code. The
support library is built using cargo, and so can depend on external crates if desired.

The infrastructure implemented by the PR is very barebones, and is the minimally required
infrastructure needed to build, run and pass the two example run-make tests ported over to the new
infrastructure:

- <https://github.com/rust-lang/rust/tree/master/tests/run-make/CURRENT_RUSTC_VERSION>
- <https://github.com/rust-lang/rust/blob/master/tests/run-make/a-b-a-linker-guard>

You likely will find that you would need to improve the API of the support library, and extend
the functionality of the support library.

## Common traps and pitfalls, and tips and tricks

- `$PATH` uses `;` on Windows and `:` for \*nixes. Use `std::env::{join,split}_paths` to properly
  handle `$PATH`.
- Be careful of path separator platform differences. Always prefer `PathBuf` operations not string
  paths if possible.
- `tests/` are not (currently) formatted by rustfmt.
- Consult <https://github.com/rust-lang/rust/blob/master/tests/run-make/tools.mk> for which flags
  and envs are passed to various executables or libraries. May have to triple check on those.
- You can always request your reviewer to [run try jobs](https://rustc-dev-guide.rust-lang.org/tests/ci.html?highlight=edit%20ci.yml#try-builds) to test out your PR on environments you don't locally have access to. Good candidate CI jobs include:

    - aarch64-apple (apple, 64 bits, aarch64/arm64)
    - armhf-gnu (cross-compile)
    - test-various (cross-compile, wasm)
    - x86_64-mingw (x86_64, 64 bits, windows, mingw)
    - x86_64-msvc (x86_64, 64 bits, windows, msvc)
    - x86_64-gnu-llvm-18 (x86_64, 64 bits, windows, gnu, llvm 18)
    - i686-msvc (x86, 32 bits, windows, msvc)

## Tests that need porting

- [x] alloc-no-oom-handling, alloc-no-rc, alloc-no-sync (https://github.com/rust-lang/rust/pull/125024)
- [x] allow-non-lint-warnings-cmdline (https://github.com/rust-lang/rust/pull/126386)
- [x] allow-warnings-cmdline-stability (https://github.com/rust-lang/rust/pull/125573)
- [x] arguments-non-c-like-enum (https://github.com/rust-lang/rust/pull/123149)
- [x] atomic-lock-free (https://github.com/rust-lang/rust/pull/127787)
- [x] branch-protection-check-IBT (https://github.com/rust-lang/rust/pull/126720, https://github.com/rust-lang/rust/pull/129156, https://github.com/rust-lang/rust/pull/134760)
- [x] c-link-to-rust-dylib (https://github.com/rust-lang/rust/pull/125808)
- [x] c-link-to-rust-staticlib (https://github.com/rust-lang/rust/pull/125027)
- [x] c-link-to-rust-va-list-fn (https://github.com/rust-lang/rust/pull/125026)
- [x] c-unwind-abi-catch-lib-panic, foreign-rust-exceptions, export-executable-symbols (https://github.com/rust-lang/rust/pull/128065)
- [x] cat-and-grep-sanity-check (https://github.com/rust-lang/rust/pull/129156, https://github.com/rust-lang/rust/pull/135824)
- [x] cdylib (https://github.com/rust-lang/rust/pull/125773)
- [x] cdylib-dylib-linkage (https://github.com/rust-lang/rust/pull/128245)
- [x] codegen-options-parsing (https://github.com/rust-lang/rust/pull/126478)
- [x] comment-section (https://github.com/rust-lang/rust/pull/126534)
- [x] compile-stdin (https://github.com/rust-lang/rust/pull/125607)
- [x] compiler-lookup-paths, dump-mono-stats, prune-link-args (https://github.com/rust-lang/rust/pull/126208)
- [x] compressed-debuginfo (https://github.com/rust-lang/rust/pull/126629)
- [x] const-prop-lint (https://github.com/rust-lang/rust/pull/125653)
- [x] const_fn_mir (https://github.com/rust-lang/rust/pull/126270)
- [x] core-no-fp-fmt-parse (https://github.com/rust-lang/rust/pull/123180)
- [x] crate-data-smoke (https://github.com/rust-lang/rust/pull/125723)
- [x] crate-hash-rustc-version (https://github.com/rust-lang/rust/pull/127693)
- [x] cross-lang-lto (https://github.com/rust-lang/rust/pull/128352)
- [x] cross-lang-lto-clang, cross-lang-lto-pgo-smoketest (https://github.com/rust-lang/rust/pull/128356)
- [x] cross-lang-lto-upstream-rlibs, long-linker-command-lines, long-linker-command-lines-cmd-exe (https://github.com/rust-lang/rust/pull/128196)
- [x] dep-graph (https://github.com/rust-lang/rust/pull/126517)
- [x] dep-info, dep-info-spaces, dep-info-doesnt-run-much (https://github.com/rust-lang/rust/pull/128787)
- [x] doctests-keep-binaries (https://github.com/rust-lang/rust/pull/124658)
- [x] doctests-runtool (https://github.com/rust-lang/rust/pull/124711)
- [x] dump-ice-to-disk, panic-abort-eh_frame (https://github.com/rust-lang/rust/pull/127523)
- [x] duplicate-output-flavors (https://github.com/rust-lang/rust/pull/126542)
- [x] dylib-chain, rlib-chain, issue-47384, msvc-opt-minsize, test-harness (https://github.com/rust-lang/rust/pull/127044)
- [x] emit-named-files (https://github.com/rust-lang/rust/pull/125849)
- [x] emit-path-unhashed, emit-shared-files (https://github.com/rust-lang/rust/pull/127335)
- [x] emit-to-stdout (https://github.com/rust-lang/rust/pull/128460, https://github.com/rust-lang/rust/pull/131355)
- [x] error-found-staticlib-instead-crate, output-filename-conflicts-with-directory, output-filename-overwrites-input, native-link-modifier-verbatim-rustc, native-link-modifier-verbatim-linker (https://github.com/rust-lang/rust/pull/126500)
- [x] exit-code (https://github.com/rust-lang/rust/pull/121884)
- [x] extern-diff-internal-name, extern-multiple-copies, extern-multiple-copies2 (https://github.com/rust-lang/rust/pull/128102)
- [x] extern-flag-disambiguates (https://github.com/rust-lang/rust/pull/128099)
- [x] extern-flag-fun, incremental-debugger-visualizer, incremental-session-fail (https://github.com/rust-lang/rust/pull/126490)
- [x] extern-flag-pathless, silly-file-names, metadata-dep-info, cdylib-fewer-symbols, symbols-include-type-name (https://github.com/rust-lang/rust/pull/127006)
- [x] extern-fn-reachable (https://github.com/rust-lang/rust/pull/128314, https://github.com/rust-lang/rust/pull/135458)
- [x] extra-filename-with-temp-outputs, issue-85019-moved-src-dir (https://github.com/rust-lang/rust/pull/127338)
- [x] fmt-write-bloat (https://github.com/rust-lang/rust/pull/128147)
- [x] foreign-double-unwind, issue-36710, foreign-exceptions (https://github.com/rust-lang/rust/pull/127926
- [x] git_clone_sha1.sh (https://github.com/rust-lang/rust/pull/129013)
- [x] glibc-staticlib-args (https://github.com/rust-lang/rust/pull/126684)
- [x] hir-tree (https://github.com/rust-lang/rust/pull/122448)
- [x] inaccessible-temp-dir, output-with-hyphens, issue-10971-temps-dir (https://github.com/rust-lang/rust/pull/126279)
- [x] incr-add-rust-src-component (https://github.com/rust-lang/rust/pull/128562, https://github.com/rust-lang/rust/pull/134656)
- [x] issue-84395-lto-embed-bitcode (https://github.com/rust-lang/rust/pull/131917)
- [x] inline-always-many-cgu (https://github.com/rust-lang/rust/pull/126823)
- [x] interdependent-c-libraries, compiler-rt-works-on-mingw, incr-foreign-head-span (https://github.com/rust-lang/rust/pull/127989)
- [x] intrinsic-unreachable, sepcomp-cci-copies, sepcomp-inlining, sepcomp-separate (https://github.com/rust-lang/rust/pull/126427)
- [x] invalid-library (https://github.com/rust-lang/rust/pull/126861)
- [x] issue-7349 (https://github.com/rust-lang/rust/pull/123474)
- [x] issue-11908 (https://github.com/rust-lang/rust/pull/125031)
- [x] issue-14500 (https://github.com/rust-lang/rust/pull/125047)
- [x] issue-14698, issue-33329, issue-107094 (https://github.com/rust-lang/rust/pull/127820)
- [x] issue-15460 (https://github.com/rust-lang/rust/pull/125886)
- [x] issue-22131, issue-26006 (https://github.com/rust-lang/rust/pull/127621)
- [x] issue-25581, extern-fn-with-extern-types, extern-fn-struct-passing-abi, longjmp-across-rust, static-extern-type, extern-fn-explicit-align, extern-fn-with-packed-struct, extern-fn-mangle (https://github.com/rust-lang/rust/pull/127491)
- [x] issue-28766 (https://github.com/rust-lang/rust/pull/125221)
- [x] issue-30063 (https://github.com/rust-lang/rust/pull/125227)
- [x] issue-37839, track-path-dep-info, track-pgo-dep-info (https://github.com/rust-lang/rust/pull/127378)
- [x] issue-46239 (https://github.com/rust-lang/rust/pull/125222)
- [x] issue-47551, issue-35164, issue-69368 (https://github.com/rust-lang/rust/pull/127624)
- [x] issue-51671 (https://github.com/rust-lang/rust/pull/125787)
- [x] issue-53964 (https://github.com/rust-lang/rust/pull/125224)
- [x] issue-64153, invalid-staticlib, no-builtins-lto (https://github.com/rust-lang/rust/pull/126437)
- [x] issue-83045, rustc-macro-dep-files, env-dep-info (https://github.com/rust-lang/rust/pull/127381)
- [x] issue-83112-incr-test-moved-file, type-mismatch-same-crate-name, issue-109934-lto-debuginfo (https://github.com/rust-lang/rust/pull/127538)
- [x] issue-85401-static-mir, missing-crate-dependency, unstable-flag-required (https://github.com/rust-lang/rust/pull/127822)
- [x] issue64319 (https://github.com/rust-lang/rust/pull/125215)
- [x] jobserver-error (https://github.com/rust-lang/rust/pull/128789, https://github.com/rust-lang/rust/pull/135461)
- [x] libs-through-symlinks (https://github.com/rust-lang/rust/pull/129011, https://github.com/rust-lang/rust/pull/134829)
- [ ] translation (https://github.com/rust-lang/rust/pull/129011, https://github.com/rust-lang/rust/pull/135818)
- [x] libtest-json, libtest-junit (https://github.com/rust-lang/rust/pull/126773, https://github.com/rust-lang/rust/pull/129037)
- [x] link-args-order, ls-metadata, lto-readonly-lib (https://github.com/rust-lang/rust/pull/126095)
- [x] link-cfg, issue-88756-default-output (https://github.com/rust-lang/rust/pull/128361)
- [x] link-framework (https://github.com/rust-lang/rust/pull/126898)
- [x] llvm-ident (https://github.com/rust-lang/rust/pull/126941)
- [x] llvm-outputs (https://github.com/rust-lang/rust/pull/126211)
- [x] lto-empty, invalid-so, issue-20626 (https://github.com/rust-lang/rust/pull/126964)
- [x] lto-linkage-used-attr, no-duplicate-libs, pgo-gen-no-imp-symbols (https://github.com/rust-lang/rust/pull/127990)
- [x] lto-smoke-c, link-path-order (https://github.com/rust-lang/rust/pull/127928)
- [x] macos-deployment-target, libtest-thread-limit (https://github.com/rust-lang/rust/pull/128507)
- [x] macos-fat-archive, manual-link, archive-duplicate-names (https://github.com/rust-lang/rust/pull/127825)
- [x] manual-crate-name (https://github.com/rust-lang/rust/pull/126064)
- [x] min-global-align, no-alloc-shim (https://github.com/rust-lang/rust/pull/128407)
- [x] multiple-emits (https://github.com/rust-lang/rust/pull/126186)
- [x] no-cdylib-as-rdylib (https://github.com/rust-lang/rust/pull/125104)
- [x] no-input-file (https://github.com/rust-lang/rust/pull/124257)
- [x] no-intermediate-extras (https://github.com/rust-lang/rust/pull/125218)
- [x] output-type-permutations (https://github.com/rust-lang/rust/pull/127098)
- [x] override-aliased-flags (https://github.com/rust-lang/rust/pull/127041)
- [x] panic-impl-transitive (https://github.com/rust-lang/rust/pull/125146)
- [x] pass-linker-flags, pass-linker-flags-flavor, pass-linker-flags-from-dep (https://github.com/rust-lang/rust/pull/127328)
- [x] pdb-buildinfo-cl-cmd, pgo-indirect-call-promotion (https://github.com/rust-lang/rust/pull/128363)
- [x] pdb-alt-path, mismatching-target-triples, mingw-export-call-convention (https://github.com/rust-lang/rust/pull/126805)
- [x] pgo-branch-weights (https://github.com/rust-lang/rust/pull/125165)
- [x] pgo-gen, pgo-use, profile (https://github.com/rust-lang/rust/pull/126957)
- [x] pgo-gen-lto (https://github.com/rust-lang/rust/pull/128757)
- [x] pointer-auth-link-with-c, c-dynamic-rlib, c-dynamic-dylib (https://github.com/rust-lang/rust/pull/127872)
- [x] prefer-dylib (https://github.com/rust-lang/rust/pull/126174)
- [x] prefer-rlib (https://github.com/rust-lang/rust/pull/126310)
- [x] pretty-print-to-file, pretty-print-with-dep-file, libtest-padding (https://github.com/rust-lang/rust/pull/126995)
- [x] print-calling-conventions, print-target-list (https://github.com/rust-lang/rust/pull/127877)
- [x] print-cfg (https://github.com/rust-lang/rust/pull/124473)
- [x] print-native-static-libs (https://github.com/rust-lang/rust/pull/124383)
- [x] raw-dylib-alt-calling-convention, raw-dylib-c, redundant-libs (https://github.com/rust-lang/rust/pull/128107)
- [x] raw-dylib-inline-cross-dylib, raw-dylib-custom-dlltool (https://github.com/rust-lang/rust/pull/127390)
- [x] remap-path-prefix, debug-assertions, emit-stack-sizes (https://github.com/rust-lang/rust/pull/126801)
- [x] remap-path-prefix-dwarf (https://github.com/rust-lang/rust/pull/128410)
- [x] repr128-dwarf (https://github.com/rust-lang/rust/pull/124280)
- [x] reproducible-build (https://github.com/rust-lang/rust/pull/128456)
- [x] reproducible-build-2, stable-symbol-names (https://github.com/rust-lang/rust/pull/127095)
- [x] return-non-c-like-enum (https://github.com/rust-lang/rust/pull/127116)
- [x] return-non-c-like-enum-from-c, pass-non-c-like-enum-to-c, c-static-dylib, c-static-rlib, extern-fn-generic, extern-fn-with-union, lto-no-link-whole-rlib, linkage-attr-on-static, issue-28595 (https://github.com/rust-lang/rust/pull/127663)
- [x] rlib-format-packed-bundled-libs, native-link-modifier-bundle (https://github.com/rust-lang/rust/pull/129018)
- [x] rlib-format-packed-bundled-libs-2, native-link-modifier-whole-archive, no-builtins-attribute (https://github.com/rust-lang/rust/pull/128075)
- [x] rust-lld, rust-lld-custom-target (https://github.com/rust-lang/rust/pull/123975)
- [x] rustdoc-determinism (https://github.com/rust-lang/rust/pull/124698)
- [x] rustdoc-error-lines (https://github.com/rust-lang/rust/pull/124753)
- [x] rustdoc-io-error (https://github.com/rust-lang/rust/pull/124807)
- [x] rustdoc-map-file (https://github.com/rust-lang/rust/pull/124837)
- [x] rustdoc-output-path (https://github.com/rust-lang/rust/pull/124888)
- [x] rustdoc-scrape-examples-invalid-expr (https://github.com/rust-lang/rust/pull/125248)
- [x] rustdoc-scrape-examples-macros (https://github.com/rust-lang/rust/pull/125401)
- [x] rustdoc-scrape-examples-multiple (https://github.com/rust-lang/rust/pull/125357)
- [x] rustdoc-scrape-examples-ordering (https://github.com/rust-lang/rust/pull/125022)
- [x] rustdoc-scrape-examples-remap (https://github.com/rust-lang/rust/pull/125207)
- [x] rustdoc-scrape-examples-test (https://github.com/rust-lang/rust/pull/125275)
- [x] rustdoc-scrape-examples-whitespace (https://github.com/rust-lang/rust/pull/125318)
- [x] rustdoc-shared-flags (https://github.com/rust-lang/rust/pull/124963)
- [x] rustdoc-target-spec-json-path (https://github.com/rust-lang/rust/pull/125071)
- [x] rustdoc-themes (https://github.com/rust-lang/rust/pull/125142)
- [x] rustdoc-verify-output-files (https://github.com/rust-lang/rust/pull/125542)
- [x] rustdoc-with-out-dir-option (https://github.com/rust-lang/rust/pull/125178)
- [x] rustdoc-with-output-option (https://github.com/rust-lang/rust/pull/125485)
- [x] rustdoc-with-short-out-dir-option (https://github.com/rust-lang/rust/pull/125445)
- [x] share-generics-dylib, raw-dylib-import-name-type, raw-dylib-link-ordinal, raw-dylib-stdcall-ordinal (https://github.com/rust-lang/rust/pull/128112)
- [x] short-ice (https://github.com/rust-lang/rust/pull/126036)
- [x] simd-ffi (https://github.com/rust-lang/rust/pull/128700)
- [ ] split-debuginfo (https://github.com/rust-lang/rust/pull/128754, https://github.com/rust-lang/rust/pull/135572)
- [x] static-dylib-by-default, sanitizer-dylib-link, sanitizer-cdylib-link, sanitizer-staticlib-link (https://github.com/rust-lang/rust/pull/128079)
- [x] static-unwinding (https://github.com/rust-lang/rust/pull/125213)
- [x] staticlib-blank-lib, rlib-format-packed-bundled-libs-3, issue-97463-abi-param-passing (https://github.com/rust-lang/rust/pull/127778)
- [x] staticlib-dylib-linkage (https://github.com/rust-lang/rust/pull/128696)
- [x] std-core-cycle, obey-crate-type-flag, mixing-libs, issue-18943 (https://github.com/rust-lang/rust/pull/126484)
- [x] stdin-non-utf8 (https://github.com/rust-lang/rust/pull/124612)
- [ ] symbol-mangling-hashed (https://github.com/rust-lang/rust/pull/128567, https://github.com/rust-lang/rust/pull/135768)
- [x] symbol-visibility (https://github.com/rust-lang/rust/pull/127060)
- [x] sysroot-crates-are-unstable (https://github.com/rust-lang/rust/pull/126231, https://github.com/rust-lang/rust/pull/129071)
- [x] target-cpu-native, target-specs, target-without-atomic-cas (https://github.com/rust-lang/rust/pull/127325)
- [x] test-benches, c-unwind-abi-catch-panic, compiler-lookup-paths-2 (https://github.com/rust-lang/rust/pull/127985)
- [x] thumb-none-cortex-m (https://github.com/rust-lang/rust/pull/128636)
- [x] thumb-none-qemu (https://github.com/rust-lang/rust/pull/128639)
- [ ] ~~tools.mk~~ (should be removed)
- [x] use-suggestions-rust-2018, overwrite-input, lto-dylib-dep, many-crates-but-no-match (https://github.com/rust-lang/rust/pull/127000)
- [x] used (https://github.com/rust-lang/rust/pull/125988)
- [x] valid-print-requests (https://github.com/rust-lang/rust/pull/124333)
- [x] version (https://github.com/rust-lang/rust/pull/123563)
- [x] volatile-intrinsics, weird-output-filenames, wasm-override-linker, wasm-exceptions-nostd (https://github.com/rust-lang/rust/pull/126880)
- [x] wasm-abi, wasm-custom-section, wasm-custom-sections-opt, wasm-export-all-symbols, wasm-import-module, wasm-panic-small, wasm-spurious-import, wasm-stringify-ints-small, wasm-symbols-different-module, wasm-symbols-not-exported, wasm-symbols-not-imported (https://github.com/rust-lang/rust/pull/122036)
- [x] x86_64-fortanix-unknown-sgx-lvi (https://github.com/rust-lang/rust/pull/129055)
- [x] emit, mixing-formats, bare-outfile (https://github.com/rust-lang/rust/pull/125383)
- [x] core-no-oom-handling, issue-24445, issue-38237 (https://github.com/rust-lang/rust/pull/125421)
- [x] issue-85441, windows-binary-no-external-deps, windows-safeseh, windows-spawn, windows-subsystem (https://github.com/rust-lang/rust/pull/125613)
- [x] lto-smoke, simple-rlib, mixing-deps (https://github.com/rust-lang/rust/pull/125638)
- [x] fpic, simple-dylib, issue-37893 (https://github.com/rust-lang/rust/pull/125662)
- [x] suspicious-library, resolve-rename, incr-prev-body-beyond-eof (https://github.com/rust-lang/rust/pull/125683)
- [x] link-arg, link-dedup, issue-26092 (https://github.com/rust-lang/rust/pull/125500)
- [x] symlinked-extern, symlinked-rlib, symlinked-libraries (https://github.com/rust-lang/rust/pull/125674)
- [x] separate-link, separate-link-fail and allocator-shim-circular-deps (https://github.com/rust-lang/rust/pull/126607)
- [x] extern-flag-rename-transitive, debugger-visualizer-dep-info, metadata-flag-frobs-symbols, extern-overrides-distribution, forced-unwind-terminate-pof (https://github.com/rust-lang/rust/pull/126644)
- [x] unknown-mod-stdin, issue-68794-textrel-on-minimal-lib, raw-dylib-cross-compilation, used-cdylib-macos (https://github.com/rust-lang/rust/pull/126698)
- [x] include_bytes_deps, optimization-remarks-dir-pgo, optimization-remarks-dir, issue-40535, rmeta-preferred (https://github.com/rust-lang/rust/pull/126709)
- [x] relocation-model, error-writing-dependencies, crate-name-priority (https://github.com/rust-lang/rust/pull/126712)
- [x] relro-levels, static-pie (https://github.com/rust-lang/rust/pull/126715)