Skip to content

Conversation

@Francesco146
Copy link

@Francesco146 Francesco146 commented Nov 5, 2025

This PR introduces significant infrastructure improvements across build systems, CI/CD pipelines, containerization, and user experience. The changes enable automated releases, reproducible builds, cross-platform support, and a modernized interactive REPL.

Release Automation & CI/CD

  • Comprehensive GitHub Actions workflow (buildAndTest.yml):
    • Multi-platform build matrix: Linux x86_64, macOS x86_64, macOS arm64
    • Automated artifact creation for each platform (mosml-<platform>-<arch>.tar.gz)
    • Windows cross-compilation via Docker (mingw32)
    • Windows installer generation using Inno Setup
    • Automatic GitHub Release creation on version tags (v*.*.*)
  • Docker build workflow (docker.yml):
    • Automated image builds for GitHub Container Registry and Docker Hub
    • Multi-registry support with proper tagging (latest + semver)
    • Build caching for improved CI performance

Docker Support

  • Dockerfile:
    • Multi-stage build for minimal image size
    • Ubuntu 22.04 base with runtime dependencies only
  • Docker Compose configuration for local development
  • Windows cross-build Dockerfile (Dockerfile.w32):
    • Ubuntu 14.04 i386 base for legacy MinGW compatibility
    • Automated Windows binary packaging
    • Cross-compilation script with extensive validation

Windows Support

  • Cross-compilation infrastructure:
    • build-win.sh script with comprehensive options and error handling
    • Support for custom source/output directories and parallel builds
    • Dry-run mode for debugging
    • Proper DESTDIR handling for staged installations
  • Windows installer improvements:
    • Italian language support added

Enhanced REPL Experience

  • Intelligent rlwrap integration in mosml launcher:
    • Automatic detection and usage when available
    • XDG Base Directory compliance for history storage
    • Fallback to $HOME/.local/share/mosml/history when XDG_DATA_HOME not set
    • Opt-out via DISABLE_RLWRAP=1 environment variable
    • Features: command history, arrow key editing, line navigation
  • Cross-platform history support including macOS, Linux, and Windows (MSYS/Git Bash)

Build System Improvements

  • Robust GMP detection:
    • Prefer pkg-config when available
    • Intelligent fallback to common system paths (Homebrew, apt, system libs)
    • Support for explicit GMPINCDIR and GMPLIBDIR overrides
    • Clear warning messages when GMP not found
  • Fixed compiler warnings and errors:
    • Standardized main() signatures across auto-aux helpers
    • C99/C11 compliance improvements
    • Header includes added where missing
  • Improved Makefile robustness:
    • Error-tolerant clean targets (continue on missing directories)
    • Support for install_w32 target in lex
    • Proper DESTDIR and PREFIX handling throughout

Bug Fixes

  • Word64 module fixes:
    • Proper handling of overflow in toInt
  • Runtime system fixes:
    • Fixed SA_NOMASKSA_NODEFER for POSIX compliance
    • Missing includes added (stdlib.h, fail.h, memory.h)

Repository Hygiene

  • Comprehensive .gitignore:
    • Build artifacts, temporary files, OS-specific files
    • Docker shared volumes, staging directories
    • Generated from gitignore.io templates (Linux, macOS, Windows, C, StandardML, LaTeX)
  • .dockerignore for efficient Docker builds
  • Version bump to 2.10.5

Documentation Updates

  • Updated installation instructions for Windows (install.txt.w32)
  • Improved Inno Setup README
  • Release notes template with platform-specific installation guides

Testing

All changes have been tested across:

  • Ubuntu (latest)
  • macOS Intel (x86_64)
  • macOS Apple Silicon (arm64)
  • Windows (cross-compiled via Docker)
  • Docker containers (REPL with rlwrap, history persistence)

Breaking Changes

All changes are backward compatible. The rlwrap integration is opt-in by availability and can be disabled. The CI process for pushing mosml images to Docker HUB require two repository secrets:

…d modernize signal handling

- Change old-style "main()" to standard "int main(int argc, char **argv)" in several auto-aux test programs (align.c, bytecopy.c, dblalign.c, endian.c, schar.c, schar2.c, setjmp.c, sighandler.c).
- Fix sighandler.c to use sig_t for the saved handler variable.
- Add missing includes: stdlib.h in runtime/io.c, unistd.h in config/auto-aux/signals.c, and fail.h/memory.h in src/dynlibs/mgd/mgd.c.
- Replace deprecated SA_NOMASK with SA_NODEFER in sys.c when installing sigaction.
…nstalls, add rlwrap, upload artifacts and create release job
- Drop the build-windows (MSYS2) job and related artifact upload
- Remove Windows entries from release notes and release artifact list
- Update create-release dependency to only require build-test
- macOS dependency step no longer installs gmp (install rlwrap only)
@Francesco146
Copy link
Author

