8000 Improve Rust distribution workflow by awakecoding · Pull Request #14 · awakecoding/llvm-prebuilt · GitHub
[go: up one dir, main page]

Skip to content

Improve Rust distribution workflow #14

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

Merged
merged 17 commits into from
Sep 21, 2022
Merged
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
3 changes: 3 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
* text=auto

*.patch text eol=lf
55 changes: 44 additions & 11 deletions .github/workflows/rust-prebuilt.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,19 @@ jobs:
name: Rust [${{matrix.arch}}-${{matrix.os}}]
runs-on: ${{matrix.runner}}
strategy:
fail-fast: true
fail-fast: false
matrix:
arch: [ x86_64 ]
os: [ windows, macos, ubuntu-18.04 ]
os: [ windows, macos, ubuntu-20.04 ]
version: [ 1.63.0 ]

include:
- os: windows
runner: windows-2022
- os: macos
runner: macos-latest
- os: ubuntu-18.04
runner: ubuntu-18.04
- os: ubuntu-20.04
runner: ubuntu-20.04

steps:
- name: Configure Windows runner
Expand All @@ -39,37 +39,70 @@ jobs:
sudo apt update
sudo apt install ninja-build xz-utils

- name: Clone Rust ${{matrix.version}}
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: '3.9'

- name: Clone project
uses: actions/checkout@v2
with:
path: llvm-prebuilt

- name: Clone Rust ${{matrix.version}}
uses: actions/checkout@v3
with:
repository: rust-lang/rust
ref: v${{matrix.version}}
ref: ${{matrix.version}}
submodules: true
fetch-depth: 1
path: rust

- name: Patch Rust
run: |
git -C rust apply ../llvm-prebuilt/patches/rust-allow-dynamic-linking-for-ios-targets.patch
git -C rust apply ../llvm-prebuilt/patches/rust-bootstrap-add-dist-dirs-env-variables.patch

- name: Configure Rust
shell: pwsh
working-directory: rust
run: |
$config = @(
"changelog-seen=2",
"[llvm]",
"download-llvm-ci=true",
"download-ci-llvm=false",
"ninja=true",
"targets=`"X86;ARM;AArch64;WebAssembly`""
"[build]",
"[install]",
"prefix=`"/opt/rust`"",
"[rust]",
"[target.x86_64-unknown-linux-gnu]",
"[dist]",
"src-tarball=false",
"compression-formats=[`"xz`"]"
)
Set-Content -Path .\config.toml -Value $config

- name: Build Rust
uses: actions/setup-python@v4
shell: pwsh
working-directory: rust
run: |
Remove-Item Env:GITHUB_ACTIONS
python x.py build

- name: Package Rust
shell: pwsh
env:
RUST_OUT_DIST_DIR: ${{ runner.temp }}/rust-dist
RUST_TMP_DIST_DIR: ${{ runner.temp }}/temp-dist
working-directory: rust
run: |
Remove-Item Env:GITHUB_ACTIONS
python x.py dist

- name: Upload Rust
uses: actions/upload-artifact@v3
with:
python-version: '3.9'
cache: 'pip'
run: python x.py build
name: rust-${{matrix.version}}-${{matrix.arch}}-${{matrix.os}}
path: ${{ runner.temp }}/rust-dist
25 changes: 25 additions & 0 deletions patches/rust-allow-dynamic-linking-for-ios-targets.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
From cfba7c0133691e510e8c11d84aafe63a9cdafea0 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Marc-Andr=C3=A9=20Moreau?= <mamoreau@devolutions.net>
Date: Wed, 21 Sep 2022 11:02:54 -0400
Subject: [PATCH] allow dynamic linking for iOS targets

---
compiler/rustc_target/src/spec/apple_sdk_base.rs | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/compiler/rustc_target/src/spec/apple_sdk_base.rs b/compiler/rustc_target/src/spec/apple_sdk_base.rs
index ecb6cbd9f8a..078e1a7bc73 100644
--- a/compiler/rustc_target/src/spec/apple_sdk_base.rs
+++ b/compiler/rustc_target/src/spec/apple_sdk_base.rs
@@ -53,7 +53,7 @@ pub fn opts(os: &'static str, arch: Arch) -> TargetOptions {
TargetOptions {
abi: target_abi(arch).into(),
cpu: target_cpu(arch).into(),
- dynamic_linking: false,
+ dynamic_linking: true,
executables: true,
link_env_remove: link_env_remove(arch),
has_thread_local: false,
--
2.25.1

34 changes: 34 additions & 0 deletions patches/rust-bootstrap-add-dist-dirs-env-variables.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
From d91ad9dda950de136024b49ff3606d52b5227645 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Marc-Andr=C3=A9=20Moreau?= <mamoreau@devolutions.net>
Date: Wed, 21 Sep 2022 15:34:19 -0400
Subject: [PATCH] add RUST_OUT_DIST_DIR, RUST_TMP_DIST_DIR environment
variables

---
src/bootstrap/dist.rs | 6 ++++++
1 file changed, 6 insertions(+)

diff --git a/src/bootstrap/dist.rs b/src/bootstrap/dist.rs
index b1fae356d89..62e666937f1 100644
--- a/src/bootstrap/dist.rs
+++ b/src/bootstrap/dist.rs
@@ -28,10 +28,16 @@ pub fn pkgname(builder: &Builder<'_>, component: &str) -> String {
}

pub(crate) fn distdir(builder: &Builder<'_>) -> PathBuf {
+ if let Ok(out_dist_dir) = env::var("RUST_OUT_DIST_DIR") {
+ return Path::new(&out_dist_dir).to_path_buf();
+ }
builder.out.join("dist")
}

pub fn tmpdir(builder: &Builder<'_>) -> PathBuf {
+ if let Ok(tmp_dist_dir) = env::var("RUST_TMP_DIST_DIR") {
+ return Path::new(&tmp_dist_dir).to_path_buf();
+ }
builder.out.join("tmp/dist")
}

--
2.25.1

0