8000 Improve Rust distribution workflow (#14) · awakecoding/llvm-prebuilt@964aea9 · GitHub
[go: up one dir, main page]

Skip to content

Commit 964aea9

Browse files
awakecodingMarc-André Moreau
and
Marc-André Moreau
authored
Improve Rust distribution workflow (#14)
* fix fix * fix fix * fix fix * fix fix * fix fix * fix fix * fix fix * change build command * try forcing CI mode off * call x.py build only * download-ci-llvm=false * x.py dist * patch rust sources, upload rust distribution * fix fix * update * try fixing patch * patch and use temporary output directories to avoid running out of space Co-authored-by: Marc-André Moreau <mamoreau@devolutions.net>
1 parent d247393 commit 964aea9

4 files changed

+106
-11
lines changed

.gitattributes

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
* text=auto
2+
3+
*.patch text eol=lf

.github/workflows/rust-prebuilt.yml

Lines changed: 44 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,19 @@ jobs:
55
name: Rust [${{matrix.arch}}-${{matrix.os}}]
66
runs-on: ${{matrix.runner}}
77
strategy:
8-
fail-fast: true
8+
fail-fast: false
99
matrix:
1010
arch: [ x86_64 ]
11-
os: [ windows, macos, ubuntu-18.04 ]
11+
os: [ windows, macos, ubuntu-20.04 ]
1212
version: [ 1.63.0 ]
1313

1414
include:
1515
- os: windows
1616
runner: windows-2022
1717
- os: macos
1818
runner: macos-latest
19-
- os: ubuntu-18.04
20-
runner: ubuntu-18.04
19+
- os: ubuntu-20.04
20+
runner: ubuntu-20.04
2121

2222
steps:
2323
- name: Configure Windows runner
@@ -39,37 +39,70 @@ jobs:
3939
sudo apt update
4040
sudo apt install ninja-build xz-utils
4141
42-
- name: Clone Rust ${{matrix.version}}
42+
- name: Setup Python
43+
uses: actions/setup-python@v4
44+
with:
45+
python-version: '3.9'
46+
47+
- name: Clone project
4348
uses: actions/checkout@v2
49+
with:
50+
path: llvm-prebuilt
51+
52+
- name: Clone Rust ${{matrix.version}}
53+
uses: actions/checkout@v3
4454
with:
4555
repository: rust-lang/rust
46-
ref: v${{matrix.version}}
56+
ref: ${{matrix.version}}
4757
submodules: true
58+
fetch-depth: 1
4859
path: rust
4960

61+
- name: Patch Rust
62+
run: |
63+
git -C rust apply ../llvm-prebuilt/patches/rust-allow-dynamic-linking-for-ios-targets.patch
64+
git -C rust apply ../llvm-prebuilt/patches/rust-bootstrap-add-dist-dirs-env-variables.patch
65+
5066
- name: Configure Rust
5167
shell: pwsh
5268
working-directory: rust
5369
run: |
5470
$config = @(
5571
"changelog-seen=2",
5672
"[llvm]",
57-
"download-llvm-ci=true",
73+
"download-ci-llvm=false",
5874
"ninja=true",
75+
"targets=`"X86;ARM;AArch64;WebAssembly`""
5976
"[build]",
6077
"[install]",
6178
"prefix=`"/opt/rust`"",
6279
"[rust]",
6380
"[target.x86_64-unknown-linux-gnu]",
6481
"[dist]",
82+
"src-tarball=false",
6583
"compression-formats=[`"xz`"]"
6684
)
6785
Set-Content -Path .\config.toml -Value $config
6886
6987
- name: Build Rust
70-
uses: actions/setup-python@v4
88+
shell: pwsh
7189
working-directory: rust
90+
run: |
91+
Remove-Item Env:GITHUB_ACTIONS
92+
python x.py build
93+
94+
- name: Package Rust
95+
shell: pwsh
96+
env:
97+
RUST_OUT_DIST_DIR: ${{ runner.temp }}/rust-dist
98+
RUST_TMP_DIST_DIR: ${{ runner.temp }}/temp-dist
99+
working-directory: rust
100+
run: |
101+
Remove-Item Env:GITHUB_ACTIONS
102+
python x.py dist
103+
104+
- name: Upload Rust
105+
uses: actions/upload-artifact@v3
72106
with:
73-
python-version: '3.9'
74-
cache: 'pip'
75-
run: python x.py build
107+
name: rust-${{matrix.version}}-${{matrix.arch}}-${{matrix.os}}
108+
path: ${{ runner.temp }}/rust-dist
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
From cfba7c0133691e510e8c11d84aafe63a9cdafea0 Mon Sep 17 00:00:00 2001
2+
From: =?UTF-8?q?Marc-Andr=C3=A9=20Moreau?= <mamoreau@devolutions.net>
3+
Date: Wed, 21 Sep 2022 11:02:54 -0400
4+
Subject: [PATCH] allow dynamic linking for iOS targets
5+
6+
---
7+
compiler/rustc_target/src/spec/apple_sdk_base.rs | 2 +-
8+
1 file changed, 1 insertion(+), 1 deletion(-)
9+
10+
diff --git a/compiler/rustc_target/src/spec/apple_sdk_base.rs b/compiler/rustc_target/src/spec/apple_sdk_base.rs
11+
index ecb6cbd9f8a..078e1a7bc73 100644
12+
--- a/compiler/rustc_target/src/spec/apple_sdk_base.rs
13+
+++ b/compiler/rustc_target/src/spec/apple_sdk_base.rs
14+
@@ -53,7 +53,7 @@ pub fn opts(os: &'static str, arch: Arch) -> TargetOptions {
15+
TargetOptions {
16+
abi: target_abi(arch).into(),
17+
cpu: target_cpu(arch).into(),
18+
- dynamic_linking: false,
19+
+ dynamic_linking: true,
20+
executables: true,
21+
link_env_remove: link_env_remove(arch),
22+
has_thread_local: false,
23+
--
24+
2.25.1
25+
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
From d91ad9dda950de136024b49ff3606d52b5227645 Mon Sep 17 00:00:00 2001
2+
From: =?UTF-8?q?Marc-Andr=C3=A9=20Moreau?= <mamoreau@devolutions.net>
3+
Date: Wed, 21 Sep 2022 15:34:19 -0400
4+
Subject: [PATCH] add RUST_OUT_DIST_DIR, RUST_TMP_DIST_DIR environment
5+
variables
6+
7+
---
8+
src/bootstrap/dist.rs | 6 ++++++
9+
1 file changed, 6 insertions(+)
10+
11+
diff --git a/src/bootstrap/dist.rs b/src/bootstrap/dist.rs
12+
index b1fae356d89..62e666937f1 100644
13+
--- a/src/bootstrap/dist.rs
14+
+++ b/src/bootstrap/dist.rs
15+
@@ -28,10 +28,16 @@ pub fn pkgname(builder: &Builder<'_>, component: &str) -> String {
16+
}
17+
18+
pub(crate) fn distdir(builder: &Builder<'_>) -> PathBuf {
19+
+ if let Ok(out_dist_dir) = env::var("RUST_OUT_DIST_DIR") {
20+
+ return Path::new(&out_dist_dir).to_path_buf();
21+
+ }
22+
builder.out.join("dist")
23+
}
24+
25+
pub fn tmpdir(builder: &Builder<'_>) -> PathBuf {
26+
+ if let Ok(tmp_dist_dir) = env::var("RUST_TMP_DIST_DIR") {
27+
+ return Path::new(&tmp_dist_dir).to_path_buf();
28+
+ }
29+
builder.out.join("tmp/dist")
30+
}
31+
32+
--
33+
2.25.1
34+

0 commit comments

Comments
 (0)
0