|
| 1 | +# Add yandere-chan.binary_tree 0.1.4 |
| 2 | + |
| 3 | +## Source and shape |
| 4 | + |
| 5 | +- Upstream: <https://github.com/YandereChan2/binary_tree>. |
| 6 | +- Version: `0.1.4`, tagged on the commit that exports the global |
| 7 | + `operator new` / `operator delete` using-declarations from the module |
| 8 | + interfaces (namespace `yandere-chan` was introduced in 0.1.3). |
| 9 | +- License: MIT. |
| 10 | +- Shape: Form A (mcpp-native library). The tarball carries |
| 11 | + `binary_tree-0.1.4/mcpp.toml`; that manifest is the build. It declares: |
| 12 | + - `include_dirs = ["."]` — the header library (`binary_tree.h`, |
| 13 | + `parent_aware_binary_tree.h`, `intrusive_binary_tree.h`, `union_data.h`, |
| 14 | + and the POC sets) stays a normal header interface; |
| 15 | + - sources `Yc.intrusive_binary_tree.cppm`, `Yc.binary_tree.cppm`, |
| 16 | + `Yc.parent_aware_binary_tree.cppm` and `src/binary_tree.cppm`; |
| 17 | + - `[lib] path = "src/binary_tree.cppm"` — the lib root re-exports the three |
| 18 | + wrappers, so `import binary_tree;` reaches all of them and `mcpp pack` has |
| 19 | + a module interface to publish. |
| 20 | +- No features and no dependencies: the library is header/module only. |
| 21 | + |
| 22 | +The four public modules are `binary_tree`, `Yc.intrusive_binary_tree`, |
| 23 | +`Yc.binary_tree` and `Yc.parent_aware_binary_tree`; module names are |
| 24 | +independent of the package namespace. |
| 25 | + |
| 26 | +## The libc++ placement-new problem and the export fix |
| 27 | + |
| 28 | +The Linux LLVM run (clang + libc++) failed on 0.1.0 with: |
| 29 | + |
| 30 | +``` |
| 31 | +libc++ __memory/allocator_traits.h:362: error: no matching function for call to '__construct_at' |
| 32 | +construct_at.h:43: ... no matching 'operator new' function |
| 33 | + for non-allocating placement new expression; include <new> |
| 34 | +``` |
| 35 | + |
| 36 | +`std::allocator_traits::construct` instantiates libc++'s `__construct_at`, |
| 37 | +whose default template argument uses placement new. Adding `<new>` to the |
| 38 | +module's global module fragment is not enough: clang's combined |
| 39 | +single-invocation module build (`-x c++-module -fmodule-output=... -c`, the |
| 40 | +mode mcpp uses) does not make the GMF declaration **visible** to the importer, |
| 41 | +even though it is reachable. The lookup happens when the consumer instantiates |
| 42 | +the template, so `import binary_tree;` alone failed. See |
| 43 | +llvm/llvm-project#218246 (and the earlier #59601), which lists the same two |
| 44 | +workarounds: instantiate in the defining module, or re-declare the missing |
| 45 | +declaration in the importing TU. |
| 46 | + |
| 47 | +0.1.4 takes a third route that keeps the consumer clean: each module interface |
| 48 | +exports a using-declaration for the global placement `operator new` and its |
| 49 | +matching `operator delete`: |
| 50 | + |
| 51 | +```cpp |
| 52 | +export module Yc.binary_tree; |
| 53 | + |
| 54 | +import Yc.intrusive_binary_tree; |
| 55 | + |
| 56 | +export using ::operator new; |
| 57 | +export using ::operator delete; |
| 58 | +``` |
| 59 | + |
| 60 | +The using-declarations are exported names (not declarations of new entities), |
| 61 | +so an importer can look placement new up without including `<new>`, and a |
| 62 | +consumer that *does* include `<new>` still compiles. The declarations must |
| 63 | +come after the imports: GCC requires post-module imports to be contiguous. |
| 64 | +Clang, MSVC and GCC 16.1 all accept the form; the umbrella module re-exports |
| 65 | +it through `export import`. |
| 66 | + |
| 67 | +0.1.0-0.1.3 are not listed: all carry the old `YandereChan2` namespace and |
| 68 | +predate this export. |
| 69 | + |
| 70 | +## Download and mirror |
| 71 | + |
| 72 | +- GLOBAL: |
| 73 | + `https://github.com/YandereChan2/binary_tree/releases/download/0.1.4/binary_tree-0.1.4.tar.gz` |
| 74 | + (a `git archive` of tag `0.1.4`, uploaded as the release asset; the tarball |
| 75 | + root is `binary_tree-0.1.4/`) |
| 76 | +- SHA-256: |
| 77 | + `e7bd88adaa156219d87db05cbe4bc0dd5447ee7c7736f138f0870ebdfa706853` |
| 78 | +- No `mcpp-res` mirror is available, so the descriptor uses the repository's |
| 79 | + plain-string upstream URL fallback. No CN mirror is invented; a maintainer |
| 80 | + can add a byte-identical GitCode release later. |
| 81 | +- `extensions.autoupdate` uses the bare tag and the tag-archive template |
| 82 | + (`archive/refs/tags/${tag}.tar.gz`), so a future release needs no uploaded |
| 83 | + asset for the updater to compute its sha. |
| 84 | + |
| 85 | +## Test member |
| 86 | + |
| 87 | +- `tests/examples/binary_tree-module/` has two test files: |
| 88 | + - `binary_tree_module.cpp` imports the lib root and each wrapper and asserts |
| 89 | + insert / in-order `for_each` / copy / `parent_of_cnroot` / intrusive-node |
| 90 | + behavior; |
| 91 | + - `binary_tree_umbrella.cpp` imports only `binary_tree` (umbrella-only) and |
| 92 | + asserts the same construction path, which proves the re-exported |
| 93 | + placement-new declarations reach an importer that never includes `<new>`. |
| 94 | + |
| 95 | + Neither file includes `<new>` or any library header. Every check affects the |
| 96 | + process exit status. |
| 97 | +- The member carries its own |
| 98 | + `[indices] yandere-chan = { path = "../../.." }` so the dependency resolves |
| 99 | + to the checked-in descriptor rather than the published remote index. |
| 100 | + |
| 101 | +## Verification |
| 102 | + |
| 103 | +- Pinned mcpp `2026.11.18.1`, the version in `validate.yml`: |
| 104 | + `mcpp xpkg parse pkgs/y/yandere-chan.binary_tree.lua` reports `parse OK` |
| 105 | + for linux, macosx and windows, and recognizes Form A. |
| 106 | +- `mcpp test -p binary_tree-module --cache off` downloads the 0.1.4 asset, |
| 107 | + compiles both tests without `<new>`, and both pass. |
| 108 | +- The same manifest builds with `mcpp build` (clang + MSVC STL), |
| 109 | + `mcpp build --toolchain msvc@system`; all four `.cppm` compile with GCC |
| 110 | + 16.1 (`-fmodules`). |
| 111 | +- A minimal clang 23.1.3 combined-mode repro of the placement-new bug |
| 112 | + (`module; #include <new>` + direct placement new) fails without the export |
| 113 | + and passes with it; MSVC 14.51 and GCC 16.1 accept the exported form. |
| 114 | + |
| 115 | +## Notes |
| 116 | + |
| 117 | +- The export is a workaround for the clang module bug, not a permanent API |
| 118 | + requirement. If a future clang makes GMF scopes visible to importers, the |
| 119 | + using-declarations can be dropped. |
| 120 | +- The POC set headers `rb_set.h` / `avl_set.h` import |
| 121 | + `parent_aware_binary_tree.h` as a header unit on MSVC; that path is not part |
| 122 | + of this package. |
| 123 | +- The package is platform-independent: the same tarball and sha are used for |
| 124 | + linux, macosx and windows. |
0 commit comments