Skip to content

Commit 4c84b5f

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 4c84b5f

File tree

5 files changed

+102
-3
lines changed

5 files changed

+102
-3
lines changed

.github/workflows/llvm.yml

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