Debian Codegraph @

.github/workflows/build-msvc.yml

raw
1 name: Build with MSVC
2
3 concurrency:
4 group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
5 cancel-in-progress: true
6
7 on:
8 push:
9 branches:
10 - '4.**'
11 - '5.**'
12 - 'trunk'
13 pull_request:
14
15 # env:
16 # Fully print commands executed by Make
17 # MAKEFLAGS: V=1
18
19 defaults:
20 run:
21 shell: bash -eo pipefail -o igncr {0}
22
23 jobs:
24 config:
25 runs-on: ubuntu-latest
26 outputs:
27 matrix: ${{ steps.matrix.outputs.result}}
28 skip-testsuite: ${{ steps.skip.outputs.result }}
29 steps:
30 - name: Compute matrix for the "build" job
31 id: matrix
32 uses: actions/github-script@v7
33 with:
34 script: |
35 // # Always test cl and clang-cl
36 let compilers = ['cl', 'clang-cl'];
37 // # Also test i686 MSVC
38 let include = [
39 {cc: 'cl', arch: 'i686'}];
40 // # If this is a pull request, see if the PR has the
41 // # 'CI: Full matrix' label. This is done using an API request,
42 // # rather than from context.payload.pull_request.labels, since we
43 // # want the _current_ list of labels. This allows the labelling to
44 // # be changed, and then forcing a re-run of the workflow, rather
45 // # than having labelling triggering a fresh workflow event (which
46 // # is wasteful).
47 if (context.payload.pull_request) {
48 const { data: labels } =
49 await github.rest.issues.listLabelsOnIssue({...context.repo, issue_number: context.payload.pull_request.number});
50 if (labels.some(label => label.name === 'CI: Full matrix')) {
51 console.log('Full matrix requested');
52 // # Test Cygwin as well
53 compilers.push('gcc');
54 // # Test bytecode-only Cygwin
55 include.push({cc: 'gcc', arch: 'x86_64', config_arg: '--disable-native-compiler'});
56 }
57 }
58 return {config_arg: [''], arch: ['x86_64'], cc: compilers, include: include};
59 - name: Determine if the testsuite should be skipped
60 id: skip
61 uses: actions/github-script@v7
62 with:
63 script: |
64 let skip_testsuite = false;
65 if (context.payload.pull_request) {
66 const { data: labels } =
67 await github.rest.issues.listLabelsOnIssue({...context.repo, issue_number: context.payload.pull_request.number});
68 skip_testsuite = labels.some(label => label.name === 'CI: Skip testsuite');
69 }
70 console.log('Skip testsuite: ' + skip_testsuite);
71 return skip_testsuite;
72
73 build:
74 permissions: {}
75
76 runs-on: windows-latest
77
78 needs: config
79
80 timeout-minutes: ${{ matrix.cc == 'gcc' && 90 || 60 }}
81
82 name: ${{ matrix.cc == 'cl' && 'MSVC' || matrix.cc == 'gcc' && 'Cygwin' || 'clang-cl' }} ${{ matrix.arch }} ${{ matrix.config_arg != '' && format('({0})', matrix.config_arg) || '' }}
83
84 strategy:
85 matrix: ${{ fromJSON(needs.config.outputs.matrix) }}
86 fail-fast: true
87
88 steps:
89
90 - name: Fetch OCaml
91 uses: actions/checkout@v5
92 with:
93 submodules: true
94
95 - name: Restore Cygwin cache
96 uses: actions/cache/restore@v4
97 with:
98 path: |
99 C:\cygwin-packages
100 key: cygwin-packages
101
102 - name: Install Cygwin
103 uses: cygwin/cygwin-install-action@v3
104 with:
105 packages: make,${{ matrix.cc != 'gcc' && 'mingw64-x86_64-' || 'gcc-fortran,' }}gcc-core
106 install-dir: 'D:\cygwin'
107
108 - name: Save Cygwin cache
109 uses: actions/cache/save@v4
110 with:
111 path: |
112 C:\cygwin-packages
113 key: cygwin-packages
114
115 - name: Set up MSVC
116 uses: ilammy/msvc-dev-cmd@v1
117 with:
118 arch: ${{ matrix.arch == 'x86_64' && 'x64' || 'x86' }}
119 if: matrix.cc != 'gcc'
120
121 - name: Compute a key to cache configure results
122 id: autoconf-cache-key
123 env:
124 HOST: ${{ format('{0}-pc-{1}', matrix.arch, (matrix.cc == 'gcc' && 'cygwin' || 'windows')) }}
125 run: |
126 echo "key=${{ env.HOST }}-${{ matrix.cc }}-${{ hashFiles('configure') }}" >> $GITHUB_OUTPUT
127
128 - name: Restore Autoconf cache
129 uses: actions/cache/restore@v4
130 with:
131 path: |
132 config.cache
133 key: ${{ steps.autoconf-cache-key.outputs.key }}
134
135 - name: Configure tree
136 env:
137 CONFIG_ARGS: >-
138 --cache-file=config.cache
139 --prefix "${{ matrix.cc != 'gcc' && '$PROGRAMFILES/Бактріан🐫' || '$(cygpath "$PROGRAMFILES/Бактріан🐫")'}}"
140 ${{ matrix.cc != 'gcc' && format('--host={0}-pc-windows', matrix.arch) || '' }}
141 ${{ matrix.cc != 'gcc' && format('CC={0}', matrix.cc) || '' }}
142 ${{ matrix.config_arg }}
143 run: |
144 eval $(tools/msvs-promote-path)
145 if ! ./configure ${{ env.CONFIG_ARGS }} ; then
146 rm -rf config.cache
147 failed=0
148 ./configure ${{ env.CONFIG_ARGS }} || failed=$?
149 if ((failed)) ; then
150 echo
151 echo "::group::config.log content ($(wc -l config.log) lines)"
152 cat config.log
153 echo '::endgroup::'
154 exit $failed
155 fi
156 fi
157
158 - name: Save Autoconf cache
159 uses: actions/cache/save@v4
160 with:
161 path: |
162 config.cache
163 key: ${{ steps.autoconf-cache-key.outputs.key }}
164
165 - name: Build OCaml
166 run: |
167 eval $(tools/msvs-promote-path)
168 make -j || failed=$?
169 if ((failed)) ; then make -j1 V=1 ; exit $failed ; fi
170 test -e runtime/libcamlrun.lib || tools/check-symbol-names runtime/*.a otherlibs/*/lib*.a
171 runtime/ocamlrun ocamlc -config
172
173 - name: Assemble backend with mingw-w64 GASM and compare
174 run: |
175 x86_64-w64-mingw32-gcc -c -I./runtime -I ./flexdll -D__USE_MINGW_ANSI_STDIO=0 -DUNICODE -D_UNICODE -DWINDOWS_UNICODE=1 -DCAMLDLLIMPORT= -DIN_CAML_RUNTIME -DNATIVE_CODE -DTARGET_amd64 -DMODEL_default -DSYS_mingw64 -o runtime/amd64.o runtime/amd64.S
176 dumpbin /disasm:nobytes runtime/amd64nt.obj > runtime/amd64nt.dump
177 awk -f tools/ci/actions/canonicalize-dumpbin.awk runtime/amd64nt.dump runtime/amd64nt.dump > runtime/amd64nt.canonical
178 dumpbin /disasm:nobytes runtime/amd64.o > runtime/amd64.dump
179 awk -f tools/ci/actions/canonicalize-dumpbin.awk runtime/amd64.dump runtime/amd64.dump > runtime/amd64.canonical
180 git diff --no-index -- runtime/amd64*.canonical
181 wc -l runtime/amd64*.dump runtime/amd64*.canonical
182 # ^ The final wc is there to make sure that the canonical files are
183 # reasonable cleaned-up versions of the raw dumpbins and not simply
184 # empty
185 if: endsWith(matrix.arch, '64') && matrix.cc != 'gcc'
186
187 - name: Run the test suite
188 if: ${{ needs.config.outputs.skip-testsuite != 'true' }}
189 run: |
190 eval $(tools/msvs-promote-path)
191 make tests
192
193 - name: Install the compiler
194 run: make install