heir icon indicating copy to clipboard operation
heir copied to clipboard

macOS bazel build fail

Open Kidebazelno opened this issue 4 months ago • 22 comments

I follow the instructions cloning into this repo and run bazel build @heir//tools:heir-opt, but I get this error. I've tried bazel build @heir//tools:heir-opt --//:enable_yosys=false in earlier issue but it has the same error. Not sure what to do next.

Starting local Bazel server (8.3.1) and connecting to it...
WARNING: WORKSPACE support will be removed in Bazel 9 (late 2025), please migrate to Bzlmod, see https://bazel.build/external/migration.
WARNING: /private/var/tmp/_bazel_choubj/8765523c248244cd4ee13cea81fab6cd/external/libffi+/BUILD.bazel:50:10: in _copy_file rule @@libffi+//:ffitarget_h: target '@@libffi+//:ffitarget_h' depends on deprecated target '@@bazel_tools//src/conditions:host_windows_x64_constraint': No longer used by Bazel and will be removed in the future. Migrate to toolchains or define your own version of this setting.
WARNING: /private/var/tmp/_bazel_choubj/8765523c248244cd4ee13cea81fab6cd/external/llvm_zlib/BUILD.bazel:23:10: in _copy_file rule @@llvm_zlib//:zconf_gen: target '@@llvm_zlib//:zconf_gen' depends on deprecated target '@@bazel_tools//src/conditions:host_windows_x64_constraint': No longer used by Bazel and will be removed in the future. Migrate to toolchains or define your own version of this setting.
INFO: Analyzed target //tools:heir-opt (393 packages loaded, 30065 targets configured).

FATAL: bazel crashed due to an internal error. Printing stack trace:
java.lang.RuntimeException: Unrecoverable error while evaluating node 'ActionLookupData0{actionLookupKey=ConfiguredTargetKey{label=@@apple_support+//crosstool:exec_wrapped_clang.target_config, config=BuildConfigurationKey[485c88f99ff237570a266f5c00366c5756563e07cddbb348b989ff21ab3b7076]}, actionIndex=0}' (requested by nodes 'ArtifactNestedSetKey[4]@282835012')
        at com.google.devtools.build.skyframe.AbstractParallelEvaluator$Evaluate.run(AbstractParallelEvaluator.java:547)
        at com.google.devtools.build.lib.concurrent.AbstractQueueVisitor$WrappedRunnable.run(AbstractQueueVisitor.java:435)
        at java.base/java.util.concurrent.ForkJoinTask$RunnableExecuteAction.compute(Unknown Source)
        at java.base/java.util.concurrent.ForkJoinTask$RunnableExecuteAction.compute(Unknown Source)
        at java.base/java.util.concurrent.ForkJoinTask$InterruptibleTask.exec(Unknown Source)
        at java.base/java.util.concurrent.ForkJoinTask.doExec(Unknown Source)
        at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(Unknown Source)
        at java.base/java.util.concurrent.ForkJoinPool.runWorker(Unknown Source)
        at java.base/java.util.concurrent.ForkJoinWorkerThread.run(Unknown Source)
Caused by: java.lang.IllegalArgumentException: com.google.devtools.build.lib.rules.apple.DottedVersion$InvalidDottedVersionException: Dotted version components must all start with the form \d+([a-z0-9]*?)?(\d+)? but got 'None'
        at com.google.devtools.build.lib.rules.apple.DottedVersion.fromStringUnchecked(DottedVersion.java:181)
        at com.google.devtools.build.lib.exec.local.XcodeLocalEnvProvider.rewriteLocalEnv(XcodeLocalEnvProvider.java:99)
        at com.google.devtools.build.lib.sandbox.DarwinSandboxedSpawnRunner.prepareSpawn(DarwinSandboxedSpawnRunner.java:219)
        at com.google.devtools.build.lib.sandbox.AbstractSandboxSpawnRunner.exec(AbstractSandboxSpawnRunner.java:112)
        at com.google.devtools.build.lib.sandbox.SandboxModule$SandboxFallbackSpawnRunner.exec(SandboxModule.java:479)
        at com.google.devtools.build.lib.exec.AbstractSpawnStrategy.exec(AbstractSpawnStrategy.java:161)
        at com.google.devtools.build.lib.exec.AbstractSpawnStrategy.exec(AbstractSpawnStrategy.java:121)
        at com.google.devtools.build.lib.exec.SpawnStrategyResolver.exec(SpawnStrategyResolver.java:45)
        at com.google.devtools.build.lib.analysis.actions.SpawnAction.execute(SpawnAction.java:253)
        at com.google.devtools.build.lib.skyframe.SkyframeActionExecutor$ActionRunner.executeAction(SkyframeActionExecutor.java:1177)
        at com.google.devtools.build.lib.skyframe.SkyframeActionExecutor$ActionRunner.run(SkyframeActionExecutor.java:1082)
        at com.google.devtools.build.lib.skyframe.ActionExecutionState.runStateMachine(ActionExecutionState.java:166)
        at com.google.devtools.build.lib.skyframe.ActionExecutionState.getResultOrDependOnFuture(ActionExecutionState.java:95)
        at com.google.devtools.build.lib.skyframe.SkyframeActionExecutor.executeAction(SkyframeActionExecutor.java:566)
        at com.google.devtools.build.lib.skyframe.ActionExecutionFunction.checkCacheAndExecuteIfNeeded(ActionExecutionFunction.java:946)
        at com.google.devtools.build.lib.skyframe.ActionExecutionFunction.computeInternal(ActionExecutionFunction.java:377)
        at com.google.devtools.build.lib.skyframe.ActionExecutionFunction.compute(ActionExecutionFunction.java:218)
        at com.google.devtools.build.skyframe.AbstractParallelEvaluator$Evaluate.run(AbstractParallelEvaluator.java:467)
        ... 8 more
Caused by: com.google.devtools.build.lib.rules.apple.DottedVersion$InvalidDottedVersionException: Dotted version components must all start with the form \d+([a-z0-9]*?)?(\d+)? but got 'None'
        at com.google.devtools.build.lib.rules.apple.DottedVersion.fromString(DottedVersion.java:203)
        at com.google.devtools.build.lib.rules.apple.DottedVersion.fromStringUnchecked(DottedVersion.java:179)
        ... 25 more ```

Kidebazelno avatar Sep 03 '25 12:09 Kidebazelno

I'm using m4 chip, Darwin Kernel Version 24.6.0

Kidebazelno avatar Sep 03 '25 12:09 Kidebazelno

This error occurs when you don't have a full xcode installation on your machine. For whatever reason, the bazel infrastructure for MacOS requires this. The command-line tools alone do not suffice.

j2kun avatar Sep 03 '25 14:09 j2kun

Cf. https://github.com/bazelbuild/bazel/issues/25728. I might be able to find a workaround

j2kun avatar Sep 03 '25 17:09 j2kun

As an experiment, you could try patching this PR and rebuilding: https://github.com/google/heir/pull/2181

j2kun avatar Sep 03 '25 17:09 j2kun

Hello, I've installed Xcode fully and tried out both the PR and the newest main content, but it both shows error about Xcode, this is the error log. Thank you!

gh pr checkout 2181
From https://github.com/google/heir
 * branch                refs/pull/2181/head -> FETCH_HEAD
Already up to date.
(base) heir % bazel build @heir//tools:heir-opt
WARNING: WORKSPACE support will be removed in Bazel 9 (late 2025), please migrate to Bzlmod, see https://bazel.build/external/migration.
DEBUG: Rule 'rules_hdl' indicated that a canonical reproducible form can be obtained by modifying arguments integrity = "sha256-ynu06uxjbIM/mI1EuiU5ej030JDuQeZgQmvBnkFsxGQ="
DEBUG: Repository rules_hdl instantiated at:
  /Users/choubj/Desktop/lab/experiments/heir/WORKSPACE.bzlmod:47:13: in <toplevel>
Repository rule http_archive defined at:
  /private/var/tmp/_bazel_choubj/8765523c248244cd4ee13cea81fab6cd/external/bazel_tools/tools/build_defs/repo/http.bzl:394:31: in <toplevel>
WARNING: /private/var/tmp/_bazel_choubj/8765523c248244cd4ee13cea81fab6cd/external/llvm_zlib/BUILD.bazel:23:10: in _copy_file rule @@llvm_zlib//:zconf_gen: target '@@llvm_zlib//:zconf_gen' depends on deprecated target '@@bazel_tools//src/conditions:host_windows_x64_constraint': No longer used by Bazel and will be removed in the future. Migrate to toolchains or define your own version of this setting.
WARNING: /private/var/tmp/_bazel_choubj/8765523c248244cd4ee13cea81fab6cd/external/libffi+/BUILD.bazel:50:10: in _copy_file rule @@libffi+//:ffitarget_h: target '@@libffi+//:ffitarget_h' depends on deprecated target '@@bazel_tools//src/conditions:host_windows_x64_constraint': No longer used by Bazel and will be removed in the future. Migrate to toolchains or define your own version of this setting.
INFO: Analyzed target //tools:heir-opt (392 packages loaded, 30058 targets configured).
ERROR: /private/var/tmp/_bazel_choubj/8765523c248244cd4ee13cea81fab6cd/external/llvm_zstd/BUILD.bazel:22:11: Compiling lib/dictBuilder/fastcover.c [for tool] failed: absolute path inclusion(s) found in rule '@@llvm_zstd//:zstd':
the source file 'lib/dictBuilder/fastcover.c' includes the following non-builtin files with absolute paths (if these are builtin files, make sure these paths are in your toolchain):
  '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/stdio.h'
  '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/_stdio.h'
  '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/_bounds.h'
  '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/sys/cdefs.h'
  '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/sys/_symbol_aliasing.h'
  '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/sys/_posix_availability.h'
  '/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/17/include/ptrcheck.h'
  '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/Availability.h'
  '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/AvailabilityVersions.h'
  '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/AvailabilityInternal.h'
  '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/AvailabilityInternalLegacy.h'
  '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/_types.h'
  '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/sys/_types.h'
  '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/machine/_types.h'
  '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/arm/_types.h'
  '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/sys/_pthread/_pthread_types.h'
  '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/sys/_types/_va_list.h'
  '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/machine/types.h'
  '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/arm/types.h'
  '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/sys/_types/_int8_t.h'
  '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/sys/_types/_int16_t.h'
  '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/sys/_types/_int32_t.h'
  '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/sys/_types/_int64_t.h'
  '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/sys/_types/_u_int8_t.h'
  '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/sys/_types/_u_int16_t.h'
  '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/sys/_types/_u_int32_t.h'
  '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/sys/_types/_u_int64_t.h'
  '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/sys/_types/_intptr_t.h'
  '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/sys/_types/_uintptr_t.h'
  '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/sys/_types/_size_t.h'
  '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/sys/_types/_null.h'
  '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/sys/stdio.h'
  '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/_printf.h'
  '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/sys/_types/_seek_set.h'
  '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/_ctermid.h'
  '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/sys/_types/_off_t.h'
  '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/sys/_types/_ssize_t.h'
  '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/secure/_stdio.h'
  '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/secure/_common.h'
  '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/stdlib.h'
  '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/_stdlib.h'
  '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/sys/wait.h'
  '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/sys/_types/_pid_t.h'
  '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/sys/_types/_id_t.h'
  '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/sys/signal.h'
  '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/sys/appleapiopts.h'
  '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/machine/signal.h'
  '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/arm/signal.h'
  '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/machine/_mcontext.h'
  '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/arm/_mcontext.h'
  '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/mach/machine/_structs.h'
  '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/mach/arm/_structs.h'
  '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/sys/_pthread/_pthread_attr_t.h'
  '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/sys/_types/_sigaltstack.h'
  '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/sys/_types/_ucontext.h'
  '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/sys/_types/_sigset_t.h'
  '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/sys/_types/_uid_t.h'
  '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/sys/resource.h'
  '/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/17/include/stdint.h'
  '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/stdint.h'
  '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/_types/_uint8_t.h'
  '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/_types/_uint16_t.h'
  '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/_types/_uint32_t.h'
  '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/_types/_uint64_t.h'
  '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/_types/_intmax_t.h'
  '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/_types/_uintmax_t.h'
  '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/sys/_types/_timeval.h'
  '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/machine/endian.h'
  '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/arm/endian.h'
  '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/sys/_endian.h'
  '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/machine/_endian.h'
  '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/arm/_endian.h'
  '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/sys/__endian.h'
  '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/libkern/_OSByteOrder.h'
  '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/libkern/arm/_OSByteOrder.h'
  '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/alloca.h'
  '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/sys/_types/_ct_rune_t.h'
  '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/sys/_types/_rune_t.h'
  '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/sys/_types/_wchar_t.h'
  '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/malloc/_malloc.h'
  '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/malloc/_malloc_type.h'
  '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/malloc/_ptrcheck.h'
  '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/_abort.h'
  '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/sys/_types/_dev_t.h'
  '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/sys/_types/_mode_t.h'
  '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/string.h'
  '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/_string.h'
  '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/sys/_types/_rsize_t.h'
  '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/sys/_types/_errno_t.h'
  '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/_strings.h'
  '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/secure/_strings.h'
  '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/secure/_string.h'
  '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/time.h'
  '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/_time.h'
  '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/sys/_types/_clock_t.h'
  '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/sys/_types/_time_t.h'
  '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/sys/_types/_timespec.h'
  '/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/17/include/stddef.h'
  '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/stddef.h'
  '/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/17/include/__stddef_header_macro.h'
  '/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/17/include/__stddef_ptrdiff_t.h'
  '/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/17/include/__stddef_size_t.h'
  '/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/17/include/__stddef_rsize_t.h'
  '/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/17/include/__stddef_wchar_t.h'
  '/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/17/include/__stddef_null.h'
  '/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/17/include/__stddef_max_align_t.h'
  '/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/17/include/__stddef_offsetof.h'
  '/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/17/include/arm_neon.h'
  '/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/17/include/arm_bf16.h'
  '/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/17/include/arm_vector_types.h'
  '/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/17/include/limits.h'
  '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/limits.h'
  '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/machine/limits.h'
  '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/arm/limits.h'
  '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/arm/_limits.h'
  '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/sys/syslimits.h'
  '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/pthread.h'
  '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/pthread/sched.h'
  '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/pthread/pthread_impl.h'
  '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/sys/_pthread/_pthread_cond_t.h'
  '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/sys/_pthread/_pthread_condattr_t.h'
  '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/sys/_pthread/_pthread_key_t.h'
  '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/sys/_pthread/_pthread_mutex_t.h'
  '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/sys/_pthread/_pthread_mutexattr_t.h'
  '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/sys/_pthread/_pthread_once_t.h'
  '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/sys/_pthread/_pthread_rwlock_t.h'
  '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/sys/_pthread/_pthread_rwlockattr_t.h'
  '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/sys/_pthread/_pthread_t.h'
  '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/pthread/qos.h'
  '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/sys/qos.h'
  '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/sys/_types/_mach_port_t.h'
ERROR: /private/var/tmp/_bazel_choubj/8765523c248244cd4ee13cea81fab6cd/external/libffi+/BUILD.bazel:124:11: Compiling src/types.c failed: absolute path inclusion(s) found in rule '@@libffi+//:libffi':
the source file 'src/types.c' includes the following non-builtin files with absolute paths (if these are builtin files, make sure these paths are in your toolchain):
  '/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/17/include/stddef.h'
  '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/stddef.h'
  '/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/17/include/__stddef_header_macro.h'
  '/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/17/include/__stddef_ptrdiff_t.h'
  '/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/17/include/__stddef_size_t.h'
  '/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/17/include/__stddef_wchar_t.h'
  '/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/17/include/__stddef_null.h'
  '/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/17/include/__stddef_max_align_t.h'
  '/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/17/include/__stddef_offsetof.h'
  '/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/17/include/limits.h'
  '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/limits.h'
  '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/sys/cdefs.h'
  '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/sys/_symbol_aliasing.h'
  '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/sys/_posix_availability.h'
  '/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/17/include/ptrcheck.h'
  '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/machine/limits.h'
  '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/arm/limits.h'
  '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/arm/_limits.h'
  '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/sys/syslimits.h'
  '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/alloca.h'
  '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/_bounds.h'
  '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/_types.h'
  '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/sys/_types.h'
  '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/machine/_types.h'
  '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/arm/_types.h'
  '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/sys/_pthread/_pthread_types.h'
  '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/sys/_types/_size_t.h'
  '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/string.h'
  '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/_string.h'
  '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/Availability.h'
  '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/AvailabilityVersions.h'
  '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/AvailabilityInternal.h'
  '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/AvailabilityInternalLegacy.h'
  '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/sys/_types/_null.h'
  '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/sys/_types/_rsize_t.h'
  '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/machine/types.h'
  '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/arm/types.h'
  '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/sys/_types/_int8_t.h'
  '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/sys/_types/_int16_t.h'
  '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/sys/_types/_int32_t.h'
  '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/sys/_types/_int64_t.h'
  '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/sys/_types/_u_int8_t.h'
  '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/sys/_types/_u_int16_t.h'
  '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/sys/_types/_u_int32_t.h'
  '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/sys/_types/_u_int64_t.h'
  '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/sys/_types/_intptr_t.h'
  '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/sys/_types/_uintptr_t.h'
  '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/sys/_types/_errno_t.h'
  '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/sys/_types/_ssize_t.h'
  '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/_strings.h'
  '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/secure/_strings.h'
  '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/secure/_common.h'
  '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/secure/_string.h'
Target //tools:heir-opt failed to build
Use --verbose_failures to see the command lines of failed build steps.
INFO: Elapsed time: 14.465s, Critical Path: 0.50s
INFO: 979 processes: 978 internal, 1 darwin-sandbox.
ERROR: Build did NOT complete successfully

Kidebazelno avatar Sep 08 '25 07:09 Kidebazelno

So I spend some time today tracking down, why my build fails. I got this error:

ERROR: /private/var/tmp/_bazel/0d09f61371de8add9eab1921e8302ffb/external/net_invisible_island_ncurses/BUILD.bazel:207:10: Linking external/net_invisible_island_ncurses/make_hash failed: (Exit 1): sandbox-exec failed: error executing CppLink command
  (cd /private/var/tmp/_bazel/0d09f61371de8add9eab1921e8302ffb/sandbox/darwin-sandbox/64/execroot/_main && \
  exec env - \
    BAZEL_CXXOPTS='-std=c++20' \
    CC=clang \
    CXX=clang++ \
    PATH=/bin:/usr/bin:/usr/local/bin \
    PWD=/proc/self/cwd \
    TMPDIR=/var/folders/z4/1bj3rn2n68bc6qj_ftqgwfgh0000gp/T/ \
    ZERO_AR_DATE=1 \
  /usr/bin/sandbox-exec -f /private/var/tmp/_bazel/0d09f61371de8add9eab1921e8302ffb/sandbox/darwin-sandbox/64/sandbox.sb /var/tmp/_bazel/install/c75d9f44afe2d8390641b36cbee642bd/process-wrapper '--timeout=0' '--kill_delay=15' '--stats=/private/var/tmp/_bazel/0d09f61371de8add9eab1921e8302ffb/sandbox/darwin-sandbox/64/stats.out' external/rules_cc++cc_configure_extension+local_config_cc/cc_wrapper.sh @bazel-out/darwin_arm64-dbg/bin/external/net_invisible_island_ncurses/make_hash-0.params)
clang: error: invalid linker name in argument '-fuse-ld=ld64.lld:'

First I thought that it might have to do with some updates on my machine, but it turns out it has to do with #2181. I can build the commit before #2181 was merged, but everything after results in me having issues with the linker

kragall avatar Sep 11 '25 16:09 kragall

@Kidebazelno can you run the build command like so: bazel build //tools:heir-opt --sandbox_debug --verbose_failures and post the output?

kragall avatar Sep 11 '25 16:09 kragall

invalid linker name in argument '-fuse-ld=ld64.lld:'

The trailing colon looks like a typo in a .bazelrc, maybe on your system (could be in $HOME/.bazelrc?). In the checked-in repo, for example, we have build:linux --linkopt="-fuse-ld=lld" (no trailing colon) which requires the dev to install lld, but we have no specification for the linker on macos.

In particular, on my personal MacOS system:

$ which ld64.lld
/opt/homebrew/bin/ld64.lld

$ which lld
/opt/homebrew/bin/lld

And lld appears to forward to ld64.lld.

You could try adding build:macos --linkopt="-fuse-ld=lld" or build:macos --linkopt="-fuse-ld=ld64.lld"

j2kun avatar Sep 11 '25 17:09 j2kun

Hello, I've installed Xcode fully and tried out both the PR and the newest main content, but it both shows error about Xcode, this is the error log. Thank you!

If you've installed XCode then your toolchain has changed, and the bazel cache is probably stale and needs manually cleaning. Try bazel clean --expunge and rebuild.

j2kun avatar Sep 11 '25 17:09 j2kun

Reading a few other places, you may also find the command bazel fetch --configure --force useful, which re-runs the parts of the compiler toolchain setup that detects external dependencies (like the include headers provided by the macos SDK)

Cf. https://github.com/bazelbuild/bazel/issues/21718#issuecomment-2475285415

j2kun avatar Sep 11 '25 17:09 j2kun

I tried bazel fetch --configure --force and bazel clean --expunge, and run bazel build //tools:heir-opt --sandbox_debug --verbose_failures, they both show this error message:

bazel build //tools:heir-opt --sandbox_debug --verbose_failures
Starting local Bazel server (8.3.1) and connecting to it...
WARNING: WORKSPACE support will be removed in Bazel 9 (late 2025), please migrate to Bzlmod, see https://bazel.build/external/migration.
DEBUG: Rule 'rules_hdl' indicated that a canonical reproducible form can be obtained by modifying arguments integrity = "sha256-ynu06uxjbIM/mI1EuiU5ej030JDuQeZgQmvBnkFsxGQ="
DEBUG: Repository rules_hdl instantiated at:
  /Users/choubj/Desktop/lab/experiments/heir/WORKSPACE.bzlmod:47:13: in <toplevel>
Repository rule http_archive defined at:
  /private/var/tmp/_bazel_choubj/8765523c248244cd4ee13cea81fab6cd/external/bazel_tools/tools/build_defs/repo/http.bzl:394:31: in <toplevel>
WARNING: /private/var/tmp/_bazel_choubj/8765523c248244cd4ee13cea81fab6cd/external/libffi+/BUILD.bazel:50:10: in _copy_file rule @@libffi+//:ffitarget_h: target '@@libffi+//:ffitarget_h' depends on deprecated target '@@bazel_tools//src/conditions:host_windows_x64_constraint': No longer used by Bazel and will be removed in the future. Migrate to toolchains or define your own version of this setting.
WARNING: /private/var/tmp/_bazel_choubj/8765523c248244cd4ee13cea81fab6cd/external/llvm_zlib/BUILD.bazel:23:10: in _copy_file rule @@llvm_zlib//:zconf_gen: target '@@llvm_zlib//:zconf_gen' depends on deprecated target '@@bazel_tools//src/conditions:host_windows_x64_constraint': No longer used by Bazel and will be removed in the future. Migrate to toolchains or define your own version of this setting.
INFO: Analyzed target //tools:heir-opt (392 packages loaded, 30060 targets configured).
INFO: From Linking external/tk_tcl/libtclAlloc.a:
warning: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/libtool: archive library: bazel-out/darwin_arm64-dbg/bin/external/tk_tcl/libtclAlloc.a the table of contents is empty (no object file members in the library define global symbols)
INFO: From Compiling src/java_raw_api.c:
external/libffi+/src/java_raw_api.c:328:46: warning: 'ffi_java_raw_size' is deprecated [-Wdeprecated-declarations]
  328 |   ffi_java_raw *raw = (ffi_java_raw*)alloca (ffi_java_raw_size (cif));
      |                                              ^
bazel-out/darwin_arm64-dbg/bin/external/libffi+/ffi.h:315:56: note: 'ffi_java_raw_size' has been explicitly marked deprecated here
  315 | size_t ffi_java_raw_size (ffi_cif *cif) __attribute__((deprecated));
      |                                                        ^
external/libffi+/src/java_raw_api.c:331:3: warning: 'ffi_java_ptrarray_to_raw' is deprecated [-Wdeprecated-declarations]
  331 |   ffi_java_ptrarray_to_raw (cif, avalue, raw);
      |   ^
bazel-out/darwin_arm64-dbg/bin/external/libffi+/ffi.h:311:93: note: 'ffi_java_ptrarray_to_raw' has been explicitly marked deprecated here
  311 | void ffi_java_ptrarray_to_raw (ffi_cif *cif, void **args, ffi_java_raw *raw) __attribute__((deprecated));
      |                                                                                             ^
2 warnings generated.
INFO: From Compiling src/misc.c [for tool]:
external/rules_flex++default_toolchain_ext+flex_v2.6.4/src/misc.c:515:40: warning: passing 'unsigned char *' to parameter of type 'const char *' converts between pointers to integer types where one is of the unique plain 'char' type and the other is not [-Wpointer-sign]
  515 |                         esc_char = (unsigned char) strtoul (array + 1, NULL, 8);
      |                                                             ^~~~~~~~~
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/_stdlib.h:194:23: note: passing argument to parameter '__str' here
  194 |          strtoul(const char *__str, char *_LIBC_CSTR *__endptr, int __base);
      |                              ^
external/rules_flex++default_toolchain_ext+flex_v2.6.4/src/misc.c:537:40: warning: passing 'unsigned char *' to parameter of type 'const char *' converts between pointers to integer types where one is of the unique plain 'char' type and the other is not [-Wpointer-sign]
  537 |                         esc_char = (unsigned char) strtoul (array + 2, NULL, 16);
      |                                                             ^~~~~~~~~
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/_stdlib.h:194:23: note: passing argument to parameter '__str' here
  194 |          strtoul(const char *__str, char *_LIBC_CSTR *__endptr, int __base);
      |                              ^
2 warnings generated.
INFO: From Compiling adler32.c [for tool]:
In file included from external/llvm_zlib/adler32.c:7:
external/llvm_zlib/zutil.h:134:11: warning: 'OS_CODE' macro redefined [-Wmacro-redefined]
  134 | #  define OS_CODE 19
      |           ^
external/llvm_zlib/zutil.h:122:11: note: previous definition is here
  122 | #  define OS_CODE  7
      |           ^
1 warning generated.
ERROR: /private/var/tmp/_bazel_choubj/8765523c248244cd4ee13cea81fab6cd/external/llvm-project/llvm/BUILD.bazel:197:11: Compiling llvm/lib/Demangle/MicrosoftDemangleNodes.cpp [for tool] failed: (Exit 1): sandbox-exec failed: error executing CppCompile command 
  (cd /private/var/tmp/_bazel_choubj/8765523c248244cd4ee13cea81fab6cd/sandbox/darwin-sandbox/53/execroot/_main && \
  exec env - \
    CC=clang \
    CXX=clang++ \
    PATH=/bin:/usr/bin:/usr/local/bin \
    PWD=/proc/self/cwd \
    TMPDIR=/var/folders/m1/mtwrwsv90hs_t0887p77hmpm0000gn/T/ \
  /usr/bin/sandbox-exec -f /private/var/tmp/_bazel_choubj/8765523c248244cd4ee13cea81fab6cd/sandbox/darwin-sandbox/53/sandbox.sb /var/tmp/_bazel_choubj/install/238d60da91a7fad3983c54b8c9e828b0/process-wrapper '--timeout=0' '--kill_delay=15' '--stats=/private/var/tmp/_bazel_choubj/8765523c248244cd4ee13cea81fab6cd/sandbox/darwin-sandbox/53/stats.out' external/rules_cc++cc_configure_extension+local_config_cc/cc_wrapper.sh -U_FORTIFY_SOURCE -fstack-protector -Wall -Wthread-safety -Wself-assign -Wunused-but-set-parameter -Wno-free-nonheap-object -fcolor-diagnostics -fno-omit-frame-pointer -g0 -O2 '-D_FORTIFY_SOURCE=1' -DNDEBUG -ffunction-sections -fdata-sections '-std=c++20' '-frandom-seed=bazel-out/darwin_arm64-opt-exec-ST-d57f47055a04/bin/external/llvm-project/llvm/_objs/Demangle/MicrosoftDemangleNodes.o' '-DLLVM_ON_UNIX=1' '-DHAVE_BACKTRACE=1' '-DBACKTRACE_HEADER=<execinfo.h>' '-DLTDL_SHLIB_EXT=".so"' '-DLLVM_PLUGIN_EXT=".so"' '-DLLVM_ENABLE_LLVM_EXPORT_ANNOTATIONS=1' '-DLLVM_ENABLE_PLUGINS=1' '-DLLVM_ENABLE_THREADS=1' '-DHAVE_DEREGISTER_FRAME=1' '-DHAVE_LIBPTHREAD=1' '-DHAVE_PTHREAD_GETNAME_NP=1' '-DHAVE_PTHREAD_H=1' '-DHAVE_PTHREAD_SETNAME_NP=1' '-DHAVE_REGISTER_FRAME=1' '-DHAVE_SETENV_R=1' '-DHAVE_STRERROR_R=1' '-DHAVE_SYSEXITS_H=1' '-DHAVE_SYS_IOCTL_H=1' '-DHAVE_UNISTD_H=1' '-DHAVE_MACH_MACH_H=1' '-DHAVE_MALLOC_MALLOC_H=1' '-DHAVE_MALLOC_ZONE_STATISTICS=1' '-DHAVE_PROC_PID_RUSAGE=1' '-DHAVE_UNW_ADD_DYNAMIC_FDE=1' '-DLLVM_NATIVE_ARCH="AArch64"' '-DLLVM_NATIVE_ASMPARSER=LLVMInitializeAArch64AsmParser' '-DLLVM_NATIVE_ASMPRINTER=LLVMInitializeAArch64AsmPrinter' '-DLLVM_NATIVE_DISASSEMBLER=LLVMInitializeAArch64Disassembler' '-DLLVM_NATIVE_TARGET=LLVMInitializeAArch64Target' '-DLLVM_NATIVE_TARGETINFO=LLVMInitializeAArch64TargetInfo' '-DLLVM_NATIVE_TARGETMC=LLVMInitializeAArch64TargetMC' '-DLLVM_NATIVE_TARGETMCA=LLVMInitializeAArch64TargetMCA' '-DLLVM_HOST_TRIPLE="arm64-apple-darwin"' '-DLLVM_DEFAULT_TARGET_TRIPLE="arm64-apple-darwin"' '-DLLVM_VERSION_MAJOR=22' '-DLLVM_VERSION_MINOR=0' '-DLLVM_VERSION_PATCH=0' '-DLLVM_VERSION_STRING="22.0.0git"' -D__STDC_LIMIT_MACROS -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS '-DLLVM_HAS_AArch64_TARGET=1' '-DLLVM_HAS_X86_TARGET=1' '-DLLVM_HAS_NVPTX_TARGET=1' '-mmacosx-version-min=15.5' -MD -MF bazel-out/darwin_arm64-opt-exec-ST-d57f47055a04/bin/external/llvm-project/llvm/_objs/Demangle/MicrosoftDemangleNodes.d -iquote external/llvm-project -iquote bazel-out/darwin_arm64-opt-exec-ST-d57f47055a04/bin/external/llvm-project -isystem external/llvm-project/llvm/include -isystem bazel-out/darwin_arm64-opt-exec-ST-d57f47055a04/bin/external/llvm-project/llvm/include -g0 -g0 -c external/llvm-project/llvm/lib/Demangle/MicrosoftDemangleNodes.cpp -o bazel-out/darwin_arm64-opt-exec-ST-d57f47055a04/bin/external/llvm-project/llvm/_objs/Demangle/MicrosoftDemangleNodes.o -no-canonical-prefixes -Wno-builtin-macro-redefined '-D__DATE__="redacted"' '-D__TIMESTAMP__="redacted"' '-D__TIME__="redacted"' -Xclang '-fmodule-name=llvm-project//llvm:Demangle' -Xclang '-fmodule-map-file=bazel-out/darwin_arm64-opt-exec-ST-d57f47055a04/bin/external/llvm-project/llvm/Demangle.cppmap' -Xclang -fno-cxx-modules -fmodules-strict-decluse -Wprivate-header -Xclang '-fmodule-map-file=external/rules_cc++cc_configure_extension+local_config_cc/module.modulemap' -Xclang '-fmodule-map-file=bazel-out/darwin_arm64-opt-exec-ST-d57f47055a04/bin/external/llvm-project/llvm/config.cppmap')
external/llvm-project/llvm/lib/Demangle/MicrosoftDemangleNodes.cpp:152:44: error: no member named 'Auto' in 'llvm::ms_demangle::PrimitiveKind'
  152 |     OUTPUT_ENUM_CLASS_VALUE(PrimitiveKind, Auto, "auto");
      |     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~
external/llvm-project/llvm/lib/Demangle/MicrosoftDemangleNodes.cpp:22:14: note: expanded from macro 'OUTPUT_ENUM_CLASS_VALUE'
   22 |   case Enum::Value:                                                            \
      |        ~~~~~~^
external/llvm-project/llvm/lib/Demangle/MicrosoftDemangleNodes.cpp:153:44: error: no member named 'DecltypeAuto' in 'llvm::ms_demangle::PrimitiveKind'
  153 |     OUTPUT_ENUM_CLASS_VALUE(PrimitiveKind, DecltypeAuto, "decltype(auto)");
      |     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
external/llvm-project/llvm/lib/Demangle/MicrosoftDemangleNodes.cpp:22:14: note: expanded from macro 'OUTPUT_ENUM_CLASS_VALUE'
   22 |   case Enum::Value:                                                            \
      |        ~~~~~~^
external/llvm-project/llvm/lib/Demangle/MicrosoftDemangleNodes.cpp:525:7: error: use of undeclared identifier 'PointerAuthQualifier'
  525 |   if (PointerAuthQualifier)
      |       ^
external/llvm-project/llvm/lib/Demangle/MicrosoftDemangleNodes.cpp:526:5: error: use of undeclared identifier 'PointerAuthQualifier'
  526 |     PointerAuthQualifier->output(OB, Flags);
      |     ^
external/llvm-project/llvm/lib/Demangle/MicrosoftDemangleNodes.cpp:597:6: error: use of undeclared identifier 'PointerAuthQualifierNode'
  597 | void PointerAuthQualifierNode::output(OutputBuffer &OB,
      |      ^
5 errors generated.
Target //tools:heir-opt failed to build
INFO: Elapsed time: 7.929s, Critical Path: 0.65s
INFO: 1634 processes: 1558 internal, 76 darwin-sandbox.
ERROR: Build did NOT complete successfully

Kidebazelno avatar Sep 12 '25 01:09 Kidebazelno

I'm also on a M4 Mac and I can get heir to build, with the caveat listed in #2213.

I have Xcode installed in version 15.5. You can check your version with this:

> xcrun --sdk macosx --show-sdk-path
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.5.sdk
> xcrun --sdk macosx --show-sdk-version
15.5

I also installed llvm and lld via homebrew. But I don't remember if installing llvm like this was necessary at some point. lld is required though. Did you make sure, your system fulfills the pre-requisites listed here: https://heir.dev/docs/getting_started/

kragall avatar Sep 12 '25 14:09 kragall

LLVM should not be required as a system dependency, since we build it from scratch in the project. If it is for some reason, that'd be a bug for me to fix.

j2kun avatar Sep 12 '25 15:09 j2kun

Oh I thought I had lld on my computer... After install via brew, it shows new error:

bazel build //tools:heir-opt --sandbox_debug --verbose_failures
INFO: Analyzed target //tools:heir-opt (32 packages loaded, 321 targets configured).
ERROR: /private/var/tmp/_bazel_choubj/8765523c248244cd4ee13cea81fab6cd/external/llvm-project/llvm/BUILD.bazel:197:11: Compiling llvm/lib/Demangle/ItaniumDemangle.cpp [for tool] failed: (Exit 1): sandbox-exec failed: error executing CppCompile command 
  (cd /private/var/tmp/_bazel_choubj/8765523c248244cd4ee13cea81fab6cd/sandbox/darwin-sandbox/196/execroot/_main && \
  exec env - \
    CC=clang \
    CXX=clang++ \
    PATH=/bin:/usr/bin:/usr/local/bin \
    PWD=/proc/self/cwd \
    TMPDIR=/var/folders/m1/mtwrwsv90hs_t0887p77hmpm0000gn/T/ \
  /usr/bin/sandbox-exec -f /private/var/tmp/_bazel_choubj/8765523c248244cd4ee13cea81fab6cd/sandbox/darwin-sandbox/196/sandbox.sb /var/tmp/_bazel_choubj/install/238d60da91a7fad3983c54b8c9e828b0/process-wrapper '--timeout=0' '--kill_delay=15' '--stats=/private/var/tmp/_bazel_choubj/8765523c248244cd4ee13cea81fab6cd/sandbox/darwin-sandbox/196/stats.out' external/rules_cc++cc_configure_extension+local_config_cc/cc_wrapper.sh -U_FORTIFY_SOURCE -fstack-protector -Wall -Wthread-safety -Wself-assign -Wunused-but-set-parameter -Wno-free-nonheap-object -fcolor-diagnostics -fno-omit-frame-pointer -g0 -O2 '-D_FORTIFY_SOURCE=1' -DNDEBUG -ffunction-sections -fdata-sections '-std=c++20' '-frandom-seed=bazel-out/darwin_arm64-opt-exec-ST-d57f47055a04/bin/external/llvm-project/llvm/_objs/Demangle/ItaniumDemangle.o' '-DLLVM_ON_UNIX=1' '-DHAVE_BACKTRACE=1' '-DBACKTRACE_HEADER=<execinfo.h>' '-DLTDL_SHLIB_EXT=".so"' '-DLLVM_PLUGIN_EXT=".so"' '-DLLVM_ENABLE_LLVM_EXPORT_ANNOTATIONS=1' '-DLLVM_ENABLE_PLUGINS=1' '-DLLVM_ENABLE_THREADS=1' '-DHAVE_DEREGISTER_FRAME=1' '-DHAVE_LIBPTHREAD=1' '-DHAVE_PTHREAD_GETNAME_NP=1' '-DHAVE_PTHREAD_H=1' '-DHAVE_PTHREAD_SETNAME_NP=1' '-DHAVE_REGISTER_FRAME=1' '-DHAVE_SETENV_R=1' '-DHAVE_STRERROR_R=1' '-DHAVE_SYSEXITS_H=1' '-DHAVE_SYS_IOCTL_H=1' '-DHAVE_UNISTD_H=1' '-DHAVE_MACH_MACH_H=1' '-DHAVE_MALLOC_MALLOC_H=1' '-DHAVE_MALLOC_ZONE_STATISTICS=1' '-DHAVE_PROC_PID_RUSAGE=1' '-DHAVE_UNW_ADD_DYNAMIC_FDE=1' '-DLLVM_NATIVE_ARCH="AArch64"' '-DLLVM_NATIVE_ASMPARSER=LLVMInitializeAArch64AsmParser' '-DLLVM_NATIVE_ASMPRINTER=LLVMInitializeAArch64AsmPrinter' '-DLLVM_NATIVE_DISASSEMBLER=LLVMInitializeAArch64Disassembler' '-DLLVM_NATIVE_TARGET=LLVMInitializeAArch64Target' '-DLLVM_NATIVE_TARGETINFO=LLVMInitializeAArch64TargetInfo' '-DLLVM_NATIVE_TARGETMC=LLVMInitializeAArch64TargetMC' '-DLLVM_NATIVE_TARGETMCA=LLVMInitializeAArch64TargetMCA' '-DLLVM_HOST_TRIPLE="arm64-apple-darwin"' '-DLLVM_DEFAULT_TARGET_TRIPLE="arm64-apple-darwin"' '-DLLVM_VERSION_MAJOR=22' '-DLLVM_VERSION_MINOR=0' '-DLLVM_VERSION_PATCH=0' '-DLLVM_VERSION_STRING="22.0.0git"' -D__STDC_LIMIT_MACROS -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS '-DLLVM_HAS_AArch64_TARGET=1' '-DLLVM_HAS_X86_TARGET=1' '-DLLVM_HAS_NVPTX_TARGET=1' '-mmacosx-version-min=15.5' -MD -MF bazel-out/darwin_arm64-opt-exec-ST-d57f47055a04/bin/external/llvm-project/llvm/_objs/Demangle/ItaniumDemangle.d -iquote external/llvm-project -iquote bazel-out/darwin_arm64-opt-exec-ST-d57f47055a04/bin/external/llvm-project -isystem external/llvm-project/llvm/include -isystem bazel-out/darwin_arm64-opt-exec-ST-d57f47055a04/bin/external/llvm-project/llvm/include -g0 -g0 -c external/llvm-project/llvm/lib/Demangle/ItaniumDemangle.cpp -o bazel-out/darwin_arm64-opt-exec-ST-d57f47055a04/bin/external/llvm-project/llvm/_objs/Demangle/ItaniumDemangle.o -no-canonical-prefixes -Wno-builtin-macro-redefined '-D__DATE__="redacted"' '-D__TIMESTAMP__="redacted"' '-D__TIME__="redacted"' -Xclang '-fmodule-name=llvm-project//llvm:Demangle' -Xclang '-fmodule-map-file=bazel-out/darwin_arm64-opt-exec-ST-d57f47055a04/bin/external/llvm-project/llvm/Demangle.cppmap' -Xclang -fno-cxx-modules -fmodules-strict-decluse -Wprivate-header -Xclang '-fmodule-map-file=external/rules_cc++cc_configure_extension+local_config_cc/module.modulemap' -Xclang '-fmodule-map-file=bazel-out/darwin_arm64-opt-exec-ST-d57f47055a04/bin/external/llvm-project/llvm/config.cppmap')
external/llvm-project/llvm/lib/Demangle/ItaniumDemangle.cpp:546:32: error: out-of-line definition of 'finishDemangle' does not match any declaration in 'llvm::ItaniumPartialDemangler'
  546 | char *ItaniumPartialDemangler::finishDemangle(void *OB) const {
      |                                ^~~~~~~~~~~~~~
1 error generated.
Target //tools:heir-opt failed to build
INFO: Elapsed time: 1.492s, Critical Path: 0.71s
INFO: 61 processes: 28 internal, 33 darwin-sandbox.
ERROR: Build did NOT complete successfully
(base) choubj@KOG heir % clang --version
Apple clang version 17.0.0 (clang-1700.0.13.5)
Target: arm64-apple-darwin24.6.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
(base) choubj@KOG heir % which clang && which lld
/usr/bin/clang
/opt/homebrew/bin/lld

I'm not sure if the miss match of clang and lld may cause some error? (I also make sure I actually fulfill the prerequisites this time, thank you for pointing it out) Also, the error in the previous one still exists after I bazel clean it

Kidebazelno avatar Sep 12 '25 15:09 Kidebazelno

Did you bazel clean --expunge or just do bazel clean? I'm not sure if it is necessary, but could you try using --expunge now and then build again?

kragall avatar Sep 15 '25 12:09 kragall

I use bazel clean --expunge, and after building it shows one of the two error messages above, both complaining about demangle error in LLVM.

Kidebazelno avatar Sep 15 '25 12:09 Kidebazelno

@Kidebazelno I suspect it's using a homebrew-installed clang instead of apple clang, despite your shell's clang correctly pointing to apple clang.

Can you try pasting the output of bazel cquery --output=starlark --starlark:expr="str(providers(target))" @bazel_tools//tools/cpp:current_cc_toolchain | sed 's/,/\n/g' into a gist and link it here? You should see some lines like

_tool_paths = {"ar": "/usr/bin/ar"
 "ld": "/usr/bin/ld"
 "cpp": "/usr/bin/cpp"
 "gcc": "/usr/lib/llvm-19/bin/clang"
 "dwp": "/usr/bin/dwp" ...

and

 built_in_include_directories = ["/usr/lib/llvm-19/lib/clang/19/include"
 "/usr/local/include"
 "/usr/include/x86_64-linux-gnu"
 "/usr/include"
...

j2kun avatar Sep 15 '25 15:09 j2kun

I also installed llvm and lld via homebrew. But I don't remember if installing llvm like this was necessary at some point. lld is required though. Did you make sure, your system fulfills the pre-requisites listed here: https://heir.dev/docs/getting_started/

After having had issues with the linker myself #2213 I found out that you should not have lld installed via homebrew on your Mac when trying to build HEIR.

Which version of Xcode do you have installed (see https://xcodereleases.com)? I'm still on 16.4. I do avoid updating Xcode because I had issues with the new versions and HEIR in the past

kragall avatar Sep 24 '25 15:09 kragall

My Xcode is 26.0, so should I downgrade it and brew uninstall lld?

Kidebazelno avatar Sep 26 '25 16:09 Kidebazelno

I would indeed try removing lld. I had previously tested my build on xcode 16.4, but I am currently upgrading to 26.1 so I can test that newer version.

j2kun avatar Sep 27 '25 03:09 j2kun

I was able to build with xcode 26.1, though I did learn that, because I have rust installed on my machine, it comes with llvm 20

$ brew info llvm
==> llvm: stable 21.1.1 (bottled), HEAD [keg-only]
Next-gen compiler infrastructure
https://llvm.org/
Installed
/opt/homebrew/Cellar/llvm/20.1.8 (9,423 files, 1.6GB)
  Poured from bottle using the formulae.brew.sh API on 2025-07-11 at 10:12:51
From: https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/l/llvm.rb
License: Apache-2.0 WITH LLVM-exception

j2kun avatar Sep 27 '25 04:09 j2kun