Disable shared to avoid linking error #137
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
| name: Cross compilers | |
| on: | |
| push: | |
| pull_request: | |
| types: [opened, synchronize, reopened, labeled, unlabeled] | |
| workflow_dispatch: | |
| # Restrict the GITHUB_TOKEN | |
| permissions: {} | |
| # See build.yml | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref }}-${{ github.event_name == 'pull_request' || github.sha }} | |
| cancel-in-progress: true | |
| env: | |
| res: 0 | |
| TESTDIR: >- | |
| C:\Бактріан🐫 | |
| STR_UTF8: >- | |
| "C:\\Бактріан🐫" | |
| STR_UTF16: >- | |
| L"C:\\\x0411\x0430\x043a\x0442\x0440\x0456\x0430\x043d\xd83d\xdc2b" | |
| EXAMPLE_PROGRAM: | | |
| let _ = | |
| Printf.printf "Version: %s\nOS: %s\nUnix: %b\nWin: %b\nCygwin: %b\n" | |
| Sys.ocaml_version Sys.os_type Sys.unix Sys.win32 Sys.cygwin | |
| COMPLIBS_PROG_X86_64: | | |
| let _ = | |
| Printf.printf "allow_unaligned_access = %b\n" Arch.allow_unaligned_access; | |
| Printf.printf "win64 = %b\n" Arch.win64 | |
| COMPLIBS_PROG_AARCH64: | | |
| let _ = | |
| Printf.printf "allow_unaligned_access = %b\n" Arch.allow_unaligned_access; | |
| Printf.printf "macosx = %b\n" Arch.macosx | |
| jobs: | |
| non-cross: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout OCaml | |
| uses: actions/checkout@v4 | |
| with: | |
| persist-credentials: false | |
| - name: Configure, build and install OCaml | |
| run: | | |
| PREFIX="$HOME/.local" | |
| echo "$PREFIX/bin" >> "$GITHUB_PATH" | |
| set -x | |
| ./configure --disable-warn-error --disable-ocamldoc \ | |
| --disable-ocamltest --disable-stdlib-manpages \ | |
| --disable-dependency-generation --prefix="$PREFIX" || res=$? | |
| if ! [ "$res" = 0 ]; then cat config.log; exit "$res"; fi | |
| make -j | |
| make install | |
| cd "$HOME" | |
| tar caf /tmp/ocaml.tar.zst .local | |
| - name: Upload Artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: non-cross-ocaml | |
| path: /tmp/ocaml.tar.zst | |
| retention-days: 1 | |
| cross-arm-macos-zig: | |
| runs-on: ubuntu-latest | |
| needs: non-cross | |
| env: | |
| ZIGPATH: /home/runner/zig | |
| ZIGURL: https://ziglang.org/download/0.13.0/zig-linux-x86_64-0.13.0.tar.xz | |
| TARGET: aarch64-apple-darwin | |
| ZTARGET: aarch64-macos | |
| steps: | |
| - name: Download Artifact | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: non-cross-ocaml | |
| - name: Install non-cross OCaml and set up environment | |
| run: | | |
| set -x | |
| tar xaf ocaml.tar.zst -C "$HOME" | |
| rm -f ocaml.tar.zst | |
| echo "$HOME/.local/bin" >> "$GITHUB_PATH" | |
| echo "$ZIGPATH" >> "$GITHUB_PATH" | |
| - name: Restore the zig compiler from cache | |
| uses: actions/cache/restore@v4 | |
| id: cache | |
| with: | |
| path: | | |
| ${{ env.ZIGPATH }} | |
| key: zig | |
| - name: Download the zig compiler | |
| run: | | |
| set -x | |
| mkdir "$ZIGPATH" | |
| cd "$ZIGPATH" | |
| wget --no-verbose -O zig.tar.xz "$ZIGURL" | |
| tar xvaf zig.tar.xz --strip-components=1 | |
| rm zig.tar.xz | |
| if: steps.cache.outputs.cache-hit != 'true' | |
| - name: Save the zig compiler to cache | |
| uses: actions/cache/save@v4 | |
| with: | |
| path: | | |
| ${{ env.ZIGPATH }} | |
| key: zig | |
| if: steps.cache.outputs.cache-hit != 'true' | |
| - name: Checkout OCaml | |
| uses: actions/checkout@v4 | |
| with: | |
| submodules: true | |
| persist-credentials: false | |
| - name: Configure, build and install the cross OCaml | |
| run: | | |
| set -x | |
| ./configure --prefix="$HOME/cross" --target=$TARGET \ | |
| CC="zig cc --target=$ZTARGET" \ | |
| PARTIALLD="zig cc --target=$ZTARGET -r" \ | |
| AR="zig ar" STRIP=: \ | |
| --disable-shared \ | |
| || res=$? | |
| if ! [ "$res" = 0 ]; then cat config.log; exit "$res"; fi | |
| make crossopt -j | |
| make installcross | |
| - name: Show opt.opt configuration | |
| run: | | |
| set -x | |
| $HOME/cross/bin/ocamlopt.opt -config | |
| cat runtime/build_config.h | |
| - name: Cross compile a small program | |
| run: | | |
| printf %s "$EXAMPLE_PROGRAM$COMPLIBS_PROG_AARCH64" > example.ml | |
| set -x | |
| cat example.ml | |
| $HOME/cross/bin/ocamlopt.opt -I $HOME/cross/lib/ocaml/compiler-libs/ ocamlcommon.cmxa ocamloptcomp.cmxa example.ml -o example -verbose |