-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
[C++] arrow.pc is missing dependencies with Windows static builds #15139
Comments
Could you show the full output of Could you show the output of |
Could you try the following for bzip2? diff --git a/cpp/cmake_modules/ThirdpartyToolchain.cmake b/cpp/cmake_modules/ThirdpartyToolchain.cmake
index d0c8c600d5..c93c6a534d 100644
--- a/cpp/cmake_modules/ThirdpartyToolchain.cmake
+++ b/cpp/cmake_modules/ThirdpartyToolchain.cmake
@@ -2546,9 +2546,17 @@ macro(build_bzip2)
endmacro()
if(ARROW_WITH_BZ2)
- resolve_dependency(BZip2)
- if(${BZip2_SOURCE} STREQUAL "SYSTEM")
- string(APPEND ARROW_PC_LIBS_PRIVATE " ${BZIP2_LIBRARIES}")
+ resolve_dependency(BZip2 PC_PACKAGE_NAMES bzip2)
+ if(${BZip2_SOURCE} STREQUAL "SYSTEM" AND NOT bzip2_PC_FOUND)
+ if(BZIP2_LIBRARY_RELEASE)
+ string(APPEND ARROW_PC_LIBS_PRIVATE " ${BZIP2_LIBRARY_RELEASE}")
+ elseif(BZIP2_LIBRARY_DEBUG)
+ string(APPEND ARROW_PC_LIBS_PRIVATE " ${BZIP2_LIBRARY_DEBUG}")
+ elseif(BZIP2_LIBRARY)
+ string(APPEND ARROW_PC_LIBS_PRIVATE " ${BZIP2_LIBRARY}")
+ else()
+ string(APPEND ARROW_PC_LIBS_PRIVATE " ${BZIP2_LIBRARIES}")
+ endif()
endif()
if(NOT TARGET BZip2::BZip2) |
I don't have a
(As an aside, I wondered if the Fedora build generates a sane looking pc file because it's finding the compression deps using system-wide pkg-config. However, I tried unsetting Regarding the patch for bzip2, that doesn't work quite right. FWIW, this largely fixes a cmake build (again I'm sure it's bad for other reasons, so just for info):
Generates a resaonable
(snappy weirdness would presumably go away if a snappy.pc actually existed) I tried adding this as a patch to vcpkg's arrow portfile but no joy (still missing compression deps). I notice it uses Thanks |
Fixing snappy at source is a no-go: google/snappy#86 Hopefully vcpkg will fix theirs: microsoft/vcpkg#28675 |
Could you try the following patch with diff --git a/cpp/cmake_modules/ThirdpartyToolchain.cmake b/cpp/cmake_modules/ThirdpartyToolchain.cmake
index 3eda538fb2..95d425d95d 100644
--- a/cpp/cmake_modules/ThirdpartyToolchain.cmake
+++ b/cpp/cmake_modules/ThirdpartyToolchain.cmake
@@ -2571,7 +2571,28 @@ endmacro()
if(ARROW_WITH_BZ2)
resolve_dependency(BZip2)
if(${BZip2_SOURCE} STREQUAL "SYSTEM")
- string(APPEND ARROW_PC_LIBS_PRIVATE " ${BZIP2_LIBRARIES}")
+ set(ARROW_BZIP2_CONFIGS "")
+ if(BZIP2_LIBRARY_RELEASE)
+ string(APPEND ARROW_PC_LIBS_PRIVATE " release[$<$<CONFIG:RELEASE>:${BZIP2_LIBRARY_RELEASE}>]")
+ list(APPEND ARROW_BZIP2_CONFIGS "$<CONFIG:RELEASE>")
+ endif()
+ if(BZIP2_LIBRARY_DEBUG)
+ string(APPEND ARROW_PC_LIBS_PRIVATE " debug[$<$<CONFIG:DEBUG:${BZIP2_LIBRARY_DEBUG}>]")
+ list(APPEND ARROW_BZIP2_CONFIGS "$<CONFIG:DEBUG>")
+ endif()
+ string(APPEND ARROW_PC_LIBS_PRIVATE " other[$<$<NOT:$<OR:")
+ if(CMAKE_VERSION VERSION_LESS "3.12")
+ string(REPLACE ";" "," ARROW_BZIP2_CONFIGS_CSV "${ARROW_BZIP2_CONFIGS}")
+ else()
+ list(JOIN ARROW_BZIP2_CONFIGS "," ARROW_BZIP2_CONFIGS_CSV)
+ endif()
+ string(APPEND ARROW_PC_LIBS_PRIVATE "${ARROW_BZIP2_CONFIGS_CSV}>>:")
+ if(BZIP2_LIBRARY)
+ string(APPEND ARROW_PC_LIBS_PRIVATE "${BZIP2_LIBRARY}")
+ else()
+ string(APPEND ARROW_PC_LIBS_PRIVATE "${BZIP2_LIBRARIES}")
+ endif()
+ string(APPEND ARROW_PC_LIBS_PRIVATE ">]")
endif()
if(NOT TARGET BZip2::BZip2) BTW, how did you install |
Thanks |
It's expected. I thought that Ah, wait. could you show You can disable system Sorry. Could you try the following? diff --git a/cpp/cmake_modules/ThirdpartyToolchain.cmake b/cpp/cmake_modules/ThirdpartyToolchain.cmake
index 3eda538fb2..0efaaa0c46 100644
--- a/cpp/cmake_modules/ThirdpartyToolchain.cmake
+++ b/cpp/cmake_modules/ThirdpartyToolchain.cmake
@@ -2571,7 +2571,28 @@ endmacro()
if(ARROW_WITH_BZ2)
resolve_dependency(BZip2)
if(${BZip2_SOURCE} STREQUAL "SYSTEM")
- string(APPEND ARROW_PC_LIBS_PRIVATE " ${BZIP2_LIBRARIES}")
+ set(ARROW_BZIP2_CONFIGS "")
+ if(BZIP2_LIBRARY_RELEASE)
+ string(APPEND ARROW_PC_LIBS_PRIVATE " $<$<CONFIG:RELEASE>:${BZIP2_LIBRARY_RELEASE}>>")
+ list(APPEND ARROW_BZIP2_CONFIGS "$<CONFIG:RELEASE>")
+ endif()
+ if(BZIP2_LIBRARY_DEBUG)
+ string(APPEND ARROW_PC_LIBS_PRIVATE " $<$<CONFIG:DEBUG:${BZIP2_LIBRARY_DEBUG}>>")
+ list(APPEND ARROW_BZIP2_CONFIGS "$<CONFIG:DEBUG>")
+ endif()
+ string(APPEND ARROW_PC_LIBS_PRIVATE " $<$<NOT:$<OR:")
+ if(CMAKE_VERSION VERSION_LESS "3.12")
+ string(REPLACE ";" "," ARROW_BZIP2_CONFIGS_CSV "${ARROW_BZIP2_CONFIGS}")
+ else()
+ list(JOIN ARROW_BZIP2_CONFIGS "," ARROW_BZIP2_CONFIGS_CSV)
+ endif()
+ string(APPEND ARROW_PC_LIBS_PRIVATE "${ARROW_BZIP2_CONFIGS_CSV}>>:")
+ if(BZIP2_LIBRARY)
+ string(APPEND ARROW_PC_LIBS_PRIVATE "${BZIP2_LIBRARY}")
+ else()
+ string(APPEND ARROW_PC_LIBS_PRIVATE "${BZIP2_LIBRARIES}")
+ endif()
+ string(APPEND ARROW_PC_LIBS_PRIVATE ">")
endif()
if(NOT TARGET BZip2::BZip2) It will generate |
Apologies for the delayed response, fighting a bout of the you-know-what.
Hmm, OK. Shame! Should the
Sure, it's a bit of a beast of a listing given the includes, so zipped. I wasn't sure from what state you wanted the listing, so it is after a vcpkg install & cmake configure (without the
Patch as below (needed a tiny tweak) did indeed generate that (I honestly can't remember when or how I tripped over lib files being linked as plain object files causing problems, so happy to ignore that until it happens again ... sorry for the noise.) Thanks!
|
… arrow.pc If bzip2 is installed for debug build and release build on Windows, find_package(BZip2) returns both static library paths of them. We should use one of them in arrow.pc. The bzip2's official build system doesn't provide bzip2.pc but vcpkg provides bzip2.pc. We can use it instead of detecting bzip2's static library path by ourselves.
Thanks for confirming the patch! |
… arrow.pc If bzip2 is installed for debug build and release build on Windows, find_package(BZip2) returns both static library paths of them. We should use one of them in arrow.pc. The bzip2's official build system doesn't provide bzip2.pc but vcpkg provides bzip2.pc. We can use it instead of detecting bzip2's static library path by ourselves.
OK. FWIW, I added this patch to vcpkg (along with microsoft/vcpkg#23898) and tried an install of arrow. It generates:
which doesn't look great. As a quick hack I added
which looks spot on to me. I'm not sure where to go with this now - a new issue in the vcpkg repo? Whilst |
….pc (#33712) ### Rationale for this change If bzip2 is installed for debug build and release build on Windows, find_package(BZip2) returns both static library paths of them. ### What changes are included in this PR? We should use one of detected library paths in arrow.pc. The bzip2's official build system doesn't provide bzip2.pc but vcpkg provides bzip2.pc. We can use it instead of detecting bzip2's static library path by ourselves. ### Are these changes tested? Yes. We test these changes in #15139 manually. ### Are there any user-facing changes? No. * Closes: #15139 Authored-by: Sutou Kouhei <[email protected]> Signed-off-by: Sutou Kouhei <[email protected]>
Oh, sorry. I merged the pull request before I see your last comment.
It seems that CMake's generate expression isn't evaluated. What is the difference between #15139 (comment) and #15139 (comment) ? |
Sorry, not sure I really understand the question but the first comment was regarding configuring and building arrow from the arrow source (which looks ok now), second was from
Setting Thanks |
Hmm. It seems that it's related to vcpkg. Could you open an issue on vcpkg? |
Sure, that's what I was asking. I'll try! |
Describe the bug, including details regarding any error messages, version, and platform.
I have been having to manually edit
arrow.pc
from a vcpkg installation of a static build of arrow (using tripletx64-windows-static-md
) for a few reasons. #14869 was a start, but now for the tricky (to me) one - missing dependencies. It doesn't seem to be a vcpkg issue, as non-vcpkg builds also generate "unconsumable" pkg-config files, so I'm posting here. Or maybe it goes all the way up to cmake, I don't know (I'm a cmake avoider...).The following is using arrow master as of a0d1630.
For example, using VS2022 (17.4.3) (and cmake 3.24.202208181-MSVC_2 from there) configured as:
when built and installed generates
arrow.pc
:This is essentially the same as an install via vcpkg. There are a few problems here:
Most of the compression deps are missing (libbrotlidec libbrotlienc zlib liblz4 libzstd).The cmake invocation generates the following:
so not surprising, I suppose! pc files are there in the
vcpkg_installed/x64-windows-static-md/debug/lib/pkgconfig
dir, however (and the libs themselves a level up).Libs
hasbz2
andsnappy
without-l
and with a file extension and path prefix. I don't think this is ideal, as without the-l
the file may be treated as a plain object file rather than import library causing issues with certain toolchains. Ultimately this could be worked around in meson, maybe, (or libpkgconf I think it uses) but...bzip2
should ideally be aRequires
too - since there are separate release and debug pkgconfig dirs they will cope with the file naming difference.And
snappy
too, but its .pc file is also broken (missing completely here;Libs: -L${libdir} -l
, i.e. not-lsnappy
, with a vcpkg install of arrow).I haven't investigated that at all yet, so keep in
Libs
, but without a path.I.e. a usable
arrow.pc
would look something like:Now I'm sure there are a gazillion of other cases to cope with where doing this would be wrong, but at least in the "get everything via vcpkg" case this
arrow.pc
works for me (and similarly editiedarrow.pc
from a vcpkg install of arrow).As an aside, the same set up of options (except no
CMAKE_MSVC_RUNTIME_LIBRARY
andx64-linux
triplet) on Fedora 37 (cmake 3.25.1) generates:This is more reasonable, though I personally think
bzip2
is handled wrong (for the same reasons as above), even if it "works". Thedebug
/optimized
stuff is still problematic but vcpkg are adding support for that there (microsoft/vcpkg#23898), so will start to work at some point - but obviously potentially not if consuming the pc file via another route.I have spent some time hacking
ThirdpartyToolchain.cmake
to see if I could make the pc files more sane, but unsuccessfully. The best I could do was getting bzip2 "better" with:but what that breaks I've no idea for other cases. As I say, not a cmake person and would like to keep it that way 😀 Happy to try any suggestions, though.
Thanks!
Component(s)
C++
The text was updated successfully, but these errors were encountered: