Allow for unboxed elements at the top-level of modules #23186
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # CYBERSECURITY WARNING: DO NOT give workflows write permission to any source code repo. | |
| # If you want this functionality, ask for help from a subset of: | |
| # @jvanburen @glittershark @mshinwell | |
| name: build | |
| on: | |
| push: | |
| branches: | |
| - main | |
| - '*microbranch' | |
| tags: | |
| - '*' | |
| pull_request: | |
| jobs: | |
| build: | |
| name: ${{ matrix.name }} | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| - name: runtime5 (x86_64-linux) | |
| config: --enable-runtime5 | |
| os: warp-ubuntu-latest-x64-8x | |
| - name: runtime5 stack-checks (x86_64-linux) | |
| config: --enable-runtime5 --enable-stack-checks | |
| os: warp-ubuntu-latest-x64-8x | |
| - name: runtime5 poll-insertion (x86_64-linux) | |
| config: --enable-runtime5 --enable-poll-insertion | |
| os: warp-ubuntu-latest-x64-8x | |
| - name: runtime5 multidomain (x86_64-linux) | |
| config: --enable-runtime5 --enable-stack-checks --enable-poll-insertion --enable-multidomain | |
| os: warp-ubuntu-latest-x64-8x | |
| - name: runtime4 dev (x86_64-linux) | |
| config: --disable-runtime5 --enable-dev | |
| os: warp-ubuntu-latest-x64-8x | |
| - name: runtime5 dev (x86_64-linux) | |
| config: --enable-runtime5 --enable-dev | |
| os: warp-ubuntu-latest-x64-8x | |
| - name: runtime5 debug stack-checks (x86_64-linux) | |
| config: --enable-runtime5 --enable-stack-checks | |
| os: warp-ubuntu-latest-x64-8x | |
| build_ocamlparam: '' | |
| use_runtime: d | |
| ocamlrunparam: "v=0,V=1" | |
| - name: runtime5 debug (x86_64-linux) | |
| config: --enable-runtime5 | |
| os: warp-ubuntu-latest-x64-8x | |
| build_ocamlparam: '' | |
| use_runtime: d | |
| ocamlrunparam: "v=0,V=1" | |
| - name: runtime4 O3 (x86_64-linux) | |
| config: --disable-runtime5 | |
| os: warp-ubuntu-latest-x64-8x | |
| build_ocamlparam: '' | |
| ocamlparam: '_,O3=1' | |
| - name: runtime4 O3 metrics (x86_64-linux) | |
| config: --disable-runtime5 | |
| os: warp-ubuntu-latest-x64-8x | |
| build_ocamlparam: '' | |
| ocamlparam: '_,O3=1' | |
| collect_metrics: true | |
| - name: runtime4 Oclassic frame-pointers poll-insertion flambda-invariants (x86_64-linux) | |
| config: --disable-runtime5 --enable-frame-pointers --enable-poll-insertion --enable-flambda-invariants | |
| os: warp-ubuntu-latest-x64-8x | |
| build_ocamlparam: '' | |
| ocamlparam: '_,Oclassic=1' | |
| disable_testcases: 'testsuite/tests/typing-local/regression_cmm_unboxing.ml testsuite/tests/int64-unboxing/test.ml' | |
| - name: runtime4 (aarch64-darwin) | |
| config: --disable-runtime5 --disable-warn-error | |
| os: warp-macos-15-arm64-6x | |
| - name: runtime5 regalloc (aarch64-darwin) | |
| config: --enable-runtime5 --disable-warn-error | |
| os: warp-macos-15-arm64-6x | |
| build_ocamlparam: '_,w=-46,save-ir-before=register_allocation' | |
| ocamlparam: '_,w=-46,save-ir-before=register_allocation' | |
| run_regalloc_tool: true | |
| - name: runtime5 debug regalloc (aarch64-darwin) | |
| config: --enable-runtime5 --disable-warn-error | |
| os: warp-macos-15-arm64-6x | |
| build_ocamlparam: '_,w=-46,save-ir-before=register_allocation' | |
| ocamlparam: '_,w=-46,save-ir-before=register_allocation' | |
| use_runtime: d | |
| ocamlrunparam: "v=0,V=1" | |
| run_regalloc_tool: true | |
| - name: runtime5 regalloc (aarch64-linux) | |
| config: --enable-runtime5 --disable-warn-error | |
| os: warp-ubuntu-latest-arm64-8x | |
| build_ocamlparam: '_,w=-46,save-ir-before=register_allocation' | |
| ocamlparam: '_,w=-46,save-ir-before=register_allocation' | |
| run_regalloc_tool: true | |
| - name: runtime4 regalloc (x86_64-linux) | |
| config: --disable-runtime5 | |
| os: warp-ubuntu-latest-x64-8x | |
| build_ocamlparam: '_,w=-46,save-ir-before=register_allocation' | |
| ocamlparam: '_,w=-46,save-ir-before=register_allocation' | |
| check_arch: true | |
| run_regalloc_tool: true | |
| - name: runtime5 frame-pointers irc (x86_64-linux) | |
| config: --enable-runtime5 --enable-frame-pointers | |
| os: warp-ubuntu-latest-x64-8x | |
| build_ocamlparam: '_,w=-46,regalloc=irc' | |
| ocamlparam: '_,w=-46,regalloc=irc' | |
| check_arch: true | |
| - name: runtime5 cfg-invariants (x86_64-linux) | |
| config: --enable-runtime5 | |
| os: warp-ubuntu-latest-x64-8x | |
| build_ocamlparam: '_,w=-46,regalloc=cfg,cfg-invariants=1,cfg-eliminate-dead-trap-handlers=1' | |
| ocamlparam: '_,w=-46,regalloc=cfg,cfg-invariants=1,cfg-eliminate-dead-trap-handlers=1' | |
| check_arch: true | |
| - name: runtime5 vectorizer (x86_64-linux) | |
| config: --enable-runtime5 | |
| os: warp-ubuntu-latest-x64-8x | |
| build_ocamlparam: '_,w=-46,regalloc=cfg,vectorize=1' | |
| ocamlparam: '_,w=-46,regalloc=cfg,vectorize=1' | |
| check_arch: true | |
| - name: runtime4 address-sanitizer (x86_64-linux) | |
| config: --disable-runtime5 --enable-address-sanitizer | |
| os: warp-ubuntu-latest-x64-8x | |
| cc: clang | |
| - name: runtime5 address-sanitizer (x86_64-linux) | |
| config: --enable-runtime5 --enable-address-sanitizer | |
| os: warp-ubuntu-latest-x64-8x | |
| cc: clang | |
| - name: runtime5 dwarf-tests (x86_64-linux) | |
| config: --enable-runtime5 | |
| os: warp-ubuntu-latest-x64-8x | |
| dwarf_tests_only: true | |
| oxcaml_llvm_tag: oxcaml-lldb-16.0.6-minus1 | |
| oxcaml_llvm_source_branch: lldb | |
| - name: runtime5 frame-pointers llvmize-tests (x86_64-linux) | |
| config: --enable-runtime5 --enable-frame-pointers | |
| os: warp-ubuntu-latest-x64-8x | |
| llvmize_tests_only: true | |
| oxcaml_llvm_tag: oxcaml-llvmize-16.0.6-minus3 | |
| oxcaml_llvm_source_branch: llvmize-oxcaml | |
| env: | |
| J: "8" | |
| run_testsuite: "true" | |
| steps: | |
| - name: Checkout the OxCaml repo | |
| uses: actions/checkout@master | |
| - name: Install clang (Linux) | |
| if: runner.os == 'Linux' && matrix.cc == 'clang' | |
| run: sudo apt-get install clang | |
| - name: Install autoconf and bash and parallel (macOS) | |
| if: runner.os == 'macOS' | |
| run: HOMEBREW_NO_INSTALL_CLEANUP=TRUE brew install autoconf bash parallel | |
| # bash >=4 is needed for tools/gen_ocamlj_rules.sh | |
| - name: Pretend we're running in a container (makes setup-ocaml go faster) | |
| if: runner.os == 'Linux' | |
| run: sudo touch /.dockerenv | |
| # makes setup-ocaml skip apt-get, which is slow on first invocation | |
| - name: Set up Opam | |
| uses: ocaml/setup-ocaml@v3 | |
| with: | |
| ocaml-compiler: oxcaml-ci-deps.5.2.0 | |
| opam-repositories: | | |
| local: file://${{ github.workspace }}/tools/ci/local-opam | |
| default: https://github.com/ocaml/opam-repository.git | |
| opam-disable-sandboxing: true | |
| opam-pin: false | |
| - name: Set up Opam environment | |
| # this command adds the opam environment to the PATH. | |
| run: | | |
| opam env --set-root --set-switch --shell=cmd | sed -n 's/^set //p' | tee -a "$GITHUB_ENV" | |
| - name: Disable any testcases | |
| run: | | |
| disable_testcases="${{matrix.disable_testcases}}" | |
| if [ -n "$disable_testcases" ]; then | |
| rm -fv $disable_testcases | |
| fi | |
| - name: Configure OxCaml | |
| run: | | |
| if [[ -n "${{matrix.cc}}" ]]; then | |
| export CC="${{matrix.cc}}" | |
| fi | |
| autoconf | |
| ./configure \ | |
| --prefix=$GITHUB_WORKSPACE/_install \ | |
| ${{ matrix.config }} | |
| - name: Setup for saving core files (Linux) | |
| if: runner.os == 'Linux' | |
| run: | | |
| sudo mkdir /cores | |
| sudo chmod 777 /cores | |
| # Core filenames will be of the form executable.pid.timestamp: | |
| sudo bash -c 'echo "/cores/%e.%p.%t" > /proc/sys/kernel/core_pattern' | |
| - name: Setup for saving core files (macOS) | |
| if: runner.os == 'macOS' | |
| run: | | |
| sudo chmod 1777 /cores | |
| sudo sysctl kern.coredump=1 | |
| /usr/libexec/PlistBuddy -c "Add :com.apple.security.get-task-allow bool true" /tmp/core.entitlements | |
| # Find opam's OCaml installation | |
| OCAML_BIN=$(opam var bin) | |
| codesign -s - -f --entitlements /tmp/core.entitlements $OCAML_BIN/ocamlc.opt | |
| codesign -s - -f --entitlements /tmp/core.entitlements $OCAML_BIN/ocamlopt.opt | |
| - name: Build, install and test OxCaml | |
| if: matrix.dwarf_tests_only != true && matrix.llvmize_tests_only != true | |
| run: | | |
| if [ "$run_testsuite" = true ]; then target=ci; else target=compiler; fi | |
| ulimit -c unlimited | |
| make $target \ | |
| || (if [ "$expected_fail" = true ]; then exit 0; else exit 1; fi); | |
| # Install the compiler for metrics_collection configuration to populate _install directory | |
| # This is needed for the metrics collection step to analyze installed artifacts | |
| if [ "${{ matrix.collect_metrics }}" = "true" ]; then | |
| make install | |
| fi | |
| env: | |
| BUILD_OCAMLPARAM: ${{ matrix.build_ocamlparam }} | |
| OCAMLPARAM: ${{ matrix.ocamlparam }} | |
| OCAMLRUNPARAM: ${{ matrix.ocamlrunparam }} | |
| USE_RUNTIME: ${{ matrix.use_runtime }} | |
| - name: Promote failed tests and capture diffs | |
| # Compute the diff for an arbitrary job, we expect all to have the same diff | |
| if: failure() && matrix.name == 'runtime5' | |
| continue-on-error: true | |
| run: | | |
| export PATH=$GITHUB_WORKSPACE/ocaml-414/_install/bin:$PATH | |
| make promote-failed | |
| if ! git diff --quiet; then | |
| git diff > $GITHUB_WORKSPACE/test-diffs.patch | |
| echo "Test output differences detected and saved to artifact" | |
| echo "DIFF_CREATED=true" >> $GITHUB_ENV | |
| else | |
| echo "No test output differences found" | |
| echo "DIFF_CREATED=false" >> $GITHUB_ENV | |
| fi | |
| - name: Install custom OxCaml LLVM | |
| if: matrix.oxcaml_llvm_tag != '' && runner.os == 'Linux' | |
| run: | | |
| # Determine architecture | |
| if [[ "${{ runner.arch }}" == "X64" ]]; then | |
| ARCH="x86_64" | |
| elif [[ "${{ runner.arch }}" == "ARM64" ]]; then | |
| ARCH="aarch64" | |
| else | |
| echo "Unsupported architecture: ${{ runner.arch }}" | |
| exit 1 | |
| fi | |
| OXCAML_LLVM_TAG="${{ matrix.oxcaml_llvm_tag }}" | |
| OXCAML_LLVM_SOURCE_BRANCH="${{ matrix.oxcaml_llvm_source_branch }}" | |
| OXCAML_LLVM_URL="https://github.com/ocaml-flambda/llvm-project/releases/download/${OXCAML_LLVM_TAG}/${OXCAML_LLVM_TAG}-llvm-linux-${ARCH}-${OXCAML_LLVM_SOURCE_BRANCH}.tar.gz" | |
| # Download and extract custom OxCaml LLVM (includes LLDB and other LLVM tools) | |
| cd $GITHUB_WORKSPACE | |
| wget -O oxcaml-llvm.tar.gz "$OXCAML_LLVM_URL" | |
| mkdir -p oxcaml-llvm | |
| tar -xzf oxcaml-llvm.tar.gz -C oxcaml-llvm --strip-components=1 | |
| - name: Build and test OxCaml DWARF | |
| if: matrix.dwarf_tests_only == true && matrix.oxcaml_llvm_tag != '' && runner.os == 'Linux' | |
| run: | | |
| ulimit -c unlimited | |
| make runtest-dwarf | |
| env: | |
| OXCAML_LLDB: ${{ github.workspace }}/oxcaml-llvm/bin/lldb | |
| - name: Promote failed DWARF tests and capture diffs | |
| if: failure() && matrix.dwarf_tests_only == true | |
| continue-on-error: true | |
| run: | | |
| export PATH=$GITHUB_WORKSPACE/ocaml-414/_install/bin:$PATH | |
| make promote | |
| if ! git diff --quiet; then | |
| git diff > $GITHUB_WORKSPACE/test-diffs.patch | |
| echo "Test output differences detected and saved to artifact" | |
| echo "DIFF_CREATED=true" >> $GITHUB_ENV | |
| else | |
| echo "No test output differences found" | |
| echo "DIFF_CREATED=false" >> $GITHUB_ENV | |
| fi | |
| - name: Build and test OxCaml Llvmize | |
| if: matrix.llvmize_tests_only == true && matrix.oxcaml_llvm_tag != '' && runner.os == 'Linux' | |
| run: | | |
| ulimit -c unlimited | |
| make runtest-llvmize | |
| env: | |
| OXCAML_CLANG: ${{ github.workspace }}/oxcaml-llvm/bin/clang | |
| - name: Promote failed llvmize tests and capture diffs | |
| if: failure() && matrix.llvmize_tests_only == true | |
| continue-on-error: true | |
| run: | | |
| export PATH=$GITHUB_WORKSPACE/ocaml-414/_install/bin:$PATH | |
| make promote | |
| if ! git diff --quiet; then | |
| git diff > $GITHUB_WORKSPACE/test-diffs.patch | |
| echo "Test output differences detected and saved to artifact" | |
| echo "DIFF_CREATED=true" >> $GITHUB_ENV | |
| else | |
| echo "No test output differences found" | |
| echo "DIFF_CREATED=false" >> $GITHUB_ENV | |
| fi | |
| - name: Upload test diffs | |
| if: failure() && env.DIFF_CREATED == 'true' | |
| uses: actions/upload-artifact@v4 | |
| continue-on-error: true | |
| with: | |
| name: test-diffs-${{ github.sha }}-${{ github.run_id }}-${{ matrix.name }} | |
| path: ${{ github.workspace }}/test-diffs.patch | |
| - name: Print diff artifact URL | |
| if: failure() && env.DIFF_CREATED == 'true' | |
| continue-on-error: true | |
| env: | |
| GH_TOKEN: ${{ github.token }} | |
| run: | | |
| ARTIFACT_NAME="test-diffs-${{ github.sha }}-${{ github.run_id }}-${{ matrix.name }}" | |
| # Wait a moment for artifact to be registered | |
| sleep 5 | |
| # Get artifact URL from GitHub API | |
| ARTIFACT_URL=$(gh api repos/${{ github.repository }}/actions/runs/${{ github.run_id }}/artifacts \ | |
| --jq ".artifacts[] | select(.name == \"$ARTIFACT_NAME\") | .archive_download_url") | |
| if [ -n "$ARTIFACT_URL" ]; then | |
| COMMAND="./tools/apply-diff.sh $ARTIFACT_URL" | |
| echo "$COMMAND" | |
| else | |
| echo "Artifact uploaded but URL not yet available. Check: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}" | |
| fi | |
| - name: Check other architectures | |
| if: matrix.check_arch == true | |
| run: make check_all_arches | |
| - name: Run register allocation on artifacts | |
| if: matrix.run_regalloc_tool == true | |
| run: | | |
| for allocator in irc ls gi; do \ | |
| ./_build/main/tools/regalloc/regalloc.exe _build \ | |
| -validate -summary -regalloc $allocator || exit 1; \ | |
| done | |
| for allocator in irc ls gi; do \ | |
| ./_build/main/tools/regalloc/regalloc.exe _build \ | |
| -validate -insert-prologue -regalloc $allocator || exit 1; \ | |
| done | |
| for allocator in irc ls gi; do \ | |
| ./_build/main/tools/regalloc/regalloc.exe _build \ | |
| -validate -param SPLIT_AROUND_LOOPS:on -regalloc $allocator || exit 1; \ | |
| done | |
| - name: Collect and push metrics | |
| if: matrix.collect_metrics == true && github.ref == 'refs/heads/main' && github.event_name == 'push' | |
| env: | |
| GH_TOKEN: ${{ secrets.METRICS_REPO_TOKEN }} | |
| COMMIT_MESSAGE: ${{ github.event.head_commit.message }} | |
| run: | | |
| # Checkout metrics repository | |
| gh repo clone oxcaml/oxcaml-metrics metrics-repo | |
| # Create data directory if it doesn't exist | |
| mkdir -p metrics-repo/data | |
| # Determine the actual commit being tested (not the merge commit for PRs) | |
| if [ "${{ github.event_name }}" = "pull_request" ]; then | |
| COMMIT_HASH="${{ github.event.pull_request.head.sha }}" | |
| else | |
| COMMIT_HASH="${{ github.sha }}" | |
| fi | |
| SHORT_HASH="${COMMIT_HASH:0:8}" | |
| DATE=$(date -u +"%Y-%m-%d") | |
| # Extract PR number from commit message | |
| PR_NUMBER=$(echo "$COMMIT_MESSAGE" | grep -oP '\(#\K[0-9]+(?=\))' || echo "N/A") | |
| # CSV filename | |
| CSV_FILE="metrics-repo/data/metrics-${DATE}-${SHORT_HASH}.csv" | |
| # Determine the actual commit being tested (not the merge commit for PRs) | |
| if [ "${{ github.event_name }}" = "pull_request" ]; then | |
| COMMIT_HASH="${{ github.event.pull_request.head.sha }}" | |
| else | |
| COMMIT_HASH="${{ github.sha }}" | |
| fi | |
| # Use the metrics collection script (CSV filename and PR number computed internally) | |
| python3 ${{ github.workspace }}/scripts/collect-size-metrics.py \ | |
| "${{ github.workspace }}/_install" \ | |
| "metrics-repo/data" \ | |
| "$COMMIT_HASH" \ | |
| "$COMMIT_MESSAGE" \ | |
| --verbose | |
| # Commit and push metrics | |
| cd metrics-repo | |
| git config user.name "github-actions[bot]" | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| # Configure git to use gh for authentication | |
| git config --local credential.helper "" | |
| git config --local credential.https://github.com.helper "!gh auth git-credential" | |
| git add data/ | |
| git commit -m "Add metrics for commit ${COMMIT_HASH}" | |
| git push | |
| - name: Upload core dumps | |
| uses: actions/upload-artifact@v4 | |
| if: failure() | |
| with: | |
| name: cores-${{ github.sha }}-${{ github.run_id }}-${{ matrix.name }} | |
| path: /cores | |
| - name: Upload DiagnosticReports (macOS) | |
| uses: actions/upload-artifact@v4 | |
| if: failure() && runner.os == 'macOS' | |
| with: | |
| name: DiagnosticReports-${{ github.sha }}-${{ github.run_id }}-${{ matrix.name }} | |
| path: /Users/runner/Library/Logs/DiagnosticReports | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} | |
| cancel-in-progress: true |