Skip to content

Commit 52da54a

Browse files
authored
fix(boost-ext.ut): add size_t alias to generated module for MinGW GCC 16.1 (#173)
* fix(boost-ext.ut): add size_t alias to generated module for MinGW GCC 16.1 * Add guard to avoid conflict `size_t` in linux headers * Fix conditional compilation for size_t definition
1 parent 312e8b0 commit 52da54a

1 file changed

Lines changed: 21 additions & 7 deletions

File tree

pkgs/b/boost-ext.ut.lua

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@
66
--
77
-- The upstream release tarball ships an official module interface unit at
88
-- `include/boost/ut.cppm` (`export module boost.ut;`). This descriptor
9-
-- reproduces that file through `generated_files` with EXACTLY ONE deviation
9+
-- reproduces that file through `generated_files` with exactly TWO deviations
1010
-- everything else, including `export import std;`, is upstream's own bytes in
1111
-- upstream's own order.
1212
--
13-
-- The one deviation: Clang on the MSVC ABI (`*-pc-windows-msvc`, this index's
13+
-- The first deviation: Clang on the MSVC ABI (`*-pc-windows-msvc`, this index's
1414
-- Windows default toolchain — llvm@20.1.7, NOT mingw, NOT cl.exe) rejects
1515
-- upstream's file with
1616
-- ut.hpp:688:29: error: use of undeclared identifier '__argc'
@@ -25,11 +25,17 @@
2525
-- reassigned from `main()`'s argv at runtime, so the stand-in values are never
2626
-- read.
2727
--
28+
-- The second deviation is a MinGW-specific fix: GCC 16.1 on
29+
-- `*-pc-windows-mingw` provides no unqualified `::size_t`, which ut.hpp
30+
-- reaches for (ut.hpp:1916 et al), and `export import std;` alone does not
31+
-- surface `std::size_t` under the plain name on that toolchain. The wrapper
32+
-- adds a module-local `using size_t = std::size_t;` before the include —
33+
-- never exported, and a no-op everywhere `::size_t` exists.
34+
--
2835
-- That is the whole delta. In particular this descriptor does NOT:
2936
-- * drop `export import std;` — keeping upstream's spelling is what makes
30-
-- GCC 16.1 accept ut.hpp's unqualified `size_t` (ut.hpp:1916 et al) and
31-
-- the `literals` using-block with no `-Wno-template-body` and no
32-
-- hand-written global-module-fragment include list;
37+
-- GCC 16.1 accept the `literals` using-block with no `-Wno-template-body`
38+
-- and no hand-written global-module-fragment include list;
3339
-- * carry the post-v2.3.1 explicit-template-instantiation block from
3440
-- upstream `master` — it is in no release tag, and the macOS crash it was
3541
-- tried against turned out to be a toolchain-side problem (below).
@@ -108,7 +114,8 @@ package = {
108114
modules = { "boost.ut" },
109115
include_dirs = { "*/include/boost" },
110116
-- Upstream's v2.3.1 include/boost/ut.cppm, reproduced verbatim apart
111-
-- from the __argc / __argv shim documented at the top of this file.
117+
-- from the __argc / __argv shim and the size_t alias documented at
118+
-- the top of this file.
112119
-- Verdir-relative path, no glob.
113120
generated_files = {
114121
["mcpp_generated/boost.ut.cppm"] = [==[
@@ -122,7 +129,14 @@ module;
122129
export module boost.ut;
123130
export import std;
124131
125-
// ---- the only mcpp-index deviation from upstream v2.3.1's ut.cppm ---------
132+
// MinGW GCC 16.1 has no unqualified ::size_t for ut.hpp's uses (ut.hpp:1916
133+
// et al), and `export import std;` alone does not expose std::size_t under
134+
// the plain name on that toolchain. Module-local alias, never exported.
135+
#if not (__has_include(<unistd.h>) or __has_include(<sys/wait.h>))
136+
using size_t = std::size_t;
137+
#endif
138+
139+
// ---- the mcpp-index deviations from upstream v2.3.1's ut.cppm ---------------
126140
// ut.hpp:687 is `#if defined(_MSC_VER)` and references the MSVC builtins
127141
// __argc / __argv. Clang on the MSVC ABI (this index's Windows default,
128142
// *-pc-windows-msvc) sets _MSC_VER but does not provide them; the adjacent

0 commit comments

Comments
 (0)