build(cmake): link migrated Rust code into native libraries
Build a configuration-matched Cargo static library during CMake builds and join its object members into the generated static libzstd archive. A single flattened archive avoids C-to-Rust and Rust-to-C archive-order failures for external consumers. Shared builds whole-archive the Cargo output so Rust-only public ABI exports remain visible. The configuration also follows partial compression and decompression builds, forced HUF modes, and supported 32-bit Linux targets. Dedicated CTest smoke consumers cover both linkage forms. Test Plan: - configure and build fresh static and shared CMake smoke targets - ctest -R 'rustLibSmoke(Static|Shared)' --output-on-failure - cargo clippy, cargo clippy --benches, cargo clippy --tests, and nightly fmt - validate partial, forced-HUF, i686, install, and incremental build paths Refs: build/cmake/lib/merge_rust_archive.cmake
This commit is contained in:
@@ -90,6 +90,23 @@ AddTestFlagsOption(ZSTD_ZSTREAM_FLAGS "$ENV{ZSTREAM_TESTTIME} $ENV{FUZZER_FLAGS}
|
||||
"Semicolon-separated list of flags to pass to the zstreamtest test (see `zstreamtest -h` for usage)")
|
||||
add_test(NAME zstreamtest COMMAND "$<TARGET_FILE:zstreamtest>" ${ZSTD_ZSTREAM_FLAGS})
|
||||
|
||||
# Verify that a consumer can link the completed static archive alone: migrated
|
||||
# Rust objects and the C code they call must not remain separate archives. The
|
||||
# shared variant also checks that whole-archive linking retains Rust-only ABI
|
||||
# exports such as the DDict lifecycle functions.
|
||||
add_executable(rustLibSmokeStatic ${TESTS_DIR}/rustLibSmoke.c)
|
||||
target_link_libraries(rustLibSmokeStatic libzstd_static)
|
||||
add_test(NAME rustLibSmokeStatic COMMAND "$<TARGET_FILE:rustLibSmokeStatic>")
|
||||
if(ZSTD_BUILD_SHARED)
|
||||
add_executable(rustLibSmokeShared ${TESTS_DIR}/rustLibSmoke.c)
|
||||
target_link_libraries(rustLibSmokeShared libzstd_shared)
|
||||
if(UNIX)
|
||||
set_property(TARGET rustLibSmokeShared APPEND PROPERTY
|
||||
BUILD_RPATH "$<TARGET_FILE_DIR:libzstd_shared>")
|
||||
add_test(NAME rustLibSmokeShared COMMAND "$<TARGET_FILE:rustLibSmokeShared>")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
#
|
||||
# playTests.sh
|
||||
#
|
||||
|
||||
Reference in New Issue
Block a user