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

Populate environment for macOS builds #67

Closed
fmeum opened this issue Aug 29, 2023 · 1 comment · Fixed by #80
Closed

Populate environment for macOS builds #67

fmeum opened this issue Aug 29, 2023 · 1 comment · Fixed by #80
Assignees
Labels
bug Something isn't working
Milestone

Comments

@fmeum
Copy link
Collaborator

fmeum commented Aug 29, 2023

While trying to set up rules_graalvm@HEAD within Bazel itself in bazelbuild/bazel#19361, I ran into CI failures on macOS due to the missing environment variable DEVELOPER_DIR (see https://buildkite.com/bazel/bazel-bazel-github-presubmit/builds/17182#018a41ad-4977-4468-b1ab-523f0710e4ad/513-543).

Could rules_graalvm be missing a call to apple_common.target_apple_env or, probably even better, apple_support.run?

@sgammon
Copy link
Owner

sgammon commented Aug 29, 2023

@fmeum We are definitely missing such calls. So far, the only way I know to initialize the Xcode environment is to pass those variables through from the default_shell_env:

if (not ctx.attr._legacy_rule):
for var in _PASSTHRU_ENV_VARS:
if var == "DEVELOPER_DIR" and unix_like:
# allow bazel to override the developer directory on mac
env[var] = apple_common.apple_toolchain().developer_dir()
elif var == "SDKROOT" and unix_like:
# allow bazel to override the apple SDK root
env[var] = apple_common.apple_toolchain().sdk_dir()
elif var in ctx.configuration.default_shell_env:
env[var] = ctx.configuration.default_shell_env[var]

If you know how to prepare the Apple toolchain, I'd love some advice on this topic, or I would be happy to accept a PR. I have a doc with hermetic compile advice (to the best of my knowledge, of course), and it recommends setting BAZEL_USE_CPP_ONLY_TOOLCHAIN=1 which isn't ideal. So I can update that too.

I'll take a look these links you've shared to absorb the docs.

Also, thanks for using the rules and for reporting your experience.

@sgammon sgammon added the bug Something isn't working label Aug 29, 2023
@sgammon sgammon added this to the 1.0.0 milestone Aug 29, 2023
@sgammon sgammon linked a pull request Sep 1, 2023 that will close this issue
@sgammon sgammon mentioned this issue Sep 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
2 participants