Skip to content

Refactor how CI works in this repository#588

Merged
abrown merged 3 commits intoWebAssembly:mainfrom
alexcrichton:rework-ci
Jun 19, 2025
Merged

Refactor how CI works in this repository#588
abrown merged 3 commits intoWebAssembly:mainfrom
alexcrichton:rework-ci

Conversation

@alexcrichton
Copy link
Collaborator

There are a number of changes in this commit aimed at addressing #587 and making it easier to test #586 in CI. Notable changes here are:

  • The matrix of what to test is much different from before. One matrix entry now builds just one target and optionally tests that target.

  • The CI matrix ensures that wasi-libc builds on a variety of platforms, e.g. Windows/macOS/Linux as well as Linux aarch64.

  • The CI matrix has one entry for building with an older version of LLVM. This version was bumped from LLVM to LLVM 11 since LLVM is installed through apt-get, not through downloads any more.

  • On Linux LLVM/Clang are downloaded through apt-get instead of from llvm-project binaries to avoid dealing with libtinfo5 and dependencies.

  • The CI matrix has a test job per-target. This can be expanded/shrunk as necessary but currently everything is tested with LLVM 16 (as before) and only on Linux (also as before). The test run is seqeunced to happen after the build of libc itself.

  • The CI matrix has split out V8 headless tests into their own job to avoid running multiple suites of tests in a single job.

  • Installation of LLVM is refactored to a separate action to reduce the noise in main.yml.

  • Setting TARGET_TRIPLE can now be done through environment variables as opposed to only through arguments to make.

  • Handling of BULITINS_LIB has improved. Previously the build target for libc_so would modify the compiler's resource directory and this is updated to use a custom directory in OBJDIR.

  • Arranging compiler-rt for tests is now done with -resource-dir instead of copying the directory into the system compiler's location.

Overall it's the intention that no amount of testing is lost in this PR. The goal is to expand things out in such a way that it's much easier to add one-off tests of wasi-libc in various build configurations and such. The theory is that this is as "simple" as adding a new matrix entry, copied from previous ones, customized with various variables and environment variables to affect the build (e.g. CFLAGS).

Closes #587

There are a number of changes in this commit aimed at addressing WebAssembly#587
and making it easier to test WebAssembly#586 in CI. Notable changes here are:

* The matrix of what to test is much different from before. One matrix
  entry now builds just one target and optionally tests that target.

* The CI matrix ensures that wasi-libc builds on a variety of platforms,
  e.g. Windows/macOS/Linux as well as Linux aarch64.

* The CI matrix has one entry for building with an older version of
  LLVM. This version was bumped from LLVM to LLVM 11 since LLVM is
  installed through `apt-get`, not through downloads any more.

* On Linux LLVM/Clang are downloaded through `apt-get` instead of from
  llvm-project binaries to avoid dealing with `libtinfo5` and
  dependencies.

* The CI matrix has a test job per-target. This can be expanded/shrunk
  as necessary but currently everything is tested with LLVM 16 (as
  before) and only on Linux (also as before). The test run is seqeunced
  to happen after the build of libc itself.

* The CI matrix has split out V8 headless tests into their own job to
  avoid running multiple suites of tests in a single job.

* Installation of LLVM is refactored to a separate action to reduce the
  noise in `main.yml`.

* Setting `TARGET_TRIPLE` can now be done through environment variables
  as opposed to only through arguments to `make`.

* Handling of `BULITINS_LIB` has improved. Previously the build target
  for `libc_so` would modify the compiler's resource directory and this
  is updated to use a custom directory in `OBJDIR`.

* Arranging compiler-rt for tests is now done with `-resource-dir`
  instead of copying the directory into the system compiler's location.

Overall it's the intention that no amount of testing is lost in this PR.
The goal is to expand things out in such a way that it's much easier to
add one-off tests of wasi-libc in various build configurations and such.
The theory is that this is as "simple" as adding a new matrix entry,
copied from previous ones, customized with various variables and
environment variables to affect the build (e.g. `CFLAGS`).

Closes WebAssembly#587
@alexcrichton
Copy link
Collaborator Author

Oh, I forgot to also mention, but this deletes the actions/upload-artifact of the sysroot at the end of the build. That doesn't actually go anywhere else at this time and AFAIK it's not really possible to depend on an artifact of a build as GitHub cleans them out relatively aggressively. That being said I'm just guessing this won't break anyone. If it does it shouldn't be hard to add back in.

@alexcrichton
Copy link
Collaborator Author

Timing wise this is before this PR and this is this PR, summarized as:

  • 10.5 minutes total wall clock before, 2m after
  • Most jobs before were 3-4 minutes with the LLVM 10 build being an outlier at 1m15s. Most jobs after are less than 1 minute with Windows being the outlier at 1.5m

@sbc100
Copy link
Member

sbc100 commented Jun 18, 2025

Oh, I forgot to also mention, but this deletes the actions/upload-artifact of the sysroot at the end of the build

Why do this is github is going to do it anyway?

Isn't it maybe nice to be able to download the artifacts or a PR for local testing sometimes?

@alexcrichton
Copy link
Collaborator Author

Sure seems reasonable. I prefer to keep things out of CI where possible as it's generally not fun to read yml, but it's pretty small in this case and if it benefits someone it's not too much harm. The origins of this upload date back to 9580a25 and the original migration from Azure Pipelines to GitHub Actions FWIW.

