`ninja t` builds test/format but fails at runtime due to missing extension libraries

XMLWordPrintableJSON

    • Type: Technical Debt
    • Resolution: Fixed
    • Priority: Minor - P4
    • WT12.0.0, 9.0.0-rc0
    • Affects Version/s: None
    • Component/s: Build
    • None
    • Storage Engines, Storage Engines - Persistence
    • 0.038
    • SE Persistence backlog
    • None

      Issue Summary

      When building the test/format binary (t) using ninja t, the build completes successfully, but the binary fails at startup with dlopen errors for extension libraries such as libwiredtiger_reverse_collator.so. The error message indicates that the expected extension libraries are missing from the build directory:

      [WT_VERB_DEFAULT][ERROR]: dlopen(../../ext/collators/reverse/libwiredtiger_reverse_collator.so):
        tried: '.../build/ext/collators/reverse/libwiredtiger_reverse_collator.so' (no such file or directory)
      t: FAILED: create_database: wiredtiger_open: No such file or directory
      

      A full ninja build resolves the issue, as it includes the extension libraries. Subsequent ninja t builds work because the libraries are already present.

      Context

      • format.h hardcodes BUILDDIR = "../../" relative to the t binary location.
      • With -DEXT_LIBPATH="" (set by CMake), t resolves extension library paths as ../../ext/collators/reverse/libwiredtiger_reverse_collator.so.
      • Extension libraries are CMake MODULE targets under ext/ and are not link-time dependencies of test_format, so ninja t does not build them unless explicitly specified.
      • Builtin extensions (compiled as OBJECT_LIBRARY into libwiredtiger) do not require separate dlopen or build steps.

      Proposed Solution

      • Add add_dependencies() in test/format/CMakeLists.txt for each extension MODULE library required at runtime.
      • Use get_target_property(TYPE) to ensure only MODULE_LIBRARY targets are included, excluding builtin OBJECT_LIBRARY extensions.
      • This change ensures ninja t builds all necessary runtime libraries without impacting incremental builds.

      Example Patch

      --- a/test/format/CMakeLists.txt
      +++ b/test/format/CMakeLists.txt
      @@ -44,5 +44,22 @@ create_test_executable(test_format
       # for sanitizers to work correctly.
       set_target_properties(test_format PROPERTIES LINKER_LANGUAGE CXX)
       target_compile_options(test_format PRIVATE -DEXT_LIBPATH="")
      +
      +# t uses dlopen() at runtime to load extension MODULE libraries from ../../ext/ (relative to the
      +# binary). Those libraries are not link-time dependencies, so ninja t won't build them unless we
      +# declare them here. Only add MODULE libraries — builtin extensions are OBJECT libraries already
      +# compiled into libwiredtiger and don't need a separate dlopen().
      +foreach(ext_target
      +        wiredtiger_reverse_collator
      +        wiredtiger_lz4 wiredtiger_snappy wiredtiger_zlib wiredtiger_zstd
      +        wiredtiger_rotn wiredtiger_sodium)
      +    if(TARGET ${ext_target})
      +        get_target_property(_ext_type ${ext_target} TYPE)
      +        if(_ext_type STREQUAL "MODULE_LIBRARY")
      +            add_dependencies(test_format ${ext_target})
      +        endif()
      +    endif()
      +endforeach()
      +
       add_test(NAME test_format COMMAND ${CMAKE_CURRENT_BINARY_DIR}/smoke.sh)
       set_tests_properties(test_format PROPERTIES LABELS "check")
      

      Original Slack thread
      This ticket was generated by AI from a Slack thread.

            Assignee:
            Etienne Petrel
            Reporter:
            Memento Slack Bot
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: