Skip to content

Commit

Permalink
Add scripts for MacOS X for ARM compiler
Browse files Browse the repository at this point in the history
  • Loading branch information
reznikmm committed Mar 13, 2024
1 parent 6b80b8c commit ee03679
Show file tree
Hide file tree
Showing 5 changed files with 169 additions and 7 deletions.
128 changes: 128 additions & 0 deletions .github/workflows/macos_arm.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
name: macOS_arm
on:
pull_request:


jobs:
gnat_gprbuild:
name: GNAT macOS
runs-on: macos-14
steps:
- name: Checkout Project
uses: actions/checkout@v2

- name: Install texinfo with Homebrew
run: brew install texinfo

- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: 3.10.11

- name: Install Python dependencies
run: |
python -m pip install --upgrade pip
pip install e3-core==22.1.0
- name: Build GNAT native
run: ./anod build gcc -v --loglevel DEBUG --enable-cleanup

- name: Build GDB
run: ./anod build gdb -v --loglevel DEBUG --enable-cleanup

- name: Package GNAT
run: ./anod build release_package --qualifier=package=gnat,do_gh_release -v --loglevel DEBUG
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # for GitHub CLI tool

- name: Build GPRbuild
run: ./anod build gprbuild -v --loglevel DEBUG --enable-cleanup

- name: Package GPRbuild
run: ./anod build release_package --qualifier=package=gprbuild,do_gh_release -v --loglevel DEBUG
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # for GitHub CLI tool

