Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Root array predicates5 #32

Root array predicates5

Root array predicates5 #32

Workflow file for this run

# Github action to test for C++ interoperability
#
# Most tests in the test-suite run on the CI when it comes to cross-platform testing.
# However, the dlang auto-tester uses somewhat old host C/C++ compiler.
# This is good for testing compatibility with e.g. LTS distributions,
# but becomes problematic when we want to test more cutting-edge features,
# such as newer C++ standards (C++17, C++20, etc...).
#
# This is the reason why we have this action: we have full control over the toolchain,
# and it is cross platform. The supported platforms are whatever Github Actions support,
# which is usually whatever the vendor (Canonical, Apple, Microsoft) supports.
#
# Notes:
# - When debugging/troubleshooting, make sure to check the printed compiler versions.
# - Try to use the native Github action syntax (${{ expression }}) when possible,
# as they are substituted with their value in the logs, unlike env variable.
# For example use `${{ github.workspace }}` over `${GITHUB_WORKSPACE}`
#
# TODO:
# - Test clang on Windows? (note: probably not all tests respect a CC/CXX env variable on Windows)
name: C++ interop tests
# Only triggers on pushes to master & stable, as well as PR to master and stable
# Sometimes reverts appear in the upstream repository (e.g. when the revert button
# is clicked by a contributor with commit access), this should be tested as PR).
#
# Also note that Github actions does not retrigger on target branch changes,
# hence the check on push.
on:
pull_request:
branches:
- master
- stable
push:
branches:
- master
- stable
# Use this branch name in your fork to test changes
- github-actions
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
main:
name: Run
if: github.repository == 'dlang/dmd'
strategy:
# Since those tests takes very little time, don't use `fail-fast`.
# If runtime expand, we might want to comment this out,
# as most failing PRs do so because they don't compile / something is broken,
# very few PRs actually benefit from this.
fail-fast: false
matrix:
include:
# Linux, clang:
# NOTE: cannot test MODEL=32 with clang on Linux, due to a single failure as of April 2025:
# runnable_cxx/cppa.d:261: cppa.check13956: Assertion `arg6 == 6' failed.
- { os: ubuntu-24.04, compiler: clang-18, model: 64 }
- { os: ubuntu-22.04, compiler: clang-15, model: 64 }
- { os: ubuntu-24.04, compiler: clang-14, model: 64 }
- { os: ubuntu-22.04, compiler: clang-11, model: 64 }
# Linux, g++:
- { os: ubuntu-24.04, compiler: g++-13, model: 64 }
- { os: ubuntu-24.04, compiler: g++-13, model: 32 }
- { os: ubuntu-22.04, compiler: g++-12, model: 64 }
- { os: ubuntu-22.04, compiler: g++-12, model: 32 }
- { os: ubuntu-22.04, compiler: g++-9, model: 64 }
- { os: ubuntu-22.04, compiler: g++-9, model: 32 }
# macOS, Apple clang from Xcode:
# Disabled due to issues with x87: https://github.com/dlang/dmd/issues/21987
#- { os: macos-15, xcode: '16.4', model: 64 }
- { os: macos-14, xcode: '16.2', model: 64 }
# Windows, cl.exe from Visual Studio:
# NOTE: as of April 2025, image windows-2025 only has VS 2022, so no point in testing that image too
- { os: windows-2022, model: 64 }
- { os: windows-2022, model: 32 }
runs-on: ${{ matrix.os }}
defaults:
run:
shell: bash
steps:
- name: Set environment variable N (parallelism)
run: echo "N=$(${{ runner.os == 'macOS' && 'sysctl -n hw.logicalcpu' || 'nproc' }})" >> $GITHUB_ENV
- name: Set environment variable MODEL
run: echo "MODEL=${{ matrix.model }}" >> $GITHUB_ENV
- name: 'macOS: Upgrade GNU make'
if: runner.os == 'macOS'
run: |
set -eux
brew install make
sudo ln -s $(which gmake) /usr/local/bin/make
make --version
########################################
# Setting up the host D compiler #
########################################
- name: Install D host compiler
uses: dlang-community/setup-dlang@v2
- name: 'Posix: Clear LD_LIBRARY_PATH environment variable' # don't use host druntime/Phobos .so/.dylib etc.
if: runner.os != 'Windows'
run: echo "LD_LIBRARY_PATH=" >> $GITHUB_ENV
##############################################
# Find out which branch we need to check out #
##############################################
- name: Determine base branch
id: base_branch
run: |
# For pull requests, base_ref will not be empty
if [ ! -z ${{ github.base_ref }} ]; then
echo "branch=${{ github.base_ref }}" >> $GITHUB_OUTPUT
# Otherwise, use whatever ref we have:
# For branches this in the format 'refs/heads/<branch_name>',
# and for tags it is refs/tags/<tag_name>.
else
echo "branch=${{ github.ref }}" >> $GITHUB_OUTPUT
fi
#####################################
# Checking out DMD and Phobos #
#####################################
- name: Checkout DMD
uses: actions/checkout@v4
with:
path: dmd
persist-credentials: false
- name: Checkout Phobos
uses: actions/checkout@v4
with:
path: phobos
repository: dlang/phobos
ref: ${{ steps.base_branch.outputs.branch }}
persist-credentials: false
########################################
# Setting up the host C++ compiler #
########################################
- name: 'Linux: Install C++ compiler'
if: runner.os == 'Linux'
run: |
set -eux
sudo apt-get update
apt_packages='${{ matrix.compiler }}'
if [[ "$MODEL" == 32 ]]; then
if [[ '${{ matrix.compiler }}' =~ ^g\+\+ ]]; then
apt_packages+=" ${{ matrix.compiler }}-multilib"
else
apt_packages+=" g++-multilib"
fi
fi
sudo apt-get install -y $apt_packages
- name: 'Windows: Set up MSVC environment' # puts cl.exe in PATH etc.
if: runner.os == 'Windows'
uses: seanmiddleditch/gha-setup-vsdevenv@v4
with:
arch: ${{ matrix.model == '64' && 'x64' || 'x86' }}
- name: 'Posix: Set up CC and CXX environment variables'
if: runner.os != 'Windows'
run: |
set -eux
if [[ '${{ runner.os }}' == Linux ]]; then
compiler='${{ matrix.compiler }}'
echo "CC=${compiler/g++/gcc}" >> $GITHUB_ENV
echo "CXX=${compiler/clang/clang++}" >> $GITHUB_ENV
elif [[ '${{ runner.os }}' == macOS ]]; then
sudo xcode-select -switch /Applications/Xcode_${{ matrix.xcode }}.app
echo "CC=cc" >> $GITHUB_ENV
echo "CXX=c++" >> $GITHUB_ENV
fi
- name: Print used C/C++ compiler versions
run: |
set -eux
if [[ '${{ runner.os }}' == Windows ]]; then
which cl.exe
else
$CC --version
$CXX --version
fi
########################################
# Building DMD, druntime, Phobos #
########################################
- name: Build compiler & standard library
run: |
set -eux
if [[ '${{ matrix.os }}' == macos-14 ]]; then
# don't try compiling a native arm64 DMD on macOS (doesn't work)
make -C dmd -j$N dmd DFLAGS="-mtriple=x86_64-apple-macos14"
fi
make -C dmd -j$N
make -C phobos -j$N
########################################
# Running the test suite #
########################################
- name: Run compiler C++ test suite
run: ./dmd/compiler/test/run.d --environment runnable_cxx dshell/dll_cxx.d ${{ matrix.os == 'macos-14' && 'HOST_DMD="$PWD/dmd/generated/osx/release/64/dmd"' || '' }}
- name: Run druntime C++ tests
run: make -C dmd/druntime -j$N test/stdcpp/.run
- name: 'Posix: Run C++ frontend unittests'
if: runner.os != 'Windows' # not supported by build.d yet
run: |
set -eux
if [[ '${{ matrix.os }}' == macos-14 ]]; then
# switch from LDC to freshly built DMD as host compiler
export HOST_DMD="$PWD/dmd/generated/osx/release/64/dmd"
export CXXFLAGS="-arch x86_64"
rm ./dmd/generated/osx/release/64/*.o
fi
./dmd/generated/build cxx-unittest