Skip to content

Add threading library#21

Open
helly25 wants to merge 1 commit into
mainfrom
feat/20240324_preiodic_thread
Open

Add threading library#21
helly25 wants to merge 1 commit into
mainfrom
feat/20240324_preiodic_thread

Conversation

@helly25

@helly25 helly25 commented Mar 24, 2024

Copy link
Copy Markdown
Owner
  • Added PeriodicThread: Runs a function periodically in its own thread.

@helly25 helly25 force-pushed the feat/20240324_preiodic_thread branch 2 times, most recently from 124186f to 458382e Compare March 26, 2024 20:45
  * Added `PeriodicThread`: Runs a function periodically in its own thread.
@helly25 helly25 force-pushed the feat/20240324_preiodic_thread branch from 458382e to 41950f1 Compare March 30, 2024 12:48
helly25 added a commit that referenced this pull request Jun 7, 2026
Switch the dev-only compile-commands extractor from inactive upstream
hedronvision to the actively-maintained helly25 fork, pinned at
cc0277ab4 (PR #21), which fixes a macOS BrokenProcessPool: the worker
pool is pinned to the `fork` start method so spawned workers no longer
re-import and re-enter main(). Add a `repo_name` alias and point
compile_commands-update.sh at it.

Verified: `./compile_commands-update.sh` -> OK, 2153 entries on macOS.
helly25 added a commit that referenced this pull request Jun 8, 2026
PRs #21 (macOS ProcessPoolExecutor fork fix) and #22 (integration CI)
landed on the helly25/bazel-compile-commands-extractor main, so move the
git_override off the unmerged branch commit (cc0277a) onto the merged
main commit. Verified: ./compile_commands-update.sh -> OK, 2153 entries.
helly25 added a commit that referenced this pull request Jun 9, 2026
* chore(deps): update Bazel to 9.1.1 and bump module dependencies

Bump Bazel 7.2.1 -> 9.1.1 and update the BCR/dev module dependencies to
their latest compatible versions.

Bazel 9 stops autoloading the legacy native `sh_*` rules. helly25_bashtest
still defines its targets with native `sh_library`, so re-enable autoload
for the shell rules from @rules_shell via
`--incompatible_autoload_externally` in .bazelrc.

abseil-cpp is held at the 20250814 series (20250814.2): newer Abseil
(20260107+) deprecates the `absl::MutexLock(Mutex*)` constructor that re2
2025-11-05 still uses, which breaks under `--cxxopt=-Werror`.

Verified with `bazel test //mbo/...` on Bazel 9.1.1: all unit tests pass
in the default (fastbuild) config.

* chore(deps): bump trunk plugins to v1.10.2 and checkov to 3.2.533

* fix(macos): bump pinned LLVM 17.0.4 → 20.1.7 to fix exec-config linker segfault

LLVM 17.0.4's bundled linker segfaults against the macOS 26 SDK when
linking tools in the exec configuration (e.g. //mbo/diff:diff, which
_diff_test builds with cfg=exec), which broke all diff tests locally.
LLVM 20.1.7 links cleanly and compiles the tree under -Werror with no
new warnings.

Also migrate the _diff_test is_windows select off the deprecated
@bazel_tools//src/conditions:host_windows to @platforms//os:windows.

* build(deps): pin bashtest 0.3.0 via git_override, drop sh_* autoload workaround

bashtest 0.3.0 loads sh_library/sh_test from @rules_shell directly, so the
--incompatible_autoload_externally=+sh_library,+sh_binary,+sh_test workaround
in .bazelrc is no longer needed under Bazel 9. Pin to the 0.3.0 tag commit via
git_override for now; swap to a plain bazel_dep 0.3.0 once it is in the BCR.

* ci: drop the MODULE 0.10.0 back-compat test matrix

Remove the `module_version: [0.10.0]` matrix dimension, the
`module_version`/`module_default` workflow inputs and the conditional
`cp bazelmod/MODULE.${module_version}.bazel MODULE.bazel` step, and
delete the now-unused `bazelmod/MODULE.0.10.0.bazel` shim. We no longer
test against the 0.10.0 module layout.

* build(deps): point compile-commands extractor at helly25 fork

Switch the dev-only compile-commands extractor from inactive upstream
hedronvision to the actively-maintained helly25 fork, pinned at
cc0277ab4 (PR #21), which fixes a macOS BrokenProcessPool: the worker
pool is pinned to the `fork` start method so spawned workers no longer
re-import and re-enter main(). Add a `repo_name` alias and point
compile_commands-update.sh at it.

Verified: `./compile_commands-update.sh` -> OK, 2153 entries on macOS.

* build(deps): LLVM toolchain ladder 20/21/22, test on macos-26

Replace the ancient 16.0.4 / 17.0.4 / 19.1.6 clang versions with a
20.1.8 / 21.1.8 / 22.1.7 ladder and move CI from the macos-15 runner to
macos-26 (Apple clang 21 + the macOS 26 SDK, i.e. what we actually run,
and the SDK where the LLVM>=20 linker fix matters).

Default/blocking toolchain stays on 20.1.8 -- the newest clang that
builds mbo cleanly. clang 21 tightened constexpr evaluation and currently
breaks our struct_names_clang.h field-name reflection
(__builtin_dump_struct in a consteval context), so 21.1.8 (the macOS
native match) and 22.1.7 ride along as non-blocking, opt-only rungs in
the continue-on-error test-clang job until that port lands; then promote
the default pin to 21.x. Drop the orphaned bazelmod/llvm.20.1.0.MODULE.bazel.

Also stop letting our global -Werror be tripped by third-party code:
- external_include_paths makes external repo headers -isystem, so their
  warnings are ignored even in our first-party TUs (clang 21's
  -Wcharacter-conversion in googletest's gtest-printers.h);
- per_file_copt on external/* sources downgrades -Werror when compiling a
  dependency's own .cc / internal headers (clang 21's
  -Wthread-safety-analysis in google_benchmark).
First-party code keeps full -Werror.

Verified locally on macOS 26: bazel test --config=clang //mbo/... -> 74/74
pass with the 20.1.8 default.

* build(deps): use published helly25_bashtest 0.3.0 from the BCR

0.3.0 is now in the Bazel Central Registry, so drop the temporary
git_override (added to get the sh_* autoload removal early) and bump the
bazel_dep to the released version.

* build(deps): re-pin compile-commands extractor to merged 75ba4c3

PRs #21 (macOS ProcessPoolExecutor fork fix) and #22 (integration CI)
landed on the helly25/bazel-compile-commands-extractor main, so move the
git_override off the unmerged branch commit (cc0277a) onto the merged
main commit. Verified: ./compile_commands-update.sh -> OK, 2153 entries.

* build(deps): work toward clang 21 default

- bazelmod/llvm.MODULE.bazel: switch default llvm_version 20.1.8 → 21.1.8.
- decompose_count: mark the overload-set structured bindings as
  [[maybe_unused]] (clang 21 warns on the decltype-only `auto&& [a1, ...]`
  names). Update the .mope template and regenerate the golden header.
- ci(main.yml): temporarily pin the llvm matrix to 20.1.8
  (TODO: restore 21.1.8 / 22.1.7 once the port is green).

* Cannot exclude what is not there.

* Must use 20.1.8 for now, as 21.1.8 is not yet the default pin and causes breakages on macOS due to tightened constexpr evaluation. Once 21.1.8 is the default pin, we can update to it and remove 20.1.8 from the workflow.

* Update method of compiler switching. Works for Bazel 9 and some Bazel 8.

* ci: single-source toolchain selection + Bazel-version matrix

test.yml:
- Split the runner into Setup / Show compiler / Build and Test. Resolve the
  C++ toolchain and Bazel flags exactly once in Setup and export them via
  $GITHUB_ENV so the later steps share one source of truth.
- Assert the actually-selected compiler and the launched Bazel version match
  what the matrix asked for, so a silent toolchain/version fallback fails CI
  loudly instead of going green on the wrong toolchain.
- Add a `bazel_version` input that pins `.bazelversion`, and neutralize any
  inherited `USE_BAZEL_VERSION` (exported empty -> bazelisk treats it as unset)
  so `.bazelversion` stays authoritative.
- Drop the old `unset CC/CXX`: only the gcc branch exports them and the new
  `Clang:` assertion verifies the result, a stronger guarantee.
- Make the cache key Bazel-version-aware so different Bazel versions don't
  clobber each other's cache.

main.yml:
- Give test-bcr a Bazel-version axis: 7.2.1 (earliest 7.x that works -- 7.1.x
  lacks `include()` and depend_on_what_you_use@0.16.0 needs >=7.2.1), 8.7.0
  (latest 8.x), 9.0.2 (latest 9.0.x), and the checked-in default 9.1.1.

* fix(clang21): store non-const value so constexpr construct_at is legal

clang 21 tightened constexpr evaluation to forbid modifying a
const-qualified object -- even through const_cast -- which broke
placement `std::construct_at` into const storage. This surfaces on the
macos-26 `native` build (Apple clang 21), which we can't disable.

- struct_names_clang.h: make `Uninitialized storage_` non-const; the two
  const_casts in the Storage ctor are then no-ops and are dropped.
- limited_vector.h: store `std::remove_const_t<T>` in the union `Data`
  and retarget the construct_at const_casts to `std::remove_const_t<T>*`,
  so `LimitedVector<const int>` constructs in a constant expression.
  Constness is reintroduced through the public accessors.

Verified: struct_names_test and limited_vector_test pass under native
clang 21.

Note: limited_ordered.h / no_destruct.h carry the same const_cast +
construct_at pattern but are never instantiated with a const value type,
so they still compile under clang 21 and are left unchanged.

* style: clang-format wrap over-long construct_at lines in limited_vector

The clang-21 fix (ab8a27e) left two `construct_at(...)` lines over the
column limit. clang-format wraps them; keeps the pre-commit clang-format
hook green.

* ci: use pip shellcheck-py hook instead of docker-based shellcheck

`koalaman/shellcheck-precommit` runs shellcheck via docker, which fails
where docker is not installed (e.g. local dev). Switch to
`shellcheck-py/shellcheck-py` v0.10.0.1 -- the same shellcheck 0.10.0
binary, pip-installed -- so the hook runs without docker locally and in
CI. No new lint findings vs. the previous 0.10.0.

* build(macos): pin deployment target to 11.0 (Apple Silicon, unblocks std::filesystem)

The native Apple-clang build passed no `-mmacosx-version-min`, so libc++'s
availability annotations gated off `std::filesystem`, failing ~278 sites
with "'path' is unavailable: introduced in macOS 10.15" across mbo/file,
mbo/diff, mbo/mope and mbo/testing. We target Apple Silicon only, so 11.0
(Big Sur) is the earliest reachable macOS and clears the 10.15 gate.

Set on compile and link, target and exec configs (the //mbo/diff:diff tool
builds for exec), in the `common:macos` block (auto-applied via
--enable_platform_specific_config). The hermetic --config=clang build is
unaffected. Full `bazel test //...` is green under native Apple clang 21
(74/74).

* ci: enable hermetic clang 21.1.8/22.1.7 as non-blocking test-clang rungs

Default pin and blocking test-bcr stay on 20.1.8; 21.1.8 runs opt only, 22.1.7 runs asan/cpp23/opt.

* docs: changelog for clang 21 fix; refresh stale 0.11.0 entries
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.

1 participant