Skip to content

Commit 4800e9c

Browse files
authored
Refactor to replace pthread with std threading. (#390)
Overall this rewrites the use of pthread in the streaming and marshalling classes with std threading utilities. The refactor has these changes: * Adds the write/write_async functions to D4StreamMarshaller that implements the repeated logic in the implementation. The implementation now calls those functions isolating the pthread async logic in, mostly, one place. * Moves the pthread code into MarshallerThread. That allows rewriting XDRStreamMarshaller to also only use the MarshallerThread without the duplicate pthread handling code. * Moves most implementation specific details from the MarshallerThread header to the source file. And makes everything except the write and wait function private. * Rewrites the MarshallerThread to use std::future and std::async to manage the asynchronous writes. It removes all the pthread code in favor of entirely portable code. * It adjusts the ABI versions to follow a more stable, and simpler, sequencing. * Updates CI to account for ABI bumps to not be ABI fails. * Updates build scripts, cmake and autotools, to match in the way they version the installed library. * Fix CML ASan and UBSan options. And add TSan option to CML. * Add autotools GH actions build to compare macOS vs Linux versioning. fixes #383 fixes #384 fixes #385 fixes #386 fixes #387
1 parent 5bf5936 commit 4800e9c

17 files changed

Lines changed: 612 additions & 735 deletions

‎.github/workflows/abi_check.sh‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/bin/sh
2+
3+
tmpfile=$(mktemp /tmp/abi_check.XXXXXX)
4+
abidiff "$@" > "${tmpfile}"
5+
abidiff_rc=$?
6+
cat ${tmpfile} | grep "SONAME changed from" -q
7+
soname_rc=$?
8+
if test ${soname_rc} -eq 0 ; then
9+
abidiff_rc=$(( abidiff_rc & 3 ))
10+
fi
11+
cat "${tmpfile}"
12+
rm "${tmpfile}"
13+
exit $abidiff_rc

‎.github/workflows/autotools.yml‎

Lines changed: 169 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,169 @@
1+
name: Autotools CI
2+
3+
on:
4+
push:
5+
branches: [master, main, feature/**, features/**]
6+
paths-ignore:
7+
- "**/*.md"
8+
- ".vscode/**"
9+
- ".github/ISSUE_TEMPLATE/**"
10+
- ".github/PULL_REQUEST_TEMPLATE*"
11+
pull_request:
12+
branches: [master, main]
13+
paths-ignore:
14+
- "**/*.md"
15+
- ".vscode/**"
16+
- ".github/ISSUE_TEMPLATE/**"
17+
- ".github/PULL_REQUEST_TEMPLATE*"
18+
# Enables triggering the workflow manually (on any branch) from the Actions tab
19+
workflow_dispatch:
20+
21+
jobs:
22+
build-and-test:
23+
strategy:
24+
fail-fast: false
25+
matrix:
26+
include:
27+
- os: ubuntu-latest
28+
name: Linux
29+
- os: macos-26
30+
name: macOS 26 arm64
31+
name: ${{ matrix.name }}
32+
runs-on: ${{ matrix.os }}
33+
env:
34+
CCACHE_DIR: ${{ github.workspace }}/.ccache
35+
# From the logs, it looks like the needed cache is a little over 8GB. jhrg 4/1/26
36+
CCACHE_MAXSIZE: 10G
37+
CCACHE_COMPRESS: "true"
38+
CMAKE_PRESET: ci
39+
# CMAKE_PRESET: release
40+
41+
steps:
42+
- name: "Checkout repository"
43+
uses: actions/checkout@v7
44+
45+
- name: "Install Linux dependencies"
46+
if: runner.os == 'Linux'
47+
run: |
48+
sudo apt-get update
49+
sudo apt-get install -y \
50+
libxml2-dev \
51+
libcurl4-openssl-dev \
52+
uuid-dev \
53+
libcppunit-dev \
54+
libtirpc-dev \
55+
libfl-dev \
56+
ccache
57+
58+
- name: "Install macOS dependencies"
59+
if: runner.os == 'macOS'
60+
env:
61+
HOMEBREW_NO_AUTO_UPDATE: "1"
62+
run: |
63+
brew install \
64+
bison \
65+
ccache \
66+
cppunit \
67+
flex \
68+
autoconf \
69+
automake \
70+
libtool
71+
72+
- name: "Configure macOS build environment"
73+
if: runner.os == 'macOS'
74+
run: |
75+
BREW_PREFIX="$(brew --prefix)"
76+
echo "$BREW_PREFIX/opt/bison/bin" >> "$GITHUB_PATH"
77+
echo "$BREW_PREFIX/opt/flex/bin" >> "$GITHUB_PATH"
78+
echo "$BREW_PREFIX/opt/libtool/libexec/gnubin" >> "$GITHUB_PATH"
79+
echo "CMAKE_PREFIX_PATH=$BREW_PREFIX" >> "$GITHUB_ENV"
80+
echo "LDFLAGS=-L$BREW_PREFIX/opt/flex/lib" >> "$GITHUB_ENV"
81+
echo "CXXFLAGS=-I$BREW_PREFIX/opt/flex/include" >> "$GITHUB_ENV"
82+
83+
- name: "Information"
84+
if: ${{ runner.os == 'Linux' || runner.os == 'macOS' }}
85+
run: |
86+
echo "====-====-====-====-====-====-====-====-====-===="
87+
which bison
88+
bison --version
89+
echo "====-====-====-====-====-====-====-====-====-===="
90+
which flex
91+
flex --version
92+
echo "====-====-====-====-====-====-====-====-====-===="
93+
which ccache
94+
ccache --version
95+
echo "====-====-====-====-====-====-====-====-====-===="
96+
which autoconf
97+
autoconf --version
98+
echo "====-====-====-====-====-====-====-====-====-===="
99+
which automake
100+
automake --version
101+
102+
- name: "Determine parallelism"
103+
if: ${{ runner.os == 'Linux' || runner.os == 'macOS' }}
104+
run: |
105+
if [ "$RUNNER_OS" = "macOS" ]; then
106+
echo "BUILD_JOBS=$(sysctl -n hw.logicalcpu)" >> "$GITHUB_ENV"
107+
else
108+
echo "BUILD_JOBS=$(nproc)" >> "$GITHUB_ENV"
109+
fi
110+
111+
- name: "Create ccache directory"
112+
run: mkdir -p "$CCACHE_DIR"
113+
114+
- name: "Restore ccache"
115+
uses: actions/cache@v6
116+
with:
117+
path: ${{ env.CCACHE_DIR }}
118+
key: ${{ runner.os }}-${{ runner.arch }}-autotools-${{ hashFiles('CMakeLists.txt', 'CMakePresets.json', '.github/workflows/cmake.yml') }}
119+
restore-keys: |
120+
${{ runner.os }}-${{ runner.arch }}-autotools-
121+
122+
- name: "Setup ccache"
123+
if: ${{ runner.os == 'Linux' || runner.os == 'macOS' }}
124+
run: |
125+
ccache --zero-stats || true
126+
ccache --max-size "$CCACHE_MAXSIZE" || true
127+
128+
- name: "Setup ccache"
129+
if: ${{ runner.os == 'Linux' }}
130+
run: |
131+
echo "/usr/lib/ccache" >> "$GITHUB_PATH"
132+
133+
- name: "Setup ccache"
134+
if: ${{ runner.os == 'macOS' }}
135+
run: |
136+
BREW_PREFIX="$(brew --prefix)"
137+
echo "$BREW_PREFIX/opt/ccache/libexec" >> "$GITHUB_PATH"
138+
139+
- name: "Build"
140+
if: ${{ runner.os == 'Linux' || runner.os == 'macOS' }}
141+
run: |
142+
autoreconf --force --install --verbose
143+
./configure --disable-dependency-tracking --prefix=${PWD}/build/install
144+
make -j$BUILD_JOBS
145+
146+
- name: "Install"
147+
if: ${{ runner.os == 'Linux' || runner.os == 'macOS' }}
148+
run: |
149+
make install
150+
151+
- name: "Install Info"
152+
if: ${{ runner.os == 'Linux' }}
153+
run: |
154+
ls -laF ${PWD}/build/install/lib
155+
readelf -d ${PWD}/build/install/lib/libdap.so | grep SONAME
156+
readelf -d ${PWD}/build/install/lib/libdapclient.so | grep SONAME
157+
readelf -d ${PWD}/build/install/lib/libdapserver.so | grep SONAME
158+
159+
- name: "Install Info"
160+
if: ${{ runner.os == 'macOS' }}
161+
run: |
162+
ls -laF ${PWD}/build/install/lib
163+
otool -L ${PWD}/build/install/lib/libdap.dylib
164+
otool -L ${PWD}/build/install/lib/libdapclient.dylib
165+
otool -L ${PWD}/build/install/lib/libdapserver.dylib
166+
167+
- name: "Show ccache stats"
168+
if: always()
169+
run: ccache --show-stats || true

‎.github/workflows/cmake.yml‎

Lines changed: 74 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: CMake CI
22

33
on:
44
push:
5-
branches: [master, main]
5+
branches: [master, main, feature/**, features/**]
66
paths-ignore:
77
- "**/*.md"
88
- ".vscode/**"
@@ -35,23 +35,14 @@ jobs:
3535
# From the logs, it looks like the needed cache is a little over 8GB. jhrg 4/1/26
3636
CCACHE_MAXSIZE: 10G
3737
CCACHE_COMPRESS: "true"
38+
CMAKE_PRESET: ci
39+
# CMAKE_PRESET: release
3840

3941
steps:
40-
- name: Checkout repository
41-
uses: actions/checkout@v4
42-
43-
- name: Create ccache directory
44-
run: mkdir -p "$CCACHE_DIR"
45-
46-
- name: Restore ccache
47-
uses: actions/cache@v4
48-
with:
49-
path: ${{ env.CCACHE_DIR }}
50-
key: ${{ runner.os }}-${{ runner.arch }}-ccache-${{ hashFiles('CMakeLists.txt', 'CMakePresets.json', '.github/workflows/cmake.yml') }}
51-
restore-keys: |
52-
${{ runner.os }}-${{ runner.arch }}-ccache-
42+
- name: "Checkout repository"
43+
uses: actions/checkout@v7
5344

54-
- name: Install Linux dependencies
45+
- name: "Install Linux dependencies"
5546
if: runner.os == 'Linux'
5647
run: |
5748
sudo apt-get update
@@ -64,7 +55,7 @@ jobs:
6455
libfl-dev \
6556
ccache
6657
67-
- name: Install macOS dependencies
58+
- name: "Install macOS dependencies"
6859
if: runner.os == 'macOS'
6960
env:
7061
HOMEBREW_NO_AUTO_UPDATE: "1"
@@ -76,36 +67,92 @@ jobs:
7667
flex \
7768
autoconf
7869
79-
- name: Configure macOS build environment
70+
- name: "Create ccache directory"
71+
run: mkdir -p "$CCACHE_DIR"
72+
73+
- name: "Restore ccache"
74+
uses: actions/cache@v6
75+
with:
76+
path: ${{ env.CCACHE_DIR }}
77+
key: ${{ runner.os }}-${{ runner.arch }}-cmake-${{ hashFiles('CMakeLists.txt', 'CMakePresets.json', '.github/workflows/cmake.yml') }}
78+
restore-keys: |
79+
${{ runner.os }}-${{ runner.arch }}-cmake-
80+
81+
- name: "Setup ccache"
82+
run: |
83+
ccache --zero-stats || true
84+
ccache --max-size "$CCACHE_MAXSIZE" || true
85+
86+
- name: "Setup ccache"
87+
if: ${{ runner.os == 'Linux' }}
88+
run: |
89+
echo "/usr/lib/ccache" >> "$GITHUB_PATH"
90+
91+
- name: "Setup ccache"
92+
if: ${{ runner.os == 'macOS' }}
93+
run: |
94+
BREW_PREFIX="$(brew --prefix)"
95+
echo "$BREW_PREFIX/opt/ccache/libexec" >> "$GITHUB_PATH"
96+
97+
- name: "Configure macOS build environment"
8098
if: runner.os == 'macOS'
8199
run: |
82100
BREW_PREFIX="$(brew --prefix)"
83101
echo "$BREW_PREFIX/opt/bison/bin" >> "$GITHUB_PATH"
84102
echo "$BREW_PREFIX/opt/flex/bin" >> "$GITHUB_PATH"
85103
echo "CMAKE_PREFIX_PATH=$BREW_PREFIX" >> "$GITHUB_ENV"
86104
87-
- name: Determine parallelism
105+
- name: "Information"
106+
run: |
107+
which bison
108+
bison --version
109+
which flex
110+
flex --version
111+
which ccache
112+
ccache --version
113+
114+
- name: "Determine parallelism"
88115
run: |
89116
if [ "$RUNNER_OS" = "macOS" ]; then
90117
echo "BUILD_JOBS=$(sysctl -n hw.logicalcpu)" >> "$GITHUB_ENV"
91118
else
92119
echo "BUILD_JOBS=$(nproc)" >> "$GITHUB_ENV"
93120
fi
94121
95-
- name: Configure (CMake preset)
122+
- name: "Configure (CMake preset)"
96123
run: |
97-
ccache --zero-stats || true
98-
ccache --max-size "$CCACHE_MAXSIZE" || true
99-
cmake --preset ci
124+
cmake --preset $CMAKE_PRESET -DCMAKE_INSTALL_PREFIX="$PWD/build/$CMAKE_PRESET-install"
125+
126+
- name: "Build"
127+
run: |
128+
cmake --build --preset $CMAKE_PRESET --parallel "$BUILD_JOBS"
129+
130+
- name: "Install"
131+
if: ${{ runner.os == 'Linux' || runner.os == 'macOS' }}
132+
run: |
133+
cmake --install build/$CMAKE_PRESET --prefix ${PWD}/build/$CMAKE_PRESET-install
134+
135+
- name: "Install Info"
136+
if: ${{ runner.os == 'Linux' }}
137+
run: |
138+
ls -laF ${PWD}/build/$CMAKE_PRESET-install/lib
139+
readelf -d ${PWD}/build/$CMAKE_PRESET-install/lib/libdap.so | grep SONAME
140+
readelf -d ${PWD}/build/$CMAKE_PRESET-install/lib/libdapclient.so | grep SONAME
141+
readelf -d ${PWD}/build/$CMAKE_PRESET-install/lib/libdapserver.so | grep SONAME
100142
101-
- name: Build
143+
- name: "Install Info"
144+
if: ${{ runner.os == 'macOS' }}
102145
run: |
103-
cmake --build --preset ci --parallel "$BUILD_JOBS"
146+
ls -laF ${PWD}/build/$CMAKE_PRESET-install/lib
147+
otool -L ${PWD}/build/$CMAKE_PRESET-install/lib/libdap.dylib
148+
otool -L ${PWD}/build/$CMAKE_PRESET-install/lib/libdapclient.dylib
149+
otool -L ${PWD}/build/$CMAKE_PRESET-install/lib/libdapserver.dylib
104150
105-
- name: Run tests (if applicable)
151+
- name: "Run tests (if applicable)"
152+
timeout-minutes: 5
106153
run: |
107-
ctest --preset ci --output-on-failure --parallel "$BUILD_JOBS"
154+
ctest --preset $CMAKE_PRESET --output-on-failure --parallel "$BUILD_JOBS"
108155
109-
- name: Show ccache stats
156+
- name: "Show ccache stats"
110157
if: always()
111158
run: ccache --show-stats || true
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
; Examples of suppressing member function changes:
2+
3+
; [suppress_function]
4+
; change_kind = added-function
5+
; name_regexp = ^libdap::(D4|XDR)StreamMarshaller::(write|write_async).*
6+
7+
; [suppress_function]
8+
; change_kind = added-function
9+
; name_regexp = ^libdap::MarshallerThread::(wait|write|write_async).*

0 commit comments

Comments
 (0)