Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make llvm_bin work for arm and correct llvm archive name #267

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
78 changes: 78 additions & 0 deletions .github/workflows/llvm.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
name: Darwin LLVM build

on:
workflow_dispatch:
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have not tested really this approach, I think it is required to be merged in master, before the button appears in Actions tab.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I think it'll only show up when merged into the main branch.

inputs:
logLevel:
description: 'Log level'
required: false
default: 'warn'
type: choice
options:
- info
- warn
- debug
push:
branches:
- '*build-llvm*'

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

env:
LLVM_VERSION: 15.0.7
MACOSX_DEPLOYMENT_TARGET: 10.11
LOG_LEVEL: ${{ inputs.logLevel || 'warn' }}

jobs:
llvm-build:
runs-on: macos-11
defaults:
run:
working-directory: ./omnibus

steps:
- name: Select Xcode
uses: maxim-lobanov/setup-xcode@v1
with:
xcode-version: '13.2.1'

- name: Download sources
uses: actions/checkout@v4

- name: Update development environment
run: |
brew update
brew install --display-times pkgconfig libtool cmake

- name: Prepare folders
run: |
sudo mkdir -p /opt/llvm
sudo chown $(whoami) /opt/llvm/
sudo mkdir -p /var/cache
sudo chown $(whoami) /var/cache

- name: Install omnibus
run: bundle check || bundle install

- name: Build llvm
run: bundle exec omnibus build llvm --log-level ${{ env.LOG_LEVEL }} --override use_git_caching:false

# Reference: https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#environment-files
- name: Extract the package name to be used for the artifact name
run: |
cd pkg
filename=$(ls -1 llvm-*.tar.gz)
echo "ARTIFACT_NAME=${filename%.tar.gz}" >> "$GITHUB_ENV"

# When an Artifact is uploaded, all the files are assembled into an immutable Zip archive.
# https://github.com/actions/upload-artifact#zip-archives
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: ${{ env.ARTIFACT_NAME }}
path: omnibus/pkg/*.tar.gz
retention-days: 1
if-no-files-found: error
compression-level: 0 # package is already compressed
8 changes: 7 additions & 1 deletion darwin/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,18 @@ The whole process is automated using a `Makefile`.
* `pkgconfig`, `libtool` (Can be installed by `$ brew install pkgconfig libtool`)
* Own `/opt/crystal`, `/var/cache`.

```
```shell
sudo mkdir -p /opt/crystal
sudo chown $(whoami) /opt/crystal/
sudo mkdir -p /var/cache
sudo chown $(whoami) /var/cache
```
* Optional: If you need to build LLVM, ensure the existence of the /opt/llvm directory.

```shell
sudo mkdir -p /opt/llvm
sudo chown $(whoami) /opt/llvm/
```

# Getting started

Expand Down
3 changes: 3 additions & 0 deletions omnibus/config/projects/llvm.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ def valid_cmake_version?

dependency 'cmake' unless valid_cmake_version?
dependency 'llvm'

# Requires for tgz_package to generate a proper archive name with sufix universal.
ohai['target_arch'] = 'universal'
dependency 'tgz_package' if macos? || mac_os_x? || centos?

exclude '\.git*'
Expand Down
6 changes: 5 additions & 1 deletion omnibus/config/software/llvm_bin.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,11 @@
raise "llvm_bin not supported"
end

source url: "http://crystal-lang.s3.amazonaws.com/llvm/llvm-#{version}-#{ohai['os']}-#{ohai['kernel']['machine']}.tar.gz",
platform = ohai['os']
# Currently, it is considered `universal` based on the alterations made in the commit 'ed5f1f97e0a67157d886dd6675902e35199a1ab3'
arch = "x86_64"

source url: "http://crystal-lang.s3.amazonaws.com/llvm/llvm-#{version}-#{platform}-#{arch}.tar.gz",
md5: source_md5

relative_path "llvm-#{version}"
9 changes: 8 additions & 1 deletion omnibus/config/software/tgz_package.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@

build do
block do
platform = ohai['os']
target_arch = ohai['target_arch'] || ohai['kernel']['machine']
destination = File.expand_path('pkg', Omnibus::Config.project_root)
version = "#{project.build_version}-#{project.build_iteration}"
version.gsub!("/", "-")
tgz_name = "#{project.name}-#{version}-#{ohai['os']}-#{ohai['kernel']['machine']}.tar.gz"
tgz_name = "#{project.name}-#{version}-#{platform}-#{target_arch}.tar.gz"
if macos? || mac_os_x?
transform = "-s /./#{project.name}-#{version}/"
else
Expand All @@ -16,5 +18,10 @@

command "tar czf #{destination}/#{tgz_name} #{transform} -C #{install_dir} .",
env: {"COPYFILE_DISABLE" => "1"}

# NOTE: For environments not in English, git_cache function expected to see message
# from git `nothing to commit`, otherwise it raises the error.
# It creates a empty file to commit something.
command "date > #{install_dir}/tgz_package_done.log"
end
end