Commit bc8dbf4
committed
fix(io): build under Emscripten without per-consumer workarounds
Two independent problems stopped an Emscripten build of this library, and both forced every
consumer to know something it should not have to.
RandomAccess.cpp: all twelve calls to ThrowNative() sit in a _WIN32 or POSIX branch, and each of
those three-way #if blocks answers Emscripten with PlatformNotSupportedException instead. On that
target the helper genuinely has no caller. GCC does not diagnose that; Clang, which Emscripten uses,
reports "unused function 'ThrowNative' [-Werror,-Wunused-function]" and the build stops. It is now
compiled only where it is used -- no suppression, and the dead code stays out of the wasm binary.
NativeDetail() had to move inside the same guard: its only caller is ThrowNative, so excluding just
ThrowNative moves the identical error one line up.
modules/io-compression: Emscripten ships zlib as a PORT rather than a system library, so
find_package(ZLIB REQUIRED) failed with "missing: ZLIB_LIBRARY ZLIB_INCLUDE_DIR" until the consumer
ran `embuilder build zlib` and passed both paths by hand. The module now requests the port itself
when targeting Emscripten and keeps find_package everywhere else.
That link option is PUBLIC deliberately. This is a STATIC library, so -sUSE_ZLIB=1 has to reach the
final executable's link line too; PRIVATE would configure and compile cleanly and then fail whoever
links the result, which is the worse of the two failures.
Verified with emsdk 6.0.6 against the CNA consumer, with NO workaround flags of any kind:
* emcmake configure succeeds -- no "Could NOT find ZLIB"
* sharp_runtime_io compiles (this was the -Werror failure)
* sharp_runtime_io_compression compiles and links
Native is unaffected -- the guard keeps both helpers, and the CMake else() branch is unchanged. The
CNA HEADLESS suite is identical before and after: 6389 tests, 6172 passed, 217 skipped, 0 failed.
Reported as finding 3 in openeggbert/cna's threeissues.md, which is being updated to match.1 parent 7a46a53 commit bc8dbf4
2 files changed
Lines changed: 26 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
5 | | - | |
6 | | - | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
7 | 20 | | |
8 | 21 | | |
9 | 22 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
80 | 80 | | |
81 | 81 | | |
82 | 82 | | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
83 | 92 | | |
84 | 93 | | |
85 | 94 | | |
| |||
94 | 103 | | |
95 | 104 | | |
96 | 105 | | |
| 106 | + | |
| 107 | + | |
97 | 108 | | |
98 | 109 | | |
99 | 110 | | |
| |||
0 commit comments