- uses: actions/upload-artifact@v2
with:
name: anod-artifacts
path: out_artifacts/*
retention-days: 1

- uses: actions/upload-artifact@v2
with:
name: release-packages
path: sbx/*/release_package*/install/*
retention-days: 5



why3:
strategy:
matrix:
ocaml-compiler:
- 4.12.1
runs-on: macos-14
steps:
- name: Checkout code
uses: actions/checkout@v2
with:
repository: 'adacore/why3'
ref: 'fsf-13'

- name: Use Setup OCaml {{ matrix.ocaml-version }}
uses: ocaml/setup-ocaml@v2
with:
ocaml-compiler: ${{ matrix.ocaml-compiler}}

- name: Setup Packages
run: |
opam depext zarith re seq why3
opam install dune dune-configurator menhir num ocamlgraph re seq yojson zarith sexplib ppx_sexp_conv ppx_deriving
- run: opam exec -- ./configure --prefix=/tmp/why3install --enable-relocation --disable-emacs-compilation --disable-hypothesis-selection --disable-js-of-ocaml --disable-zip

- run: opam exec -- make

- run: opam exec -- make install_spark2014

- run: git log --format="%H" -n 1 > /tmp/why3install/why3-version.txt

- name: Upload the build artifact
uses: actions/upload-artifact@v2
with:
name: why3
path: /tmp/why3install


alt_ergo:
strategy:
matrix:
ocaml-compiler:
- 4.12.1

runs-on: macos-14
steps:
- name: Checkout code
uses: actions/checkout@v2
with:
repository: 'adacore/alt-ergo'
ref: 'master'

- name: Use Setup OCaml {{ matrix.ocaml-version }}
uses: ocaml/setup-ocaml@v2
with:
ocaml-compiler: ${{ matrix.ocaml-compiler }}

- run: opam install alt-ergo --destdir=/tmp/alt-ergo-install

- run: git log --format="%H" -n 1 > /tmp/alt-ergo-install/alt-ergo-version.txt

- name: Upload the build artifact
uses: actions/upload-artifact@v2
with:
name: alt-ergo
path: /tmp/alt-ergo-install



3 changes: 3 additions & 0 deletions lib/platform_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ def update_db(self) -> None:
self.host_guess.pop("x86-windows")
self.host_guess.update(
{
"aarch64-darwin": {"os": "Darwin", "cpu": "arm64"},
"x86_64-windows64": {
"os": "Windows",
"cpu": "AMD64",
Expand All @@ -32,6 +33,7 @@ def update_db(self) -> None:

self.platform_info.update(
{
"aarch64-darwin": {"cpu": "aarch64", "os": "darwin", "is_hie": False},
"riscv32-elf": {"cpu": "riscv32", "os": "none", "is_hie": True},
"riscv64-elf": {"cpu": "riscv64", "os": "none", "is_hie": True},
"riscv32-unknown-elf": {"cpu": "riscv32", "os": "none", "is_hie": True},
Expand All @@ -41,6 +43,7 @@ def update_db(self) -> None:

self.build_targets.update(
{
"aarch64-darwin": {"name": "aarch64-apple-darwin%(os_version)s"},
"riscv32-elf": {"name": "riscv32-elf"},
"riscv64-elf": {"name": "riscv64-elf"},
"riscv32-unknown-elf": {"name": "riscv32-unknown-elf"},
Expand Down
9 changes: 6 additions & 3 deletions specs/base_gcc.anod
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,16 @@ class base_gcc(spec("common")):

@property
def tarball(self):
return "gnat-%s-%s.tar.gz" % (self.env.platform, self.version)
return "gnat-macos-aarch64-13.2.1.tar.gz"
# To be reverted after the bootstrap
# return "gnat-%s-%s.tar.gz" % (self.env.platform, self.version)

@property
def url(self):
return (
"https://github.com/alire-project/GNAT-FSF-builds/releases/download/gnat-%s/%s"
% (self.version, self.tarball)
"https://github.com/simonjwright/alire-index.mac/releases/download/toolchain-13.2.1/gnat-macos-aarch64-13.2.1.tar.gz"
# "https://github.com/reznikmm/GNAT-FSF-builds/releases/download/gnat-%s/%s"
# % (self.version, self.tarball)
)

@Anod.primitive()
Expand Down
26 changes: 22 additions & 4 deletions specs/gcc.anod
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ from e3.anod.loader import spec
from e3.env import Env
import os

# A wrapper to call ld-classic on MacOS X
patch_name = "ld"

class GCC(spec("gh-artifact")):
@property
Expand All @@ -21,14 +23,24 @@ class GCC(spec("gh-artifact")):
return [
self.HTTPSSourceBuilder(
name=self.tarball,
url="https://ftp.gnu.org/gnu/gcc/gcc-%s/%s"
% (self.version, self.tarball),
)
url=(
"https://ftp.gnu.org/gnu/gcc/gcc-%s/%s"
% (self.version, self.tarball)
if self.env.target.cpu.name == "x86_64"
else
"https://github.com/iains/gcc-13-branch/archive/refs/"
+ "tags/gcc-13.2-darwin-r0.tar.gz"
)
),
self.LocalSourceBuilder(name=patch_name)
]

@property
def build_source_list(self):
return [Anod.Source(name=self.tarball, publish=True, dest="")]
return [
Anod.Source(name=self.tarball, publish=True, dest=""),
self.Source(name=patch_name, publish=True, unpack_cmd=cp, dest="patches")
]

@property
def bootstrap(self):
Expand Down Expand Up @@ -287,4 +299,10 @@ class GCC(spec("gh-artifact")):
delete=False,
)

# Add ld-classic wrapper
if self.env.target.os.name == "darwin":
cp(
os.path.join(self["SRC_DIR"], "patches", patch_name),
os.path.join(self["INSTALL_DIR"], "libexec", "gcc", "aarch64-apple-darwin23.2.0", self.version),
)
self.clean()
10 changes: 10 additions & 0 deletions specs/patches/ld
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/sh

classic=$(xcrun --find ld-classic 2>/dev/null) || true

if [ -n "$classic" ]; then
exec $classic "$@"
else
exec ld "$@"
fi

0 comments on commit ee03679

Please sign in to comment.