Skip to content
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

[vcpkg-ci-meson] New test port #38658

Draft
wants to merge 18 commits into
base: master
Choose a base branch
from
Draft

Conversation

dg0yt
Copy link
Contributor

@dg0yt dg0yt commented May 9, 2024

Check canonical use of builtin dependency providers.

meson issues:

  • cmake dependency method return debug lib paths in release config.
    Reason: CMake is run without CMAKE_BUILD_TYPE.
    Proposed: Set CMAKE_BUILD_TYPE. Vcpkg port vcpkg-tool-meson.
    Cherry-picked into [vcpkg-tool-meson] Fix warnings, cmake, llvm 18 #38796.
  • intl failing on windows-static triplets
    Reason: meson not using iconv linking requirement unless asking for static intl.
    Proposed: add iconv dep when linking fails. Meson.
    Patch: dependencies-misc-diff.
  • intl failing on apple
    Reason: meson not using CoreFoundation linking requirement.
    Proposed: add foundation framework dep when linking fails. Meson.
    Patch: dependencies-misc.diff.
  • Not using vcpkg cmake toolchain, ignoring vcpkg cmake wrappers
    Ignoring $<CONFIG:...> elements.
    Observed for the intl cmake method (vcpkg patch): Intl::Intl is not configured with Iconv::Iconv as expected.
    Reason: Meson's cmake dependency parser cannot handle generator expression in interface link libraries (even not the typical generated $<LINK_ONLY:>): Meson not respecting config dependent generator expressions in INTERFACE_LINK_LIBRARIES from CMake dependencies.  mesonbuild/meson#8232
    Proposed: Extend generator expression support. Meson.
    Patch: cmake-generator-expressions.patch.
  • Link check doesn't use WindowsApp.lib on uwp
    Observed for iconv, despite WindowsApp.lib being in the crossfile's winlibs.
    Reason: A link check is more bare-bones than generating build rules for executable target. The link check needs explicit link args.
    Proposal: Add winlibs to link checks. Meson.
    Patch: winlibs.patch.
  • CMake dependency provider not handling -framework FRAMEWORK link libraries.
    Observed after adding -framework CoreFoundation in vcpkg wrapper for FindIntl.cmake.
    Reason: -framework arguments are not recognized as linker options, and cannot be resolved as CMake targets.
    Proposal: Treat them like -lLIB. Meson.
    Patch: cmake-trace-framework.diff.
  • CMake dependency provider doesn't establish proper link lib order. Most linkers on unixish platforms need independent libs last.
    Observed for intl/iconv/charset in x64-mingw-static, although without raising an error.
    Reason: Meson sorts libs alphabetically, after losing order while forming a set.
    Proposal: Remove lib list cleanup. (Maybe remove early duplicates). Meson.
    Patch: cmake-no-sorted.diff.
  • CMake dependency provider doesn't establish proper link lib order. Most linkers on unixish platforms need independent libs last.
    Even with sorting removed, the result will be wrong:
    Reason: link libs are added as soon as reaching a target in the dependency digraph. This is not the required topological sort.
    Proposal: Implement topological sort. Meson.
    Patch: TBD (FTR I worked on this topic recently in pkgconf.)

@dg0yt dg0yt force-pushed the vcpkg-ci-meson branch 2 times, most recently from 2f54ad0 to 33207ce Compare May 9, 2024 20:03
@JonLiu1993 JonLiu1993 self-assigned this May 10, 2024
@JonLiu1993 JonLiu1993 added the category:new-port The issue is requesting a new library to be added; consider making a PR! label May 10, 2024
Copy link
Contributor Author

@dg0yt dg0yt left a comment

Choose a reason for hiding this comment

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

- if self.static:
- if not self._add_sub_dependency(iconv_factory(env, self.for_machine, {'static': True})):
+ code = '''#include <libintl.h>\n\nint main() {\n gettext("Hello world");\n}'''
+ if self.static or not self.clib_compiler.links(code, env, dependencies=[self], extra_args=self.clib_compiler.get_option_link_args(self.clib_compiler.get_options()))[0]:
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixing meson intl detection on windows-static...
... but still not using WindowsApp.lib from c(pp)_winlibs.
Reference: mesonbuild/meson#7630 (comment) (from 2020!).

