Skip to content

Add cross-platform testing utils #105

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

alexfmpe
Copy link

@alexfmpe alexfmpe commented Jul 8, 2025

cc @amesgen @Bodigrim @dmjio @maralorn @TerrorJack @ymeister

Problem

There've been several issues/PRs to splitmix attempting fixes for a platform that are generally hard to test on the maintainer side, and sometimes also end up breaking another platform in the process.

It seems to me there are two main sources of burden to maintainers when it comes to cross-platform support:

  1. detecting failures
  2. fixing failures

One suggested approach was to have a fork per platform, but if we want to minimize the aggregated ecosystem effort, it's better to handle things in one place, instead of having multiple downstreams project re-discover the forks and add them as patches for each platform they need.

Solution

With this PR I add a few helpers using the nixpkgs cross infrastructure to target several platforms (when compatible with the build platform).
If desired, these can be added to CI (potentially blocking merges and/or releases).

This would simplify the 'detecting' bit at the cost of a new bit of burden on maintaining the .nix.
I can commit to that maintenance and I believe several others would agree to commit as well since that sort of work has been happening already, just scattered across repos. There's certainly been override/patch/source-repository-package juggling happening on nixpkgs/miso/reflex-dom/etc for a while, and this approach already seems like less work to me.

As for 'fixing', it should becomes less of a concern if we break things less.

So far I've only described building, and nothing about detecting/fixing runtime failures, which is the case for #75.
Currently, this PR only runs wasm tests, but the idea is to gradually expand coverage.

Usage

$ uname -o -m
x86_64 GNU/Linux

$ make native 
nix-build -A native.splitmix
/nix/store/scnx4r5zddkwif3kz8vv5ni0in5xlpcw-splitmix-0.1.1

$ make freebsd
nix-build -A freebsd.splitmix
/nix/store/3rg9mp6qfbbvhgxvbir8388hxdn4rgfh-splitmix-x86_64-unknown-freebsd-0.1.1

$ make android
nix-build -A android.splitmix
/nix/store/a3v5j3lkx4viha00yr5sv8idgziwdshp-splitmix-static-aarch64-unknown-linux-musl-0.1.1

$ make js
nix-build -A js.splitmix
/nix/store/k8pfz2s8gbrqs1g7wv8na3qyqkj2gw3s-splitmix-0.1.1

$ make wasm
nix shell \
  'gitlab:haskell-wasm/ghc-wasm-meta/7927129e42bcd6a54b9e06e26455803fa4878261?host=gitlab.haskell.org' \
  --command sh -c "wasm32-wasi-cabal update && wasm32-wasi-cabal test all --ghc-options='-single-threaded' --test-wrapper=wasmtime"
(...)
Test suite examples: PASS
Test suite initialization: PASS
Test suite splitmix-dieharder: PASS
Test suite splitmix-th-test: PASS
Test suite splitmix-tests: PASS
Test suite montecarlo-pi-32: PASS
Test suite montecarlo-pi: PASS

Comment on lines +38 to +39
native:
nix-build -A native.splitmix
Copy link
Author

@alexfmpe alexfmpe Jul 8, 2025

Choose a reason for hiding this comment

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

This one is not needed I think, given the normal cabal flow, mostly added out of completeness

js:
nix-build -A js.splitmix

wasm:
Copy link
Author

@alexfmpe alexfmpe Jul 8, 2025

Choose a reason for hiding this comment

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

Not in nixpkgs yet, so we're using ghc-wasm-meta for now.

wasm:
nix shell \
'gitlab:haskell-wasm/ghc-wasm-meta/7927129e42bcd6a54b9e06e26455803fa4878261?host=gitlab.haskell.org' \
--command sh -c "wasm32-wasi-cabal update && wasm32-wasi-cabal test all --ghc-options='-single-threaded' --test-wrapper=wasmtime"
Copy link
Author

@alexfmpe alexfmpe Jul 8, 2025

Choose a reason for hiding this comment

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

I wonder if -single-threaded should instead be conditionally enabled in the .cabal since wasm backend does not currently support -threaded so for now downstream will have to disable at least that test suite

source-repository-package
type: git
location: https://github.com/haskell-wasm/hostname
tag: 8d110f03b3117af233683ac90b125fcfc767a2ef
Copy link
Author

Choose a reason for hiding this comment

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

I assume this will eventually get upstreamed (we are the inconvenienced downstream in this case)

@phadej
Copy link
Collaborator

phadej commented Jul 10, 2025

Sorry, but I wont work with nix based solutions. I'm not versatile in Nix and nix scripts always bitrot sooner that I'd hope (though the promise is that they wont).

@phadej phadej closed this Jul 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.

2 participants