Skip to content

Commit 7adffe5

Browse files
bscottmpkoning2
authored andcommitted
Github CI/CD updates
- Nuke and reinstall HomeBrew for macOS builds. Gets around the whole problem of stale links and conflicting packages installed in the GitHub macOS images. - macOS 12 and Ubuntu 20.04 officially deprecated. Ubuntu 20.04 will be removed from GitHub's runner images on 01 APR 2025. - .travis/deps.sh: Add mingw32 as a dependency target, enable MinGW64 32-bit builds. - Work around LTO bug on Ubuntu and macOS compilers, where LTO appears to miscalculate the number of bytes stored when using the default byte swapping 'for' loop. This is a workaround that uses compiler swapping intrinsics for well known sizes that appeases LTO. The alternative is to wait for a compiler fix, which is infeasible.
1 parent 6fd146a commit 7adffe5

File tree

4 files changed

+145
-61
lines changed

4 files changed

+145
-61
lines changed

.github/workflows/build.yml

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -40,25 +40,22 @@ jobs:
4040
- scelbi 3b2 i701 i704 i7010 i7070 i7080 i7090 sigma uc15 i650 sel32 intel-mds ibm1130
4141
steps:
4242
- uses: actions/checkout@v4
43-
## Workaround for remnant symlinks in /usr/local pointing back to
44-
## macOS frameworks.
45-
##
46-
## Future: Will have to keep an eye on SDL_ttf's Python dependency
47-
## so that the correct/appropriate Python version is removed.
48-
- name: Remnant symlink cleanup (macOS)
43+
44+
## Nuke homebrew and start with a clean instance:
45+
- name: Reinstall HomeBrew (macOS)
4946
if: ${{runner.os == 'macOS'}}
5047
run: |
51-
brew unlink python@3 || true
52-
brew uninstall --ignore-dependencies python@3 || true
53-
brew unlink [email protected] || true
54-
brew uninstall --ignore-dependencies [email protected] || true
55-
for f in $(find /usr/local/bin -type l -print); do \
56-
(readlink $f | grep -q -s "/Library") && echo Removing "$f" && rm -f "$f"; \
57-
done || exit 0
48+
/usr/bin/sudo /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/uninstall.sh)"
49+
[ -d /opt/homebrew ] && ( sudo rm -rf /opt/homebrew/* || true )
50+
[ -d /usr/local ] && ( sudo rm -rf /usr/local/* || true )
51+
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
52+
5853
## Install our regular dependencies.
5954
- name: Install dependencies (macOS)
6055
if: ${{runner.os == 'macOS'}}
61-
run: sh -ex .travis/deps.sh osx
56+
run: |
57+
sh -ex .travis/deps.sh osx
58+
6259
- name: Install dependencies (Linux)
6360
if: ${{runner.os == 'Linux'}}
6461
run: sh -ex .travis/deps.sh linux

.github/workflows/cmake-builds.yml

Lines changed: 37 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
# (*) "artefact" for the rest of the Anglosphere
1818
#-
1919
matrix:
20-
os: [ubuntu-20.04, ubuntu-22.04, ubuntu-latest]
20+
os: [ubuntu-22.04, ubuntu-latest]
2121
steps:
2222
- uses: actions/checkout@v4
2323
- name: Install dependencies
@@ -47,7 +47,7 @@ jobs:
4747

4848

4949
cmake-macOS:
50-
name: macOS 12+
50+
name: macOS
5151
runs-on: ${{ matrix.os }}
5252
strategy:
5353
#-
@@ -57,35 +57,28 @@ jobs:
5757
# that the build produces.
5858
#
5959
# (*) "artefact" for the rest of the Anglosphere -
60+
#
61+
# As of 18 NOV 2024, Github deprecated macos-12.
6062
matrix:
61-
os: [macos-12, macos-13, macos-latest]
63+
os: [macos-13, macos-14, macos-latest]
6264

6365
env:
6466
CPACK_SUFFIX: ${{matrix.os != 'macos-14' && 'x86_64' || 'm1'}}.${{matrix.os}}
6567

6668
steps:
6769
- uses: actions/checkout@v4
6870

69-
## Workaround for remnant symlinks in /usr/local pointing back to
70-
## macOS frameworks.
71-
##
72-
## Future: Will have to keep an eye on SDL_ttf's Python dependency
73-
## so that the correct/appropriate Python version is removed.
74-
##
75-
## Redirect stderr to /dev/null so that GH doesn't emit useless failure
76-
## messages.
77-
- name: Remnant symlink cleanup
78-
run: |
79-
brew unlink python@3 2> /dev/null || true
80-
brew uninstall --ignore-dependencies python@3 2> /dev/null || true
81-
brew unlink [email protected] 2> /dev/null || true
82-
brew uninstall --ignore-dependencies [email protected] 2> /dev/null || true
83-
for f in $(find /usr/local/bin -type l -print); do \
84-
(readlink $f | grep -q -s "/Library") && echo Removing "$f" && rm -f "$f"; \
85-
done || exit 0
71+
## Nuke homebrew and start with a clean instance.
72+
- name: Reinstall HomeBrew (macOS)
73+
run: |
74+
/usr/bin/sudo /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/uninstall.sh)"
75+
[ -d /opt/homebrew ] && ( sudo rm -rf /opt/homebrew/* || true )
76+
[ -d /usr/local ] && ( sudo rm -rf /usr/local/* || true )
77+
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
8678
8779
- name: Install dependencies
88-
run: sh -ex .travis/deps.sh osx
80+
run: |
81+
sh -ex .travis/deps.sh osx
8982
9083
- name: cmake-builder.sh
9184
run: |
@@ -192,6 +185,17 @@ jobs:
192185
cmake-vs2022:
193186
name: VS 2022 Win10 native VCPKG
194187
runs-on: windows-latest
188+
strategy:
189+
#-
190+
# The CMake builds produce artifacts (*) and the runner image's name is
191+
# used in the artifact's name, simh-4.1.0-x86_64-ubuntu-20.04.deb.
192+
# Consequently, each runner image is enumerated for each artifact (*)
193+
# that the build produces.
194+
#
195+
# (*) "artefact" for the rest of the Anglosphere
196+
#-
197+
matrix:
198+
build: [vs2022]
195199
steps:
196200
- uses: actions/checkout@v4
197201
- name: vs2022 build
@@ -209,34 +213,36 @@ jobs:
209213
Push-Location $env:VCPKG_ROOT
210214
git pull
211215
Pop-Location
212-
./cmake/cmake-builder.ps1 -flavor vs2022 -config Release -clean -lto -verbose -notest -cpack_suffix win32-native
216+
./cmake/cmake-builder.ps1 -flavor ${{matrix.build}} -config Release -clean -lto -verbose `
217+
-notest `
218+
-cpack_suffix ${{matrix.build}}
213219
- name: SIMH simulator suite test
214220
shell: pwsh
215221
run: |
216-
./cmake/cmake-builder.ps1 -flavor vs2022 -config Release -testOnly
222+
./cmake/cmake-builder.ps1 -flavor ${{matrix.build}} -config Release -testOnly
217223
## Install isn't strictly necessary, but it's a good way to see what dependencies
218224
## (IMPORTED_RUNTIME_ARTIFACTS) get installed.
219225
- name: Install
220226
shell: pwsh
221227
run: |
222-
cmake/cmake-builder.ps1 -config Release -flavor vs2022 -installOnly
228+
cmake/cmake-builder.ps1 -config Release -flavor ${{matrix.build}} -installOnly
223229
- name: SIMH packaging
224230
shell: pwsh
225231
run: |
226-
cd cmake\build-vs2022
232+
cd cmake\build-${{matrix.build}}
227233
cpack -G "NSIS;WIX;ZIP" -C Release
228234
- name: Upload ZIP
229235
uses: actions/upload-artifact@v4
230236
with:
231-
name: simh-4.1.0-win32-vs2022.zip
232-
path: cmake/build-vs2022/simh-4.1.0-win32-native.zip
237+
name: simh-4.1.0-${{matrix.build}}.zip
238+
path: cmake/build-${{matrix.build}}/simh-4.1.0-${{matrix.build}}.zip
233239
- name: Upload EXE installer
234240
uses: actions/upload-artifact@v4
235241
with:
236-
name: simh-4.1.0-win32-vs2022.exe
237-
path: cmake/build-vs2022/simh-4.1.0-win32-native.exe
242+
name: simh-4.1.0-${{matrix.build}}.exe
243+
path: cmake/build-${{matrix.build}}/simh-4.1.0-${{matrix.build}}.exe
238244
- name: Upload MSI installer
239245
uses: actions/upload-artifact@v4
240246
with:
241-
name: simh-4.1.0-win32-vs2022.msi
242-
path: cmake/build-vs2022/simh-4.1.0-win32-native.msi
247+
name: simh-4.1.0-${{matrix.build}}.msi
248+
path: cmake/build-${{matrix.build}}/simh-4.1.0-${{matrix.build}}.msi

.travis/deps.sh

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,20 @@ install_linux() {
2727
sudo apt-get install -ym libegl1-mesa-dev libgles2-mesa-dev
2828
sudo apt-get install -ym libsdl2-dev libfreetype6-dev libsdl2-ttf-dev
2929
sudo apt-get install -ym libpcap-dev libvdeplug-dev
30-
sudo apt-get install -ym cmake cmake-data
30+
sudo apt-get install -ym cmake cmake-data ninja-build
31+
}
32+
33+
install_mingw32() {
34+
## Doesn't have libpcap or cmake's extra modules. Not that this
35+
## makes much of a difference.
36+
pacman -S --needed mingw-w64-i686-ninja \
37+
mingw-w64-i686-cmake \
38+
mingw-w64-i686-gcc \
39+
mingw-w64-i686-make \
40+
mingw-w64-i686-pcre \
41+
mingw-w64-i686-freetype \
42+
mingw-w64-i686-SDL2 \
43+
mingw-w64-i686-SDL2_ttf
3144
}
3245

3346
install_mingw64() {
@@ -71,14 +84,15 @@ install_clang64() {
7184

7285

7386
case "$1" in
74-
osx|macports|linux|mingw64|ucrt64|clang64)
87+
osx|macports|linux|mingw32|mingw64|ucrt64|clang64)
7588
install_"$1"
7689
;;
7790
arch-linux)
7891
install_arch_linux
7992
;;
8093
*)
81-
echo "$0: Need an operating system name: osx, arch-linux, linux, mingw64 or ucrt64"
94+
echo "$0: Need an operating system name:"
95+
typeset -f | sed -e '/^install_/!d' -e 's/^install_/ - /' -e 's/ ()//' | sort
8296
exit 1
8397
;;
8498
esac

sim_fio.c

Lines changed: 80 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -127,22 +127,89 @@ if (sim_end || (count == 0) || (size == sizeof (char)))
127127
sim_byte_swap_data (bptr, size, count);
128128
}
129129

130+
#if defined(__GNUC__) || defined(__clang__)
131+
#define sim_bswap16 __builtin_bswap16
132+
#define sim_bswap32 __builtin_bswap32
133+
#define sim_bswap64 __builtin_bswap64
134+
135+
#define USE_BSWAP_INTRINSIC
136+
#elif defined(_MSC_VER)
137+
#define sim_bswap16 _byteswap_ushort
138+
#define sim_bswap32 _byteswap_ulong
139+
#define sim_bswap64 _byteswap_uint64
140+
141+
#define USE_BSWAP_INTRINSIC
142+
#endif
143+
130144
void sim_byte_swap_data (void *bptr, size_t size, size_t count)
131145
{
132-
uint32 j;
133-
int32 k;
134-
unsigned char by, *sptr, *dptr;
146+
size_t j;
147+
uint8 *sptr = (uint8 *) bptr;
148+
149+
if (sim_end || (count == 0) || (size == sizeof (char)))
150+
return;
151+
152+
/* Note: Restructured this code so that GCC Link Time Optimization doesn't generate
153+
* spurious buffer overwrite messages.
154+
*
155+
* LTO tries to inline this function where it's used and ends up evaluating the loop.
156+
* It's clearly a LTO bug that needs to be worked around as opposed to waiting for a
157+
* compiler update (and SIMH can't guarantee that users will maintain updated platforms).
158+
*
159+
* Output from the compiler looks like:
160+
*
161+
* 363 | int32 f, u, comp, cyl, sect, surf;
162+
* | ^
163+
* PDP18B/pdp18b_rp.c:363:13: note: at offset [16, 48] into destination object ‘comp’ of size 4
164+
* PDP18B/pdp18b_rp.c:363:13: note: at offset [80, 17179869168] into destination object ‘comp’ of size 4
165+
* In function ‘sim_byte_swap_data’,
166+
* inlined from ‘sim_byte_swap_data’ at sim_fio.c:130:6,
167+
* inlined from ‘sim_buf_swap_data’ at sim_fio.c:127:1,
168+
* inlined from ‘sim_fread’ at sim_fio.c:158:1,
169+
* inlined from ‘rp_svc’ at PDP18B/pdp18b_rp.c:442:15:
170+
* sim_fio.c:142:17: error: writing 4 bytes into a region of size 0 [-Werror=stringop-overflow=]
171+
* 142 | *sptr++ = *(dptr + k);
172+
*/
173+
174+
for (j = 0; j < count; j++) { /* loop on items */
175+
#if defined(USE_BSWAP_INTRINSIC)
176+
switch (size) {
177+
case sizeof(uint16):
178+
*((uint16 *) sptr) = sim_bswap16 (*((uint16 *) sptr));
179+
break;
135180

136-
if (sim_end || (count == 0) || (size == sizeof (char)))
137-
return;
138-
for (j = 0, dptr = sptr = (unsigned char *) bptr; /* loop on items */
139-
j < count; j++) {
140-
for (k = (int32)(size - 1); k >= (((int32) size + 1) / 2); k--) {
141-
by = *sptr; /* swap end-for-end */
142-
*sptr++ = *(dptr + k);
143-
*(dptr + k) = by;
181+
case sizeof(uint32):
182+
*((uint32 *) sptr) = sim_bswap32 (*((uint32 *) sptr));
183+
break;
184+
185+
case sizeof(t_uint64):
186+
*((t_uint64 *) sptr) = sim_bswap64 (*((t_uint64 *) sptr));
187+
break;
188+
189+
default:
190+
#endif
191+
192+
{
193+
/* Either there aren't any intrinsics that do byte swapping or
194+
* it's not a well known size. */
195+
uint8 *dptr;
196+
size_t k;
197+
const size_t midpoint = (size + 1) / 2;
198+
199+
dptr = sptr + size - 1;
200+
for (k = size - 1; k >= midpoint; k--) {
201+
uint8 by = *sptr; /* swap end-for-end */
202+
*sptr++ = *dptr;
203+
*dptr-- = by;
204+
}
205+
}
206+
207+
#if defined(USE_BSWAP_INTRINSIC)
208+
break;
144209
}
145-
sptr = dptr = dptr + size; /* next item */
210+
#endif
211+
212+
sptr += size; /* next item */
146213
}
147214
}
148215

@@ -550,7 +617,7 @@ dwStatus = FormatMessageA (FORMAT_MESSAGE_FROM_SYSTEM|
550617
Error, // __in DWORD dwMessageId,
551618
0, // __in DWORD dwLanguageId,
552619
szMsgBuffer, // __out LPTSTR lpBuffer,
553-
sizeof (szMsgBuffer) -1, // __in DWORD nSize,
620+
sizeof (szMsgBuffer) - 1, // __in DWORD nSize,
554621
NULL); // __in_opt va_list *Arguments
555622
if (0 == dwStatus)
556623
snprintf(szMsgBuffer, sizeof(szMsgBuffer) - 1, "Error Code: 0x%X", Error);

0 commit comments

Comments
 (0)