Skip to content

bazel: add patches to compile with gcc-11#28548

Merged
adamjstewart merged 4 commits intospack:developfrom
glennpj:bazel
Aug 11, 2022
Merged

bazel: add patches to compile with gcc-11#28548
adamjstewart merged 4 commits intospack:developfrom
glennpj:bazel

Conversation

@glennpj
Copy link
Copy Markdown
Contributor

@glennpj glennpj commented Jan 21, 2022

Bazel does not currently build with GCC-11. There are patches available on the bazel project site for Alpine Linux that should work. The problem is that java-tools also needs patching.

@adamjstewart
Copy link
Copy Markdown
Member

Based on #27138 (comment) I'm guessing that this wasn't enough to solve the issue?

@adamjstewart
Copy link
Copy Markdown
Member

#29016 adds Bazel 5, might be worth looking at. If that fixes GCC 11 build issues I vote we close this.

@glennpj
Copy link
Copy Markdown
Contributor Author

glennpj commented May 16, 2022

My apologies for this PR languishing so long. I committed another set of changes to address older versions.

  1. Versions less than 4 can also be patched to get those versions to compile with newer GCC versions.
  2. Version 4.0.0 is kind of a special case. As commented in the package.py file, it needs newer versions of grpc and abseil. I am not sure how to handle that. For now, that version is in a conflicts statement.

#29016 adds Bazel 5, might be worth looking at. If that fixes GCC 11 build issues I vote we close this.

Bazel 5 does build without the patches. I allowed for that in the constraints settings of this PR. I do not think we should close this though as this gets bazel 3 to build with newer GCC versions.

Note: I could not build versions @:0.16 so I marked those deprecated.

@glennpj glennpj marked this pull request as ready for review May 16, 2022 01:28
@glennpj glennpj requested a review from adamjstewart May 16, 2022 01:29
@adamjstewart
Copy link
Copy Markdown
Member

Also see #30655

@adamjstewart
Copy link
Copy Markdown
Member

So, I need Bazel 4.1+ for Apple M1 support, and we have a few open Bazel PRs now, including #29016 and #30655. I'm no longer maintaining the Bazel package, which means that no one is maintaining the package, which means that no one cares if the package breaks. So I'm inclined to just start merging things and ask questions later. This PR seems to encompass most (all?) of #30655, and #29016 hasn't gotten a response since I reviewed it. So I'm thinking about just merging this and closing #30655 and #29016. Any objections from @elfprince13 or @haralmha? Any volunteers to officially maintain the package?

@haralmha
Copy link
Copy Markdown
Contributor

@adamjstewart sounds good to me. We are building the bazel based packages from wheels now anyway.

@adamjstewart
Copy link
Copy Markdown
Member

Tried building this on macOS 12.3.1 and Apple M1 Pro with Apple Clang 13.1.6 and JDK 18.0.1.1 but it doesn't build for me. Here is the build log: spack-build-out.txt. Any idea why this doesn't work?

@elfprince13
Copy link
Copy Markdown
Contributor

I can check tomorrow if this solves my issue.

@adamjstewart
Copy link
Copy Markdown
Member

Also tried Bazel 5.1.1 but I also saw build issues. Maybe my JDK version is too new?

@elfprince13
Copy link
Copy Markdown
Contributor

