Skip to content

Commit

Permalink
flambda-backend: Merge ocaml-jst
Browse files Browse the repository at this point in the history
  • Loading branch information
mshinwell committed Oct 24, 2022
2 parents 115083b + 05e2ed4 commit e501946
Show file tree
Hide file tree
Showing 41 changed files with 7,027 additions and 5,727 deletions.
10 changes: 10 additions & 0 deletions .depend
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,7 @@ parsing/ast_mapper.cmo : \
utils/load_path.cmi \
utils/config.cmi \
utils/clflags.cmi \
parsing/builtin_attributes.cmi \
parsing/asttypes.cmi \
parsing/ast_helper.cmi \
parsing/ast_mapper.cmi
Expand All @@ -276,6 +277,7 @@ parsing/ast_mapper.cmx : \
utils/load_path.cmx \
utils/config.cmx \
utils/clflags.cmx \
parsing/builtin_attributes.cmx \
parsing/asttypes.cmi \
parsing/ast_helper.cmx \
parsing/ast_mapper.cmi
Expand All @@ -287,11 +289,13 @@ parsing/asttypes.cmi : \
parsing/attr_helper.cmo : \
parsing/parsetree.cmi \
parsing/location.cmi \
parsing/builtin_attributes.cmi \
parsing/asttypes.cmi \
parsing/attr_helper.cmi
parsing/attr_helper.cmx : \
parsing/parsetree.cmi \
parsing/location.cmx \
parsing/builtin_attributes.cmx \
parsing/asttypes.cmi \
parsing/attr_helper.cmi
parsing/attr_helper.cmi : \
Expand All @@ -307,6 +311,7 @@ parsing/builtin_attributes.cmo : \
utils/config.cmi \
utils/clflags.cmi \
parsing/asttypes.cmi \
parsing/ast_helper.cmi \
parsing/builtin_attributes.cmi
parsing/builtin_attributes.cmx : \
utils/warnings.cmx \
Expand All @@ -317,6 +322,7 @@ parsing/builtin_attributes.cmx : \
utils/config.cmx \
utils/clflags.cmx \
parsing/asttypes.cmi \
parsing/ast_helper.cmx \
parsing/builtin_attributes.cmi
parsing/builtin_attributes.cmi : \
parsing/parsetree.cmi \
Expand Down Expand Up @@ -448,6 +454,7 @@ parsing/parser.cmo : \
parsing/docstrings.cmi \
utils/clflags.cmi \
parsing/camlinternalMenhirLib.cmi \
parsing/builtin_attributes.cmi \
parsing/asttypes.cmi \
parsing/ast_helper.cmi \
parsing/parser.cmi
Expand All @@ -460,6 +467,7 @@ parsing/parser.cmx : \
parsing/docstrings.cmx \
utils/clflags.cmx \
parsing/camlinternalMenhirLib.cmx \
parsing/builtin_attributes.cmx \
parsing/asttypes.cmi \
parsing/ast_helper.cmx \
parsing/parser.cmi
Expand Down Expand Up @@ -3522,6 +3530,7 @@ lambda/translattribute.cmo : \
parsing/location.cmi \
lambda/lambda.cmi \
utils/config.cmi \
parsing/builtin_attributes.cmi \
lambda/translattribute.cmi
lambda/translattribute.cmx : \
utils/warnings.cmx \
Expand All @@ -3532,6 +3541,7 @@ lambda/translattribute.cmx : \
parsing/location.cmx \
lambda/lambda.cmx \
utils/config.cmx \
parsing/builtin_attributes.cmx \
lambda/translattribute.cmi
lambda/translattribute.cmi : \
typing/typedtree.cmi \
Expand Down
110 changes: 110 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
name: build
on: [push, pull_request]
jobs:
build:
name: ${{ matrix.name }}
runs-on: ${{ matrix.os }}

strategy:
fail-fast: false
matrix:
include:
- name: closure-nnp-local
config: --enable-stack-allocation
os: ubuntu-latest
ocamlparam: ''
check_arch: true

- name: flambda-local
config: --enable-flambda --enable-stack-allocation
os: ubuntu-latest

- name: i386
config: CC='cc32' AS='as --32' ASPP='gcc -m32 -c' -host i386-linux PARTIALLD='ld -r -melf_i386'
os: ubuntu-latest
ocamlparam: ''
boot_config: CC='cc32' AS='as --32' ASPP='gcc -m32 -c' -host i386-linux PARTIALLD='ld -r -melf_i386'
boot_cachekey: 32bit

env:
J: "3"

steps:
- name: Install GNU parallel
if: matrix.os == 'macos-latest'
run: HOMEBREW_NO_INSTALL_CLEANUP=TRUE brew install parallel

- name: Install GCC 32-bit libraries
if: matrix.name == 'i386'
run: |
sudo apt-get install gcc-multilib gfortran-multilib
- name: Checkout the ocaml-jst repo
uses: actions/checkout@master
with:
path: 'ocaml-jst'

- name: Cache OCaml 4.12 and dune
uses: actions/cache@v1
id: cache
with:
path: ${{ github.workspace }}/ocaml-412/_install
key: ${{ matrix.os }}-cache-ocaml-412-dune-341-bits-${{ matrix.boot_cachekey }}

- name: Checkout OCaml 4.12
uses: actions/checkout@master
if: steps.cache.outputs.cache-hit != 'true'
with:
repository: 'ocaml/ocaml'
path: 'ocaml-412'
ref: '4.12'

