Skip to content

Allow running the mold test suite#903

Merged
davidlattimore merged 8 commits intowild-linker:mainfrom
lapla-cogito:external_suites
Jun 26, 2025
Merged

Allow running the mold test suite#903
davidlattimore merged 8 commits intowild-linker:mainfrom
lapla-cogito:external_suites

Conversation

@lapla-cogito
Copy link
Copy Markdown
Member

@lapla-cogito lapla-cogito commented Jun 19, 2025

The goal is to make running the mold test suite in wild mode easier, thereby facilitating the discovery of potential bugs and missing implementations. This can be achieved by executing tests with the mold_tests feature enabled (i.e., cargo test --features mold_tests). Future PRs will automatically classify which outputs should be properly ignored, such as error messages.

As some preliminary statistics, the following tests currently pass as is (on my x86-64 machine):

click to expand
test/arch-aarch64-variant-pcs.sh
test/arch-arm-thumb-interwork.sh
test/arch-arm-tlsdesc.sh
test/arch-arm-range-extension-thunk.sh
test/arch-riscv64-variant-cc.sh
test/arch-x86_64-apx-gottpoff2.sh
test/arch-x86_64-apx-gotpcrelx.sh
test/arch-x86_64-apx-gottpoff.sh
test/arch-x86_64-emulation-deduction.sh
test/abs-error.sh
test/absolute-symbols.sh
test/arch-riscv64-attributes2.sh
test/arch-riscv64-relax-align.sh
test/ar-alignment.sh
test/arch-x86_64-incompatible-libs2.sh
test/arch-x86_64-incompatible-libs-linker-script.sh
test/arch-x86_64-incompatible-obj.sh
test/arch-x86_64-apx-tlsdesc.sh
test/arch-x86_64-incompatible-libs.sh
test/arch-x86_64-incompatible-libs-linker-script2.sh
test/arch-x86_64-init-array.sh
test/arch-x86_64-reloc-zero.sh
test/arch-x86_64-section-alignment.sh
test/arch-x86_64-preinit-array.sh
test/arch-x86_64-note-property.sh
test/arch-x86_64-gnu-retain.sh
test/arch-x86_64-ifunc-alias.sh
test/arch-x86_64-tls-ld-mcmodel-large.sh
test/arch-x86_64-z-rewrite-endbr3.sh
test/arch-x86_64-function-multiversion.sh
test/arch-x86_64-z-ibtplt.sh
test/arch-x86_64-mergeable-records.sh
test/arch-x86_64-exception-mcmodel-large.sh
test/compress-debug-sections-zstd.sh
test/as-needed-dso.sh
test/crel.sh
test/arch-x86_64-tls-gd-mcmodel-large.sh
test/as-needed-dso2.sh
test/bsymbolic-non-weak-functions.sh
test/as-needed.sh
test/bsymbolic-non-weak.sh
test/bsymbolic-functions.sh
test/bsymbolic.sh
test/compressed-debug-info.sh
test/dead-debug-sections.sh
test/arch-x86_64-tls-module-base.sh
test/dt-init.sh
test/defsym-lto.sh
test/debug-macro-section.sh
test/demangle-rust.sh
test/dependency-file-lto.sh
test/duplicate-error-lto.sh
test/dynamic.sh
test/empty-version.sh
test/empty-file.sh
test/arch-x86_64-tls-gd-to-ie.sh
test/dynamic-dt-debug.sh
test/export-dynamic.sh
test/gdb-index-empty.sh
test/gnu-hash.sh
test/gnu-warning.sh
test/export-from-exe.sh
test/gnu-unique.sh
test/func-addr.sh
test/gnu-retain.sh
test/icf-small.sh
test/execstack.sh
test/hello-dynamic.sh
test/hidden-weak-undef.sh
test/ifunc-export.sh
test/hidden-archive.sh
test/dt-needed.sh
test/icf-safe.sh
test/ifunc-dlopen.sh
test/ifunc-dso.sh
test/ifunc-dynamic.sh
test/ifunc-noplt.sh
test/large-max-page-size-strip.sh
test/ifunc-funcptr.sh
test/large-max-page-size.sh
test/large-text.sh
test/hello-static.sh
test/lto-comdat.sh
test/lto-llvm.sh
test/lto-archive.sh
test/lto-llvm2.sh
test/lto-no-plugin.sh
test/lto-archive2.sh
test/lto-archive3.sh
test/linker-script2.sh
test/lto-gcc.sh
test/linker-script3.sh
test/linker-script5.sh
test/lto-dso.sh
test/linker-script6.sh
test/missing-but-ok.sh
test/lto-nostdlib.sh
test/lto-version-script.sh
test/issue646.sh
test/no-object-file.sh
test/ifunc-static-pie.sh
test/ifunc-static.sh
test/nostdlib.sh
test/link-order.sh
test/pie.sh
test/non-canonical-plt.sh
test/reloc-rodata.sh
test/main-in-dso.sh
test/preinit-array.sh
test/plt-dso.sh
test/mcmodel-large.sh
test/protected-dynsym.sh
test/pltgot.sh
test/protected.sh
test/range-extension-thunk2.sh
test/push-pop-state.sh
test/relocatable-compressed-debug-info.sh
test/range-extension-thunk4.sh
test/relax-got-load.sh
test/response-file2.sh
test/response-file.sh
test/relro.sh
test/soname.sh
test/symbol-version-lto.sh
test/strip-debug.sh
test/many-input-sections.sh
test/shared.sh
test/shared-abs-sym.sh
test/symbol-rank.sh
test/start-stop-symbol.sh
test/symbol-version3.sh
test/tbss-only.sh
test/sysroot-linker-script.sh
test/tail-call.sh
test/textrel.sh
test/sysroot2.sh
test/tls-dso.sh
test/tls-alignment-multi.sh
test/tls-large-static-image.sh
test/tls-df-static-tls.sh
test/symbol-version4.sh
test/tls-pic.sh
test/exception.sh
test/tls-nopic.sh
test/tls-ld.sh
test/tls-ld-noplt.sh
test/tls-gd-dlopen.sh
test/thread-count.sh
test/static-pie.sh
test/tls-le.sh
test/tls-large-alignment.sh
test/tls-ie.sh
test/sysroot.sh
test/tls-small-alignment.sh
test/tlsdesc-import.sh
test/tls-gd-noplt.sh
test/version-script.sh
test/tlsdesc-dlopen.sh
test/tlsdesc-local-dynamic.sh
test/version-script21.sh
test/version-script7.sh
test/tlsdesc-initial-exec.sh
test/version-script9.sh
test/visibility.sh
test/tls-gd-to-ie.sh
test/wrap-lto.sh
test/weak-export-dso.sh
test/weak-export-dso2.sh
test/range-extension-thunk3.sh
test/z-now.sh
test/z-dynamic-undefined-weak2.sh
test/z-origin.sh
test/tlsdesc-static.sh
test/weak-undef4.sh
test/tlsdesc.sh
test/weak-undef-dso.sh
test/tls-gd.sh
test/z-separate-code.sh

