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