Skip to content

Single Threaded + Emscripten Support#301

Merged
vincentlaucsb merged 19 commits intomasterfrom
single-thread
Apr 6, 2026
Merged

Single Threaded + Emscripten Support#301
vincentlaucsb merged 19 commits intomasterfrom
single-thread

Conversation

@vincentlaucsb
Copy link
Copy Markdown
Owner

@vincentlaucsb vincentlaucsb commented Apr 6, 2026

PR Summary: Emscripten + Single-Threading Support (v3.0.0)

Summary

This PR adds first-class support for threadless and Emscripten/WebAssembly targets while keeping the existing public API intact.

Goals

  • Remove mmap dependency on Emscripten at compile time
  • Support builds without thread libraries
  • Preserve CSVReader("file.csv") ergonomics across platforms
  • Improve portability and validation confidence

Key Changes

  • Emscripten parser path:
    • Exclude MmapParser with compile-time guards
    • Route filename construction through stream parsing
    • Remove runtime mmap-failure behavior on wasm targets
  • Threading configuration:
    • CSV_ENABLE_THREADS=0 forced on Emscripten
    • Default CSV_ENABLE_THREADS=1 elsewhere
    • Auto-disable threading when CMake cannot find thread support
  • Reader internals:
    • Refactor shared stream initialization to remove duplication
    • Reuse shared init path in the Emscripten filename constructor
    • Scope owned_file_stream to Emscripten only
  • Portability:
    • Remove CMAKE_CXX_STANDARD preprocessor dependency
    • Simplify C++ feature detection around __cplusplus and _MSVC_LANG
  • Quality and correctness:
    • Harden streamoff to size_t conversions with checks
    • Fix CodeQL finding in pow10() via integral exponent enforcement
    • Restore important thread-safety/concurrency comments
  • Workflow/security:
    • Pin setup-emsdk by commit hash
    • Add Emscripten workflow test execution via CMAKE_CROSSCOMPILING_EMULATOR=node
  • Docs:
    • Update README Integration section for threading modes
    • Add non-CMake macro usage (#define CSV_ENABLE_THREADS 0)
    • Add Emscripten behavior notes

Compatibility

  • No public API breakage for existing usage patterns
  • Native builds still use threaded + mmap fast path when available
  • Behavior changes are limited to build-time/platform path selection

Validation

  • Native single-thread Release build: pass
  • Native single-thread Release tests: 100% pass
  • Emscripten workflow build/test validation added in this PR

Reviewer Focus

  • Emscripten constructor path and parser selection
  • Threading defaults and CMake fallback behavior
  • Emscripten workflow run path (CMAKE_CROSSCOMPILING_EMULATOR=node)
  • File I/O sizing assumptions across platforms

@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 6, 2026

Codecov Report

❌ Patch coverage is 85.18519% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 90.87%. Comparing base (7577473) to head (7fa7a6a).
⚠️ Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
include/internal/basic_csv_parser.cpp 60.00% 1 Missing and 1 partial ⚠️
include/internal/csv_reader.hpp 93.33% 0 Missing and 1 partial ⚠️
include/internal/data_type.hpp 0.00% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #301      +/-   ##
==========================================
- Coverage   90.95%   90.87%   -0.08%     
==========================================
  Files          23       23              
  Lines        1515     1513       -2     
  Branches      617      616       -1     
==========================================
- Hits         1378     1375       -3     
- Misses         42       43       +1     
  Partials       95       95              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Comment thread .github/workflows/cmake-multi-platform.yml Fixed
@vincentlaucsb vincentlaucsb changed the title Single Threaded/Emscripten Support Single Threaded + Emscripten Support Apr 6, 2026
@vincentlaucsb vincentlaucsb merged commit bb3f5a3 into master Apr 6, 2026
23 checks passed
@vincentlaucsb vincentlaucsb deleted the single-thread branch April 6, 2026 07:31
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.

2 participants