Skip to content

Commit

Permalink
Move env setup outside of build.sh
Browse files Browse the repository at this point in the history
  • Loading branch information
topjohnwu committed Jun 18, 2024
1 parent 1ff1a3c commit dcfd8a0
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 21 deletions.
12 changes: 9 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,13 @@ jobs:
python-version: "3.x"

- name: Build toolchain
run: ./build.sh
run: |
sudo apt-get -y install cmake ninja-build libzstd-dev binutils-dev
wget https://apt.llvm.org/llvm.sh
chmod +x llvm.sh
sudo ./llvm.sh 17
rm llvm.sh
./build.sh
- name: Upload build artifact
uses: actions/upload-artifact@v4
Expand Down Expand Up @@ -93,6 +99,7 @@ jobs:

- name: Build toolchain
run: |
brew install ninja zstd binutils
./build.sh clone build
mkdir tmp
tar c out | xz --x86 --lzma2 > tmp/out.x64.tar.xz
Expand All @@ -119,9 +126,8 @@ jobs:
python-version: "3.x"

- name: Build toolchain
env:
SKIP_DIST: 1
run: |
brew install ninja zstd binutils
./build.sh clone build
mkdir tmp
tar c out | xz > tmp/out.arm64.tar.xz
Expand Down
21 changes: 6 additions & 15 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,30 +23,21 @@ if [ $OS = "darwin" ]; then
NATIVE_TRIPLE="${NATIVE_ARCH}-apple-darwin"
DYN_EXT='dylib'
EXE_FMT='Mach-O'

# Hardcode to 16k page to support both x64 and arm64
# export JEMALLOC_SYS_WITH_LG_PAGE=14

command -v ninja >/dev/null || brew install ninja
command -v zstd >/dev/null || brew install zstd
brew install binutils
sed -i '' "s|BREW_PREFIX|$(brew --prefix)|g" config-darwin.toml
else
NDK_DIRNAME='linux-x86_64'
TRIPLE="${ARCH}-unknown-linux-gnu"
NATIVE_TRIPLE="${NATIVE_ARCH}-unknown-linux-gnu"
DYN_EXT='so'
EXE_FMT='ELF'

command -v cmake >/dev/null || sudo apt-get -y install cmake
command -v ninja >/dev/null || sudo apt-get -y install ninja-build
command -v clang-12 >/dev/null || sudo apt-get -y install clang-12
command -v lld-12 >/dev/null || sudo apt-get -y install lld-12
dpkg-query -W libzstd-dev >/dev/null 2>&1 || sudo apt-get -y install libzstd-dev
sudo apt-get -y install binutils-dev
fi

build() {
if [ $OS = "darwin" ]; then
sed -i '' "s|BREW_PREFIX|$(brew --prefix)|g" config-darwin.toml
# Manually set page size if cross compilation is required (arm64 require 16k page)
# export JEMALLOC_SYS_WITH_LG_PAGE=14
fi

cd rust
python3 ./x.py --config "../config-${OS}.toml" --host $TRIPLE install
cd ../
Expand Down
6 changes: 3 additions & 3 deletions config-linux.toml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,6 @@ codegen-units = 1

[target.x86_64-unknown-linux-gnu]
llvm-has-rust-patches = false
cc = "clang-12"
cxx = "clang++-12"
linker = "clang-12"
cc = "clang-17"
cxx = "clang++-17"
linker = "clang-17"

0 comments on commit dcfd8a0

Please sign in to comment.