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

Fail to build in MacOS #259

Open
lgalfaso opened this issue Oct 23, 2024 · 3 comments
Open

Fail to build in MacOS #259

lgalfaso opened this issue Oct 23, 2024 · 3 comments

Comments

@lgalfaso
Copy link

Expected Behavior

Fail to compile in MacOS

Actual Behavior

% bazel build --sandbox_debug //...
WARNING: For repository 'rules_java', the root module requires module version [email protected], but got [email protected] in the resolved dependency graph.
INFO: Analyzed 81 targets (127 packages loaded, 5768 targets configured).
ERROR: /private/var/tmp/_bazel_lmirelmann/cb69affe826809a241c0977900dc1520/external/_main~non_module_dependencies~honggfuzz/BUILD.bazel:131:11: Compiling libhfuzz/performance.c failed: (Exit 1): sandbox-exec failed: error executing CppCompile command 
  (cd /private/var/tmp/_bazel_lmirelmann/cb69affe826809a241c0977900dc1520/sandbox/darwin-sandbox/142/execroot/_main && \
  exec env - \
    PATH=/Users/lmirelmann/Library/Caches/bazelisk/downloads/sha256/0a9bfb9581a37049b7dcf204cc569b0458bedba20e84c55c0952161e036525ba/bin:/usr/local/bin:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/local/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/appleinternal/bin:/Library/Apple/usr/bin:/Library/TeX/texbin \
    PWD=/proc/self/cwd \
    TMPDIR=/var/folders/yy/tq88v3x96m7_03ct6y81plqh0000gn/T/ \
  /usr/bin/sandbox-exec -f /private/var/tmp/_bazel_lmirelmann/cb69affe826809a241c0977900dc1520/sandbox/darwin-sandbox/142/sandbox.sb /var/tmp/_bazel_lmirelmann/install/92a4dbac19ba995301329efc59d9b07c/process-wrapper '--timeout=0' '--kill_delay=15' '--stats=/private/var/tmp/_bazel_lmirelmann/cb69affe826809a241c0977900dc1520/sandbox/darwin-sandbox/142/stats.out' external/bazel_tools~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 -MD -MF bazel-out/darwin_x86_64-fastbuild/bin/external/_main~non_module_dependencies~honggfuzz/_objs/honggfuzz_engine/performance.d '-frandom-seed=bazel-out/darwin_x86_64-fastbuild/bin/external/_main~non_module_dependencies~honggfuzz/_objs/honggfuzz_engine/performance.o' -iquote external/_main~non_module_dependencies~honggfuzz -iquote bazel-out/darwin_x86_64-fastbuild/bin/external/_main~non_module_dependencies~honggfuzz '-mmacos-version-min=15.0' -D_GNU_SOURCE -D_HF_ARCH_LINUX -fPIC -Wall -Wextra -Werror -Wno-override-init -Wno-initializer-overrides -Wno-gnu-empty-initializer -Wno-format-pedantic -Wno-gnu-statement-expression -mllvm '-inline-threshold=2000' -fblocks '-fsanitize-coverage=0' '-fno-sanitize=all' -fno-stack-protector -U_FORTIFY_SOURCE '-D_FORTIFY_SOURCE=0' -no-canonical-prefixes -Wno-builtin-macro-redefined '-D__DATE__="redacted"' '-D__TIMESTAMP__="redacted"' '-D__TIME__="redacted"' -c external/_main~non_module_dependencies~honggfuzz/libhfuzz/performance.c -o bazel-out/darwin_x86_64-fastbuild/bin/external/_main~non_module_dependencies~honggfuzz/_objs/honggfuzz_engine/performance.o)
In file included from external/_main~non_module_dependencies~honggfuzz/libhfuzz/performance.c:10:
external/_main~non_module_dependencies~honggfuzz/honggfuzz.h:374:5: error: unknown type name 'timer_t'; did you mean 'time_t'?
  374 |     timer_t timerId;
      |     ^~~~~~~
      |     time_t
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/sys/_types/_time_t.h:31:33: note: 'time_t' declared here
   31 | typedef __darwin_time_t         time_t;
      |                                 ^
1 error generated.
INFO: Elapsed time: 5.920s, Critical Path: 0.15s
INFO: 39 processes: 38 internal, 1 darwin-sandbox.
ERROR: Build did NOT complete successfully
% bazel query --output=build @local_config_platform//:host
# /private/var/tmp/_bazel_lmirelmann/cb69affe826809a241c0977900dc1520/external/local_config_platform/BUILD.bazel:4:9
platform(
  name = "host",
  constraint_values = ["@platforms//cpu:x86_64", "@platforms//os:osx"],
)
# Rule host instantiated at (most recent call last):
#   /private/var/tmp/_bazel_lmirelmann/cb69affe826809a241c0977900dc1520/external/local_config_platform/BUILD.bazel:4:9 in <toplevel>

For reasons that are not clear to me, the compilation of honggfuzz has the flag -D_HF_ARCH_LINUX that should not be there (as there is a select in honggfuzz.BUILD). Not sure why this is happening.

Steps to Reproduce the Problem

  1. From a Mac, run bazel build //...

Specifications

  • Version: Git at commit 1b9ddac66217c77f4eea0d3a8b765953ab5080b5
  • Platform: MacOS 15.0.1, x86
@lgalfaso
Copy link
Author

I'm leaning to think that there is an issue with Bazel.

If I change to use bazel 6.5.0, then

% git diff
diff --git a/.bazelversion b/.bazelversion
index a8907c0..f22d756 100644
--- a/.bazelversion
+++ b/.bazelversion
@@ -1 +1 @@
-7.0.2
+6.5.0
% bazel build fuzzing/engines:honggfuzz
INFO: Analyzed target //fuzzing/engines:honggfuzz (0 packages loaded, 0 targets configured).
INFO: Found 1 target...
Target //fuzzing/engines:honggfuzz up-to-date:
  bazel-bin/external/honggfuzz/libhonggfuzz_engine.lo
INFO: Elapsed time: 0.160s, Critical Path: 0.00s
INFO: 1 process: 1 internal.
INFO: Build completed successfully, 1 total action

Forcing to use bazel 7.0.0, then the same error shows up.

@fmeum
Copy link
Member

fmeum commented Oct 23, 2024

Bazelisk has a --bisect flag that automatically finds the breaking Bazel commit. Could you run that?

@lgalfaso
Copy link
Author

OMG this was painful. Executed

BAZELISK_SHUTDOWN=True BAZELISK_CLEAN=True bazel --bisect=ba3e0cc691fc758ff9510271b962685fcaf14691..7.0.0 build "@honggfuzz//:honggfuzz_engine"

(yes, started with ba3e0cc691fc758ff9510271b962685fcaf14691 as bazel was somehow broken in many releases in between and had to do a scripted bisect using some other script to find a good build).

It shows that

first bad commit is bazelbuild/bazel@30d033c

This is, looks like this is related to bzlmod :(

To double check this, executed

bazel build --noenable_bzlmod "@honggfuzz//:honggfuzz_engine"

and it build without errors.

Not sure how to move forward, as I ended in this rabbit hole when trying to use rules_fuzzing as a dependency from Bazel Repository Central.

Side note, bazelisk is a good tool, but a little more flexibility, it would be amazing. eg

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

No branches or pull requests

2 participants