All output of cargo test --features mold_tests has been consolidated into this.

@lapla-cogito
Copy link
Copy Markdown
Member Author

Since the architecture being tested should be injectable via environment variables from outside, expanding this support to all architectures currently supported by wild should be achievable when running these tests via GitHub Actions.

@davidlattimore
Copy link
Copy Markdown
Member

Thanks for working on this PR! Don't worry about those two test failures on ubuntu:25.10, they're not related to your change and have been happening all day. We might need to disable 25.10 if they continue.

My first question is how does this use wild as the linker when running the tests?

@lapla-cogito lapla-cogito force-pushed the external_suites branch 3 times, most recently from 8aac347 to a187694 Compare June 19, 2025 09:21
@lapla-cogito
Copy link
Copy Markdown
Member Author

lapla-cogito commented Jun 19, 2025

@davidlattimore Sorry, I simply forgot to add the PATH modification 😅 and have now corrected it (I've also updated the list of passed tests and the output of cargo test).

Comment thread wild/tests/integration_tests.rs Outdated
Comment thread wild/tests/integration_tests.rs Outdated
Comment thread wild/tests/integration_tests.rs Outdated
Comment thread wild/tests/integration_tests.rs Outdated
Comment thread wild/tests/integration_tests.rs Outdated
Comment thread wild/tests/integration_tests.rs Outdated
@lapla-cogito lapla-cogito force-pushed the external_suites branch 3 times, most recently from fe716fd to 8da0878 Compare June 19, 2025 13:08
@marxin
Copy link
Copy Markdown
Collaborator

marxin commented Jun 19, 2025

Have a couple of general comments:

  1. I would really like direct integration of the individual tests from the Mold's test suite using the following compile-time glob listing: https://docs.rs/rstest/0.25.0/rstest/attr.rstest.html#files-path-as-input-arguments.
  2. Having that, the test harness will run the tests in parallel, as we won't have to implement our own parallelism.
  3. It would also be great to list all the known failing Mold tests and have XFAIL (fail the test if the test is actually passing).
  4. As a follow-up, I know Mold's test suite supports running cross-arch tests using QEMU; it would be nice to support it.
  5. Filtering of tests/arch-* should depend on the host system.
  6. To prevent the Mold test-suite output, I would consider suppressing set -x, which is set by common.inc.

@marxin
Copy link
Copy Markdown
Collaborator

marxin commented Jun 19, 2025

One potential integration opportunity would be adding Mold as a submodule of the project.
@davidlattimore: What do you think about it?

@davidlattimore
Copy link
Copy Markdown
Member

One potential integration opportunity would be adding Mold as a submodule of the project.
@davidlattimore: What do you think about it?

I guess that should be OK. Perhaps in a subdirectory. e.g. external_test_suites/mold

@lapla-cogito
Copy link
Copy Markdown
Member Author

One potential integration opportunity would be adding Mold as a submodule of the project.
@davidlattimore: What do you think about it?

I guess that should be OK. Perhaps in a subdirectory. e.g. external_test_suites/mold

I'm generally reluctant to use external test suites as submodules:

  1. Submodules require the entire repository. Since we only need the test suite itself, this is excessively redundant.
  2. If there are updates to the external test suite and we want to incorporate those changes, we'd need to explicitly update the submodule (this is just one example - we could maintain the mold test suite itself as a GitHub Actions cache and periodically update the cache at fixed intervals like weekly via cron jobs, allowing CI to automatically obtain the latest results without manual intervention).

@marxin
Copy link
Copy Markdown
Collaborator

marxin commented Jun 20, 2025

  • Submodules require the entire repository. Since we only need the test suite itself, this is excessively redundant.

Well, yes, but we're speaking about a rather small git repository.

  • If there are updates to the external test suite and we want to incorporate those changes, we'd need to explicitly update the submodule (this is just one example - we could maintain the mold test suite itself as a GitHub Actions cache and periodically update the cache at fixed intervals like weekly via cron jobs, allowing CI to automatically obtain the latest results without manual intervention).

That's, from my perspective, a desired feature. Every time we pull Mold's changes, one needs to triage new tests and mark them as passing or failing. Otherwise, everyone from Wild's developers will stick to a different revision of Mold, and then we'll see test suite pass rate inconsistency.

Plus, having the test suite at a fixed location will simplify any current code that deals with the proper finding of the tests.

@mati865
Copy link
Copy Markdown
Member

mati865 commented Jun 20, 2025

You also do not always have to initialize the submodules. This is how the Rust compiler repository works. It has some necessary submodules, like docs, but you can skip others depending on your build configuration.

@davidlattimore
Copy link
Copy Markdown
Member

That's, from my perspective, a desired feature. Every time we pull Mold's changes, one needs to triage new tests and mark them as passing or failing. Otherwise, everyone from Wild's developers will stick to a different revision of Mold, and then we'll see test suite pass rate inconsistency.

I think this argument is a pretty compelling reason to want either a submodule, or some other mechanism that involves having the commit hash of mold to use checked into our repo.

  1. I would really like direct integration of the individual tests from the Mold's test suite using the following compile-time glob listing: https://docs.rs/rstest/0.25.0/rstest/attr.rstest.html#files-path-as-input-arguments.

This would definitely be very nice and from the look of things, I think shouldn't be too hard.

It's also fine to leave changes until later PRs if you prefer - just let us know which things you'd like to leave for later.

@lapla-cogito lapla-cogito force-pushed the external_suites branch 2 times, most recently from 9c5c412 to ece6606 Compare June 24, 2025 13:55
@lapla-cogito lapla-cogito force-pushed the external_suites branch 5 times, most recently from f1d0075 to 5d1e723 Compare June 24, 2025 14:23
@RossSmyth
Copy link
Copy Markdown
Contributor

RossSmyth commented Jun 24, 2025

Submodules and nix flakes interact extremely poorly for very silly reasons. I have no clue how to get them to work together after messing with it for a few minutes and googling around. If it is holding you up, you can comment out these lines and it should work
https://github.com/davidlattimore/wild/blob/c2e0af40fd040a556d9ebf27e93d7f1ed4893f8e/flake.nix#L49-L57

@davidlattimore
Copy link
Copy Markdown
Member

It looks as though rstest is giving an error at build time if the file pattern doesn't exist. That's unfortunate. The only solution I can think of at the moment would be to put that test behind a cfg. e.g. #[cfg(feature = "mold-tests")]

@davidlattimore
Copy link
Copy Markdown
Member

Or, if we wanted it to be driven by test-config.toml then we could have a build.rs that parses test-config.toml and if the mold tests are enabled (which could be a boolean in the config) prints cargo::rustc-cfg=mold_tests. It'd also need to print cargo::rustc-check-cfg=mold-tests regardless of whether they're enabled. It should also print cargo::rerun-if-changed=test-confiig.toml. Then in the code, you can use #[cfg(mold-tests)].

@marxin
Copy link
Copy Markdown
Collaborator

marxin commented Jun 25, 2025

I'm curious if we could simply remove the build.rs file (and the integration into config.toml) and manually drive the testing of Mold's test suite using a cfg feature? Doing that, we'll end up with a much smaller change?

Comment thread wild/tests/integration_tests.rs
Comment thread wild/tests/integration_tests.rs
@lapla-cogito lapla-cogito force-pushed the external_suites branch 2 times, most recently from 073685d to ee42093 Compare June 25, 2025 07:02
@lapla-cogito
Copy link
Copy Markdown
Member Author

I'm curious if we could simply remove the build.rs file (and the integration into config.toml) and manually drive the testing of Mold's test suite using a cfg feature? Doing that, we'll end up with a much smaller change?

I was exactly struggling with the best way to centrally manage ExternalTestSuites when your suggestion about using feature flags seemed particularly promising. Thanks!

@davidlattimore
Copy link
Copy Markdown
Member

I'm curious if we could simply remove the build.rs file (and the integration into config.toml) and manually drive the testing of Mold's test suite using a cfg feature? Doing that, we'll end up with a much smaller change?

I was exactly struggling with the best way to centrally manage ExternalTestSuites when your suggestion about using feature flags seemed particularly promising. Thanks!

I guess that means that we don't need anything in test-config.toml - whether we look for and run mold's test suite is controlled entire by --features mold-tests or something like that. That is nice and simple :) It also has the advantage that we can choose from run to run whether we want to run those tests.

@lapla-cogito lapla-cogito force-pushed the external_suites branch 2 times, most recently from 0850fb5 to 36c6133 Compare June 25, 2025 07:17
Comment thread fakes/mold Outdated
Comment thread wild/Cargo.toml Outdated
Comment thread wild/tests/integration_tests.rs
Comment thread wild/tests/integration_tests.rs
Comment thread .github/workflows/ci.yml
Comment thread wild/tests/integration_tests.rs Outdated
Comment thread wild/tests/integration_tests.rs
Comment thread wild/tests/integration_tests.rs
@davidlattimore davidlattimore merged commit a0fe3b6 into wild-linker:main Jun 26, 2025
20 checks passed
@lapla-cogito lapla-cogito deleted the external_suites branch June 26, 2025 22:18
AadiWaghray pushed a commit to AadiWaghray/wild that referenced this pull request Aug 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants