Skip to content

Commit 9bdaf68

Browse files
authored
feat: add optimization flags (#30)
1 parent fb3cbe4 commit 9bdaf68

File tree

5 files changed

+123
-40
lines changed

5 files changed

+123
-40
lines changed

.github/workflows/rust-compiler-builder.yml

Lines changed: 33 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -51,38 +51,66 @@ jobs:
5151
# https://github.com/actions/runner-images?tab=readme-ov-file#available-images
5252
# https://github.com/actions/runner-images/tree/main/images/macos
5353
# https://developer.apple.com/support/xcode/
54+
# https://support.apple.com/en-us/100100
5455

5556
# Regression: macos-14 arm64
5657

57-
- rust-targets: x86_64-apple-darwin,aarch64-apple-darwin,aarch64-apple-ios,arm64e-apple-darwin,arm64e-apple-ios
58-
os: macos-13 # x86-64
58+
- rust-targets: arm64e-apple-darwin
59+
rust-host: x86_64-apple-darwin
60+
os: macos-13
5961
xcode-version: 15.2
6062
rust-config: configure
63+
rust-no-debug-assertions: 1
6164
rust-use-lld: false
6265
macosx_deployment_target: 11.0
63-
iphoneos_deployment_target: 14.0
66+
iphoneos_deployment_target: 15.0
67+
# TODO: FIX ME
68+
rust-configure-args: >-
69+
--set target.arm64e-apple-darwin.profiler=false
70+
71+
- rust-targets: aarch64-apple-ios,arm64e-apple-darwin
72+
rust-host: x86_64-apple-darwin
73+
os: macos-13
74+
xcode-version: 15.2
75+
rust-config: configure
76+
rust-no-debug-assertions: 1
77+
rust-use-lld: false
78+
macosx_deployment_target: 11.0
79+
iphoneos_deployment_target: 15.0
80+
rust-configure-args: >-
81+
--set target.arm64e-apple-darwin.profiler=false
6482
6583
- rust-targets: x86_64-apple-tvos,aarch64-apple-tvos,arm64e-apple-tvos
66-
os: macos-13 # x86-64
84+
rust-host: x86_64-apple-darwin
85+
os: macos-13
6786
xcode-version: 15.2
6887
rust-config: configure
88+
rust-no-debug-assertions: 1
6989
rust-use-lld: false
7090
macosx_deployment_target: 11.0
71-
tvos_deployment_target: 14.0
91+
tvos_deployment_target: 15.0
92+
rust-configure-args: >-
93+
--set target.x86_64-apple-tvos.profiler=false
94+
--set target.aarch64-apple-tvos.profiler=false
95+
--set target.arm64e-apple-tvos.profiler=false
7296
7397
runs-on: ${{ matrix.os }}
7498
env:
7599
# Tools
76100
SCCACHE_GHA_ENABLED: 'on'
77101
# The Rust Compiler
78102
BOOTSTRAP_SKIP_TARGET_SANITY: 1 # TODO: disable BOOTSTRAP_SKIP_TARGET_SANITY when the 1.83 rustc is available
103+
NO_DEBUG_ASSERTIONS: ${{ matrix.rust-no-debug-assertions}}
79104
MACOSX_DEPLOYMENT_TARGET: ${{ matrix.macosx_deployment_target }}
105+
MACOSX_STD_DEPLOYMENT_TARGET: ${{ matrix.macosx_deployment_target }}
80106
IPHONEOS_DEPLOYMENT_TARGET: ${{ matrix.iphoneos_deployment_target }}
81107
TVOS_DEPLOYMENT_TARGET: ${{ matrix.tvos_deployment_target }}
82108
RUST_BACKTRACE: ${{ github.event.inputs.rust-backtrace || '0' }}
83109
RUST_CHANNEL: ${{ github.event.inputs.rust-channel || 'dev' }}
110+
RUST_HOST: ${{ matrix.rust-host }}
84111
RUST_TARGETS: ${{ matrix.rust-targets }}
85112
RUST_VERBOSE: ${{ github.event.inputs.rust-verbose || '0' }}
113+
RUST_CONFIGURE_ARGS: ${{ matrix.rust-configure-args }} --set change-id=99999999
86114

87115
steps:
88116
- name: Configure Cache Env
@@ -110,7 +138,6 @@ jobs:
110138
111139
- name: Show System Info
112140
run: |
113-
114141
echo "::group::uname"
115142
uname -a
116143
echo "::endgroup::"

Makefile

Lines changed: 66 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,22 @@
1+
.DEFAULT_GOAL := help
2+
3+
################################################################################
4+
15
RUST_GIT_URL ?= https://github.com/rust-lang/rust.git
2-
RUST_TOOLS ?= cargo,clippy,rustdoc,rustfmt,rust-analyzer,analysis,src
3-
RUST_TARGETS ?= aarch64-apple-darwin,aarch64-apple-ios,arm64e-apple-darwin,arm64e-apple-ios
46
RUST_HOST ?= x86_64-apple-darwin
5-
RUST_VERBOSE ?= 0
7+
RUST_TARGETS ?= arm64e-apple-darwin
8+
RUST_TOOLS ?= cargo,clippy,rustdoc,rustfmt,rust-analyzer,analysis,src
69
RUST_CHANNEL ?= dev
10+
RUST_CODEGEN_BACKENDS ?= llvm
11+
RUST_USE_LLD ?= false
12+
RUST_VERBOSE ?= 0
713
RUST_DESCRIPTION ?= ""
814
RUST_INSTALL_DIR ?= install
915
RUST_DIST_FORMATS ?= xz
10-
RUST_USE_LLD ?= false
11-
12-
## ▸▸▸ Auxiliary commands ◂◂◂
13-
.PHONY: help
14-
help: ## Show this help
15-
@fgrep -h "## " $(MAKEFILE_LIST) | fgrep -v fgrep | sed -e 's/\\$$//' | sed -e 's/## //'
16-
17-
.PHONY: clean
18-
clean: ## Remove download artifacts
19-
rm -rf rust
16+
RUST_CONFIGURE_ARGS ?=
2017

2118
# Note: use Makefile.local for customization
19+
-include misc/make/utility.Makefile
2220
-include misc/make/doc.Makefile
2321
-include misc/make/offline.Makefile
2422
-include Makefile.local
@@ -36,45 +34,87 @@ download: ## Download Rust sources
3634
## ▸▸▸ Configure commands ◂◂◂
3735

3836
.PHONY: configure
39-
configure: ## Configure Rust
37+
configure: ## Configure Rust & LLVM with optimizations
4038
cd rust && ./configure \
4139
--enable-option-checking \
40+
--enable-verbose-configure \
41+
--enable-sccache \
42+
--enable-ninja \
4243
--enable-verbose-tests \
43-
--codegen-backends=llvm \
4444
--enable-codegen-tests \
4545
--enable-dist-src \
46-
--tools=${RUST_TOOLS} \
46+
--enable-optimize-llvm \
47+
--enable-full-tools \
48+
--enable-sanitizers \
49+
--enable-profiler \
50+
--host=${RUST_HOST} \
51+
--target=${RUST_TARGETS} \
52+
--set llvm.download-ci-llvm=false \
53+
--set llvm.targets="AArch64;X86" \
54+
--set llvm.experimental-targets="" \
55+
--set llvm.static-libstdcpp \
56+
--set llvm.tests=true \
57+
--set build.verbose=${RUST_VERBOSE} \
58+
--set rust.channel=${RUST_CHANNEL} \
59+
--set rust.jemalloc \
60+
--set rust.lto=thin \
61+
--set rust.codegen-units=1 \
62+
--set rust.codegen-backends=${RUST_CODEGEN_BACKENDS} \
63+
--set rust.use-lld=${RUST_USE_LLD} \
64+
--set rust.omit-git-hash=true \
65+
--dist-compression-formats=${RUST_DIST_FORMATS} \
66+
--prefix=${RUST_INSTALL_DIR} \
67+
${RUST_CONFIGURE_ARGS}
68+
69+
.PHONY: configure-dev
70+
configure-dev: ## Configure Rust without optimizations
71+
cd rust && ./configure \
72+
--enable-option-checking \
73+
--enable-verbose-configure \
74+
--enable-verbose-tests \
75+
--enable-codegen-tests \
76+
--host=${RUST_HOST} \
4777
--target=${RUST_TARGETS} \
78+
--tools=${RUST_TOOLS} \
4879
--set llvm.download-ci-llvm=true \
4980
--set build.verbose=${RUST_VERBOSE} \
5081
--set rust.channel=${RUST_CHANNEL} \
5182
--set rust.description=${RUST_DESCRIPTION} \
5283
--set rust.use-lld=${RUST_USE_LLD} \
5384
--dist-compression-formats=${RUST_DIST_FORMATS} \
54-
--prefix=${RUST_INSTALL_DIR}
85+
--prefix=${RUST_INSTALL_DIR} \
86+
${RUST_CONFIGURE_ARGS}
5587

56-
.PHONY: configure-with-llvm
57-
configure-with-llvm: ## Configure Rust and LLVM
88+
.PHONY: configure-dev-llvm
89+
configure-dev-llvm: ## Configure Rust & LLVM without optimizations
5890
cd rust && ./configure \
5991
--enable-option-checking \
60-
--enable-sccache \
61-
--enable-ninja \
92+
--enable-verbose-configure \
6293
--enable-verbose-tests \
6394
--enable-codegen-tests \
64-
--enable-dist-src \
65-
--enable-full-tools \
66-
--tools=${RUST_TOOLS} \
95+
--enable-sccache \
96+
--enable-ninja \
97+
--host=${RUST_HOST} \
6798
--target=${RUST_TARGETS} \
99+
--tools=${RUST_TOOLS} \
100+
--enable-debug-assertions \
101+
--enable-overflow-checks \
102+
--enable-llvm-assertions \
103+
--codegen-backends=${RUST_CODEGEN_BACKENDS} \
68104
--set llvm.download-ci-llvm=false \
69105
--set llvm.targets="AArch64;X86" \
70106
--set llvm.experimental-targets="" \
107+
--set llvm.static-libstdcpp \
71108
--set llvm.tests=true \
72109
--set build.verbose=${RUST_VERBOSE} \
73110
--set rust.channel=${RUST_CHANNEL} \
74-
--set rust.description=${RUST_DESCRIPTION} \
111+
--set rust.verify-llvm-ir \
112+
--set rust.use-lld=${RUST_USE_LLD} \
113+
--set rust.codegen-backends=${RUST_CODEGEN_BACKENDS} \
75114
--set rust.omit-git-hash=true \
76115
--dist-compression-formats=${RUST_DIST_FORMATS} \
77-
--prefix=${RUST_INSTALL_DIR}
116+
--prefix=${RUST_INSTALL_DIR} \
117+
${RUST_CONFIGURE_ARGS}
78118

79119
## ▸▸▸ Target Info commands ◂◂◂
80120

Makefile.example.local

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
# RUST_TOOLS = cargo,rustfmt
2-
# RUST_TARGETS = arm64e-apple-ios,arm64e-apple-darwin
1+
# RUST_GIT_URL = https://github.com/arttet/rust.git
2+
# RUST_HOST = aarch64-apple-darwin
3+
# RUST_TARGETS = aarch64-apple-darwin,aarch64-apple-ios,arm64e-apple-darwin,arm64e-apple-ios
4+
# RUST_TOOLS = cargo,clippy,rustdoc,rustfmt,rust-analyzer,analysis,src
35
# RUST_CHANNEL = stable
46
# RUST_VERBOSE = 3

README.md

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,18 @@ Builds the *Rust* compiler and [Tier 3 targets](https://doc.rust-lang.org/nightl
77
## Usage
88

99
```sh
10-
$ make
11-
▸▸▸ Auxiliary commands ◂◂◂
12-
help: Show this help
13-
clean: Remove downloaded artifacts
1410
▸▸▸ Download commands ◂◂◂
1511
download: Download Rust sources
1612
▸▸▸ Configure commands ◂◂◂
17-
configure: Configure Rust
18-
configure-with-llvm: Configure Rust and LLVM
13+
configure: Configure Rust & LLVM with optimizations
14+
configure-dev: Configure Rust without optimizations
15+
configure-dev-llvm: Configure Rust & LLVM without optimizations
1916
▸▸▸ Target Info commands ◂◂◂
2017
show-target-info: Show target info
18+
▸▸▸ Utility commands ◂◂◂
19+
help: Show this help
20+
clean: Remove generated artifacts
21+
prune: Remove all downloaded artifacts
2122
▸▸▸ Documentation commands ◂◂◂
2223
doc-build: Build the documentation site [env: DOC_DIR=]
2324
doc-serve: Serve the documentation site [env: DOC_PORT=]

misc/make/utility.Makefile

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
## ▸▸▸ Utility commands ◂◂◂
2+
3+
.PHONY: help
4+
help: ## Show this help
5+
@fgrep -h "## " $(MAKEFILE_LIST) | fgrep -v fgrep | sed -e 's/\\$$//' | sed -e 's/## //'
6+
7+
.PHONY: clean
8+
clean: ## Remove generated artifacts
9+
rm -rf rust/config.toml
10+
11+
.PHONY: prune
12+
prune: ## Remove all downloaded artifacts
13+
rm -rf rust

0 commit comments

Comments
 (0)