Skip to content

[C++] Windows compute testing helper exports static API definitions to shared-linked tests #55279

Open

Description

@ConnorQi01

Describe the bug

On Windows, arrow_compute_testing exports ARROW_STATIC and
ARROW_COMPUTE_STATIC when ARROW_BUILD_STATIC is enabled. That option
means a static library variant is available; it does not mean tests selected
static linkage.

With both library variants enabled and ARROW_TEST_LINKAGE=shared, the
PUBLIC definitions propagate static declarations into a test linking Arrow
DLL import libraries. The real arrow-dlpack-test target fails with duplicate
arrow::Status constructor/destructor definitions (LNK2005 followed by
LNK1169).

How to reproduce

On Windows with Visual Studio and MSVC, configure from the repository root:

cmake -S cpp -B build -G "Visual Studio 18 2026" -A x64 -DARROW_BUILD_TESTS=ON -DARROW_BUILD_SHARED=ON -DARROW_BUILD_STATIC=ON -DARROW_TEST_LINKAGE=shared -DARROW_ACERO=ON -DARROW_FILESYSTEM=ON -DARROW_PARQUET=OFF -DARROW_SUBSTRAIT=ON -DARROW_DATASET=ON -DRE2_BUILD_TESTING=OFF
cmake --build build --config Release --target arrow-dlpack-test --parallel 4

Inspect arrow_compute_testing's PUBLIC compile definitions and those
inherited by dlpack_test.cc. Static API definitions are present despite
shared test linkage.

Expected: export those definitions only when ARROW_TEST_LINKAGE is
static.

Version and proposed fix

The real-target failure was reproduced at
d228ba5a9def26e67e12b2e475be0b00edb77aea. The same conditional is present
at current main 4a6ebc06dc2bb967263fdf83449ac104e54cbaba.

Change the Windows conditional from ARROW_BUILD_STATIC to
ARROW_TEST_LINKAGE STREQUAL "static".

Validation

With the same compiler, configuration and build directory, the original
target fails to link. After the one-condition change it builds successfully,
and arrow-dlpack-test passes all 39 tests from 10 suites.

An extracted exact CMake target-section check also passes the three linkage
controls: shared tests with both library variants, static tests, and
shared-only libraries. The whole Arrow suite was not run.

Tool assistance

Copilot assisted with diagnosis, the conditional change, and this report.
The results above came from actual target builds and test execution; no
private compiler inputs or internal build logs are attached.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions