Skip to content

Comments

protobuf: fix protoc used when cross-compiling#370155

Merged
misuzu merged 4 commits intoNixOS:stagingfrom
FliegendeWurst:protobuf-cross
Jan 29, 2025
Merged

protobuf: fix protoc used when cross-compiling#370155
misuzu merged 4 commits intoNixOS:stagingfrom
FliegendeWurst:protobuf-cross

Conversation

@FliegendeWurst
Copy link
Member

@FliegendeWurst FliegendeWurst commented Jan 2, 2025

This basically inlines the fix applied in most consumers of protobuf.

OpenCV 4 derivation is simplified to automatically use the right protoc. (It didn't work before anyhow.)

Things done

  • Built on platform(s)
    • x86_64-linux: pkgsCross.aarch64-multiplatform.protobuf_{21,23,24,25,26,27,28} pkgsCross.aarch64-multiplatform.opencv4 builds
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • For non-Linux: Is sandboxing enabled in nix.conf? (See Nix manual)
    • sandbox = relaxed
    • sandbox = true
  • Tested, as applicable:
  • Tested compilation of all packages that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage
  • Tested basic functionality of all binary files (usually in ./result/bin/)
  • 25.05 Release Notes (or backporting 24.11 and 25.05 Release notes)
    • (Package updates) Added a release notes entry if the change is major or breaking
    • (Module updates) Added a release notes entry if the change is significant
    • (Module addition) Added a release notes entry if adding a new NixOS module
  • Fits CONTRIBUTING.md.

Add a 👍 reaction to pull requests you find important.

@FliegendeWurst FliegendeWurst added the 6.topic: cross-compilation Building packages on a different platform than they will be used on label Jan 2, 2025
@FliegendeWurst FliegendeWurst force-pushed the protobuf-cross branch 2 times, most recently from ed76dfa to 176d3ae Compare January 2, 2025 09:39
@uninsane uninsane requested a review from GaetanLepage January 5, 2025 21:12
@github-actions github-actions bot added 10.rebuild-darwin: 1001-2500 This PR causes many rebuilds on Darwin and should most likely target the staging branches. 10.rebuild-linux: 101-500 This PR causes between 101 and 500 packages to rebuild on Linux. labels Jan 5, 2025
@nix-owners nix-owners bot requested review from basvandijk and sikmir January 5, 2025 22:46
Copy link
Contributor

@GaetanLepage GaetanLepage left a comment

Choose a reason for hiding this comment

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

LGTM.
I would like another ACK from someone who is more familiar with cross-compilation.

@wegank wegank added the 12.approvals: 1 This PR was reviewed and approved by one person. label Jan 6, 2025
@FliegendeWurst FliegendeWurst force-pushed the protobuf-cross branch 3 times, most recently from e6b0cb8 to 6eee173 Compare January 13, 2025 21:16
@wegank wegank removed the 12.approvals: 1 This PR was reviewed and approved by one person. label Jan 14, 2025
Copy link
Contributor

@misuzu misuzu left a comment

Choose a reason for hiding this comment

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

LGTM!

@misuzu misuzu added the 12.approvals: 2 This PR was reviewed and approved by two persons. label Jan 14, 2025
@wegank wegank added 12.approvals: 3+ This PR was reviewed and approved by three or more persons. and removed 12.approvals: 2 This PR was reviewed and approved by two persons. labels Jan 15, 2025
@FliegendeWurst FliegendeWurst marked this pull request as draft January 16, 2025 15:44
@FliegendeWurst
Copy link
Member Author

FliegendeWurst commented Jan 16, 2025

So I thought about this again, and I think adding a setup-hook as below would be the better solution.
It has the benefit that the cross-compiled protobuf package can be used as dev package on the host, which would otherwise not be possible.
(Actually I am not sure that makes much sense with the way buildPlatform etc. work at the moment.)

ProtobufCMakeFlags() {
  cmakeFlagsArray+=(
    -DPROTOC_EXE="@build_protobuf@/bin/protoc"
  )
}

preConfigureHooks+=(ProtobufCMakeFlags)

^ has essentially the same effect as the previous patch to the CMake files, overriding the path to protoc.

@uninsane uninsane mentioned this pull request Jan 22, 2025
5 tasks
@FliegendeWurst FliegendeWurst marked this pull request as ready for review January 23, 2025 22:18
@nix-owners nix-owners bot requested review from RaghavSood and mmahut January 23, 2025 22:20
@github-actions github-actions bot added 10.rebuild-linux: 2501-5000 This PR causes many rebuilds on Linux and should target the staging branches. and removed 10.rebuild-linux: 101-500 This PR causes between 101 and 500 packages to rebuild on Linux. labels Jan 23, 2025
@nix-owners nix-owners bot requested review from philipmw and rnhmjoj January 23, 2025 22:26
Copy link
Contributor

@rnhmjoj rnhmjoj left a comment

Choose a reason for hiding this comment

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

Ok for the monero part.

@wegank wegank added the 12.approved-by: package-maintainer This PR was reviewed and approved by a maintainer listed in any of the changed packages. label Jan 25, 2025
Copy link
Contributor

@misuzu misuzu left a comment

Choose a reason for hiding this comment

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

Tested by building:

  • pkgs.monero-cli
  • pkgs.monero-gui
  • pkgs.opencv4
  • pkgsCross.riscv64.opencv4
  • pkgsCross.riscv64.protobuf_21
  • pkgsCross.riscv64.protobuf_23
  • pkgsCross.riscv64.protobuf_24
  • pkgsCross.riscv64.protobuf_25
  • pkgsCross.riscv64.protobuf_26
  • pkgsCross.riscv64.protobuf_27
  • pkgsCross.riscv64.protobuf_28
  • pkgsCross.riscv64.protobuf_29

@misuzu misuzu merged commit 62a28e5 into NixOS:staging Jan 29, 2025
29 of 31 checks passed
@GaetanLepage
Copy link
Contributor

Thanks guys !

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

Labels

6.topic: cross-compilation Building packages on a different platform than they will be used on 10.rebuild-darwin: 1001-2500 This PR causes many rebuilds on Darwin and should most likely target the staging branches. 10.rebuild-linux: 2501-5000 This PR causes many rebuilds on Linux and should target the staging branches. 12.approvals: 3+ This PR was reviewed and approved by three or more persons. 12.approved-by: package-maintainer This PR was reviewed and approved by a maintainer listed in any of the changed packages.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants