-
Notifications
You must be signed in to change notification settings - Fork 4k
GH-46797: [C++] Support Meson on Windows #47282
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
|
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? or 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( | |||
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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:
arrow/cpp/src/arrow/CMakeLists.txt
Line 767 in 97d7cdb
| compute/kernels/ree_util_internal.cc |
There was a problem hiding this comment.
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
cpp/src/arrow/util/meson.build
Outdated
| @@ -224,18 +222,25 @@ utility_test_srcs = [ | |||
| ] | |||
|
|
|||
| if host_machine.system() == 'windows' | |||
| # meson does not natively support manifest files like CMake does | |||
There was a problem hiding this comment.
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...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
mesonbuild/meson#13041 may be related.
/MANIFEST:EMBED /MANIFESTINPUT:io_util_test.manifest linker options may work.
See also: https://learn.microsoft.com/en-us/cpp/build/reference/manifestinput-specify-manifest-input?view=msvc-170
kou
left a comment
There was a problem hiding this 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?
.github/workflows/cpp_extra.yml
Outdated
| key: cpp-ccache-windows-${{ env.CACHE_VERSION }}-${{ hashFiles('cpp/**') }} | ||
| restore-keys: cpp-ccache-windows-${{ env.CACHE_VERSION }}- |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| 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 }}- |
.github/workflows/cpp_extra.yml
Outdated
| 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 || '' }}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| 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" |
.github/workflows/cpp_extra.yml
Outdated
| 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 || '' }} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| ARROW_USE_MESON=ON ci/scripts/cpp_test.sh $(pwd) $(pwd)/build ${{ matrix.run-options || '' }} | |
| ci/scripts/cpp_test.sh $(pwd) $(pwd)/build |
.github/workflows/cpp_extra.yml
Outdated
| # We can invalidate the current cache by updating this. | ||
| CACHE_VERSION: "2022-09-13" | ||
| - name: Build | ||
| shell: cmd |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| 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( | |||
There was a problem hiding this comment.
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:
arrow/cpp/src/arrow/CMakeLists.txt
Line 767 in 97d7cdb
| compute/kernels/ree_util_internal.cc |
cpp/src/arrow/meson.build
Outdated
| if host_machine.system() != 'windows' | ||
| dl_dep = dependency('dl') | ||
| else | ||
| dl_dep = declare_dependency() | ||
| endif |
There was a problem hiding this comment.
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.)
| 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 |
cpp/src/arrow/meson.build
Outdated
| ) | ||
|
|
||
| arrow_compile_args = [] | ||
| if host_machine.system() == 'windows' and get_option('default_library') != 'shared' |
There was a problem hiding this comment.
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:
| 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?
There was a problem hiding this comment.
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, | |||
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
cpp/src/arrow/util/meson.build
Outdated
| @@ -224,18 +222,25 @@ utility_test_srcs = [ | |||
| ] | |||
|
|
|||
| if host_machine.system() == 'windows' | |||
| # meson does not natively support manifest files like CMake does | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
mesonbuild/meson#13041 may be related.
/MANIFEST:EMBED /MANIFESTINPUT:io_util_test.manifest linker options may work.
See also: https://learn.microsoft.com/en-us/cpp/build/reference/manifestinput-specify-manifest-input?view=msvc-170
|
|
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 |
c3b74be to
d7c42c4
Compare
.github/workflows/cpp_extra.yml
Outdated
| 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 || '' }}" |
There was a problem hiding this comment.
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 ?
There was a problem hiding this comment.
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?
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.
aca8728 to
39c6cf0
Compare
5a1752d to
e74984e
Compare
| thrift_dep = dependency( | ||
| 'thrift', | ||
| allow_fallback: false, | ||
| method: host_machine.system() == 'windows' ? 'cmake' : 'auto', |
There was a problem hiding this comment.
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
1b564ca to
48805dd
Compare
|
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. |
48805dd to
4322abe
Compare
4322abe to
fc1c08b
Compare
|
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 |
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