@@ -84,6 +84,19 @@ proc applyTsanSuppressions() =
8484 elif " suppressions=" notin existing:
8585 putEnv (" TSAN_OPTIONS" , existing & " :suppressions=" & suppPath)
8686
87+ proc removeStaleEchoLib () =
88+ # # The CBOR and `abi = c` echo e2e suites both compile examples/echo/echo.nim
89+ # # to the same repo-root `libecho.so`, differing only by `-d:ffiEchoAbiC`.
90+ # # CMake keys the dylib rebuild on echo.nim's mtime, not the ABI flag, so a
91+ # # `libecho.so` left by an earlier CBOR e2e step is silently reused by the
92+ # # abi=c build — the flat-struct C caller then reaches the CBOR entry points
93+ # # (wrong arity/ABI) and segfaults. Delete it first to force a fresh rebuild
94+ # # with the right ABI.
95+ for name in [" libecho.so" , " libecho.dylib" , " echo.dll" ]:
96+ let path = thisDir () / name
97+ if fileExists (path):
98+ rmFile (path)
99+
87100task buildffi, " Compile the library" :
88101 exec " nim c " & nimFlagsOrc & " --app:lib --noMain ffi.nim"
89102
@@ -141,6 +154,7 @@ task test_c_e2e, "Build and run the C end-to-end tests for the timer example":
141154task test_c_abi_e2e, " Build and run the CBOR-free abi=c C end-to-end test (echo)" :
142155 # Regenerate the abi=c bindings so the suite always runs against fresh codegen.
143156 runOrQuit " nimble genbindings_c_abi_echo"
157+ removeStaleEchoLib ()
144158 runOrQuit " cmake -S tests/e2e/c_abi -B tests/e2e/c_abi/build"
145159 runOrQuit " cmake --build tests/e2e/c_abi/build --config Debug"
146160 runOrQuit " ctest --test-dir tests/e2e/c_abi/build --output-on-failure -C Debug"
@@ -180,6 +194,7 @@ task test_c_abi_e2e_sanitized,
180194 " Build and run the abi=c C e2e test with a sanitizer (NIM_FFI_SAN)" :
181195 let san = getEnv (" NIM_FFI_SAN" , " none" )
182196 runOrQuit " nimble genbindings_c_abi_echo"
197+ removeStaleEchoLib ()
183198 runOrQuit " cmake -S tests/e2e/c_abi -B tests/e2e/c_abi/build" & " -DNIM_FFI_SANITIZER=" &
184199 san
185200 runOrQuit " cmake --build tests/e2e/c_abi/build --config Debug -j"
0 commit comments