Bug 259056 - devel/bazel: fix build on powerpc*
Summary: devel/bazel: fix build on powerpc*
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: powerpc Any
: --- Affects Only Me
Assignee: Piotr Kubaj
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-10-11 00:39 UTC by Piotr Kubaj
Modified: 2021-10-12 20:46 UTC (History)
2 users (show)

See Also:
aehlig: maintainer-feedback+


Attachments
patch (1.73 KB, patch)
2021-10-11 00:39 UTC, Piotr Kubaj
no flags Details | Diff
v2 (3.86 KB, patch)
2021-10-11 15:39 UTC, Piotr Kubaj
no flags Details | Diff
v3 (2.58 KB, patch)
2021-10-11 15:41 UTC, Piotr Kubaj
no flags Details | Diff
v4 (2.55 KB, patch)
2021-10-11 15:43 UTC, Piotr Kubaj
aehlig: maintainer-approval+
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Piotr Kubaj freebsd_committer freebsd_triage 2021-10-11 00:39:31 UTC
Created attachment 228573 [details]
patch

bazel uses a bundled abseil. To build on powerpc*, abseil requires a trivial patch.

However, since abseil is bundled, it needs to be patched in bazel's source. Then its sha256 needs to be updated.

grpc also has abseil's sha256 bundled, so it also needs to be updated.
Then grpc's hash too needs to be updated.

For the record, the error is:
In file included from external/com_google_absl/absl/base/internal/unscaledcycleclock.cc:27:
/usr/include/sys/sysctl.h:1185:25: error: unknown type name 'u_int'
int     sysctl(const int *, u_int, void *, size_t *, const void *, size_t);
                            ^
external/com_google_absl/absl/base/internal/unscaledcycleclock.cc:91:10: error: unknown type name 'once_flag'
  static once_flag init_timebase_frequency_once;
         ^
external/com_google_absl/absl/base/internal/unscaledcycleclock.cc:93:18: error: no member named 'LowLevelCallOnce' in namespace 'absl::lts_2020_02_25::base_internal'
  base_internal::LowLevelCallOnce(&init_timebase_frequency_once, [&]() {
  ~~~~~~~~~~~~~~~^
Comment 1 Klaus Aehlig 2021-10-11 06:33:22 UTC
Thanks for looking into the build failures of bazel on powerpc. As I don't have that architecture, I appreciate your help.

With respect to the the patch, I think, something went wrong during generation or upload: it mentions ${FILESDIR}/extra-patch-absl_base_internal_unscaledcycleclock.cc but does not add that file (as if the -N option was missing in the invocation of `diff`).

Concerning the way the patch is added to the build, I think the approach of unpacking and repacking distfiles (in this case the bundled ones) is very maintainable. As
- bazel includes grpc as an http_archive,
- grp includes abseil as an http_archive, and
- bazel's http_archive supports patching[1]
I would use that official bazel mechanism to add the patch to the build. More precisely, I would do the following.

At pre (or even post) patch time copy the extra patch files to ${WRKSRC}/third_party/grpc.

Patch line 1235 of the ${WRKSRC}/WORKSPACE to include an additional patch after the patch mentioned there already.

That patch patches bazel/grpc_deps.bzl to change the definition of the http_archive of abseil to include your patch (by adding the patches attribute). It has to be a p0 patch relative to grpc's root.

What do you think? In my opinion, using bazel's official patching mechanism in the described way, the port stays easier to adapt on updates of bazel. Should we do it like this? Can you update your patch accordingly?

Thanks again for caring about the bazel port.
Klaus



[1] https://docs.bazel.build/versions/main/repo/http.html#http_archive
Comment 2 Piotr Kubaj freebsd_committer freebsd_triage 2021-10-11 15:39:58 UTC
Created attachment 228589 [details]
v2

Thanks for your quick reply. Please have a look at the attached patch.
Comment 3 Piotr Kubaj freebsd_committer freebsd_triage 2021-10-11 15:41:18 UTC
Created attachment 228590 [details]
v3

Remove the previous (commented out) method of patching.
Comment 4 Piotr Kubaj freebsd_committer freebsd_triage 2021-10-11 15:43:50 UTC
Created attachment 228591 [details]
v4

Add @ before CP to silence it and merge two CP's into one.
Comment 5 Klaus Aehlig 2021-10-11 21:12:31 UTC
Comment on attachment 228591 [details]
v4

Thanks for cleaning up patch. Looks good now! And thank you for taking care of the powerpc architecture.
Comment 6 commit-hook freebsd_committer freebsd_triage 2021-10-12 19:07:58 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/ports/commit/?id=8abf3fd74456a955857e83bb337184d62d27a90c

commit 8abf3fd74456a955857e83bb337184d62d27a90c
Author:     Piotr Kubaj <pkubaj@FreeBSD.org>
AuthorDate: 2021-10-12 18:37:02 +0000
Commit:     Piotr Kubaj <pkubaj@FreeBSD.org>
CommitDate: 2021-10-12 18:37:02 +0000

    devel/bazel: fix build on powerpc*

    bazel uses a bundled abseil. To build on powerpc*, abseil requires a trivial
    patch.

    In file included from external/com_google_absl/absl/base/internal/unscaledcycleclock.cc:27:
    /usr/include/sys/sysctl.h:1185:25: error: unknown type name 'u_int'
    int     sysctl(const int *, u_int, void *, size_t *, const void *, size_t);
                                ^
    external/com_google_absl/absl/base/internal/unscaledcycleclock.cc:91:10: error: unknown type name 'once_flag'
      static once_flag init_timebase_frequency_once;
             ^
    external/com_google_absl/absl/base/internal/unscaledcycleclock.cc:93:18: error: no member named 'LowLevelCallOnce' in namespace 'absl::lts_2020_02_25::base_internal'
      base_internal::LowLevelCallOnce(&init_timebase_frequency_once, [&]() {
      ~~~~~~~~~~~~~~~^

    PR:     259056
    Approved by:    ehlig@linta.de (maintainer)

 devel/bazel/Makefile                                       |  5 +++++
 ...ra-patch-absl_base_internal_unscaledcycleclock.cc (new) | 14 ++++++++++++++
 devel/bazel/files/extra-patch-bazel_grpc__deps.bzl (new)   | 10 ++++++++++
 devel/bazel/files/patch-WORKSPACE (new)                    | 14 ++++++++++++++
 4 files changed, 43 insertions(+)
Comment 7 Piotr Kubaj freebsd_committer freebsd_triage 2021-10-12 20:46:32 UTC
Committed, thanks!