Check that expected symbols are present

This commit is contained in:
2026-05-19 22:04:36 +09:00
parent a1c1411536
commit 7d91226dd2
+26 -3
View File
@@ -67,9 +67,32 @@ in stdenv.mkDerivation (finalAttrs: {
runHook postInstall
'';
# TODO: Add a checkphase that runs nm on the provided extensions to ensure the expected symbols are present.
# Also verify that the `sqlite_api` symbol is not present, and give a nice warning about using -DSQLITE_CORE
# if it is.
doCheck = true;
checkPhase = ''
runHook preCheck
for ext in ${lib.escapeShellArgs (builtins.catAttrs "library" extensions)}; do
if nm -g --defined-only "$ext" | grep -q " sqlite_api$"; then
echo "Extension $ext appears to reference the 'sqlite_api' symbol, which is not expected for extensions which are going to be statically linked."
echo "If your are building the extension yourself, please ensure that it is built with \`-DSQLITE_CORE\`"
exit 1
fi
done
declare -A expectedSymbols;
${lib.concatMapStringsSep "\n" (ext: "expectedSymbols[${lib.escapeShellArg ext.init}]=${lib.escapeShellArg ext.library};") extensions}
${lib.concatMapStringsSep "\n" (ext: "expectedSymbols[${lib.escapeShellArg ext.shutdown}]=${lib.escapeShellArg ext.library};") (lib.filter (ext: ext.shutdown or null != null) extensions)}
for sym in "''${!expectedSymbols[@]}"; do
if ! nm -g --defined-only "''${expectedSymbols[$sym]}" | grep -q " ''${sym}$"; then
echo "Expected symbol $sym not found in ''${expectedSymbols[$sym]}."
exit 1
fi
done
runHook postCheck
'';
passthru = {
extraLDFLAGS = [