the only thing that i can think of for a working mosml implementation on Windows is my port of mosml to Docker:

https://github.com/Francesco146/mosml-docker

@Francesco146
Copy link
Author

Francesco146 commented Nov 6, 2025

update: https://github.com/kfl/mosml/wiki/Notes-about-how-to-build-Moscow-ML-installers#for-windows this seems to work, it still uses the deprecated i586-mingw32msvc-gcc, but a simple change in the Makefile worked and produced:

camlrt.dll  camlrunm.exe  mosml.exe  mosmlc.exe  mosmlyac.exe

i'll push the changes here

@Francesco146 Francesco146 force-pushed the gnu-tty-stds-and-fixes branch from a7403f6 to ca07940 Compare November 7, 2025 21:16
@Francesco146 Francesco146 changed the title Expand CI build matrix with release artifacts, add rlwrap-enabled REPL, and improve GMP detection Improve portability and distribution: Windows cross-build, Docker images, new REPL history with rlwrap, and enhanced GMP detection Nov 7, 2025
@Francesco146 Francesco146 force-pushed the gnu-tty-stds-and-fixes branch 3 times, most recently from d85956e to 8a8b25f Compare November 8, 2025 15:58
@Francesco146 Francesco146 changed the base branch from master to devel November 14, 2025 12:32
@Francesco146
Copy link
Author

okay, update: i've published the automatic build system for Windows. it all uses InnoSetup, so that's cool. i changed the branch to devel, but as i suspected, it introduced some regression:

File “Word64.sml”, line 171, characters 25-44:
!         if w > fromWord_ 0wx3FFFFFFFFFFFFFFF then raise Overflow
!                          ^^^^^^^^^^^^^^^^^^^
make[1]: *** [Word64.uo] Error 2
make[1]: *** Waiting for unfinished jobs....
! Lexical error: word constant is too large.
make[1]: Leaving directory `/mosml/src/mosmllib'
make: *** [world] Error 2

i'll take a look at these right now

@Francesco146 Francesco146 force-pushed the gnu-tty-stds-and-fixes branch from 43758a3 to 12ea1dc Compare November 14, 2025 12:45
@Francesco146
Copy link
Author

i found an issue in the Word64 conversion layer:

  1. the *X conversion functions in Word64.sml (toIntX, toLargeIntX, toLargeWordX, toLargeX) were incorrectly bound to the zero-extending primitive boxed_uint64_toword. these functions are intended to perform sign extension, so this mismatch could lead to incorrect results for values where bit 63 is set.

i've updated (84b1250) the SML prim_val binding to reference a new primitive boxed_uint64_toword_signed and added the corresponding implementation in boxed_num.c, which:

  • reads the 64-bit boxed value
  • sign-extends bit 63 into the host integer/word
  • returns the correctly boxed result
  • follows the same runtime registration and error handling as the existing zero-extending primitive

@Francesco146
Copy link
Author

also, in the Word64 shift functions:

  1. the shift functions in Word64.sml (<<, >>, ~>>) were using toInt k to check shift bounds. for very large k, toInt k can raise Overflow, making the functions unsafe for large shift counts.

i've updated (82e40e3) the functions to use word-level comparisons instead of converting k to an ML int. the changes:

  • compare k directly to fromInt 64 and fromInt 0 using existing word comparison primitives or less_/equal_ helpers
  • ensure shifts with k >= 64 or k < 0 return ZERO (or the sign-extended result for ~>>) safely

@Francesco146
Copy link
Author

Francesco146 commented Nov 14, 2025

hmm, i think it's better to address these corrections in another PR. i believe Int64 and Word64 need some changes in terms of functionality, but also bug fixing and documentation in the signatures, should i revert this changes for now?

edit: note that 15d25ff is needed for the CI/CD to succeed

@Francesco146 Francesco146 changed the title Improve portability and distribution: Windows cross-build, Docker images, new REPL history with rlwrap, and enhanced GMP detection Add release automation, Docker support, Windows cross-compilation, and enhanced REPL experience Nov 14, 2025
@Francesco146
Copy link
Author

Francesco146 commented Nov 14, 2025

done, sorry for the back and forth, i found a few edge cases that my additions didn't handle. everything should be fine now and ready for review. i think it's best to revert the two commits, but i'll wait to hear what you think :)

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.

3 participants