Copy link
Collaborator

@abrown abrown left a comment

Choose a reason for hiding this comment

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

I think this is great! We could probably polish up the resource directory bits to only set up the resources needed for the currently-running job but, honestly, that can be done later. This is definitely a step forward.

Copy link
Member

@sunfishcode sunfishcode left a comment

Choose a reason for hiding this comment

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

Agreed, this looks like a good step forward!

@abrown abrown merged commit 48eb92c into WebAssembly:main Jun 19, 2025
14 checks passed
@alexcrichton alexcrichton deleted the rework-ci branch June 19, 2025 19:58
@yamt
Copy link
Contributor

yamt commented Jun 23, 2025

after this change, "CC=/opt/wasi-sdk-25.0/bin/clang make -j8 libc_so" doesn't work anymore. is it intended?

it seems that, BUILTINS_LIB was set to the non-existent path (build/wasm32-wasi/resource-dir//lib/wasi/libclang_rt.builtins-wasm32.a) and i causes the "%.a" rule to generate an empty library.

/opt/wasi-sdk-25.0/bin/clang -O2 -DNDEBUG --target=wasm32-wasi -nodefaultlibs \
	-shared --sysroot=/Users/yamamoto/git/wasi-libc/sysroot \
	-o /Users/yamamoto/git/wasi-libc/sysroot/lib/wasm32-wasi/libc.so -Wl,--whole-archive build/wasm32-wasi/libc.so.a -Wl,--no-whole-archive build/wasm32-wasi/resource-dir//lib/wasi/libclang_rt.builtins-wasm32.a \
	-Wl,--allow-undefined-file=linker-provided-symbols.txt \
	-resource-dir build/wasm32-wasi/resource-dir
wasm-ld: warning: creating shared libraries, with -shared, is not yet stable
wasm-ld: error: build/wasm32-wasi/libc.so.a(pselect.pic.o): undefined symbol: __muloti4
wasm-ld: error: build/wasm32-wasi/libc.so.a(futimens.pic.o): undefined symbol: __muloti4
wasm-ld: error: build/wasm32-wasi/libc.so.a(futimens.pic.o): undefined symbol: __muloti4
wasm-ld: error: build/wasm32-wasi/libc.so.a(utimensat.pic.o): undefined symbol: __muloti4
wasm-ld: error: build/wasm32-wasi/libc.so.a(utimensat.pic.o): undefined symbol: __muloti4
wasm-ld: error: build/wasm32-wasi/libc.so.a(clock_nanosleep.pic.o): undefined symbol: __muloti4
wasm-ld: error: build/wasm32-wasi/libc.so.a(cacosl.pic.o): undefined symbol: __subtf3
wasm-ld: error: build/wasm32-wasi/libc.so.a(casinl.pic.o): undefined symbol: __subtf3
wasm-ld: error: build/wasm32-wasi/libc.so.a(casinl.pic.o): undefined symbol: __addtf3
wasm-ld: error: build/wasm32-wasi/libc.so.a(casinl.pic.o): undefined symbol: __multf3
wasm-ld: error: build/wasm32-wasi/libc.so.a(casinl.pic.o): undefined symbol: __subtf3
wasm-ld: error: build/wasm32-wasi/libc.so.a(casinl.pic.o): undefined symbol: __multf3
wasm-ld: error: build/wasm32-wasi/libc.so.a(casinl.pic.o): undefined symbol: __multf3
wasm-ld: error: build/wasm32-wasi/libc.so.a(casinl.pic.o): undefined symbol: __subtf3
wasm-ld: error: build/wasm32-wasi/libc.so.a(casinl.pic.o): undefined symbol: __addtf3
wasm-ld: error: build/wasm32-wasi/libc.so.a(catanl.pic.o): undefined symbol: __multf3
wasm-ld: error: build/wasm32-wasi/libc.so.a(catanl.pic.o): undefined symbol: __subtf3
wasm-ld: error: build/wasm32-wasi/libc.so.a(catanl.pic.o): undefined symbol: __multf3
wasm-ld: error: build/wasm32-wasi/libc.so.a(catanl.pic.o): undefined symbol: __subtf3
wasm-ld: error: build/wasm32-wasi/libc.so.a(catanl.pic.o): undefined symbol: __addtf3
wasm-ld: error: too many errors emitted, stopping now (use -error-limit=0 to see all errors)
clang: error: linker command failed with exit code 1 (use -v to see invocation)

stefson added a commit to stefson/wasi-libc that referenced this pull request Jun 23, 2025
@alexcrichton
Copy link
Collaborator Author

No that's not intentional. If you can figure out why that works on CI but doesn't work for you that'd be appreciated!

TerrorJack added a commit to haskell-wasm/wasi-libc that referenced this pull request Jun 28, 2025
@yamt
Copy link
Contributor

yamt commented Jul 1, 2025

No that's not intentional. If you can figure out why that works on CI but doesn't work for you that'd be appreciated!

because the ci supplies compiler-rt in a bit unusual way?

cp build/download/libclang_rt.builtins-wasm32.a $WASI_DIR
cp build/download/libclang_rt.builtins-wasm32.a $WASIP1_DIR
cp build/download/libclang_rt.builtins-wasm32.a $WASIP2_DIR

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.

ci: improve the testing of multiple configurations

5 participants