Skip to content

Commit 5a1b883

Browse files
committed
Fix GitHub workflows
Switching to Clang with commit 66bff8e ("Convert object_defs.py to auto-generated file") caused the GitHub build/release workflows to stop working due to the new requirements for Clang, LLVM, and the Clang Python bindings. Fixing this requires adding new GitHub actions to install LLVM and Clang, configure the build environment and make some code changes to allow for emulator to compile cleanly.
1 parent f74c89e commit 5a1b883

10 files changed

Lines changed: 75 additions & 25 deletions

File tree

.github/workflows/build-arm.yml

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ jobs:
4444
uses: actions/setup-python@v5
4545
with:
4646
python-version: '3.13'
47+
cache: 'pip'
4748
- name: Get Version
4849
id: vortex-version
4950
run: echo "vortex-version=$(git describe --tags --abbrev=0)" >> $GITHUB_OUTPUT
@@ -56,12 +57,21 @@ jobs:
5657
sudo apt install -y meson libgirepository-2.0-dev libcairo2-dev
5758
python -m pip install --upgrade pip setuptools wheel flake8 meson
5859
pip install -r virtualenv.txt
59-
# - name: Lint with flake8
60-
# run: |
61-
# # stop the build if there are Python syntax errors or undefined names
62-
# flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
63-
# # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
64-
# flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
60+
- name: Install LLVM and Clang
61+
uses: KyleMayes/install-llvm-action@v2
62+
with:
63+
version: "21.1.8"
64+
env: 1
65+
- name: Install Python Dependencies
66+
run: |
67+
python -m pip install --upgrade pip
68+
python -m pip install clang clang-format
69+
- name: Setup Environment
70+
run: |
71+
echo CLANG_INCLUDE_PATH=$(llvm-config --includedir) >> $GITHUB_ENV
72+
echo LIBRARY_PATH=$(llvm-config --libdir) >> $GITHUB_ENV
73+
echo LLVM_CFLAGS=$(llvm-config --cflags) >> $GITHUB_ENV
74+
echo CC=clang >> $GITHUB_ENV
6575
- name: Build emulator ${{ steps.vortex-version.outputs.vortex-version }}
6676
run: make package
6777
- name: Upload asset

.github/workflows/build-x64.yml

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ jobs:
4444
uses: actions/setup-python@v5
4545
with:
4646
python-version: '3.13'
47+
cache: 'pip'
4748
- name: Get Version
4849
id: vortex-version
4950
run: echo "vortex-version=$(git describe --tags --abbrev=0)" >> $GITHUB_OUTPUT
@@ -56,12 +57,21 @@ jobs:
5657
sudo apt install -y meson libgirepository-2.0-dev libcairo2-dev
5758
python -m pip install --upgrade pip setuptools wheel flake8 meson
5859
pip install -r virtualenv.txt
59-
# - name: Lint with flake8
60-
# run: |
61-
# # stop the build if there are Python syntax errors or undefined names
62-
# flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
63-
# # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
64-
# flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
60+
- name: Install LLVM and Clang
61+
uses: KyleMayes/install-llvm-action@v2
62+
with:
63+
version: "21.1.8"
64+
env: 1
65+
- name: Install Python Dependencies
66+
run: |
67+
python -m pip install --upgrade pip
68+
python -m pip install clang clang-format
69+
- name: Setup Environment
70+
run: |
71+
echo CLANG_INCLUDE_PATH=$(llvm-config --includedir) >> $GITHUB_ENV
72+
echo LIBRARY_PATH=$(llvm-config --libdir) >> $GITHUB_ENV
73+
echo LLVM_CFLAGS=$(llvm-config --cflags) >> $GITHUB_ENV
74+
echo CC=clang >> $GITHUB_ENV
6575
- name: Build emulator ${{ steps.vortex-version.outputs.vortex-version }}
6676
run: make package
6777
- name: Upload asset

Makefile

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,25 +24,40 @@ VENV ?=
2424
VENV_PYTHON := $(VENV)/bin/python3
2525
DEBUG_OPTS :=
2626
MESON_DEBUG_OPTS :=
27-
GCC_BUILD_OPTS :=
2827
VERSION=$(shell git describe --tags --abbrev=0)
2928
KVER := $(shell uname -r)
3029
ARCH := $(shell uname -m)
3130

3231
PYTHON_VERSION=$(shell $(PYTHON) -c "import platform; print(platform.python_version())")
3332
PYTHON_VERSION_NUMS = $(subst ., ,$(PYTHON_VERSION))
3433

34+
# Setup Clang
35+
CLANG_INCLUDE_DIR=$(shell llvm-config --includedir)
36+
CLANG_LIB_DIR=$(shell llvm-config --libdir)
37+
LIBRARY_PATH=$(shell llvm-config --libdir)
38+
CC=clang
39+
LD_LIBRATY_PATH += $(shell llvm-config --libdir)
40+
CFLAGS += $(shell llvm-config --cflags)
41+
LDFLAGS += -L$(shell llvm-config --libdir)
42+
3543
ifeq ($(DEBUG),1)
36-
GCC_BUILD_OPTS=CFLAGS='-DVORTEX_DEBUG -g
44+
CFLAGS += -DVORTEX_DEBUG -g
3745
ifeq ($(TIMER_DEBUG),1)
38-
GCC_BUILD_TOPS += -DVORTEX_TIMERS_DEBUG
46+
CFLAGS += -DVORTEX_TIMERS_DEBUG
3947
endif
40-
GCC_BUILD_OPTS += '
4148
MESON_BUILD_OPTS=--config-settings=setup-args="-Dbuildtype=debug"
4249
endif
4350

51+
export CC
52+
export CFLAGS
53+
export LDFLAGS
54+
export CLANG_INCLUDE_DIR
55+
export CLANG_LIB_DIR
56+
export LIBRARY_PATH
57+
export LD_LIBRARY_PATH
58+
4459
all: version
45-
CC=clang $(GCC_BUILD_OPTS) $(PYTHON) -m pip install --no-build-isolation \
60+
$(PYTHON) -m pip install --no-build-isolation \
4661
--editable . $(MESON_BUILD_OPTS)
4762
@if [ ! -L compile_commands.json ]; then \
4863
ln -s build/cp$(word 1,$(PYTHON_VERSION_NUMS))$(word 2,$(PYTHON_VERSION_NUMS))/compile_commands.json \
@@ -78,7 +93,7 @@ venv:
7893
$(VENV)/bin/pip install -r ./virtualenv.txt
7994

8095
wheel: venv version
81-
CC=clang $(VENV_PYTHON) -m build -w .
96+
$(VENV_PYTHON) -m build -w .
8297

8398
package: version
8499
$(PYTHON) -m build -w .

src/core/mem_debug.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@
1515
* You should have received a copy of the GNU General Public License
1616
* along with this program. If not, see <http://www.gnu.org/licenses/>.
1717
*/
18-
#define _GNU_SOURCE
18+
#ifndef _GNU_SOURCE
19+
#define _GNU_SOURCE 1
20+
#endif
1921
#include <stdio.h>
2022
#include <dlfcn.h>
2123
#include <stdbool.h>

src/core/objects/axis.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@
1515
* You should have received a copy of the GNU General Public License
1616
* along with this program. If not, see <http://www.gnu.org/licenses/>.
1717
*/
18-
#define _GNU_SOURCE
18+
#ifndef _GNU_SOURCE
19+
#define _GNU_SOURCE 1
20+
#endif
1921
#include <stdint.h>
2022
#include <string.h>
2123
#include <stdbool.h>

src/lib/logging/logging.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@
1515
* You should have received a copy of the GNU General Public License
1616
* along with this program. If not, see <http://www.gnu.org/licenses/>.
1717
*/
18-
#define _GNU_SOURCE
18+
#ifndef _GNU_SOURCE
19+
#define _GNU_SOURCE 1
20+
#endif
1921
#include <stdio.h>
2022
#include <stddef.h>
2123
#include <stdint.h>

src/lib/random.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@
1515
* You should have received a copy of the GNU General Public License
1616
* along with this program. If not, see <http://www.gnu.org/licenses/>.
1717
*/
18-
#define _GNU_SOURCE
18+
#ifndef _GNU_SOURCE
19+
#define _GNU_SOURCE 1
20+
#endif
1921
#include <pthread.h>
2022
#include <stdlib.h>
2123
#include <values.h>

src/threads/core_threads.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@
1515
* You should have received a copy of the GNU General Public License
1616
* along with this program. If not, see <http://www.gnu.org/licenses/>.
1717
*/
18-
#define _GNU_SOURCE
18+
#ifndef _GNU_SOURCE
19+
#define _GNU_SOURCE 1
20+
#endif
1921
#include <errno.h>
2022
#include <pthread.h>
2123
#include <stdlib.h>

tools/clang_ast/clang_ast_builder.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@
1818
import os
1919

2020
def get_clang_cursor_kind_defs():
21-
filename = "/usr/include/clang-c/Index.h"
21+
include_path = os.environ.get("CLANG_INCLUDE_PATH", "/usr/include")
22+
filename = os.path.join(include_path, "clang-c/Index.h")
2223
enum_found = False
2324
defs = ["enum CursorKind {"]
2425
enum_values = {}
@@ -50,7 +51,8 @@ def get_clang_cursor_kind_defs():
5051
return defs
5152

5253
def get_clang_type_kind_defs():
53-
filename = "/usr/include/clang-c/Index.h"
54+
include_path = os.environ.get("CLANG_INCLUDE_PATH", "/usr/include")
55+
filename = os.path.join(include_path, "clang-c/Index.h")
5456
enum_found = False
5557
defs = ["enum TypeKind {"]
5658
enum_values = {}

tools/find_modules.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@
2121

2222
def find_hw_objects(source_dir):
2323
object_dir = pathlib.PosixPath(source_dir)
24+
libdir = os.environ.get("CLANG_LIB_DIR")
25+
if libdir:
26+
cindex.Config.set_library_path(libdir)
2427
index = cindex.Index.create()
2528
objects = []
2629
for file in object_dir.iterdir():

0 commit comments

Comments
 (0)