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

[perfetto] initial port of 43.1 #37959

Merged
merged 1 commit into from
Apr 15, 2024
Merged

Conversation

rtzoeller
Copy link
Contributor

@rtzoeller rtzoeller commented Apr 3, 2024

  • Changes comply with the maintainer guide.
  • The name of the port matches an existing name for this component on https://repology.org/ if possible, and/or is strongly associated with that component on search engines.
  • Optional dependencies are resolved in exactly one way. For example, if the component is built with CMake, all find_package calls are REQUIRED, are satisfied by vcpkg.json's declared dependencies, or disabled with CMAKE_DISABLE_FIND_PACKAGE_Xxx.
  • The versioning scheme in vcpkg.json matches what upstream says.
  • The license declaration in vcpkg.json matches what upstream says.
  • The installed as the "copyright" file matches what upstream says.
  • The source code of the component installed comes from an authoritative source.
  • The generated "usage text" is accurate. See adding-usage for context.
  • The version database is fixed by rerunning ./vcpkg x-add-version --all and committing the result.
  • Only one version is in the new port's versions file.
  • Only one version is added to each modified port's versions file.

@rtzoeller
Copy link
Contributor Author

@microsoft-github-policy-service agree company="ALIARO"

@rtzoeller rtzoeller marked this pull request as ready for review April 4, 2024 04:47
@rtzoeller
Copy link
Contributor Author

I've only directly tested the output on Linux x64, but I have no reason to believe it will not work in other environments.

@dg0yt
Copy link
Contributor

dg0yt commented Apr 5, 2024

How much overlap has this port with an official (gn) build?
Isn't it possible to use a shared lib on non-windows?

@rtzoeller
Copy link
Contributor Author

rtzoeller commented Apr 5, 2024

How much overlap has this port with an official (gn) build?

@dg0yt one of the outputs of the official build is the pair of amalgamated source files we're consuming, which are attached to each tagged release (e.g. for 43.0).

This greatly simplifies the build process, and matches the example built with CMake.

Isn't it possible to use a shared lib on non-windows?

Maybe, but I've not verified Perfetto's functionality when built into a shared library and presumed we could enable it later if needed without breaking compatibility.

If this is a blocker for the initial port let me know and I'll happily investigate.

@rtzoeller
Copy link
Contributor Author

Isn't it possible to use a shared lib on non-windows?

Looks like it is. I'll get a fix pushed shortly.

@rtzoeller rtzoeller marked this pull request as draft April 5, 2024 14:58
@rtzoeller rtzoeller marked this pull request as ready for review April 5, 2024 15:31
ports/perfetto/CMakeLists.txt Outdated Show resolved Hide resolved
ports/perfetto/CMakeLists.txt Outdated Show resolved Hide resolved
ports/perfetto/usage Outdated Show resolved Hide resolved
@WangWeiLin-MV WangWeiLin-MV self-assigned this Apr 7, 2024
@WangWeiLin-MV WangWeiLin-MV added the category:new-port The issue is requesting a new library to be added; consider making a PR! label Apr 7, 2024
ports/perfetto/CMakeLists.txt Outdated Show resolved Hide resolved
ports/perfetto/portfile.cmake Outdated Show resolved Hide resolved
ports/perfetto/portfile.cmake Outdated Show resolved Hide resolved
@rtzoeller rtzoeller force-pushed the perfetto branch 2 times, most recently from d8596fc to b2332d8 Compare April 8, 2024 13:21
@rtzoeller
Copy link
Contributor Author

@WangWeiLin-MV I've squashed the proposed changes into the original commit and added you as a co-author for it. This should be ready for another review.

WangWeiLin-MV
WangWeiLin-MV previously approved these changes Apr 9, 2024
Copy link
Contributor

@WangWeiLin-MV WangWeiLin-MV left a comment

Choose a reason for hiding this comment

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

Port usage tests pass with following triplets:

  • x64-linux
  • x64-windows
  • x64-windows-static
  • x64-windows-static-md
  • x86-windows

ports/perfetto/vcpkg.json Show resolved Hide resolved
@WangWeiLin-MV WangWeiLin-MV added the info:reviewed Pull Request changes follow basic guidelines label Apr 9, 2024
@rtzoeller rtzoeller force-pushed the perfetto branch 2 times, most recently from 7486698 to 2d80dbd Compare April 9, 2024 04:03
WangWeiLin-MV
WangWeiLin-MV previously approved these changes Apr 9, 2024
@JavierMatosD
Copy link
Contributor

Hi @rtzoeller,

We generally aim to use upstream's build configurations directly and only resort to providing unofficial exports when integrating with upstream would involve extensive patching or customization that doesn't seem justifiable. Could you share your rationale for opting for an unofficial CMake export instead of adapting Perfetto's existing Meson build for vcpkg? I'm not deeply familiar with Meson and its intricacies, so your insights would be very valuable to me and perhaps highlight aspects I might not be aware of.

Thanks for your contribution and looking forward to your thoughts!

@JavierMatosD JavierMatosD added the requires:vcpkg-team-review This PR or issue requires someone on the vcpkg team to take a further look. label Apr 9, 2024
@rtzoeller
Copy link
Contributor Author

rtzoeller commented Apr 9, 2024

Thanks for the insight @JavierMatosD.

Could you share your rationale for opting for an unofficial CMake export instead of adapting Perfetto's existing Meson build for vcpkg?

I wasn't previously aware of any existing Meson support in Perfetto (the source comment referring to Meson came from @WangWeiLin-MV); the primary build instructions only mention GN as a build system, although the repo also provides an example of using CMake to consume the amalgamated source files. In my usage of Perfetto I've always consumed the amalgamated SDK source files (e.g. for v43.0), and given the example CMake build this was the most approachable option. I'm also trying to integrate vcpkg into a CMake project which would consume the perfetto dependency, so it was a natural fit.

I now see that there is a meson.build file, and can take a look at consuming it.

I'm not deeply familiar with Meson and its intricacies, so your insights would be very valuable to me and perhaps highlight aspects I might not be aware of.

I have zero familiarity with Meson, so please bear with me as I attempt to rework this PR. 😄

@rtzoeller
Copy link
Contributor Author

rtzoeller commented Apr 9, 2024

At first glance the existing Meson support appears to be rather incomplete.

AFAICT, it only supports building a static library and does not install any headers (but does include the .proto file). It's likely possible for us to patch meson.build as part of the port, but I'm unsure that's any better than the current CMake situation -- the minimal commit history for meson.build and lack of documentation/examples using Meson to consume Perfetto admittedly don't inspire a ton of confidence in me.


@JavierMatosD can you please advise on which direction is acceptable for moving forward? Thanks!

  • Continue maintaining an unofficial CMake build (i.e. merge the existing PR).
  • Patch the existing Meson build system to also install perfetto.h to the include directory.
    • Optionally patch the Meson build system to support building as a dynamic library.
    • Full disclosure: I have effectively no experience with Meson other than reviewing the existing build just now.
  • Move away from the amalgamated SDK builds provided by the official Perfetto releases and build the source directly with GN instead.
    • Full disclosure: I have no experience with GN.

@rtzoeller
Copy link
Contributor Author

rtzoeller commented Apr 10, 2024

@JavierMatosD @WangWeiLin-MV I looked at what it would take to port this to use the Meson build; the results are here.

It still needs to be cleaned up (and building as a shared library is still an unknown), but my primary takeaway was that using the Meson build costs us the automatic CMake integration for clients -- I still needed to write an unofficial-perfetto-config.cmake file for clients to be able to use find_package() and link successfully.

@JavierMatosD
Copy link
Contributor

Big thanks for diving into the integration options! I'm initially leaning towards the unofficial CMake route because it seems super practical for now. But, I want to run it by our team to double-check we’re all on the same page for the long haul.

I’ll circle back with you as soon as we've made a decision. Really appreciate your patience and all the effort you're putting into this!

@dg0yt
Copy link
Contributor

dg0yt commented Apr 10, 2024

This port has no dependencies. So providing an unofficial CMake config shouldn't be more difficult to write by hand than a whole vendored CMake build system. If meson doesn't already provided official pkg-config files.

@JavierMatosD
Copy link
Contributor

@data-queue, @ras0219, @vicroms, @BillyONeal, and I discussed this and based on the CMake usage in Perfetto’s upstream example here, we agree that adopting CMake is appropriate. This approach is supported by the example provided by the library developers and aligns with our existing tools, avoiding the complexities and maintenance challenges associated with using GN.

ports/perfetto/CMakeLists.txt Show resolved Hide resolved
)

set(THREADS_PREFER_PTHREAD_FLAG TRUE)
find_package(Threads REQUIRED)
Copy link
Contributor

Choose a reason for hiding this comment

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

Should Threads be listed as a dependency?

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'm unsure what you mean here aside from what's asked in the other comment.

Should PThreads be a dependency (or feature) in the vcpkg.json?

Copy link
Contributor

Choose a reason for hiding this comment

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

The lib pthread is a system library, it just requires the find_package, and it will only be used on NON-WINDOWS. The checks in upstream https://github.com/google/perfetto/blob/v43.1/include/perfetto/ext/base/thread_checker.h#L22-L24.

ports/perfetto/CMakeLists.txt Show resolved Hide resolved
ports/perfetto/CMakeLists.txt Show resolved Hide resolved
endif(WIN32)

if(MSVC)
target_compile_options(perfetto PRIVATE "/permissive-")
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is this needed?

Copy link
Contributor Author

@rtzoeller rtzoeller Apr 12, 2024

Choose a reason for hiding this comment

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

To be clear that turns off permissive mode (note the minus), and puts MSVC into standards-compliant mode.

I wasn't able to get it to fail without this flag as part of the automated build, but my recollection from previous usage is that it's needed for older MSVC versions (2017?).

It's in the recommended set of flags for using the tracing compiler:

# Enable standards-compliant mode when using the Visual Studio compiler.
if (MSVC)
  target_compile_options(example PRIVATE "/permissive-")
endif (MSVC)

I can remove it if you want!

Copy link
Contributor

Choose a reason for hiding this comment

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

If it's not strictly required we should remove this. Thanks for the explanation!

Never mind. I think we should just follow upstreams recommendation here. :)

@JavierMatosD
Copy link
Contributor

Setting the PR to draft. Please mark ready for review when you've responded. That way I will know you've responded

@JavierMatosD JavierMatosD marked this pull request as draft April 12, 2024 14:34
Co-authored-by: WangWeiLin-MV <156736127+WangWeiLin-MV@users.noreply.github.com>
endif(WIN32)

if(MSVC)
target_compile_options(perfetto PRIVATE "/permissive-")
Copy link
Contributor

Choose a reason for hiding this comment

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

If it's not strictly required we should remove this. Thanks for the explanation!

Never mind. I think we should just follow upstreams recommendation here. :)

"license": "Apache-2.0",
"supports": "!uwp & !x86",
"dependencies": [
"pthreads",
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
"pthreads",
{
"name"" "pthreads",
"platform": "!windows"
},

Copy link
Contributor

Choose a reason for hiding this comment

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

@JavierMatosD Are you serious about this? Almost no port does this, but almost every non-trivial port uses pthreads.

Copy link
Contributor

Choose a reason for hiding this comment

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

Serious about what exactly? Adding the platform expression or adding it as a dependency?

Copy link
Contributor

Choose a reason for hiding this comment

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

Do we really request a pthreads dependency on platforms where the port is empty and where most ports don't use the dependency and where depending ports don't need to be rebuilt when the windows-only implementation is updated?

@JavierMatosD JavierMatosD removed the requires:vcpkg-team-review This PR or issue requires someone on the vcpkg team to take a further look. label Apr 15, 2024
@JavierMatosD JavierMatosD merged commit b4a3d89 into microsoft:master Apr 15, 2024
16 checks passed
JavierMatosD pushed a commit that referenced this pull request Apr 16, 2024
### Change
- Upgrade `perfetto` version to
[v44.0](https://github.com/google/perfetto/releases/tag/v44.0)
- Remove dependency `pthread` because the lib is a system library which
just requires the `find_package` and will only be used on NON-WINDOWS.
The checks in upstream
[perfetto/ext/base/thread_checker.h#L22-L24](https://github.com/google/perfetto/blob/v44.0/include/perfetto/ext/base/thread_checker.h#L22-L24)
- Remove the `x86` exclusion from
#37959 (comment)

### Checklist
- [x] Changes comply with the [maintainer
guide](https://github.com/microsoft/vcpkg-docs/blob/main/vcpkg/contributing/maintainer-guide.md).
- [x] SHA512s are updated for each updated download.
- [x] The "supports" clause reflects platforms that may be fixed by this
new version.
- [ ] ~Any fixed [CI
baseline](https://github.com/microsoft/vcpkg/blob/master/scripts/ci.baseline.txt)
entries are removed from that file.~
- [ ] ~Any patches that are no longer applied are deleted from the
port's directory.~
- [x] The version database is fixed by rerunning `./vcpkg x-add-version
--all` and committing the result.
- [x] Only one version is added to each modified port's versions file.

### Test
Port usage tests pass with following triplets:
* x64-linux
* x64-windows
* x64-windows-static
* x64-windows-static-md
* x86-windows
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! info:reviewed Pull Request changes follow basic guidelines
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants