Skip to content

Commit

Permalink
Compile with both gcc and clang
Browse files Browse the repository at this point in the history
  • Loading branch information
davidmallasen committed Dec 5, 2024
1 parent 4e9f006 commit 3bf4b23
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 15 deletions.
7 changes: 3 additions & 4 deletions .github/workflows/building.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
name: Building tests
name: Compile all apps
on: [push, pull_request]

jobs:
test_applications:
runs-on: ubuntu-latest
container:
image: ghcr.io/esl-epfl/x-heep-toolchain:latest
name: Builds apps with gcc and clang. All must build successfully.
name: Compiles all apps with gcc and clang. All must compile successfully.
steps:
- name: Checkout the pushed code.
uses: actions/checkout@v3
- name: Configure the job container and run tests.
- name: Configure the job container and compile all apps.
run: |
# Create the virtual environment and install the requirements.
conda init bash
Expand All @@ -28,4 +28,3 @@ jobs:
make mcu-gen X_HEEP_CFG=configs/ci.hjson
python3 .github/workflows/test-apps/test_apps.py --compile-only
15 changes: 11 additions & 4 deletions .github/workflows/simulate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,23 @@ jobs:
image: ghcr.io/esl-epfl/x-heep-toolchain:latest
name: Simulate all apps. All must pass.
steps:
- name: Checkout
- name: Checkout the pushed code.
uses: actions/checkout@v3
- name: Run all apps
- name: Configure the job container and simulate all apps
run: |
# Create the virtual environment and install the requirements.
conda init bash
source /root/.bashrc
conda activate core-v-mini-mcu
make clean-all
# All peripherals are included to make sure all apps can be built.
sed 's/is_included: "no",/is_included: "yes",/' -i mcu_cfg.hjson
sed 's/num_channels: 0x1,/num_channels: 0x4,/' -i mcu_cfg.hjson
sed 's/num_channels_per_master_port: 0x1,/num_channels_per_master_port: 0x4,/' -i mcu_cfg.hjson
make mcu-gen MEMORY_BANKS=6
python3 .github/workflows/test-apps/test_apps.py
# The MCU is generated with various memory banks to avoid example code not fitting.
make mcu-gen X_HEEP_CFG=configs/ci.hjson
python3 .github/workflows/test-apps/test_apps.py
41 changes: 34 additions & 7 deletions .github/workflows/test-apps/test_apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
# Timeout for the simulation in seconds
SIM_TIMEOUT_S = 180

# Available compilers
COMPILERS = ["gcc", "clang"]

# Available simulators
SIMULATORS = ["verilator"]

Expand Down Expand Up @@ -100,15 +103,31 @@ class Application:

def __init__(self, name: str):
self.name = name
self.compilation_success = False
self.compilation_success = {}
self.simulation_results = {}

def set_compilation_status(self, success: bool):
self.compilation_success = success
def set_compilation_status(self, compiler: str, success: bool):
"""
Set if the compilation with the compiler was successful or not.
"""
if compiler not in COMPILERS:
raise ValueError(f"Compiler {compiler} is not supported.")
self.compilation_success[compiler] = success

def add_simulation_result(self, simulator: str, result: SimResult):
"""
Add the simulation result for the simulator.
"""
if simulator not in SIMULATORS:
raise ValueError(f"Simulator {simulator} is not supported.")
self.simulation_results[simulator] = result

def compilation_succeeded(self):
"""
Check if the compilation was successful with every compiler.
"""
return all(self.compilation_success.values())


def compile_app(an_app, compiler, linker):
"""
Expand Down Expand Up @@ -271,7 +290,7 @@ def filter_results(app_list):
if in_blacklist(app.name):
skipped_apps.append(app)
# If the app didn't compile, no need to check the simulations
elif not app.compilation_success:
elif not app.compilation_succeeded():
compilation_failed_apps.append(app)
else:
# Check if the app failed in any simulator
Expand Down Expand Up @@ -381,11 +400,19 @@ def main():

# Compile every app and run with the simulators
for an_app in app_list:
# If the app is in the blacklist, print a message and skip it
if not in_blacklist(an_app.name):
compilation_result = compile_app(an_app, "gcc", "on_chip")
an_app.set_compilation_status(compilation_result)
if compilation_result and not args.compile_only:
# Compile the app with every compiler
for compiler in COMPILERS:
compilation_result = compile_app(an_app, compiler, "on_chip")
an_app.set_compilation_status(compiler, compilation_result)

# Run the app with every simulator if the compilation was successful
if not args.compile_only and an_app.compilation_succeeded:
# Recompile the app with gcc
compile_app(an_app, "gcc", "on_chip")
for simulator in SIMULATORS:
# Only run the app with verilator if it is not in the verilator_blacklist
if simulator == "verilator" and in_verilator_blacklist(an_app.name):
an_app.add_simulation_result(simulator, SimResult.SKIPPED)
print(
Expand Down

0 comments on commit 3bf4b23

Please sign in to comment.