@@ -356,7 +356,7 @@ function(vcpkg_configure_meson)
set(meson_input_file_${buildname} "${CURRENT_BUILDTREES_DIR}/meson-${TARGET_TRIPLET}-${suffix_${buildname}}.log")
endif()

vcpkg_list(APPEND arg_OPTIONS --backend ninja --wrap-mode nodownload -Dbuildtype=plain -Doptimization=plain)
vcpkg_list(APPEND arg_OPTIONS --backend ninja --wrap-mode nodownload -Doptimization=plain)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Original form was suggested in mesonbuild/meson#11257 (comment) (from Jan 2023), and added despite the config warning it generates.
Maybe the original issues was fixed with 1.0.1 (Feb 2023).

Choose a reason for hiding this comment

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

It suffices to only pass -Dbuildtype=plain, I think. I may have missed a / in that comment and forgot to reply?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The general options here are combined with per-build-type options which ATM control meson's -Ddebug.

Let's say the key goal is to use the pristine flags provided by vcpkg while keeping meson informed about the type of build.

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 see now that there is also a build type custom which would be implicitly activated by -Doptimization=plain -Ddebug=true.
https://mesonbuild.com/Builtin-options.html#details-for-buildtype

@dg0yt
Copy link
Contributor Author

dg0yt commented May 13, 2024

(Sorry AT eli-schwartz, I pressed submit too early.)

@dg0yt
Copy link
Contributor Author

dg0yt commented May 15, 2024

Effect of *LINK_ONLY* patch, x64-mingw-static on linux host:

Guessed CMake target 'Intl::Intl'
CMake TARGET:
  -- name:      Intl::Intl
  -- type:      INTERFACE
  -- imported:  True
  -- properties: {
      'INTERFACE_INCLUDE_DIRECTORIES': ['/vcpkg/vcpkg/installed/x64-mingw-static/include']
      'INTERFACE_LINK_LIBRARIES': ['/vcpkg/vcpkg/installed/x64-mingw-static/debug/lib/libintl.a', '*LINK_ONLY*Iconv::Iconv']
     }
  -- tline: CMake TRACE: /vcpkg/vcpkg/downloads/tools/cmake-3.29.2-linux/cmake-3.29.2-linux-x86_64/share/cmake-3.29/Modules/FindIntl.cmake:178 add_library(['Intl::Intl', 'INTERFACE', 'IMPORTED'])
CMake TARGET:
  -- name:      Iconv::Iconv
  -- type:      INTERFACE
  -- imported:  True
  -- properties: {
      'INTERFACE_INCLUDE_DIRECTORIES': ['/vcpkg/vcpkg/installed/x64-mingw-static/include']
      'INTERFACE_LINK_LIBRARIES': ['/vcpkg/vcpkg/installed/x64-mingw-static/debug/lib/libiconv.a', 'Iconv::Charset']
     }
  -- tline: CMake TRACE: /vcpkg/vcpkg/downloads/tools/cmake-3.29.2-linux/cmake-3.29.2-linux-x86_64/share/cmake-3.29/Modules/FindIconv.cmake:178 add_library(['Iconv::Iconv', 'INTERFACE', 'IMPORTED'])
CMake TARGET:
  -- name:      Iconv::Charset
  -- type:      INTERFACE
  -- imported:  True
  -- properties: {
      'INTERFACE_LINK_LIBRARIES': ['/vcpkg/vcpkg/installed/x64-mingw-static/debug/lib/libcharset.a', '']
      'INTERFACE_INCLUDE_DIRECTORIES': ['']
     }
  -- tline: CMake TRACE: /vcpkg/vcpkg/installed/x64-mingw-static/share/iconv/vcpkg-cmake-wrapper.cmake:10 add_library(['Iconv::Charset', 'INTERFACE', 'IMPORTED'])
Include Dirs:         ['/vcpkg/vcpkg/installed/x64-mingw-static/include']
Compiler Options:     []
Libraries:            ['/vcpkg/vcpkg/installed/x64-mingw-static/debug/lib/libcharset.a', '/vcpkg/vcpkg/installed/x64-mingw-static/debug/lib/libiconv.a', '/vcpkg/vcpkg/installed/x64-mingw-static/debug/lib/libintl.a']

