Skip to content

Commit df13bef

Browse files
Merge pull request #1914 from AxiomCodeAI/fix/engine-runtime-deps
build-engines: engines start on a clean machine — static libgomp on Linux, no OpenMP on Windows (#1913)
2 parents 9a10b66 + 090c5f5 commit df13bef

1 file changed

Lines changed: 42 additions & 10 deletions

File tree

‎.github/workflows/build-engines.yml‎

Lines changed: 42 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -164,15 +164,19 @@ jobs:
164164
for lang in $LANGUAGES; do
165165
if cmp -s "gen/$lang.id" "engines/$lang/ENGINE_ID"; then echo "$lang: cached, rules unchanged"; continue; fi
166166
mkdir -p "engines/$lang"
167-
# OpenMP on BOTH architectures: the arm64 crash mode was two weak-ordering
168-
# holes in the vendored headers (write-entry RMW + unfenced node publication),
169-
# both patched above and validated 10/10 under load on linux-arm64 and
170-
# darwin-arm64 (seqlock-fix-3). libgomp links STATICALLY so the binary runs on
171-
# machines with no gcc runtime. The .parallel marker beside the binary is what
167+
# OpenMP on BOTH architectures: the arm64 crash modes were weak-ordering holes in
168+
# the vendored headers (write-entry RMW + unfenced node publication, seqlock-fix-3)
169+
# and a null child read by the optimistic descent (seqlock-fix-4), all patched above
170+
# and validated under load on linux-arm64 and darwin-arm64. The .parallel marker beside the binary is what
172171
# run-souffle.sh reads to pass a real -j at run time.
173-
OMP="-fopenmp -Wl,-Bstatic,-lgomp,-Bdynamic"
174-
c++ -std=c++17 -O3 -w $OMP -static-libstdc++ -static-libgcc -I gen "gen/$lang.cpp" -o "engines/$lang/axiomcode-engine-$lang"
175-
[ -n "$OMP" ] && touch "engines/$lang/axiomcode-engine-$lang.parallel"
172+
# libgomp links STATICALLY so the binary runs on machines with no gcc runtime
173+
# (a stock Ubuntu has no libgomp.so.1). -fopenmp on the LINK line makes the driver
174+
# append its own dynamic -lgomp, whatever -Wl,-Bstatic says, so -fopenmp compiles
175+
# only, and the link names libgomp.a by path; libgomp.a needs -ldl.
176+
c++ -std=c++17 -O3 -w -fopenmp -I gen -c "gen/$lang.cpp" -o "gen/$lang.o"
177+
c++ "gen/$lang.o" -o "engines/$lang/axiomcode-engine-$lang" -static-libstdc++ -static-libgcc "$(c++ -print-file-name=libgomp.a)" -lpthread -ldl
178+
rm -f "gen/$lang.o"
179+
touch "engines/$lang/axiomcode-engine-$lang.parallel"
176180
cp "gen/$lang.id" "engines/$lang/ENGINE_ID"
177181
done
178182
mkdir -p engines/queries
@@ -195,9 +199,27 @@ jobs:
195199
if [ "$(printf '%s\n2.28\n' "$need" | sort -V | tail -1)" != 2.28 ]; then echo "::error::$f needs glibc $need (> 2.28)"; bad=1; fi
196200
done
197201
exit $bad
202+
# A RUNTIME A CLEAN MACHINE HAS. A binary that loads a library the build host has and a user's machine does not
203+
# starts here and fails there: libgomp.so.1 is not on a stock Ubuntu. Every engine may need only the C library
204+
# and the loader.
205+
- name: Linux binaries load nothing a stock system lacks
206+
if: startsWith(matrix.target.platform, 'linux')
207+
run: |
208+
set -e
209+
bad=0
210+
for f in engines/*/axiomcode-*; do
211+
case "$f" in *.parallel) continue;; esac
212+
extra="$(readelf -d "$f" | sed -n 's/.*(NEEDED).*\[\(.*\)\]/\1/p' | grep -vE '^(libc|libm|libpthread|libdl|librt|ld-linux[-a-z0-9_]*)\.so' || true)"
213+
if [ -n "$extra" ]; then echo "::error::$f needs $(echo $extra) — not on a stock system"; bad=1; fi
214+
done
215+
exit $bad
198216
- uses: ilammy/msvc-dev-cmd@v1
199217
if: startsWith(matrix.target.platform, 'win32')
200218
with: { arch: x64 }
219+
# NO OPENMP ON WINDOWS. /openmp links vcomp140.dll (and through it vcruntime140.dll), which a Windows machine
220+
# without the Visual C++ Redistributable does not have: every language engine then exits 0xC0000135 before it
221+
# reads a fact. The engines are built serial, as through 0.1.8, so they need nothing past the static CRT; no
222+
# .parallel marker is written, so run-souffle.sh passes no -j.
201223
- name: Compile every language (Windows, MSVC)
202224
if: startsWith(matrix.target.platform, 'win32')
203225
shell: cmd
@@ -206,9 +228,8 @@ jobs:
206228
fc /b gen\%%L.id engines\%%L\ENGINE_ID >nul 2>&1
207229
if errorlevel 1 (
208230
if not exist engines\%%L mkdir engines\%%L
209-
cl /nologo /std:c++17 /O2 /EHsc /bigobj /w /permissive- /Zc:__cplusplus /D_CRT_SECURE_NO_WARNINGS /DNOMINMAX /DUSE_CUSTOM_GETOPTLONG /openmp /I gen gen\%%L.cpp /Fe:engines\%%L\axiomcode-engine-%%L.exe
231+
cl /nologo /std:c++17 /O2 /EHsc /bigobj /w /permissive- /Zc:__cplusplus /D_CRT_SECURE_NO_WARNINGS /DNOMINMAX /DUSE_CUSTOM_GETOPTLONG /I gen gen\%%L.cpp /Fe:engines\%%L\axiomcode-engine-%%L.exe
210232
if errorlevel 1 exit /b 1
211-
type nul > engines\%%L\axiomcode-engine-%%L.exe.parallel
212233
copy /y gen\%%L.id engines\%%L\ENGINE_ID
213234
) else (
214235
echo %%L: cached, rules unchanged
@@ -226,6 +247,17 @@ jobs:
226247
)
227248
)
228249
dir /s engines
250+
- name: Windows binaries load nothing a stock system lacks
251+
if: startsWith(matrix.target.platform, 'win32')
252+
shell: bash
253+
run: |
254+
set -e
255+
bad=0
256+
for f in engines/*/axiomcode-*.exe; do
257+
extra="$(dumpbin //dependents "$f" | grep -ioE '^ +[a-z0-9_.-]+\.dll' | tr -d ' ' | grep -iE '^(vcomp|vcruntime|msvcp|concrt|libgomp|libstdc|libgcc)' || true)"
258+
if [ -n "$extra" ]; then echo "::error::$f needs $(echo $extra) — not on a stock Windows"; bad=1; fi
259+
done
260+
exit $bad
229261
- name: Smoke — every binary starts on empty inputs
230262
shell: bash
231263
run: |

0 commit comments

Comments
 (0)