Skip to content

portability: MinGW, musl Linux, older glibc, and GCC warnings (#62) - #66

Merged
Tom-A-Lynch merged 1 commit into
masterfrom
toks/portability-fixes
Dec 1, 2026
Merged

Tom-A-Lynch merged 1 commit into
masterfrom
toks/portability-fixes

Conversation

@Tom-A-Lynch

Copy link
Copy Markdown
Contributor

Implements the portable, zero-risk fixes from #62 (reported by @ararslan; FreeBSD is intentionally left out since there is no FreeBSD host or CI coverage):

  • Makefile, src/par/par.c: guard #pragma comment(lib, "synchronization.lib") under _MSC_VER, pass -lsynchronization on link lines for MinGW targets via PAR_LIBS, and emit libtoks.dll when OS=windows.
  • src/par/par.c: guard pthread_attr_setaffinity_np with defined(__GLIBC__) so musl Linux compiles cleanly.
  • src/platform/mem.c: define _GNU_SOURCE on Linux so MAP_ANONYMOUS and madvise are exposed on glibc < 2.19 (e.g. manylinux2014).
  • src/core/spm_c.c: factor static inline __attribute__((always_inline)) k7_spm_c_in with an external toks_k7_spm_c wrapper so GCC emits no -Wattributes warning and Windows MSVC still links toks_k7_spm_c cleanly (bare inline __attribute__((always_inline)) caused LNK2019 in test_k7.exe).
  • src/core/spm_build.c: size form[16] so GCC 13 builds the entire library cleanly under -Werror=array-bounds.

Receipts:

  • Linux x86-64 (aimax395b, load 0.18): make -j16 test and TOKS_TIER=scalar make -j16 test both 0 failures; make -j16 CC=gcc lib + test_k7 (4,464,586 checks, 0 fail) + test_par (42,536 checks, 0 fail) with GCC 13.3.0 under -Werror.
  • Windows x86-64 (aimax395): tools\win\build.cmd FAIL=0, tools\win\test.cmd FAIL=0.
  • Dry-run check: make -n TARGET=x86_64-w64-mingw32 lib emits libtoks.dll and passes -lsynchronization only at link time.

Take the low-risk portability and compiler fixes reported in #62:
- Makefile + src/par/par.c: guard MSVC's #pragma comment(lib,
  "synchronization.lib") under _MSC_VER, link -lsynchronization for
  MinGW targets via PAR_LIBS, and name the shared library libtoks.dll
  on Windows.
- src/par/par.c: guard pthread_attr_setaffinity_np with __GLIBC__ so
  musl Linux compiles cleanly.
- src/platform/mem.c: define _GNU_SOURCE on Linux for glibc < 2.19
  where _DEFAULT_SOURCE was not yet defined.
- src/core/spm_c.c: split k7_spm_c_in (static inline always_inline)
  from the external toks_k7_spm_c wrapper, silencing GCC's -Wattributes
  warning while keeping strong external linkage on Windows MSVC.
- src/core/spm_build.c: size form[16] instead of form[15] so GCC 13
  builds the library cleanly under -Werror=array-bounds.

Reported-by: Alex Arslan <ararslan@comcast.net>
@Tom-A-Lynch
Tom-A-Lynch merged commit 0c211e6 into master Dec 1, 2026
8 checks passed
@Tom-A-Lynch
Tom-A-Lynch deleted the toks/portability-fixes branch December 1, 2026 16:02
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