- name: Setup 32-bit C compiler
if: matrix.name == 'i386' && steps.cache.outputs.cache-hit != 'true'
run: |
mkdir -p ocaml-412/_install/bin
{ echo '#!/bin/sh'; echo 'exec gcc -m32 "$@"'; } > ocaml-412/_install/bin/cc32
chmod +x ocaml-412/_install/bin/cc32
- name: Build OCaml 4.12
if: steps.cache.outputs.cache-hit != 'true'
working-directory: ocaml-412
run: |
export PATH=$GITHUB_WORKSPACE/ocaml-412/_install/bin:$PATH
./configure --prefix=$GITHUB_WORKSPACE/ocaml-412/_install ${{ matrix.boot_config }}
make -j $J world.opt
make install
# Remove unneeded parts to shrink cache file
rm -rf $GITHUB_WORKSPACE/ocaml-412/_install/{lib/ocaml/compiler-libs,lib/ocaml/expunge,bin/*.byte}
- name: Checkout dune github repo
uses: actions/checkout@master
if: steps.cache.outputs.cache-hit != 'true'
with:
repository: 'ocaml/dune'
ref: '3.4.1'
path: 'dune'

- name: Build dune
working-directory: dune
if: steps.cache.outputs.cache-hit != 'true'
run: |
PATH=$GITHUB_WORKSPACE/ocaml-412/_install/bin:$PATH make release
cp dune.exe $GITHUB_WORKSPACE/ocaml-412/_install/bin/dune
- name: Configure OCaml
working-directory: ocaml-jst
run: |
export PATH=$GITHUB_WORKSPACE/ocaml-412/_install/bin:$PATH
autoconf
./configure \
--prefix=$GITHUB_WORKSPACE/_install \
${{ matrix.config }}
- name: Build, install and test ocaml-jst
working-directory: ocaml-jst
run: |
export PATH=$GITHUB_WORKSPACE/ocaml-412/_install/bin:$PATH
make -f Makefile.jst runtest-upstream
env:
BUILD_OCAMLPARAM: ${{ matrix.ocamlparam }}
107 changes: 0 additions & 107 deletions .github/workflows/main.yml

This file was deleted.

4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@ _build
/ocamlopt.opt
/ocamlnat
/dirs-to-ignore.inc
/dune-project
/*.sexp
/_install
/_runtest

# specific files and patterns in sub-directories

Expand Down
30 changes: 30 additions & 0 deletions HACKING.jst.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
= Hacking on ocaml-jst

ocaml-jst has a dune-based build system which is different from
upstream OCaml. To get started, you'll need a working install of OCaml
4.12 and dune, e.g. via OPAM:

$ opam switch create 4.12.0
$ eval $(opam env)
$ opam install dune

You should also install merlin:

$ opam install merlin

and follow its instructions for how to set up your editor.

Once you have OCaml and dune, you can build and test ocaml-jst with:

$ ./configure --prefix=/where/to/install
$ make -f Makefile.jst runtest-upstream

Other useful Makefile targets are:

$ make -f Makefile.jst compiler

to build without running the testsuite, or:

$ make -f Makefile.jst hacking

to start a continuously polling build of the compiler.
7 changes: 6 additions & 1 deletion Makefile.common-jst
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,11 @@ runtest-upstream: _install
mkdir _runtest/tools
ln -s ../_install/bin/ocamlmklib.byte _runtest/tools/ocamlmklib
ln -s ../_install/bin/ocamlobjinfo.byte _runtest/tools/ocamlobjinfo
# ocamldoc
rm _runtest/ocamldoc
mkdir _runtest/ocamldoc
ln -s ../../_install/bin/ocamldoc.byte _runtest/ocamldoc/ocamldoc
cp $(main_build)/$(ocamldir)/ocamldoc/.odoc_lib.objs/byte/*.cm* _runtest/ocamldoc
# ocamltest itself
mkdir _runtest/ocamltest
cp $(main_build)/$(ocamldir)/ocamltest/ocamltest.byte _runtest/ocamltest/ocamltest
Expand Down Expand Up @@ -280,4 +285,4 @@ runtest-upstream: _install
# This target is like a polling version of upstream "make ocamlopt"
.PHONY: hacking
hacking: _build/_bootinstall
$(dune) build $(ws_boot) -w boot_ocamlopt.exe
$(dune) build $(ws_boot) -w $(boot_ocamlopt)
1 change: 1 addition & 0 deletions Makefile.config.in
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,7 @@ STDLIB_MANPAGES=@stdlib_manpages@
NAKED_POINTERS=@naked_pointers@
INTEL_JCC_BUG_CFLAGS=@intel_jcc_bug_cflags@
STACK_ALLOCATION=@stack_allocation@
DUNE=@dune@

### Native command to build ocamlrun.exe

Expand Down
32 changes: 32 additions & 0 deletions Makefile.jst
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
SHELL = /usr/bin/env bash
include Makefile.config
export ARCH


ifeq ($(shell test -x '$(DUNE)' || echo fail), fail)
$(error Dune not found. Run ./configure --with-dune=/path/to/dune.exe (See HACKING.jst))
endif

dune = $(DUNE)

ifeq ($(shell which ocamlopt >& /dev/null || echo fail), fail)
$(error ocamlopt not found. See HACKING.jst)
endif

boot_ocamlc = main_native.exe
boot_ocamlopt = optmain_native.exe
boot_ocamlmklib = tools/ocamlmklib.exe
boot_ocamldep = tools/ocamldep.exe
boot_ocamlobjinfo = tools/objinfo.exe
ocamldir = .
#toplevels_installed = top opttop
toplevels_installed = top


dune-project: dune-project.jst
cp $^ $@

duneconf/jst-extra.inc:
echo '(include ../jst.dune)' > $@

include Makefile.common-jst
Loading

0 comments on commit e501946

Please sign in to comment.