diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f992215f..0520427a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -565,6 +565,21 @@ jobs: # ⭐ And the one that is this machine, run rather than inspected — the same # criterion the Linux job holds itself to, applied from a different host. + # ⭐ AND A HOSTED C++ PROGRAM, WHICH IS WHERE THREADS AND FILES ARE. + # + # `same-source` also runs on bare metal, so it cannot start a thread; + # `examples/cxx` can, and on Windows a joined std::thread was an access + # violation until openkal-musl 0.13.2 widened C++ `pthread_t`. + - name: A hosted C++ program above it runs on this host + run: | + set -euo pipefail + cd examples/cxx + rm -rf target + # The other observations were written for Linux; this step asks for the + # thread, so a difference elsewhere is reported without failing it. + mcpp run --target '${{ matrix.native }}' 2>&1 | tee out.log || true + grep -q 'ok: a thread is started and joined' out.log + - name: The artefact for this host runs on it run: | set -euo pipefail diff --git a/examples/cxx/src/main.cpp b/examples/cxx/src/main.cpp index f0bf52b8..8c3b3645 100644 --- a/examples/cxx/src/main.cpp +++ b/examples/cxx/src/main.cpp @@ -18,6 +18,7 @@ #include #include #include +#include // ⭐ THREE NAMES A PROGRAM ABOVE THIS STACK MAY USE, ASSERTED BY COMPILING. // @@ -67,6 +68,20 @@ int main() { check(hidden + weak == 18 && weak_alias{3}.value == 3, "hidden, weak and weak_alias are the program's own identifiers"); + // --- std::thread, which is the C++ face of openkal.task ----------------- + // + // ⚠️ A THREAD THAT STARTS IS NOT A THREAD THAT IS JOINED. libc++ keeps the + // pthread_t it was given, and musl declared that type `unsigned long` for + // C++ --- thirty-two bits on Windows --- so the join read through half a + // pointer and ended the program. Fixed in openkal-musl 0.13.2. + { + int written = 0; + std::thread worker([&] { written = 42; }); + const bool joinable = worker.joinable(); + worker.join(); + check(joinable && written == 42 && !worker.joinable(), "a thread is started and joined"); + } + // --- std::filesystem, which is the C++ face of openkal.fs --------------- namespace fs = std::filesystem; diff --git a/mcpp.toml b/mcpp.toml index 0f1b172f..d2ea818d 100644 --- a/mcpp.toml +++ b/mcpp.toml @@ -1,7 +1,7 @@ [package] namespace = "mcpplibs" name = "openkal-llvm-runtime" -version = "0.9.2" +version = "0.9.3" description = "LLVM's C++ runtime libraries — libc++, libc++abi and libunwind — configured for openkal-musl rather than for a host C library." license = "Apache-2.0" authors = ["mcpplibs"] @@ -208,7 +208,7 @@ sources = [ cflags = ["-DDISABLE_AARCH64_FMV=1"] [dependencies] -openkal-musl = "0.13.1" +openkal-musl = "0.13.2" [build] cxx_standard = "c++23"