Just tried building Bazel 4.2.2 and this also needs a patch for:

  >> 72881    external/com_google_absl/absl/synchronization/internal/graphcycles.cc:451:26: error: no member named 'numeric_limits' in namespace 'std'
     72882      if (x->version == std::numeric_limits<uint32_t>::max()) {
     72883                        ~~~~~^
  >> 72884    external/com_google_absl/absl/synchronization/internal/graphcycles.cc:451:41: error: unexpected type name 'uint32_t': expected expression
     72885      if (x->version == std::numeric_limits<uint32_t>::max()) {
     72886                                            ^
  >> 72887    external/com_google_absl/absl/synchronization/internal/graphcycles.cc:451:52: error: no member named 'max' in the global namespace
     72888      if (x->version == std::numeric_limits<uint32_t>::max()) {
     72889                                                     ~~^
     72890    3 errors generated.
     72891    [935 / 2,844] 7 actions running
     72892        JavacBootstrap .../devtools/build/buildjar/libstarlark-deps.jar; 48s local
     72893        Compiling src/google/protobuf/descriptor.cc; 12s local

@glennpj
Copy link
Copy Markdown
Contributor Author

glennpj commented May 30, 2022

Just tried building Bazel 4.2.2 and this also needs a patch for:

@elfprince13 This PR patches that already. Version 4.2.2 builds fine for me.

@adamjstewart
Copy link
Copy Markdown
Member

@glennpj when you get a chance can you rebase and make sure your patches still apply to all versions? @elfprince13 and I can test this and get it merged soon.

@adamjstewart
Copy link
Copy Markdown
Member

Need to rebase/merge master. Probably want to run @spackbot fix style before that though.

@spackbot-app
Copy link
Copy Markdown

spackbot-app bot commented Aug 2, 2022

Let me see if I can fix that for you!

@adamjstewart
Copy link
Copy Markdown
Member

Oops, didn't intend to run that for you...

@spackbot-app
Copy link
Copy Markdown

spackbot-app bot commented Aug 2, 2022

I was able to run spack style --fix for you!

spack style --fix
==> Running style checks on spack
  selected: isort, mypy, black, flake8
==> Modified files
  var/spack/repos/builtin/packages/bazel/package.py
==> Running isort checks
  isort checks were clean
==> Running mypy checks
Success: no issues found in 555 source files
  mypy checks were clean
==> Running black checks
reformatted var/spack/repos/builtin/packages/bazel/package.py
All done! ✨ 🍰 ✨
1 file reformatted.
  black checks were clean
==> Running flake8 checks
var/spack/repos/builtin/packages/bazel/package.py:124: [E501] line too long (137 > 99 characters)
  flake8 found errors
Keep in mind that I cannot fix your flake8 or mypy errors, so if you have any you'll need to fix them and update the pull request. If I was able to push to your branch, if you make further changes you will need to pull from your updated branch before pushing again.

I've updated the branch with isort fixes.

@glennpj
Copy link
Copy Markdown
Contributor Author

glennpj commented Aug 2, 2022

@spackbot fix style

@spackbot-app
Copy link
Copy Markdown

spackbot-app bot commented Aug 2, 2022

Let me see if I can fix that for you!

@spackbot-app
Copy link
Copy Markdown

spackbot-app bot commented Aug 2, 2022

I was able to run spack style --fix for you!

spack style --fix
==> Running style checks on spack
  selected: isort, mypy, black, flake8
==> Modified files
  var/spack/repos/builtin/packages/bazel/package.py
==> Running isort checks
  isort checks were clean
==> Running mypy checks
Success: no issues found in 555 source files
  mypy checks were clean
==> Running black checks
reformatted var/spack/repos/builtin/packages/bazel/package.py
All done! ✨ 🍰 ✨
1 file reformatted.
  black checks were clean
==> Running flake8 checks
var/spack/repos/builtin/packages/bazel/package.py:124: [E501] line too long (137 > 99 characters)
  flake8 found errors
Keep in mind that I cannot fix your flake8 or mypy errors, so if you have any you'll need to fix them and update the pull request. If I was able to push to your branch, if you make further changes you will need to pull from your updated branch before pushing again.

I've updated the branch with isort fixes.

glennpj and others added 3 commits August 2, 2022 16:57
- deprecate versions 0.16 and lower as they do not build
- versions older than 0.22 depend on java@8
- adjust when patches are applied
- adjust gcc conflicts directive
@glennpj
Copy link
Copy Markdown
Contributor Author

glennpj commented Aug 3, 2022

So, spackbot adds a conflicts label but does not remove it when conflicts are resolved.

@adamjstewart
Copy link
Copy Markdown
Member

The conflicts label is for usage of the conflicts directive in a package, not for merge conflicts. Maybe we should remove that label, I agree that it's kind of confusing.

@glennpj
Copy link
Copy Markdown
Contributor Author

glennpj commented Aug 8, 2022

The conflicts label is for usage of the conflicts directive in a package, not for merge conflicts. Maybe we should remove that label, I agree that it's kind of confusing.

The label referring to package conflicts makes perfect sense, but my brain did associate it with the merge conflicts at the time. Perhaps package-conflicts or something similar.

@adamjstewart
Copy link
Copy Markdown
Member

Is this PR good to go now? @elfprince13 can you test this and make sure it solves your problems?

@adamjstewart adamjstewart changed the title bazel: new versions and patches to compile with gcc-11 bazel: add patches to compile with gcc-11 Aug 9, 2022
Copy link
Copy Markdown
Member

@adamjstewart adamjstewart left a comment

Choose a reason for hiding this comment

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

Added a commit to fix some issues I noticed during patching. With these changes, all patches now apply successfully to all versions. I haven't actually tested building older bazel with newer GCC, but I'll leave that part to someone else to test.

@@ -0,0 +1,14 @@
diff --git a/third_party/ijar/zlib_client.h b/third_party/ijar/zlib_client.h
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Any reason not to combine 1 and 2 into a single patch?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

No, the reason they are separate was just to be consistent with the source the patches were derived from. That is also why they are named the way they are. I thought that would be the most clear way to track what is going on.

@aweits
Copy link
Copy Markdown
Contributor

aweits commented Aug 10, 2022

Added a commit to fix some issues I noticed during patching. With these changes, all patches now apply successfully to all versions. I haven't actually tested building older bazel with newer GCC, but I'll leave that part to someone else to test.

works over here....

[aweits@skl-a-00 spack]$ spack find [email protected] %[email protected]
==> 1 installed package
-- linux-rhel7-skylake_avx512 / [email protected] ----------------------
[email protected]

@adamjstewart adamjstewart merged commit 4d06dcd into spack:develop Aug 11, 2022
@glennpj glennpj deleted the bazel branch August 11, 2022 02:05
@elfprince13
Copy link
Copy Markdown
Contributor

Is this PR good to go now? @elfprince13 can you test this and make sure it solves your problems?

It didn't but #40084 should get us the rest of the way there.

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

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

5 participants