Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -569,7 +569,8 @@ jobs:
#
# `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`.
# violation until openkal-musl 0.13.2 widened C++ `pthread_t`; on macOS a
# detached one ending was, until openkal-musl 0.13.3.
- name: A hosted C++ program above it runs on this host
run: |
set -euo pipefail
Expand All @@ -579,6 +580,7 @@ jobs:
# 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
grep -q 'ok: a detached thread runs and ends' out.log

- name: The artefact for this host runs on it
run: |
Expand Down
16 changes: 16 additions & 0 deletions examples/cxx/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
#include <random>
#include <system_error>
#include <thread>
#include <atomic>
#include <chrono>

// ⭐ THREE NAMES A PROGRAM ABOVE THIS STACK MAY USE, ASSERTED BY COMPILING.
//
Expand Down Expand Up @@ -82,6 +84,20 @@ int main() {
check(joinable && written == 42 && !worker.joinable(), "a thread is started and joined");
}

// ⚠️ AND A DETACHED THREAD ENDS WITHOUT ENDING THE PROGRAM. musl released a
// detached thread's mapping from a 256-byte stack every exiting thread
// shares, and openkal-musl's path for the calls that end the thread overran
// it into the context table; on macOS the program stopped as the thread
// ended. Fixed in openkal-musl 0.13.3.
{
static std::atomic<bool> ran{false};
std::thread([] { ran = true; }).detach();
for (int i = 0; i < 400 && !ran; ++i) std::this_thread::sleep_for(std::chrono::milliseconds(5));
// Running is reported before ending; the pause lets the thread end.
std::this_thread::sleep_for(std::chrono::milliseconds(100));
check(ran, "a detached thread runs and ends");
}

// --- std::filesystem, which is the C++ face of openkal.fs ---------------

namespace fs = std::filesystem;
Expand Down
4 changes: 2 additions & 2 deletions mcpp.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
namespace = "mcpplibs"
name = "openkal-llvm-runtime"
version = "0.9.3"
version = "0.9.4"
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"]
Expand Down Expand Up @@ -208,7 +208,7 @@ sources = [
cflags = ["-DDISABLE_AARCH64_FMV=1"]

[dependencies]
openkal-musl = "0.13.2"
openkal-musl = "0.13.3"

[build]
cxx_standard = "c++23"
Expand Down
Loading