Skip to content

Add attributes for g++ and clang++ to export the emulator functions #211

Add attributes for g++ and clang++ to export the emulator functions

Add attributes for g++ and clang++ to export the emulator functions #211

Workflow file for this run

name: CMake
on:
# Triggers the workflow on push, PR or manual dispatch
push:
branches:
# Also launch the CI when creating a tag
tags:
pull_request:
# Allows you to run this workflow manually from the Actions tab by
# selection CMake and then "Run workflow" menu on the right branch
# and clicking on "launch_tmate_terminal_for_debug".
# Unfortunately this works only for the default branch.
# So you can either
# - change as the default one default the branch of the PR on the
# GitHub repository owning the PR and launching in Actions tab;
# - or edit directly the step below which runs tmate and push to the
# PR, ignoring the manual workflow launch.
workflow_dispatch:
inputs:
launch_tmate_terminal_for_debug:
type: boolean
description: 'Run the build with tmate debugging enabled (https://github.com/marketplace/actions/debugging-with-tmate)'
required: false
default: false
compilation_time_out:
type: number
description: Run the build with a timeout in minutes to have
partial compilation to bootstrap ccache
required: false
default: 10
defaults:
run:
# This is already the default, except when running inside another Docker
# image, which is the case here. So set it up globally to avoid
# repeating elsewhere.
shell: bash
env:
# Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.)
BUILD_TYPE: Release
jobs:
build-and-test:
name: Run the validation inside Docker with specific OS and options
# By latest GitHub means actually latest LTS only
runs-on: ubuntu-latest
# Run into an even more recent Ubuntu inside Docker to have recent
# compilers and C++ standard library
container:
# Ubuntu 23.10
image: docker://ubuntu:mantic
strategy:
# Run all the test even if there are some which fail
fail-fast: false
matrix:
include:
- c_compiler: gcc-13
cxx_compiler: g++-13
OpenMP: ON
OpenCL: OFF
- c_compiler: gcc-13
cxx_compiler: g++-13
OpenMP: ON
OpenCL: ON
- c_compiler: clang-19
cxx_compiler: clang++-19
OpenMP: ON
OpenCL: OFF
- c_compiler: clang-19
cxx_compiler: clang++-19
OpenMP: ON
OpenCL: ON
# Cancel old CI jobs for a PR when the PR is updated
concurrency:
# Create a job equivalence class with an id crafted to only
# cancel in-progress runs of the same workflow and same
# job-index in the matrix
group: '${{ github.workflow }}-job-index-${{ strategy.job-index }} @ ${{ github.event.pull_request.head.label || github.head_ref || github.ref }} for ${{ matrix }}'
# Cancel only pull-request related events
cancel-in-progress: ${{ startsWith(github.ref, 'refs/pull/') }}
steps:
- name: Display environment variables
run: env
- name: User and group ids
run: id -a
- name: Execution context information
# Display a lot of information to help further development
# https://docs.github.com/en/actions/learn-github-actions/variables
# https://docs.github.com/en/enterprise-cloud@latest/actions/learn-github-actions/contexts
# The problem is that echo-ing directly "${{ toJSON(github) }}"
# in the shell is not escaped and for example '&' breaks
# things or can lead to server-side script injection. :-(
# So, use environment setting and display the environment
# variable in the shell between "" to avoid unsafe
# interpretation.
env:
execution_context_var_github: ${{ toJSON(github) }}
execution_context_var_env: ${{ toJSON(env) }}
execution_context_var_vars: ${{ toJSON(vars) }}
execution_context_var_job: ${{ toJSON(job) }}
execution_context_var_steps: ${{ toJSON(steps) }}
execution_context_var_runner: ${{ toJSON(runner) }}
execution_context_var_strategy: ${{ toJSON(strategy) }}
execution_context_var_matrix: ${{ toJSON(matrix) }}
execution_context_var_needs: ${{ toJSON(needs) }}
execution_context_var_inputs: ${{ toJSON(inputs) }}
run: |
echo "::group::github context"
echo "$execution_context_var_github"
echo "::endgroup::"
echo "::group::env context"
echo "$execution_context_var_env"
echo "::endgroup::"
echo "::group::vars context"
echo "$execution_context_var_vars"
echo "::endgroup::"
echo "::group::job context"
echo "$execution_context_var_job"
echo "::endgroup::"
echo "::group::steps context"
echo "$execution_context_var_steps"
echo "::endgroup::"
echo "::group::runner context"
echo "$execution_context_var_runner"
echo "::endgroup::"
echo "::group::strategy context"
echo "$execution_context_var_strategy"
echo "::endgroup::"
echo "::group::matrix context"
echo "$execution_context_var_matrix"
echo "::endgroup::"
echo "::group::needs context"
echo "$execution_context_var_needs"
echo "::endgroup::"
echo "::group::inputs context"
echo "$execution_context_var_inputs"
echo "::endgroup::"
- name: Install required packages
run: |
apt-get update
apt-get install -y build-essential cmake g++ gdb git \
libboost1.81-all-dev libgtkmm-3.0-dev librange-v3-dev \
pkgconf
- name: Check out repository code
uses: actions/checkout@v3
- name: Declare LLVM package repository if needed
if: startsWith(matrix.c_compiler, 'clang') || startsWith(matrix.cxx_compiler, 'clang')
run: |
apt-get install -y wget
wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | apt-key add -
# "Parse" the Linux distribution parameters
source /etc/os-release
echo "deb http://apt.llvm.org/$VERSION_CODENAME llvm-toolchain-$VERSION_CODENAME main" \
> /etc/apt/sources.list.d/llvm.list
echo "deb-src http://apt.llvm.org/$VERSION_CODENAME llvm-toolchain-$VERSION_CODENAME main" \
>> /etc/apt/sources.list.d/llvm.list
apt-get update
- name: Install the C compiler
run: apt-get install -y ${{matrix.c_compiler}}
- name: Install the C++ compiler
# Do not install the C++ compiler if it is clang++ since it comes
# along the Clang C compiler. Need "${{ }}" because it starts
# with "!"
if: ${{ !startsWith(matrix.cxx_compiler, 'clang') }}
run: apt-get install -y ${{matrix.cxx_compiler}}
- name: Install OpenMP support if needed
# Clang requires a specific OpenMP library to run
if: matrix.OpenMP == 'ON' && startsWith(matrix.cxx_compiler, 'clang')
run: |
# Get the clang++ version, which is what is left when we remove "clang++-"
CXX_COMPILER=${{matrix.cxx_compiler}}
cxx_compiler_version=${CXX_COMPILER#clang++-}
apt-get install -y libomp-${cxx_compiler_version}-dev
- name: Install OpenCL with PoCL if needed
if: matrix.OpenCL == 'ON'
run: apt-get install -y opencl-headers ocl-icd-opencl-dev libpocl-dev
# Use ccache to speed-up compilation to also fit into GitHub Actions
# resource limitations, see:
# https://github.com/hendrikmuhs/ccache-action
# The cache is saved in a "Post install-ccache" step, even if
# the job is canceled or some previous step fails, which is good
# to avoid wasting constrained compilation resources
- name: install-ccache
uses: hendrikmuhs/ccache-action@v1.2
with:
max-size: "1G"
key: ${{runner.os}}-${{matrix.c_compiler}}-${{matrix.cxx_compiler}}-${{matrix.OpenMP}}-${{matrix.OpenCL}}
- name: Configure CMake for ${{matrix.c_compiler}}, ${{matrix.cxx_compiler}},
OpenMP=${{matrix.OpenMP}}, OpenCL=${{matrix.OpenCL}}
# Create the build directory in ${{github.workspace}}/build
# and inject ccache in the build system
run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}}
-DTRISYCL_OPENCL=${{matrix.OpenCL}} -DTRISYCL_OPENMP=${{matrix.OpenMP}}
-DCMAKE_C_COMPILER=${{matrix.c_compiler}} -DCMAKE_CXX_COMPILER=${{matrix.cxx_compiler}}
-DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache
- name: Build for ${{matrix.c_compiler}}, ${{matrix.cxx_compiler}},
OpenMP=${{matrix.OpenMP}}, OpenCL=${{matrix.OpenCL}}
# Some atrocities here because if the time-out value comes
# from a variable of type 'number' it actually is interpreted
# as a string and parsing fails. GitHub bug or expression
# typing fuzziness? So, first use toJSON() to test for
# non-existence of the variable to return null which is
# implicitly up-casted to a string by the comparison and
# returns a default timeout value for 1 day. Otherwise, if the
# variable is set, interpret the string number as JSON to
# force the type to be a number.
timeout-minutes: ${{ ((toJSON(inputs.compilation_time_out) == 'null') && 1440)
|| fromJSON(inputs.compilation_time_out) }}
# Compile all the tests using all the available cores
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}}
--verbose --parallel `nproc`
# Launch an ssh session via a proxy server if there is a need
# for debug. This seems to live for 35 min max
# https://github.com/mxschmitt/action-tmate
- name: Setup tmate session
uses: mxschmitt/action-tmate@v3
# To run this, launch it manually on the default branch and
# click on "launch_tmate_terminal_for_debug"
if: github.event_name == 'workflow_dispatch'
&& inputs.launch_tmate_terminal_for_debug
with:
# Since we run in Docker, no need to use sudo
sudo: false
- name: Test for ${{matrix.c_compiler}}, ${{matrix.cxx_compiler}},
OpenMP=${{matrix.OpenMP}}, OpenCL=${{matrix.OpenCL}}
# Run the tests which do not use the GUI since there is no
# display or user
run: |
# Request unlimited stack size needed for some tests
ulimit -s unlimited
ctest --label-exclude GUI --test-dir ${{github.workspace}}/build --build-config ${{env.BUILD_TYPE}}