Skip to content

Commit a99bba0

Browse files
committed
Use zig cc for SwiftShader on Linux
1 parent 6f709a9 commit a99bba0

16 files changed

+109
-26
lines changed

.github/workflows/swiftshader.yml

Lines changed: 3 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -21,32 +21,6 @@ jobs:
2121
- os: ubuntu-22.04
2222
name: Linux
2323
nuke_invoke: ./build.sh
24-
extras: |
25-
# We need to adjust APT sources for multiarch. Use the ones corresponding to
26-
# Ubuntu 22.04 with appropriate `arch` values. ports.ubuntu.com is required
27-
# for armhf and arm64.
28-
sudo tee /etc/apt/sources.list << EOF
29-
deb [arch=amd64] http://archive.ubuntu.com/ubuntu jammy main multiverse restricted universe
30-
deb [arch=amd64] http://archive.ubuntu.com/ubuntu jammy-backports main multiverse restricted universe
31-
deb [arch=amd64] http://archive.ubuntu.com/ubuntu jammy-security main multiverse restricted universe
32-
deb [arch=amd64] http://archive.ubuntu.com/ubuntu jammy-updates main multiverse restricted universe
33-
deb [arch=arm64,armhf] http://ports.ubuntu.com jammy main multiverse restricted universe
34-
deb [arch=arm64,armhf] http://ports.ubuntu.com jammy-backports main multiverse restricted universe
35-
deb [arch=arm64,armhf] http://ports.ubuntu.com jammy-security main multiverse restricted universe
36-
deb [arch=arm64,armhf] http://ports.ubuntu.com jammy-updates main multiverse restricted universe
37-
deb [arch=amd64] http://security.ubuntu.com/ubuntu jammy main multiverse restricted universe
38-
deb [arch=amd64] http://security.ubuntu.com/ubuntu jammy-backports main multiverse restricted universe
39-
deb [arch=amd64] http://security.ubuntu.com/ubuntu jammy-security main multiverse restricted universe
40-
deb [arch=amd64] http://security.ubuntu.com/ubuntu jammy-updates main multiverse restricted universe
41-
EOF
42-
sudo dpkg --add-architecture arm64
43-
sudo dpkg --add-architecture armhf
44-
sudo apt update
45-
sudo apt install -y gcc-aarch64-linux-gnu gcc-arm-linux-gnueabihf
46-
sudo apt install -y g++-aarch64-linux-gnu g++-arm-linux-gnueabihf
47-
for arch in amd64 arm64 armhf; do
48-
sudo apt install -y libx11-xcb-dev:$arch
49-
done
5024
- os: windows-2022
5125
name: Windows
5226
nuke_invoke: ./build.cmd
@@ -83,6 +57,9 @@ jobs:
8357
dotnet-version: |
8458
6.0.201
8559
7.0.*
60+
- name: Install Zig
61+
if: ${{ matrix.env.name == 'Linux' }}
62+
uses: goto-bus-stop/setup-zig@v2
8663
- name: Build SwiftShader
8764
run: ${{ matrix.env.nuke_invoke }} SwiftShader
8865
env:

build/cmake/fudge.sh

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#!/bin/bash
2+
3+
# Origignal script from https://github.com/ziglang/zig/issues/4911
4+
# Modified to add SILKDOTNET_ paths in response to some issues with SwiftShader
5+
6+
args=""
7+
for arg in "$@"
8+
do
9+
parg="$arg"
10+
11+
option=${arg%=*}
12+
target=${arg#*=}
13+
if [[ $option == "-march" || $option == "-mcpu" || $option == "-mtune" ]]; then
14+
moveon=0
15+
for replace in $SILKDOTNET_ReplaceArchitectureZigCcFlags
16+
do
17+
replacetarget=${replace%=*}
18+
replacement=${replace#*=}
19+
# echo $replacetarget A $replacement B $target END
20+
if [[ $replacetarget == $target ]]; then
21+
if [[ "$replacement" == "" ]]; then
22+
moveon=1
23+
else
24+
target="$replacement"
25+
fi
26+
fi
27+
done
28+
if [[ $moveon == 1 || "$SILKDOTNET_RemoveAllPotentiallyProblematicZigCcFlags" == "1" ]]; then
29+
continue
30+
else
31+
fixedTarget=${target//-/_}
32+
parg="$option=$fixedTarget"
33+
fi
34+
fi
35+
args="$args $parg"
36+
done

build/cmake/zig-ar.cmd

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
@echo off
2+
zig ar %*

build/cmake/zig-ar.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#!/bin/sh
2+
zig ar "$@"

build/cmake/zig-c++.cmd

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
@echo off
2+
: TODO add -march/-mtune handling if necessary
3+
zig c++ %*

build/cmake/zig-c++.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/bin/bash
2+
. "$(dirname ${BASH_SOURCE[0]})/fudge.sh" $args
3+
zig c++ $args

build/cmake/zig-cc.cmd

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
@echo off
2+
: TODO add -march/-mtune handling if necessary
3+
zig cc %*

build/cmake/zig-cc.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/bin/bash
2+
. "$(dirname ${BASH_SOURCE[0]})/fudge.sh" $args
3+
zig cc $args

build/cmake/zig-ranlib.cmd

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
@echo off
2+
zig ranlib %*

build/cmake/zig-ranlib.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#!/bin/sh
2+
zig ranlib "$@"

0 commit comments

Comments
 (0)