Skip to content

Commit 6d4e3bb

Browse files
authored
Use portions of LLVM (assembler, strip) and GNU gold (#1)
GNU Binutils have problems dealing with diacritic characters on Windows platform. Fixing the issue in the Binutils codebase is not straightforward, so we decided to use portions of the LLVM toolchain (`llvm-mc`, the assembler, and `llvm-objcopy` which doubles as `strip`) instead, since they don't have said problem with diacritcs. The initial plan was to switch the linker to LLVM's `lld` as well, but since its binary comes up at 70mb (twice that on mac, with two architectures) we decided to keep using GNU ld (`gold`) for the moment. In order to maintain compatibility with Mono AOT and Xamarin.Android, it was necessary to develop a GNU Assembler (`gas`) wrapper around `llvm-mc`. Implement build and packaging for LLVM, GNU Binutils and XA own utilities.
1 parent a9cf720 commit 6d4e3bb

37 files changed

+2464
-134
lines changed

.github/workflows/ci.yml

Lines changed: 226 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: CI
22
env:
3-
BINUTILS_VERSION: 2.35.2
3+
BUILD_DIR: xa-build
44

55
on:
66
push:
@@ -11,99 +11,284 @@ on:
1111
workflow_dispatch:
1212

1313
jobs:
14-
build_linux:
15-
runs-on: ubuntu-18.04
14+
build_llvm_linux:
15+
runs-on: ubuntu-20.04
1616
steps:
1717
- uses: actions/checkout@v2
18+
with:
19+
submodules: recursive
20+
21+
- name: Install LLVM build dependencies
22+
run: >-
23+
sudo apt-get update;
24+
sudo apt-get -f -u install cmake ninja-build chrpath texinfo sharutils libffi-dev
25+
lsb-release patchutils diffstat xz-utils python3-dev libedit-dev libncurses5-dev swig
26+
python3-six python3-sphinx binutils-dev libxml2-dev libjsoncpp-dev pkg-config lcov
27+
procps help2man zlib1g-dev g++-multilib libjs-mathjax python3-recommonmark libpfm4-dev
28+
python3-setuptools libz3-dev ccache
29+
30+
- name: build Linux LLVM
31+
run: ./build-llvm.sh
32+
33+
- name: package LLVM config and build logs
34+
if: ${{ always() }}
35+
run: find ${BUILD_DIR} -name 'config.*' -o -name '*.log' -o -name 'CMakeCache.txt' | zip -9 build-logs-linux-llvm.zip -@
36+
37+
- name: upload LLVM config and build logs
38+
if: ${{ always() }}
39+
uses: actions/upload-artifact@v2
40+
with:
41+
name: build-logs
42+
path: build-logs-linux-llvm.zip
43+
44+
- name: package LLVM artifacts
45+
run: tar cjf artifacts-linux-llvm.tar.bz2 artifacts
46+
47+
- name: upload Linux LLVM artifacts
48+
uses: actions/upload-artifact@v2
49+
with:
50+
name: linux
51+
path: artifacts-linux-llvm.tar.bz2
52+
53+
build_binutils_linux:
54+
runs-on: ubuntu-20.04
55+
steps:
56+
- uses: actions/checkout@v2
57+
with:
58+
submodules: recursive
59+
60+
- name: Install Binutils build dependencies
61+
run: >-
62+
sudo apt-get update;
63+
sudo apt-get -f -u install mingw-w64 autoconf gettext texinfo dwz xz-utils zlib1g-dev libz-mingw-w64-dev
64+
65+
- name: build Linux and Windows Binutils
66+
run: ./build-binutils.sh
67+
68+
- name: package Binutils config and build logs
69+
if: ${{ always() }}
70+
run: find ${BUILD_DIR} -name 'config.*' | zip -9 build-logs-linux-binutils.zip -@
71+
72+
- name: upload Binutils config and build logs
73+
if: ${{ always() }}
74+
uses: actions/upload-artifact@v2
75+
with:
76+
name: build-logs
77+
path: build-logs-linux-binutils.zip
78+
79+
- name: package Binutils artifacts
80+
run: tar cjf artifacts-linux-binutils.tar.bz2 artifacts
81+
82+
- name: upload Linux and Windows Binutils artifacts
83+
uses: actions/upload-artifact@v2
84+
with:
85+
name: linux
86+
path: artifacts-linux-binutils.tar.bz2
87+
88+
build_xautils_linux:
89+
runs-on: ubuntu-20.04
90+
steps:
91+
- uses: actions/checkout@v2
92+
with:
93+
submodules: recursive
94+
95+
- name: Install Xamarin.Android Utilities build dependencies
96+
run: >-
97+
sudo apt-get update;
98+
sudo apt-get -f -u install mingw-w64 cmake ninja-build xz-utils zlib1g-dev libz-mingw-w64-dev
99+
100+
- name: build Linux and Windows Xamarin.Android Utilities
101+
run: CC=gcc-10 CXX=g++-10 ./build-xa-utils.sh
102+
103+
- name: package Xamarin.Android Utilities config and build logs
104+
if: ${{ always() }}
105+
run: find ${BUILD_DIR} -name 'CMakeCache.txt' -o -name 'CMake*.log' | zip -9 build-logs-linux-xa-utils.zip -@
106+
107+
- name: upload Xamarin.Android Utilities config and build logs
108+
if: ${{ always() }}
109+
uses: actions/upload-artifact@v2
110+
with:
111+
name: build-logs
112+
path: build-logs-linux-xa-utils.zip
113+
114+
- name: package Xamarin.Android Utilities artifacts
115+
run: tar cjf artifacts-linux-xa-utils.tar.bz2 artifacts
116+
117+
- name: upload Linux and Windows Xamarin.Android Utilities artifacts
118+
uses: actions/upload-artifact@v2
119+
with:
120+
name: linux
121+
path: artifacts-linux-xa-utils.tar.bz2
122+
123+
build_llvm_macos:
124+
runs-on: macos-11
125+
steps:
126+
- uses: actions/checkout@v2
127+
with:
128+
submodules: recursive
18129

19-
- name: Install build dependencies
130+
- name: Install LLVM build dependencies
20131
run: |
21-
sudo apt-get update
22-
sudo apt-get -f -u install mingw-w64 autoconf gettext texinfo dwz xz-utils zlib1g-dev
132+
brew update
133+
brew install cmake ninja ccache
23134
24-
- name: build Linux and Windows
25-
run: ./build.sh ${BINUTILS_VERSION}
135+
- name: build macOS LLVM
136+
run: bash ./build-llvm.sh
26137

27-
- name: package config and build logs
138+
- name: package LLVM config and build logs
28139
if: ${{ always() }}
29-
run: find build -name 'config.*' | zip -9 linux-build-logs.zip -@
140+
run: find ${BUILD_DIR} -name 'config.*' -o -name '*.log' -o -name 'CMakeCache.txt' | zip -9 build-logs-macos-llvm.zip -@
30141

31-
- name: upload config and build logs
142+
- name: upload LLVM config and build logs
32143
if: ${{ always() }}
33144
uses: actions/upload-artifact@v2
34145
with:
35146
name: build-logs
36-
path: linux-build-logs.zip
147+
path: build-logs-macos-llvm.zip
37148

38-
- name: package artifacts
39-
run: tar cjf linux-artifacts.tar.bz2 artifacts
149+
- name: package LLVM artifacts
150+
run: tar cjf artifacts-macos-llvm.tar.bz2 artifacts
40151

41-
- name: upload Linux and Windows artifacts
152+
- name: upload macOS LLVM artifacts
42153
uses: actions/upload-artifact@v2
43154
with:
44-
name: linux-windows
45-
path: linux-artifacts.tar.bz2
155+
name: macOS
156+
path: artifacts-macos-llvm.tar.bz2
46157

47-
build_macos:
48-
runs-on: macos-10.15
158+
build_binutils_macos:
159+
runs-on: macos-11
49160
steps:
50161
- uses: actions/checkout@v2
162+
with:
163+
submodules: recursive
51164

52-
- name: Install build dependencies
165+
- name: Install Binutils build dependencies
53166
run: |
54167
brew update
55168
brew install make autoconf gettext xz
56169
57-
- name: build macOS
58-
run: bash -x ./build.sh ${BINUTILS_VERSION}
170+
- name: build macOS Binutils
171+
run: bash ./build-binutils.sh
172+
173+
- name: package Binutils config and build logs
174+
if: ${{ always() }}
175+
run: find ${BUILD_DIR} -name 'config.*' | zip -9 build-logs-macos-binutils.zip -@
176+
177+
- name: upload Binutils config and build logs
178+
if: ${{ always() }}
179+
uses: actions/upload-artifact@v2
180+
with:
181+
name: build-logs
182+
path: build-logs-macos-binutils.zip
183+
184+
- name: package Binutils artifacts
185+
run: tar cjf artifacts-macos-binutils.tar.bz2 artifacts
186+
187+
- name: upload macOS Binutils artifacts
188+
uses: actions/upload-artifact@v2
189+
with:
190+
name: macOS
191+
path: artifacts-macos-binutils.tar.bz2
192+
193+
build_xautils_macos:
194+
runs-on: macos-11
195+
steps:
196+
- uses: actions/checkout@v2
197+
with:
198+
submodules: recursive
199+
200+
- name: Install Xamarin.Android Utilities build dependencies
201+
run: |
202+
brew update
203+
brew install make cmake xz ninja
204+
205+
- name: build macOS Xamarin.Android Utilities
206+
run: bash ./build-xa-utils.sh
59207

60-
- name: package config and build logs
208+
- name: package Xamarin.Android Utilities config and build logs
61209
if: ${{ always() }}
62-
run: find build -name 'config.*' | zip -9 macos-build-logs.zip -@
210+
run: find ${BUILD_DIR} -name 'CMakeCache.txt' -o -name 'CMake*.log' | zip -9 build-logs-macos-xa-utils.zip -@
63211

64-
- name: upload config and build logs
212+
- name: upload Xamarin.Android Utilities config and build logs
65213
if: ${{ always() }}
66214
uses: actions/upload-artifact@v2
67215
with:
68216
name: build-logs
69-
path: macos-build-logs.zip
217+
path: build-logs-macos-xa-utils.zip
70218

71-
- name: package artifacts
72-
run: tar cjf macos-artifacts.tar.bz2 artifacts
219+
- name: package Xamarin.Android Utilities artifacts
220+
run: tar cjf artifacts-macos-xa-utils.tar.bz2 artifacts
73221

74-
- name: upload macOS artifacts
222+
- name: upload macOS Xamarin.Android Utilities artifacts
75223
uses: actions/upload-artifact@v2
76224
with:
77225
name: macOS
78-
path: macos-artifacts.tar.bz2
226+
path: artifacts-macos-xa-utils.tar.bz2
227+
228+
build_llvm_windows:
229+
runs-on: windows-2019
230+
steps:
231+
- uses: actions/checkout@v2
232+
with:
233+
submodules: recursive
234+
235+
- name: Add msbuild to PATH
236+
uses: microsoft/setup-msbuild@v1.1
237+
238+
- name: build Windows LLVM
239+
run: ./build-llvm.cmd
240+
241+
- name: package LLVM artifacts
242+
run: 7z a artifacts-windows-llvm.7z artifacts
243+
244+
- name: upload Windows LLVM artifacts
245+
uses: actions/upload-artifact@v2
246+
with:
247+
name: Windows
248+
path: artifacts-windows-llvm.7z
79249

80250
package_binaries:
81-
runs-on: ubuntu-18.04
82-
needs: [build_linux, build_macos]
251+
runs-on: ubuntu-20.04
252+
needs: [build_llvm_linux, build_binutils_linux, build_xautils_linux, build_llvm_macos, build_binutils_macos, build_xautils_macos, build_llvm_windows]
83253
steps:
84-
- name: Download Linux and Windows artifacts
254+
- uses: actions/checkout@v2
255+
256+
- name: Download Linux artifacts
85257
uses: actions/download-artifact@v2
86258
with:
87-
name: linux-windows
259+
name: linux
88260

89261
- name: Download macOS artifacts
90262
uses: actions/download-artifact@v2
91263
with:
92264
name: macOS
93265

94-
- name: Unpack Linux and Windows artifacts
266+
- name: Download Windows artifacts
267+
uses: actions/download-artifact@v2
268+
with:
269+
name: Windows
270+
271+
- name: Unpack Linux artifacts
95272
run: |
96-
tar xf linux-artifacts.tar.bz2
273+
tar xf artifacts-linux-llvm.tar.bz2
274+
tar xf artifacts-linux-binutils.tar.bz2
275+
tar xf artifacts-linux-xa-utils.tar.bz2
97276
98277
- name: Unpack macOS artifacts
99278
run: |
100-
tar xf macos-artifacts.tar.bz2
279+
tar xf artifacts-macos-llvm.tar.bz2
280+
tar xf artifacts-macos-binutils.tar.bz2
281+
tar xf artifacts-macos-xa-utils.tar.bz2
282+
283+
- name: Unpack Windows artifacts
284+
run: |
285+
7z x artifacts-windows-llvm.7z
101286
102-
- name: Pack Linux, macOS and Windows artifacts
103-
run: tar cjf xamarin-android-binutils.tar.bz2 artifacts
287+
- name: Package Linux, macOS and Windows artifacts
288+
run: ./package.sh
104289

105-
- name: upload Xamarin.Android Binutils
290+
- name: upload Xamarin.Android Toolchain
106291
uses: actions/upload-artifact@v2
107292
with:
108293
name: Xamarin.Android
109-
path: xamarin-android-binutils.tar.bz2
294+
path: artifacts/xamarin-android-toolchain.tar.bz2

.gitignore

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,12 @@
3232
*.app
3333

3434
# Other
35-
/build
35+
/xa-build
3636
/artifacts
3737
/prep
3838
/*.7z
3939
/*.zip
40+
/*.tar.bz2
41+
.ccls-cache
42+
.projectile
43+
compile_commands.json

.gitmodules

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
[submodule "external/llvm"]
2+
path = external/llvm
3+
url = https://github.com/llvm/llvm-project.git
4+
shallow = true
5+
branch = release/13.x

0 commit comments

Comments
 (0)