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

Bazel: pull in some dependencies to the internal repo #17382

Closed
wants to merge 4 commits into from

Conversation

redsun82
Copy link
Contributor

@redsun82 redsun82 commented Sep 4, 2024

This allows to build the ruby and python packs (and the upcoming experimental rust one) from within codeql. The files have been copied without any changes (besides some path changes) in c1fa0e3. Then 2931721 fixes an initial problem with the lipo transition, and restricts it to opt mode: the idea being that we only need universal binaries in the release, but a developer explicitly using the dbg or fastbuild compilation mode can do away without the double building.

A follow-up PR on the internal repo will remove the originals and use the definitions introduced here.

This allows to build the ruby and python packs
(and the upcoming experimental rust one) from
within `codeql`.
@redsun82 redsun82 requested a review from criemen September 4, 2024 13:43
@redsun82 redsun82 requested a review from a team as a code owner September 4, 2024 13:43
@redsun82 redsun82 marked this pull request as draft September 4, 2024 14:04
@redsun82
Copy link
Contributor Author

redsun82 commented Sep 4, 2024

hmm, this is broken on macOS, I need some more changes

@redsun82 redsun82 marked this pull request as ready for review September 4, 2024 15:43
Copy link
Collaborator

@criemen criemen left a comment

Choose a reason for hiding this comment

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

Hey,
I have added a bunch of comments, all around the same topic. Let's discuss those further, and once we have agreed on a direction, I'll review the internal PR.

I also raised a discussion on slack about integration testing build system changes in the submodule.


rust_host_tools = use_extension("@rules_rust//rust:extensions.bzl", "rust_host_tools")

rust.toolchain(
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is this definition really relevant for the external repo? Keeping the versions in sync internally and externally is not-so-great, and toolchains need to be defined in the root module.

In particular, we will never build (release) universal binaries from the public repo, so the extra target triples also are, as far as I can see, unnecessary, if we can avoid triggering the lipo transition.

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 don't think sync would be necessary, but in order to have a lipo rule in this repository one needs the toolchain definition to pull in the additional triples.

Anyway, I'll drop this PR for another approach

"""
Checks that the supplied binary doesn't use symbols that are not available in older glibc versions.
"""
# Note this accesses system binaries that are not declared anywhere,
Copy link
Collaborator

Choose a reason for hiding this comment

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

This can be removed iirc, as rules_python now ships a hermetic python interpreter (verification of that would be nice, though).

@@ -0,0 +1,66 @@
package(default_visibility = ["//visibility:public"])
Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't enjoy that we now have the platform definitions externally, but the toolchain defs internally (and the toolchains themselves belong to and need to stay internally AFAIUI).
Is there any way we can put this file back to the internal repo?

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 didn't mind too much, as this is defining constraints, not the actual toolchains. But in any case, this will go

# this default also covers bazel's own default
return "@codeql//misc/bazel/platforms:host_toolchain_%s" % arch

def _x86_32_transition_impl(settings, _attr):
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is now a lot of stuff we're only using internally (as we don't have C++ code that ends up in a pack in the external repo). That introduces a coupling between internal+external repo we didn't have before. Would it make sense to split this up into the universal binary transition, and the rest?

I believe we already transitively depend on the apple_support (bazel itself does, iirc). Avoiding that dependency was the only reason not to use https://github.com/bazelbuild/apple_support/blob/master/doc/rules.md#universal_binary.
Maybe now's the time to drop our lipo rule and use that instead? That saves us from having to move some of this code around, and an external dep is always easiest from a repo coordination perspective.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

agreed

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 believe we already transitively depend on the apple_support (bazel itself does, iirc). Avoiding that dependency was the only reason not to use https://github.com/bazelbuild/apple_support/blob/master/doc/rules.md#universal_binary.
Maybe now's the time to drop our lipo rule and use that instead? That saves us from having to move some of this code around, and an external dep is always easiest from a repo coordination perspective.

I don't think we rely implicitly on apple_support, at least it does not appear in bazel mod graph. The big downside we found in apple_support and its universal_binary, is that it relied on a full Xcode installation (I think it calls xcrun lipo), and we really don't want such a heavy dependency for our developers when we can use command line tools. I don't think that has changed in the meantime.

@redsun82 redsun82 closed this Sep 5, 2024
@redsun82 redsun82 deleted the redsun82/bazel branch September 5, 2024 06:25
redsun82 pushed a commit that referenced this pull request Sep 5, 2024
This is another shot at #17382,
using a different and more lightweight approach.

This allows building the ruby and python (and in the future also rust)
packs from within the codeql repository. This will:
* skip defining the glibc symbols checking, which only makes sense when
  building the release from the internal repository
* stub out our `universal_binary` rule, which we only need when building
  the release.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants