Open srdo-humio opened 7 months ago
rules_graalvm
uses apple_support
to set up the correct build environment for Xcode on macOS. As far as I understand, this requires the toolchain registered by apple_support
, which in turn requires full Xcode and does not work with just the command-line tools.
@keith Is there a way to use apple_support.run
in a way that also works with Bazel's auto-configured Unix toolchain?
i think it's possible for apple_support.run to support CLT only, but it would require the unix toolchain to add some env vars which it doesn't today. and generally so far we've been trying to reduce the unix toolchain's knowledge of apple specific weirdnesses. maybe we could make that action fallback to just a normal run if it wasn't using xcode? I don't recall what xcode specific bits rules_graalvm needed
It needs to pass through the Apple variables (mostly DEVELOPER_DIR
) in a weird way because that's how GraalVM expects them. Is there a way to detect "if it wasn't using xcode" in the rule implementation function?
i think in that case the xcode config apis from bazel return none. so theoretically we could use that. i think we'd have to still provide those variables, but at that point i guess we could safely hardcode them to where we "know" the CLT should be
I'm running into the same, except that, technically, I do have a complete Xcode installation—it just doesn't live beneath /Applications
. In our case, we're treating everything like a standard Unix toolchain. We generate wrappers for Clang utils and provide them to Bazel via CC
and CXX
env vars. Additional environment variables (e.g. OTOOL
, LIPO
) point directly to /alternate/location/xcode-major.minor/Xcode.app/Developer/...
.
I'm using the Bazel CLI flags such as macos_minimum_os
described above. I, too, run into the DEVELOPER_DIR: unbound variable
error described above.
IIUC:
rules_cc
before apple_support
, so Bazel's chosen CC toolchain will be rules_cc
's.apple_support
, and so it uses apple_support.run
. I assume this is why @fmeum asked about a way to detect whether or not we're using Xcode.To make progress locally, I'm patching Bazel's MODULE.bazel and adding a single_version_override(module_name = "rules_graalvm", patches=[...])
.
What's the right path forward?
apple_support.run
?
apple_support.run
internally check if the toolchain is an Xcode toolchain and behave accordingly?Since it's already asking a lot of rulesets to use apple_support
for Xcode support on macOS, I think that this logic should ideally live in apple_support.run
.
Description of the bug:
I'm unable to build
bazel build //src:java_tools_prebuilt_zip
on MacOS with only the Xcode command line tools installed. It's unclear to me whether this is a bug, me needing to adjust Bazel's flags, or whetherrules_graalvm
'snative_image
simply requires a full Xcode install and can't be used with only the command line tools.Which category does this issue belong to?
No response
What's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.
Have a MacOS device. Do not have Xcode installed. Install the Xcode command line tools via
xcode-select –-install
.Run
bazel build //src:java_tools_prebuilt_zip
. It should fail.Which operating system are you running Bazel on?
MacOS 14.4.1
What is the output of
bazel info release
?release 7.1.1
If
bazel info release
returnsdevelopment version
or(@non-git)
, tell us how you built Bazel.No response
What's the output of
git remote get-url origin; git rev-parse HEAD
?No response
Is this a regression? If yes, please try to identify the Bazel commit where the bug was introduced.
No response
Have you found anything relevant by searching the web?
https://github.com/bazelbuild/bazel/issues/20638 https://github.com/bazelbuild/bazel/issues/20513#issuecomment-1861775111
Any other information, logs, or outputs that you want to share?
Here's some context on my machine, and what I've tried:
Running
bazel build //src:java_tools_prebuilt_zip
on current master gets meI figured it might be a problem with the
--macos_minimum_os
, so I edited the.bazelrc
to saybuild:macos --macos_minimum_os=11.3 --host_macos_minimum_os=11.3 --macos_sdk_version=11.3
. This gets meI have tried adding
common --repo_env=BAZEL_NO_APPLE_CPP_TOOLCHAIN=1
to the .bazelrc, and this makes no difference, with or without the other changes to the sdk version flags.I have tried editing the MODULE.bazel file to ensure the
apple_support
line appears beforerules_cc
, since one of the linked issues implied order was important.