Skip to content

GH-50449: [C++] Invalid version script argument supplied to MSVC linker#50450

Open
johnwparent wants to merge 2 commits into
apache:mainfrom
johnwparent:cmake-no-version-script-msvc
Open

GH-50449: [C++] Invalid version script argument supplied to MSVC linker#50450
johnwparent wants to merge 2 commits into
apache:mainfrom
johnwparent:cmake-no-version-script-msvc

Conversation

@johnwparent

@johnwparent johnwparent commented Jul 9, 2026

Copy link
Copy Markdown

Rationale for this change

Preventing an invalid argument to be supplied to the MSVC linker, which can potentially break arrow builds on paths with spaces on Windows when using MSVC.

Example of failing build without this patch: https://gitlab.spack.io/spack/spack-packages/-/jobs/22969196

What changes are included in this PR?

cpp/CMakeLists.txt has been updated to add a specific check for the MSVC toolchain, and if true, sets CXX_LINKER_SUPPORTS_VERSION_SCRIPT to FALSE.

Are these changes tested?

Yes, see the build of arrow in this CI run in Spack's built with this patch and a path with a space: https://gitlab.spack.io/spack/spack-packages/-/jobs/22970695

Are there any user-facing changes?

No

Alternatively, the check_linker_flag could be turned into a try_compile with a -wall flag (and the MSVC equivalent) turned on, or the path to the version script could be properly quoted on all platforms, but this feels like the most robust solutions with the smallest impact.

Signed-off-by: John Parent <john.parent@kitware.com>
@kou kou changed the title GH-50449: Invalid version script argument supplied to MSVC linker GH-50449: [C++] Invalid version script argument supplied to MSVC linker Jul 9, 2026

@kou kou left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting.

If we use LINKER:-version-script=... instead of -Wl,--version-script=..., does check_linker_flag() with MSVC report FALSE?

If check_linker_flag() with MSVC doesn't report FALSE for any flags, I feel that it's a problem of CMake. Could you report it to CMake?

Comment thread cpp/CMakeLists.txt Outdated
Comment thread cpp/CMakeLists.txt
else()
set(CXX_LINKER_SUPPORTS_VERSION_SCRIPT TRUE)
endif()
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
elseif(MSVC)

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I let this be the more restrictive condition as I wasn't sure if any "MSVC like" compilers would support the version file, I'm not aware of any that do, so I think this suggestion is probably fine, but I'm not aware of the scope of Arrow's deployment, and just wanted to point out there are side effects from changing this check beyond terseness, just to be safe.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All MSVC like compilers behave like #50450 (comment) , right? (All symbols are hidden by default.)

If so, can we use elseif(MSVC) here?

Comment thread cpp/CMakeLists.txt Outdated
Co-authored-by: Sutou Kouhei <kou@cozmixng.org>
@johnwparent

Copy link
Copy Markdown
Author

Interesting.

If we use LINKER:-version-script=... instead of -Wl,--version-script=..., does check_linker_flag() with MSVC report FALSE?

If check_linker_flag() with MSVC doesn't report FALSE for any flags, I feel that it's a problem of CMake. Could you report it to CMake?

It's an inherent behavior of MSVC's linker, but it does look like that module attempts to catch diagnostic output. I'll see if we're interested in a patch.

Another question, that I didn't both to ask for Spack, but is relevant to this patch, is do we want to control symbol visibility with MSVC the same way the version script is doing here? In which case we can write a .def or similar file instead of skipping this entirely.

@github-actions github-actions Bot added awaiting committer review Awaiting committer review and removed awaiting review Awaiting review labels Jul 9, 2026
@kou

kou commented Jul 9, 2026

Copy link
Copy Markdown
Member

is do we want to control symbol visibility with MSVC the same way the version script is doing here?

Yes. It's better. We don't want to export symbols for bundled dependencies because they may be conflicted with other products that use Apache Arrow C++.

@johnwparent

johnwparent commented Jul 9, 2026

Copy link
Copy Markdown
Author

is do we want to control symbol visibility with MSVC the same way the version script is doing here?

Yes. It's better. We don't want to export symbols for bundled dependencies because they may be conflicted with other products that use Apache Arrow C++.

Unless you're re-exporting this symbols deliberately, for DLLs with MSVC, you don't need to worry, the transitive symbols are hidden by default (all symbols are hidden by default with MSVC)

@kou

kou commented Jul 10, 2026

Copy link
Copy Markdown
Member

OK. Then we don't need this feature for MSVC.

Comment thread cpp/CMakeLists.txt
Comment on lines 359 to 364
if(CMAKE_VERSION VERSION_LESS 3.18)
if(APPLE OR WIN32)
set(CXX_LINKER_SUPPORTS_VERSION_SCRIPT FALSE)
else()
set(CXX_LINKER_SUPPORTS_VERSION_SCRIPT TRUE)
endif()

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you remove this because we require CMake 3.25 or later now?

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants