"Fossies" - the Fresh Open Source Software Archive

Member "dmd2/src/druntime/.github/workflows/cxx.yml" (20 Nov 2020, 13303 Bytes) of package /linux/misc/dmd.2.094.2.linux.tar.xz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Ansible YAML source code syntax highlighting (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file.

    1 # Github action to test for C++ interoperability
    2 #
    3 # This file is modeled after DMD's Github action definition (`runnable_cxx.yml`).
    4 # Its goal is to test interaction with the C++ standard library on multiple platforms.
    5 # Look up the DMD file for more information about reasoning, patterns, caveats, etc...
    6 #
    7 # TODO:
    8 # - Implement Windows + MSVC 2017 support (investigate 2015)
    9 # - Implement Windows + clang support
   10 # - Implement Linux + Clang 32 bits support (if possible)
   11 name: stdcpp
   12 
   13 on:
   14   pull_request:
   15     branches:
   16       - master
   17       - stable
   18   push:
   19     branches:
   20       - master
   21       - stable
   22       # Use this branch name in your fork to test changes
   23       - github-actions
   24 
   25 jobs:
   26   main:
   27     name: Run
   28     strategy:
   29       fail-fast: false
   30       # Matches the matrix in DMD to support the same platforms
   31       matrix:
   32         os: [ macOS-10.15, ubuntu-16.04, windows-2019 ]
   33         target: [
   34           clang-9.0.0, clang-8.0.0, clang-7.0.0, clang-6.0.0,
   35           g++-9, g++-8, g++-7, g++-6, g++-5,
   36           msvc-2019, msvc-2017, msvc-2015
   37         ]
   38 
   39         exclude:
   40           # Ubuntu supports clang and g++
   41           - { os: ubuntu-16.04, target: msvc-2019 }
   42           - { os: ubuntu-16.04, target: msvc-2017 }
   43           - { os: ubuntu-16.04, target: msvc-2015 }
   44           # OSX only supports clang
   45           - { os: macOS-10.15, target: g++-9 }
   46           - { os: macOS-10.15, target: g++-8 }
   47           - { os: macOS-10.15, target: g++-7 }
   48           - { os: macOS-10.15, target: g++-6 }
   49           - { os: macOS-10.15, target: g++-5 }
   50           - { os: macOS-10.15, target: msvc-2019 }
   51           - { os: macOS-10.15, target: msvc-2017 }
   52           - { os: macOS-10.15, target: msvc-2015 }
   53           # We don't test g++ on Windows as DMD only mangles for MSVC
   54           - { os: windows-2019, target: g++-9 }
   55           - { os: windows-2019, target: g++-8 }
   56           - { os: windows-2019, target: g++-7 }
   57           - { os: windows-2019, target: g++-6 }
   58           - { os: windows-2019, target: g++-5 }
   59 
   60           # TODO: Implement support for clang and MSVC2017 on Windows
   61           # Currently those are still being run by the auto-tester
   62           # We can hardly test below 2017 in the CI because there's
   63           # no way to install it via command line
   64           # (TODO: Test with 2015 as the blog post is slightly ambiguous)
   65           # https://devblogs.microsoft.com/cppblog/introducing-the-visual-studio-build-tools/
   66           - { os: windows-2019, target: msvc-2017 }
   67           - { os: windows-2019, target: msvc-2015 }
   68           - { os: windows-2019, target: clang-9.0.0 }
   69           - { os: windows-2019, target: clang-8.0.0 }
   70           - { os: windows-2019, target: clang-7.0.0 }
   71           - { os: windows-2019, target: clang-6.0.0 }
   72 
   73         include:
   74           # Clang boilerplate
   75           - { target: clang-9.0.0, compiler: clang, cxx-version: 9.0.0 }
   76           - { target: clang-8.0.0, compiler: clang, cxx-version: 8.0.0 }
   77           - { target: clang-7.0.0, compiler: clang, cxx-version: 7.0.0 }
   78           - { target: clang-6.0.0, compiler: clang, cxx-version: 6.0.0 }
   79           # g++ boilerplace
   80           - { target: g++-9, compiler: g++, cxx-version: 9.3.0 }
   81           - { target: g++-8, compiler: g++, cxx-version: 8.4.0 }
   82           - { target: g++-7, compiler: g++, cxx-version: 7.5.0 }
   83           - { target: g++-6, compiler: g++, cxx-version: 6.5.0 }
   84           - { target: g++-5, compiler: g++, cxx-version: 5.5.0 }
   85           # Platform boilerplate
   86           - { os: ubuntu-16.04, arch: x86_64-linux-gnu-ubuntu-16.04 }
   87           - { os: macOS-10.15,  arch: x86_64-apple-darwin }
   88           # Clang 9.0.0 have a different arch for OSX
   89           - { os: macOS-10.15, target: clang-9.0.0, arch: x86_64-darwin-apple }
   90 
   91     runs-on: ${{ matrix.os }}
   92     steps:
   93 
   94     ########################################
   95     #    Setting up the host D compiler    #
   96     ########################################
   97     - name: Prepare compiler
   98       uses: dlang-community/setup-dlang@v1
   99       with:
  100           compiler: dmd-2.091.0
  101 
  102     ##############################################
  103     # Find out which branch we need to check out #
  104     ##############################################
  105     - name: Determine base branch
  106       id: base_branch
  107       shell: bash
  108       run: |
  109         # For pull requests, base_ref will not be empty
  110         if [ ! -z ${{ github.base_ref }} ]; then
  111             echo "::set-output name=branch::${{ github.base_ref }}"
  112         # Otherwise, use whatever ref we have:
  113         # For branches this in the format 'refs/heads/<branch_name>',
  114         # and for tags it is refs/tags/<tag_name>.
  115         else
  116             echo "::set-output name=branch::${{ github.ref }}"
  117         fi
  118 
  119     #########################################
  120     # Checking out up DMD, druntime, Phobos #
  121     #########################################
  122     - name: Checkout DMD
  123       uses: actions/checkout@v2
  124       with:
  125         path: dmd
  126         repository: dlang/dmd
  127         ref: ${{ steps.base_branch.outputs.branch }}
  128         persist-credentials: false
  129     - name: Checkout druntime
  130       uses: actions/checkout@v2
  131       with:
  132         path: druntime
  133         persist-credentials: false
  134     - name: Checkout Phobos
  135       uses: actions/checkout@v2
  136       with:
  137         path: phobos
  138         repository: dlang/phobos
  139         ref: ${{ steps.base_branch.outputs.branch }}
  140         persist-credentials: false
  141 
  142 
  143     ########################################
  144     #   Setting up the host C++ compiler   #
  145     ########################################
  146     - name: '[Posix] Setting up clang ${{ matrix.cxx-version }}'
  147       if: matrix.compiler == 'clang' && runner.os != 'Windows'
  148       run: |
  149         wget --quiet --directory-prefix=${{ github.workspace }} https://releases.llvm.org/${{ matrix.cxx-version }}/clang+llvm-${{ matrix.cxx-version }}-${{ matrix.arch }}.tar.xz
  150         tar -x -C ${{ github.workspace }} -f ${{ github.workspace }}/clang+llvm-${{ matrix.cxx-version }}-${{ matrix.arch }}.tar.xz
  151         TMP_CC='${{ github.workspace }}/clang+llvm-${{ matrix.cxx-version }}-${{ matrix.arch }}/bin/clang'
  152         # On OSX, the system header are installed via `xcode-select` and not distributed with clang
  153         # Since some part of the testsuite rely on CC being only a binary (not a command),
  154         # and config files where only introduced from 6.0.0, use a wrapper script.
  155         if [ "${{ matrix.os }}" == "macOS-10.15" ]; then
  156           # Note: heredoc shouldn't be indented
  157           cat <<EOF > ${TMP_CC}-wrapper
  158         #!/bin/bash
  159         ${TMP_CC} -isystem /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/ \$@
  160         EOF
  161           # Invoking clang with `clang++` will link the C++ standard library
  162           # Make sure we got two separate wrapper for this
  163           cat <<EOF > ${TMP_CC}++-wrapper
  164         #!/bin/bash
  165         ${TMP_CC}++ -isystem /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/ \$@
  166         EOF
  167           chmod +x ${TMP_CC}-wrapper ${TMP_CC}++-wrapper
  168           echo "CC=${TMP_CC}-wrapper" >> $GITHUB_ENV
  169           echo "CXX=${TMP_CC}++-wrapper" >> $GITHUB_ENV
  170         else
  171           # Note: druntime's tests use `CXX` and DMD uses `CC`
  172           echo "CC=${TMP_CC}" >> $GITHUB_ENV
  173           echo "CXX=${TMP_CC}++" >> $GITHUB_ENV
  174         fi
  175 
  176     # On OSX and Linux, clang is installed by default and in the path,
  177     # so make sure ${CC} works
  178     - name: '[Posix] Verifying installed clang version'
  179       if: matrix.compiler == 'clang' && runner.os != 'Windows'
  180       run: |
  181         set -e
  182         if ${CXX} --version | grep -q 'version ${{ matrix.cxx-version }}'; then
  183           ${CXX} --version
  184           ${CXX} -print-search-dirs -print-libgcc-file-name
  185         else
  186             echo "Expected version ${{ matrix.cxx-version }}, from '${CC}', got:"
  187             ${CXX} --version
  188             exit 1
  189         fi
  190 
  191     # G++ is only supported on Linux
  192     - name: '[Linux] Setting up g++ ${{ matrix.cxx-version }}'
  193       if: matrix.compiler == 'g++'
  194       run: |
  195         # Workaround bug in Github actions
  196         curl https://cli-assets.heroku.com/apt/release.key | sudo apt-key add -
  197         # Make sure we have the essentials
  198         sudo apt-get update
  199         sudo apt-get install build-essential software-properties-common -y
  200         # This ppa provides multiple versions of g++
  201         sudo add-apt-repository ppa:ubuntu-toolchain-r/test -y
  202         sudo apt-get update
  203         sudo apt-get install ${{ matrix.target }} ${{ matrix.target }}-multilib
  204         echo "CC=${{ matrix.target }}" >> $GITHUB_ENV
  205         echo "CXX=${{ matrix.target }}" >> $GITHUB_ENV
  206 
  207     # Make sure ${CC} works and we don't use the $PATH one
  208     - name: '[Linux] Verifying installed g++ version'
  209       if: matrix.compiler == 'g++'
  210       run: |
  211         set -e
  212         if ${CXX} --version | grep -q '${{ matrix.target }} (Ubuntu '; then
  213           ${CXX} --version
  214         else
  215             echo "Expected version ${{ matrix.target }}, from '${CXX}', got:"
  216             ${CXX} --version
  217             exit 1
  218         fi
  219 
  220     # Restore or install dmc (and DM make)
  221     - name: '[Windows] Restore dmc from cache'
  222       id: cache-dmc
  223       if: runner.os == 'Windows'
  224       uses: actions/cache@v1
  225       with:
  226         path: ${{ github.workspace }}/tools/
  227         key: ${{ matrix.os }}-dmc857
  228 
  229     - name: '[Windows] Install dmc'
  230       if: runner.os == 'Windows' && steps.cache-dmc.outputs.cache-hit != 'true'
  231       shell: powershell
  232       run: |
  233         $url = "http://ftp.digitalmars.com/Digital_Mars_C++/Patch/dm857c.zip"
  234         $sha256hash = "3034016E02057618F1C6E33B9B3EACAE5F5BE25B203025BCC08F1C5D9340AE38"
  235         Write-Host ('Downloading {0} ...' -f $url)
  236         [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
  237         $ProgressPreference = 'SilentlyContinue'
  238         New-Item -ItemType directory -Path ${{ github.workspace }}\tools\
  239         Invoke-WebRequest -Uri $url -OutFile '${{ github.workspace }}\tools\dmc.zip'
  240         if ((Get-FileHash '${{ github.workspace }}\tools\dmc.zip' -Algorithm "SHA256").Hash -ne $sha256hash) {
  241           exit 1
  242         }
  243         Expand-Archive '${{ github.workspace }}\tools\dmc.zip' -DestinationPath ${{ github.workspace }}\tools\
  244 
  245     - name: '[Windows] Set environment variables'
  246       if: runner.os == 'Windows'
  247       run: |
  248         echo "${{ github.workspace }}\tools\dm\bin\" >> $GITHUB_PATH
  249 
  250     ########################################
  251     #    Building DMD, druntime, Phobos    #
  252     ########################################
  253     - name: '[Posix] Build compiler & standard library'
  254       if: runner.os != 'Windows'
  255       run: |
  256         # All hosts are 64 bits but let's be explicit
  257         ./dmd/src/build.d -j2 MODEL=64
  258         make -C druntime -f posix.mak -j2 MODEL=64
  259         make -C phobos   -f posix.mak -j2 MODEL=64
  260         # Both version can live side by side (they end up in a different directory)
  261         # However, since clang does not provide a multilib package, only test 32 bits with g++
  262         if [ ${{ matrix.compiler }} == "g++" ]; then
  263           ./dmd/src/build.d -j2 MODEL=32
  264           make -C druntime -f posix.mak -j2 MODEL=32
  265           make -C phobos   -f posix.mak -j2 MODEL=32
  266         fi
  267 
  268     - name: '[Windows] Build compiler & standard library'
  269       if: runner.os == 'Windows'
  270       shell: cmd
  271       env:
  272         HOST_DC: ${{ env.DC }}
  273       run: |
  274         call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Auxiliary\Build\vcvars64.bat"
  275         dmd -run ./dmd/src/build.d -j2 MODEL=64
  276         if %errorlevel% neq 0 exit /b %errorlevel%
  277         # Note: Only CC for druntime and AR for Phobos are required ATM,
  278         # but providing all three to avoid surprise for future contributors
  279         # Those should really be in the path, though.
  280         cd druntime
  281         make -f win64.mak CC=cl LD=link AR=lib
  282         if %errorlevel% neq 0 exit /b %errorlevel%
  283         cd ..\phobos\
  284         make -f win64.mak CC=cl LD=link AR=lib
  285         if %errorlevel% neq 0 exit /b %errorlevel%
  286         cd ..\
  287 
  288     ########################################
  289     #        Running the test suite        #
  290     ########################################
  291     - name: '[Posix] Run C++ test suite'
  292       if: runner.os != 'Windows'
  293       run: |
  294         make -C druntime -f posix.mak test/stdcpp/.run MODEL=64
  295         if [ ${{ matrix.compiler }} == "g++" ]; then
  296           make -C druntime -f posix.mak test/stdcpp/.run MODEL=32
  297         fi
  298 
  299     - name: '[Windows] Run C++ test suite'
  300       if: runner.os == 'Windows'
  301       shell: cmd
  302       env:
  303         HOST_DC: ${{ env.DC }}
  304       run: |
  305         call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Auxiliary\Build\vcvars64.bat"
  306         cd druntime
  307         make -f win64.mak test_stdcpp CC=cl LD=link AR=lib
  308         if %errorlevel% neq 0 exit /b %errorlevel%
  309 
  310     ########################################
  311     #     Dump symbols on link failure     #
  312     ########################################
  313     - name: '[Posix,Fail] Dump C++ / D binary symbols'
  314       if: failure() && runner.os != 'Windows'
  315       run: |
  316         ls -l druntime/generated/*/release/*/
  317         for file in druntime/generated/*/release/*/*.o*; do
  318           echo "========== Symbols for '$file' =========="
  319           nm $file
  320         done