OCaml Weekly News
Hello
Here is the latest OCaml Weekly News, for the week of August 09 to 16, 2022.
Table of Contents
- Emacs on windows, merlin mode, merlin server remote on linux, tramp, ssh
- clangml 4.2.0: OCaml bindings for Clang API (for C and C++ parsing)
- opam 2.1.3
- Application-specific Improvements to the Ecosystem
- Use GitHub CI to build simple binary distribution?
- setup-dkml.yml GitHub Actions workflow for distributing binaries
- Diskuv OCaml 1.x.x; Windows OCaml installer no longer in preview
- Old CWN
Emacs on windows, merlin mode, merlin server remote on linux, tramp, ssh
Artem Pianykh said
I managed to set up Emacs + TRAMP + LSP to do remote development (not on the first attempt though, as these things were quite fiddly to set up).
Here's what I got:
- You need
opam install ocaml-lsp-server
on the remote machine. - Tell TRAMP to use path from the remote shell:
(add-to-list 'tramp-remote-path 'tramp-own-remote-path)
- Use Eglot as an LSP client. Although,
lsp-mode
claims that they support remote servers, I couldn't quite make it work withlsp-mode
. This is what I have in myinit.el
:
(require 'eglot) (add-hook 'tuareg-mode-hook #'eglot-ensure)
clangml 4.2.0: OCaml bindings for Clang API (for C and C++ parsing)
Thierry Martinez announced
clangml.4.7.0
is now in opam, with the bug fixes/features requested by @n47 and some others. All LLVM/Clang
versions up to 14.0.x are supported, as well as OCaml 5.0. The official repo is now on github:
https://github.com/thierry-martinez/clangml which should ease posting issues and pull requests (and should be more
convenient than discussions on this thread!).
Support for the upcoming Clang 15 is planned for the next release that should happen soon (the development version already supports Clang 15).
opam 2.1.3
R. Boujbel announced
We are pleased to announce minor release of opam 2.1.3.
This opam release consists of backported fixes. You’ll find more information in the blog post.
To upgrade simply run:
bash -c "sh <(curl -fsSL https://raw.githubusercontent.com/ocaml/opam/master/shell/install.sh) --version 2.1.3"
Application-specific Improvements to the Ecosystem
Deep in this thread, Jp R said
Regarding Perl vs OCaml: An (impressive) implementation of all the solutions of the Perl Cookbook in the Objective CAML language (used at the time) is available here: http://pleac.sourceforge.net/pleac_ocaml/index.html
Re-writing these examples with "modern" code/libraries could be very interesting.
Use GitHub CI to build simple binary distribution?
Christian Lindig asked
Is there a recommended way (or example) to build a simple binary distribution of an OCaml project using the GitHub CI? I am mostly interested in building the executables and packaging them in some archive format and make that available for download for different architectures.
Guillaume Bury replied
I have such a workflow for one of my project, see this workflow
file. It automatically triggers on new
releases, builds the project with the appropriate compiler (e.g. flambda
), and uploads the built artefact to the
release page where it can be downloaded. It currently works for both linux and mac (last time I tried it with windows
I got some errors and I haven't yet had the time to look into that, so i don't know if the errors were caused by the
workflow, or my project).
jbeckford also replied
That was a weird coincidence that I released a GitHub workflow https://discuss.ocaml.org/t/ann-setup-dkml-yml-github-actions-workflow-for-distributing-binaries/10308 for this today. @zozozo's solution is simpler if it works for your intended target audience.
Calascibetta Romain replied
I did the same for my little project bob but it provides a Cosmopolitan binary which should run anywhere, see the workflow and the last uploaded artifact :slight_smile:.
setup-dkml.yml GitHub Actions workflow for distributing binaries
jbeckford announced
I am pleased to announce the `v0` release of `setup-dkml.yml`, a GitHub Actions workflow for distributing executables or libraries to the public:
It is similar to the GitHub Action setup-ocaml but has several advantages when you are releasing a finished product to the public:
- On Linux it uses an ancient GLIBC (C library) so your binaries run on most Linux distributions without static linking. Statically linked binaries are simple to distribute, but can be problematic for some copy-left licenses, and makes it difficult for your end-users to do security patching of the libraries you linked with.
- On Windows it uses the Visual Studio compiler rather than the non-standard (for Windows) GCC compiler. This is a necessity when distributing Windows libraries, and reduces runtime bugs when linking native Windows libraries into your OCaml-built Windows executables. In addition you can generate Windows 32-bit binaries.
- On macOS it can build both ARM64 and x86_64 binaries if you use opam-monorepo to build your project. Alpha-release caution: This works today but only if you hand-edit the .locked file. So only advanced users today!
Even if you are not releasing to the public, if you are a package maintainer you may want to use both setup-ocaml
and setup-dkml
so that you get additional coverage for Visual Studio and MSYS2 on
Windows, and coverage for an older GLIBC on Linux.
The full comparison matrix available at https://github.com/diskuv/dkml-workflows#readme is:
setup-dkml |
setup-ocaml |
Consequence |
---|---|---|
dkml-base-compiler |
ocaml-base-compiler |
setup-dkml only supports 4.12.1 today. setup-ocaml supports all versions and variants of OCaml |
GitHub child workflow | GitHub Action | setup-dkml is more complex to configure, and takes longer to run |
MSVC + MSYS2 | GCC + Cygwin | On Windows setup-dkml can let your native code use ordinary Windows libraries without ABI conflicts. You can also distribute your executables without the license headache of redistributing or statically linking libgcc_s_seh and libstdc++ |
dkml-base-compiler |
ocaml-base-compiler |
On macOS, setup-dkml cross-compiles to ARM64 with dune -x darwin_arm64 |
CentOS 7 and Linux distros from 2014 | Latest Ubuntu | On Linux, setup-dkml builds with an old GLIBC. setup-dkml dynamically linked Linux executables will be highly portable as GLIBC compatibility issues should be rare, and compatible with the unmodified LGPL license used by common OCaml dependencies like GNU MP |
0 yrs | 4 yrs | setup-ocaml is officially supported and well-tested. |
Some pinned packages | No packages pinned | setup-dkml , for some packages, must pin the version so that cross-platform patches (especially for Windows) are available. With setup-ocaml you are free to use any version of any package |
diskuv/diskuv-opam-repository |
fdopen/opam-repository |
Custom patches for Windows are sometimes needed. setup-dkml uses a much smaller set of patches. setup-ocaml uses a large but deprecated set of patches. |
Put simply, use
setup-dkml
when you are distributing executables or libraries to the public. Usesetup-ocaml
for all other needs.
setup-dkml
will setup the following OCaml build environments for you:
ABIs | Native ocamlopt compiler supports building executables for the following operating systems: |
---|---|
win32-windows_x86 | 32-bit Windows [1] for Intel/AMD CPUs |
win32-windows_x86_64 | 64-bit Windows [1] for Intel/AMD CPUs |
macos-darwin_all | 64-bit macOS for Intel and Apple Silicon CPUs. Using dune -x darwin_arm64 will cross-compile to both; otherwise defaults to Intel. |
manylinux2014-linux_x86 | 32-bit Linux: CentOS 7, CentOS 8, Fedora 32+, Mageia 8+, openSUSE 15.3+, Photon OS 4.0+ (3.0+ with updates), Ubuntu 20.04+ |
manylinux2014-linux_x86_64 | 64-bit Linux: CentOS 7, CentOS 8, Fedora 32+, Mageia 8+, openSUSE 15.3+, Photon OS 4.0+ (3.0+ with updates), Ubuntu 20.04+ |
Thanks to the OCaml Software Foundation (OCSF) for their support of DKML. Enjoy!
Diskuv OCaml 1.x.x; Windows OCaml installer no longer in preview
jbeckford announced
Diskuv OCaml (DKML) has graduated to version 1.0.0. That means you'll see DKML listed as a Windows option for OCaml on the various OCaml websites soon.
To recap … by following the simple download and install instructions for Windows you will get:
- OCaml 4.12.1
dune
andopam
working transparently as if you were on Unix- a
playground
Opam switch so you can start coding without having to learn many Opam commands - your Opam switches supported by the Visual Studio OCaml plugin
- all the prerequisites you need for OCaml programming:
- a C compiler and assembler (Visual Studio Build Tools)
- a UNIX environment (MSYS2; mostly you won't see it)
- source control (Git for Windows)
- support! File an issue at https://github.com/diskuv/dkml-installer-ocaml/issues. I don't promise your Windows issue will be fixed, but it will be reviewed.
Changes since 0.4.0:
- An uninstaller. Now you can Add and Remove "Diskuv OCaml" from the Control Panel
- The old GitLab repository at https://gitlab.com/diskuv/diskuv-ocaml is being retired. There will be a new GitLab repository with much more testing capacity that will be online in the next few months.
Full documentation is at https://diskuv.gitlab.io/diskuv-ocaml/#introduction.
Package maintainers: Have a look at the just announced setup-dkml
to test your own GitHub packages using most of the Windows functionality listed above.
Thanks (again!) to the OCaml Software Foundation (OCSF) for their support of DKML. Please consider becoming a contributor to DKML to improve the Windows ecosystem. Enjoy!
Old CWN
If you happen to miss a CWN, you can send me a message and I'll mail it to you, or go take a look at the archive or the RSS feed of the archives.
If you also wish to receive it every week by mail, you may subscribe online.