Skip to content

Commit 8f2ab59

Browse files
committed
llvm_bin uses same universal darwin archive for arm as for x86_64.
Allow to override target architecture sufix in archive name in tgz_package. tgz_package uses build platform for naming archives. When build packages for multiple architectures like x86_64 and arm, then the archive name is not correct. Update the script of tgz_package to check for configuration option `ohai['target_arch']` as target arch name. It allows to specify architecture in project like: ``` ohai['target_arch'] = 'universal' dependency 'tgz_package' ``` Presenting GitHub Actions as an efficient solution for building LLVM from the ground up, seamlessly replicating the functionality of CircleCI. Unlike the extended duration of the CircleCI task, a new GitHub Actions workflow ensures a comprehensive build of LLVM, addressing time limitations and guaranteeing the successful completion of the package build process.
1 parent 9d6e645 commit 8f2ab59

File tree

5 files changed

+101
-3
lines changed

5 files changed

+101
-3
lines changed

.github/workflows/llvm.yml

+78
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
name: Darwin LLVM build
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
logLevel:
7+
description: 'Log level'
8+
required: false
9+
default: 'warn'
10+
type: choice
11+
options:
12+
- info
13+
- warn
14+
- debug
15+
push:
16+
branches:
17+
- '*build-llvm*'
18+
19+
concurrency:
20+
group: ${{ github.workflow }}-${{ github.ref }}
21+
cancel-in-progress: true
22+
23+
env:
24+
LLVM_VERSION: 15.0.7
25+
MACOSX_DEPLOYMENT_TARGET: 10.11
26+
LOG_LEVEL: ${{ inputs.logLevel || 'warn' }}
27+
28+
jobs:
29+
llvm-build:
30+
runs-on: macos-11
31+
defaults:
32+
run:
33+
working-directory: ./omnibus
34+
35+
steps:
36+
- name: Select Xcode
37+
uses: maxim-lobanov/setup-xcode@v1
38+
with:
39+
xcode-version: '13.2.1'
40+
41+
- name: Download sources
42+
uses: actions/checkout@v4
43+
44+
- name: Update development environment
45+
run: |
46+
brew update
47+
brew install --display-times pkgconfig libtool cmake
48+
49+
- name: Prepare folders
50+
run: |
51+
sudo mkdir -p /opt/llvm
52+
sudo chown $(whoami) /opt/llvm/
53+
sudo mkdir -p /var/cache
54+
sudo chown $(whoami) /var/cache
55+
56+
- name: Install omnibus
57+
run: bundle check || bundle install
58+
59+
- name: Build llvm
60+
run: bundle exec omnibus build llvm --log-level ${{ env.LOG_LEVEL }} --override use_git_caching:false
61+
62+
# Reference: https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#environment-files
63+
- name: Extract the package name to be used for the artifact name
64+
run: |
65+
cd pkg
66+
filename=$(ls -1 llvm-*.tar.gz)
67+
echo "ARTIFACT_NAME=${filename%.tar.gz}" >> "$GITHUB_ENV"
68+
69+
# When an Artifact is uploaded, all the files are assembled into an immutable Zip archive.
70+
# https://github.com/actions/upload-artifact#zip-archives
71+
- name: Upload artifact
72+
uses: actions/upload-artifact@v4
73+
with:
74+
name: ${{ env.ARTIFACT_NAME }}
75+
path: omnibus/pkg/*.tar.gz
76+
retention-days: 1
77+
if-no-files-found: error
78+
compression-level: 0 # package is already compressed

darwin/README.md

+7-1
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,18 @@ The whole process is automated using a `Makefile`.
99
* `pkgconfig`, `libtool` (Can be installed by `$ brew install pkgconfig libtool`)
1010
* Own `/opt/crystal`, `/var/cache`.
1111

12-
```
12+
```shell
1313
sudo mkdir -p /opt/crystal
1414
sudo chown $(whoami) /opt/crystal/
1515
sudo mkdir -p /var/cache
1616
sudo chown $(whoami) /var/cache
1717
```
18+
* Optional: If you need to build LLVM, ensure the existence of the /opt/llvm directory.
19+
20+
```shell
21+
sudo mkdir -p /opt/llvm
22+
sudo chown $(whoami) /opt/llvm/
23+
```
1824

1925
# Getting started
2026

omnibus/config/projects/llvm.rb

+3
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ def valid_cmake_version?
1818

1919
dependency 'cmake' unless valid_cmake_version?
2020
dependency 'llvm'
21+
22+
# Requires for tgz_package to generate a proper archive name with sufix universal.
23+
ohai['target_arch'] = 'universal'
2124
dependency 'tgz_package' if macos? || mac_os_x? || centos?
2225

2326
exclude '\.git*'

omnibus/config/software/llvm_bin.rb

+5-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,11 @@
1818
raise "llvm_bin not supported"
1919
end
2020

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

2428
relative_path "llvm-#{version}"

omnibus/config/software/tgz_package.rb

+8-1
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,12 @@
44

55
build do
66
block do
7+
platform = ohai['os']
8+
target_arch = ohai['target_arch'] || ohai['kernel']['machine']
79
destination = File.expand_path('pkg', Omnibus::Config.project_root)
810
version = "#{project.build_version}-#{project.build_iteration}"
911
version.gsub!("/", "-")
10-
tgz_name = "#{project.name}-#{version}-#{ohai['os']}-#{ohai['kernel']['machine']}.tar.gz"
12+
tgz_name = "#{project.name}-#{version}-#{platform}-#{target_arch}.tar.gz"
1113
if macos? || mac_os_x?
1214
transform = "-s /./#{project.name}-#{version}/"
1315
else
@@ -16,5 +18,10 @@
1618

1719
command "tar czf #{destination}/#{tgz_name} #{transform} -C #{install_dir} .",
1820
env: {"COPYFILE_DISABLE" => "1"}
21+
22+
# NOTE: For environments not in English, git_cache function expected to see message
23+
# from git `nothing to commit`, otherwise it raises the error.
24+
# It creates a empty file to commit something.
25+
command "date > #{install_dir}/tgz_package_done.log"
1926
end
2027
end

0 commit comments

Comments
 (0)