IMO the final list of libraries is in wrong order, but /usr/lib/ccache/x86_64-w64-mingw32-gcc doesn't complain when linking. 🤔

@dg0yt
Copy link
Contributor Author

dg0yt commented May 15, 2024

IMO the final list of libraries is in wrong order, but /usr/lib/ccache/x86_64-w64-mingw32-gcc doesn't complain when linking. 🤔

OMG, our version of meson sorts the libs alphabetically. Fixed in mesonbuild/meson@05f4e0d because it broke Apple frameworks, but plain static linking also needs to respect order.

@Neumann-A
Copy link
Contributor

Neumann-A commented May 15, 2024

Yeah fun with meson o.O. The self proclaimed build system of the future..... just feel free to patch the hell out of it until it learns to behave :)

@eli-schwartz
Copy link

@dg0yt considering there is no complaint when linking, one may theorize that meson knows what it is doing and this isn't a problem after all.

I would elaborate on what exactly I mean by that (I had a lengthy comment prepared last night), but it seems the peanut gallery has found your PR and reduced my ability to care.

Instead I'll leave @Neumann-A with the following insight:

/usr/bin/ld: cannot find -lintl-NOTFOUND

Truly, we live in the glorious future of build systems, within which perfection has been reached and the One True Way has been discovered.


This message has been sponsored by CMAKE(tm), the ISO standard build system of the 21st century. Accept no substitutes.

@Neumann-A
Copy link
Contributor

@dg0yt If you touch meson anyway you might want to directly update to 1.4.0 and investigate what issues appear with that version. I have another change in #37409 which allows to setup extra properties in meson but that probably has to wait until another port actually requires it.

don't know why eli-schwartz feels personally attacked by my previous comment but it seems like you have to carry the meson behavior discussion to the meson github. (Probably also makes it more discoverable for other people having a similar issues/questions)

@yurybura
Copy link
Contributor

@dg0yt If you touch meson anyway you might want to directly update to 1.4.0 and investigate what issues appear with that version. I have another change in #37409 which allows to setup extra properties in meson but that probably has to wait until another port actually requires it.

I've tried to update meson to 1.4.0 in #37599. LLVM update is blocked by mesa, mesa build is blocked by meson...

@dg0yt
Copy link
Contributor Author

dg0yt commented May 15, 2024

I do have some sympathy for, and some disappointments from, both CMake and meson. And the same is true for vcpkg, maybe even worse.

These disappointments are no excuse for disrespectful communication.

@eli-schwartz
Copy link

I do have some sympathy for, and some disappointments from, both CMake and meson. And the same is true for vcpkg, maybe even worse.

Software is, indeed, complicated and occasionally frustrating. I'm not aware of anyone that ever achieved perfection.

Which does make it a bit annoying when I'm pinged on vcpkg <--> meson integration issues and then have to deal with people that to my knowledge have never once attempted to be cordial with the meson project, who show up exclusively in this issue to make... non-cordial jokes.

Perhaps it will be better going forth -- it seems he's blocked me on github and I can only assume intends to not come asking me for help with meson in the future.

@@ -20,6 +20,7 @@ pkg-config= ['@PKGCONFIG@']
[properties]
cmake_toolchain_file = '@SCRIPTS@/buildsystems/vcpkg.cmake'
[cmake]
CMAKE_BUILD_TYPE = '@buildconfig@'
Copy link
Contributor

Choose a reason for hiding this comment

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

Better check the toolchain meson generates. Could very well be that it is overriding this value.

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 isn't added for fun. I didn't test with Meson 1.4 which has changes for CMAKE_BUILD_TYPE. But at the moment we need this. And ideally the proper configuration is validated by vcpkg-ci-meson.

Copy link
Contributor

Choose a reason for hiding this comment

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

I did not see any change in 1.4 regarding CMAKE_BUILD_TYPE in the generated toolchain nor the invocation log.

Copy link
Contributor

Choose a reason for hiding this comment

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

Would it make sense to split this and the changes to vcpkg_configure_meson suppressing the meson warnings out into a different PR?

The list in #38658 (comment) seems quite long and the stuff I mentioned seems to be trivial to merge while the other points might require a lot more iterations and time to solve.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Some splitting could be applied. But this is still in an experimental phase. Basically I'm studying mingw cross builds on linux in order to fix windows and uwp ;-) (How did I get here? Must have been gtk.)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

FTR this is the coming change in meson: mesonbuild/meson#12947

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Would it make sense to split this and the changes to vcpkg_configure_meson suppressing the meson warnings out into a different PR?

#38796

@@ -0,0 +1,23 @@
project('vcpkg-ci-meson', 'c', version: '1.0')

apple_frameworks = dependency('appleframeworks', modules: 'foundation', required: false)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Workaround.

@yurybura yurybura mentioned this pull request May 17, 2024
7 tasks

cargs += self.get_compiler_check_args(mode)
+ if mode is CompileCheckMode.LINK:
+ # Add <lang>_winlibs, accounting for machhine file
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Suggested change
+ # Add <lang>_winlibs, accounting for machhine file
+ # Add <lang>_winlibs, accounting for machine file

- if not self._add_sub_dependency(iconv_factory(env, self.for_machine, {'static': True})):
+ code = '''#include <libintl.h>\n\nint main() {\n gettext("Hello world");\n}'''
+ if self.static or not self.clib_compiler.links(code, env, dependencies=[self])[0]:
+ if not self._add_sub_dependency(iconv_factory(env, self.for_machine, {'static': self.static})):
Copy link
Contributor Author

Choose a reason for hiding this comment

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

NB: system iconv on macOS is dynamic lib.

@dg0yt
Copy link
Contributor Author

dg0yt commented May 21, 2024

@eli-schwartz The original post is now updated to reflect sub-issues and proposed fixes, including naming the relevant patches. I understand that the patches need to be transfered to meson PRs. The entry barrier is creating proper unit tests which correspond to what is an end-to-end test in port vcpkg-ci-meson, for the static and uwp vcpkg triplets. I'm not very familiar with python and meson. And I have seen some meson PRs targeting CMake support with a conan background. There is some overlap.

@BillyONeal
Copy link
Member

/azp run

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

vicroms pushed a commit that referenced this pull request May 23, 2024
Cherry-picked and extended from
#38658.
And a minor refactoring for easier management of patches.
llvm 18 changes for #37599,
squashed from
#37599 (comment).
@Neumann-A
Copy link
Contributor

@dg0yt Do you think you'll need more changes to vcpkg-tool-meson? I need to refactor it a bit so that I can get the command line flags out of it without actually calling meson. I need that so that the meson backend in python can be called with the arguments vcpkg would normally use to call meson directly.

vicroms pushed a commit that referenced this pull request May 23, 2024
Cherry-picked from #38658: Fixes errors like
~~~
CMake Error at
/Users/vcpkg/Data/installed/x64-osx/share/ffmpeg/FindFFMPEG.cmake:70
(find_library):
  Could not find

FFMPEG_DEPENDENCY_-F/Library/Developer/CommandLineTools/SDKs/MacOSX14.2.sdk/System/Library/Frameworks_RELEASE
  using the following names:

-F/Library/Developer/CommandLineTools/SDKs/MacOSX14.2.sdk/System/Library/Frameworks
Call Stack (most recent call first):
/Users/vcpkg/Data/installed/x64-osx/share/ffmpeg/FindFFMPEG.cmake:144
(append_dependencies)

/Users/vcpkg/Data/installed/x64-osx/share/ffmpeg/vcpkg-cmake-wrapper.cmake:25
(_find_package)
/Users/vcpkg/Data/work/1/s/scripts/buildsystems/vcpkg.cmake:813
(include)
  CMakeLists.txt:32 (find_package)
~~~
@dg0yt
Copy link
Contributor Author

dg0yt commented May 23, 2024

Do you think you'll need more changes to vcpkg-tool-meson?

@Neumann-A It should only need a cleanup and rebase onto master after integration of the split-out PRs. Then the PR will be ready for review. (I need to see if the current changes are accepted into vcpkg and into meson. Fixing the remaining lib order quirk is out of scope for this PR.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
category:new-port The issue is requesting a new library to be added; consider making a PR!
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants