Skip to content

Conversation

@WillAyd
Copy link
Contributor

@WillAyd WillAyd commented Aug 7, 2025

Rationale for this change

This allows users on the Windows platform to use the Meson build system

What changes are included in this PR?

Updates to the Meson configurations and source files to accommodate Windows

Are these changes tested?

Yes

Are there any user-facing changes?

No

@github-actions
Copy link

github-actions bot commented Aug 7, 2025

Thanks for opening a pull request!

If this is not a minor PR. Could you open an issue for this pull request on GitHub? https://github.com/apache/arrow/issues/new/choose

Opening GitHub issues ahead of time contributes to the Openness of the Apache Arrow project.

Then could you also rename the pull request title in the following format?

GH-${GITHUB_ISSUE_ID}: [${COMPONENT}] ${SUMMARY}

or

MINOR: [${COMPONENT}] ${SUMMARY}

See also:

@@ -347,7 +347,7 @@ Result<std::shared_ptr<ArrayData>> PreallocateRunEndsArray(
/// \param has_validity_buffer a validity buffer must be allocated
/// \param length the length of the values array
/// \param data_buffer_size the size of the data buffer for string and binary types
ARROW_COMPUTE_EXPORT Result<std::shared_ptr<ArrayData>> PreallocateValuesArray(
ARROW_EXPORT Result<std::shared_ptr<ArrayData>> PreallocateValuesArray(
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Although this file is in the compute/kernels tree, the associated module is built as part of the arrow lib irrespective of whether compute is enabled or not. As such, I figured it made more sense to use the EXPORT semantics from the arrow lib rather than arrow_compute

Copy link
Member

Choose a reason for hiding this comment

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

Really?
It seems that it's used by libarrow_compute not libarrow:

compute/kernels/ree_util_internal.cc

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah you are right - I can fix this

@@ -224,18 +222,25 @@ utility_test_srcs = [
]

if host_machine.system() == 'windows'
# meson does not natively support manifest files like CMake does
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't think the Meson support for manifest files is as nice as CMake's, but I'm also not super familiar with them. Need to research this a bit more...

Copy link
Member

Choose a reason for hiding this comment

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

@WillAyd WillAyd added the CI: Extra Run extra CI label Aug 7, 2025
@github-actions github-actions bot added awaiting committer review Awaiting committer review and removed awaiting review Awaiting review labels Aug 7, 2025
Copy link
Member

@kou kou left a comment

Choose a reason for hiding this comment

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

Could you open an issue for this?

Comment on lines 208 to 209
key: cpp-ccache-windows-${{ env.CACHE_VERSION }}-${{ hashFiles('cpp/**') }}
restore-keys: cpp-ccache-windows-${{ env.CACHE_VERSION }}-
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
key: cpp-ccache-windows-${{ env.CACHE_VERSION }}-${{ hashFiles('cpp/**') }}
restore-keys: cpp-ccache-windows-${{ env.CACHE_VERSION }}-
key: cpp-ccache-windows-meson-${{ env.CACHE_VERSION }}-${{ hashFiles('cpp/**') }}
restore-keys: cpp-ccache-windows-meson-${{ env.CACHE_VERSION }}-

shell: cmd
run: |
call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64
bash -c "ARROW_USE_MESON=ON; ci/scripts/cpp_build.sh $(pwd) $(pwd)/build ${{ matrix.run-options || '' }}"
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
bash -c "ARROW_USE_MESON=ON; ci/scripts/cpp_build.sh $(pwd) $(pwd)/build ${{ matrix.run-options || '' }}"
bash -c "ci/scripts/cpp_build.sh $(pwd) $(pwd)/build"

run: |
# For ORC
export TZDIR=/c/msys64/usr/share/zoneinfo
ARROW_USE_MESON=ON ci/scripts/cpp_test.sh $(pwd) $(pwd)/build ${{ matrix.run-options || '' }}
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
ARROW_USE_MESON=ON ci/scripts/cpp_test.sh $(pwd) $(pwd)/build ${{ matrix.run-options || '' }}
ci/scripts/cpp_test.sh $(pwd) $(pwd)/build

# We can invalidate the current cache by updating this.
CACHE_VERSION: "2022-09-13"
- name: Build
shell: cmd
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
shell: cmd
shell: cmd
env:
ARROW_USE_MESON: ON

@@ -347,7 +347,7 @@ Result<std::shared_ptr<ArrayData>> PreallocateRunEndsArray(
/// \param has_validity_buffer a validity buffer must be allocated
/// \param length the length of the values array
/// \param data_buffer_size the size of the data buffer for string and binary types
ARROW_COMPUTE_EXPORT Result<std::shared_ptr<ArrayData>> PreallocateValuesArray(
ARROW_EXPORT Result<std::shared_ptr<ArrayData>> PreallocateValuesArray(
Copy link
Member

Choose a reason for hiding this comment

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

Really?
It seems that it's used by libarrow_compute not libarrow:

compute/kernels/ree_util_internal.cc

Comment on lines 18 to 22
if host_machine.system() != 'windows'
dl_dep = dependency('dl')
else
dl_dep = declare_dependency()
endif
Copy link
Member

Choose a reason for hiding this comment

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

Could you swap these branches for easy to read? (In general, no "not" is easier to read.)

Suggested change
if host_machine.system() != 'windows'
dl_dep = dependency('dl')
else
dl_dep = declare_dependency()
endif
if host_machine.system() == 'windows'
dl_dep = declare_dependency()
else
dl_dep = dependency('dl')
endif

)

arrow_compile_args = []
if host_machine.system() == 'windows' and get_option('default_library') != 'shared'
Copy link
Member

Choose a reason for hiding this comment

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

We can always define ARROW_STATIC:

Suggested change
if host_machine.system() == 'windows' and get_option('default_library') != 'shared'
if get_option('default_library') != 'shared'

BTW, does this work with default_library=both?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I haven't gotten default_library=both to work yet, but haven't put a ton of effort into debugging it either. Happy to do so after getting shared/static support stabilized

@@ -484,14 +505,22 @@ if needs_compute
arrow_compute_lib = library(
'arrow-compute',
sources: arrow_compute_lib_sources,
dependencies: arrow_dep,
dependencies: [arrow_dep] + int128_deps,
Copy link
Member

Choose a reason for hiding this comment

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

Hmm. Why do we need this?

If libarrow is a static library, it must have int128_deps dependency. libarrow consumers should not care about int128_deps.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is to build the library itself, not to expose it to consumers. I believe that MSVC/Windows do not offer a native 128 bit integer, so the int128_deps grabs it from the boost multiprecision header. On other platforms, this dependency is empty

Copy link
Member

Choose a reason for hiding this comment

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

Ah, compute also uses arrow::internal::int128_t. Sorry. I thought that decimal in libarrow only uses arrow::internal::int128_t.

@@ -224,18 +222,25 @@ utility_test_srcs = [
]

if host_machine.system() == 'windows'
# meson does not natively support manifest files like CMake does
Copy link
Member

Choose a reason for hiding this comment

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

@github-actions github-actions bot added awaiting changes Awaiting changes and removed awaiting committer review Awaiting committer review labels Aug 8, 2025
@WillAyd WillAyd changed the title Meson win support GH-46797: [C++] Support Meson on Windows Aug 8, 2025
@github-actions
Copy link

github-actions bot commented Aug 8, 2025

⚠️ GitHub issue #46797 has been automatically assigned in GitHub to PR creator.

@WillAyd
Copy link
Contributor Author

WillAyd commented Aug 8, 2025

Could you open an issue for this?

Sorry about that - there is an open issue I just messed up the commit name. I've updated the title now and can squash on next push

@github-actions github-actions bot added awaiting change review Awaiting change review and removed awaiting changes Awaiting changes labels Aug 8, 2025
@WillAyd WillAyd force-pushed the meson-win-support branch 2 times, most recently from c3b74be to d7c42c4 Compare August 8, 2025 14:55
call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64
echo %PATH%
dir "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Tools\MSVC\14.44.35207\bin\HostX64\x64"
bash -c "ci/scripts/cpp_build.sh $(pwd) $(pwd)/build ${{ matrix.run-options || '' }}"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I believe the current error has to do with the fact that calling `bash -c link ..." invokes the linker that comes bundled with bash, and not the linker that the vcvarsall.bat script is supposed to activate. You can reproduce this locally:

> link /help
Microsoft (R) Incremental Linker Version 14.44.35214.0
Copyright (C) Microsoft Corporation.  All rights reserved.

   For help on Linker, type `link /link' or `link'
   For help on Library Manager, type `link /lib' or `lib'
   For help on Dumper, type `link /dump' or `dumpbin'
   For help on Editor, type `link /edit' or `editbin'
   For help on CvtCIL, type `link /cvtcil'
   For help on PushThunkObj Generator, type `link /pushthunkobj'
> bash -c "link /help"
link: missing operand after ‘/help’
Try 'link --help' for more information.
> bash -c "link --help"
Usage: link FILE1 FILE2
  or:  link OPTION
Call the link function to create a link named FILE2 to an existing FILE1.

      --help        display this help and exit
      --version     output version information and exit

GNU coreutils online help: <https://www.gnu.org/software/coreutils/>
Report any translation bugs to <https://translationproject.org/team/>
Full documentation <https://www.gnu.org/software/coreutils/link>
or available locally via: info '(coreutils) link invocation'

I guess the current CMake configuration doesn't care about this, although it makes sense for Meson to be suspect of this environment.

Maybe its worth creating a separate cpp_build.bat script for Windows platforms to use? What do you think @kou ?

Copy link
Member

Choose a reason for hiding this comment

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

How about trying meson setup --vsenv instead of calling vcvarsall.bat manually?

https://mesonbuild.com/Using-with-Visual-Studio.html

If no Visual Studio Command Prompt was detected, and no mingw compilers are detected either, meson will attempt to find "a" Visual Studio installation for you automatically, by asking Microsoft's "vswhere" program. If you want to ignore mingw compilers, pass the --vsenv option on the meson command line. If you need to guarantee a specific Visual Studio version, set it up manually.

@github-actions github-actions bot added awaiting changes Awaiting changes awaiting change review Awaiting change review and removed awaiting change review Awaiting change review awaiting changes Awaiting changes labels Aug 9, 2025
@WillAyd WillAyd force-pushed the meson-win-support branch 3 times, most recently from aca8728 to 39c6cf0 Compare August 11, 2025 19:27
@WillAyd WillAyd force-pushed the meson-win-support branch 2 times, most recently from 5a1752d to e74984e Compare September 18, 2025 14:38
thrift_dep = dependency(
'thrift',
allow_fallback: false,
method: host_machine.system() == 'windows' ? 'cmake' : 'auto',
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This appears to be an upstream issue where the library names used in the pkg-config files do not match the library names distributed on windows. See https://issues.apache.org/jira/browse/THRIFT-5894

@WillAyd WillAyd force-pushed the meson-win-support branch 3 times, most recently from 1b564ca to 48805dd Compare September 24, 2025 18:53
@WillAyd
Copy link
Contributor Author

WillAyd commented Sep 24, 2025

Still looking at this - unfortunately it looks like Thrift must be located on the system (hence the conda usage), but the grpc/libprotobuf used in conda don't seem to play nicely with the symbol visibility expectations on Windows.

@WillAyd WillAyd force-pushed the meson-win-support branch from 48805dd to 4322abe Compare October 6, 2025 19:31
@WillAyd
Copy link
Contributor Author

WillAyd commented Oct 23, 2025

I am still looking at this, but I think it will take a bit longer unfortunately. gRPC has some custom library naming conventions on Windows that don't appear reflected in the upstream Meson wrap entry. Its not possible to use the conda packaged gRPC libraries because they have symbol visibility issues on Windows, so the former will likely need to be fixed before this can continue

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants