Skip to content

Bazel doesn't work in MacOS  #486

Open
@xieyuschen

Description

@xieyuschen

I could run bazel test //... in main latest commit in my ubuntu22.04, but I encountered several problems in macOS when i tried my new feature in macos #478 (comment)

I have listed some problems I encountered.

1(fixed): bindgen issue

The issue is propably caused by incorrect release downloading.

/bin/bash: external/bindgen/bindgen: cannot execute binary file
My Solution(Click me to unfold)
-    sha256 = "b7e2321ee8c617f14ccc5b9f39b3a804db173ee217e924ad93ed16af6bc62b1d",
-    strip_prefix = "bindgen-cli-x86_64-unknown-linux-gnu",
-    urls = ["https://github.com/rust-lang/rust-bindgen/releases/download/v0.69.5/bindgen-cli-x86_64-unknown-linux-gnu.tar.xz"],
+   strip_prefix = "bindgen-cli-aarch64-apple-darwin",
+   urls = ["https://github.com/rust-lang/rust-bindgen/releases/download/v0.69.5/bindgen-cli-aarch64-apple-darwin.tar.xz"],

2(fixed) cbindgen issue

It's similar, the downloading binary is still for linux only. Download its source code and build it during the project works.

My Solution(Click me to unfold)
--- a/WORKSPACE.bazel
+++ b/WORKSPACE.bazel
@@ -50,9 +53,8 @@ rust_register_toolchains(
 maybe(
     name = "bindgen",
     repo_rule = http_archive,
-    sha256 = "b7e2321ee8c617f14ccc5b9f39b3a804db173ee217e924ad93ed16af6bc62b1d",
-    strip_prefix = "bindgen-cli-x86_64-unknown-linux-gnu",
-    urls = ["https://github.com/rust-lang/rust-bindgen/releases/download/v0.69.5/bindgen-cli-x86_64-unknown-linux-gnu.tar.xz"],
+    strip_prefix = "bindgen-cli-aarch64-apple-darwin",
+    urls = ["https://github.com/rust-lang/rust-bindgen/releases/download/v0.69.5/bindgen-cli-aarch64-apple-darwin.tar.xz"],

+rust_repositories()
+
+http_archive(
+    name = "cbindgen_source",
+    urls = ["https://github.com/mozilla/cbindgen/archive/refs/tags/0.26.0.tar.gz"],
 )
 
+load("@rules_rust//rust:defs.bzl", "rust_library")

--- a/iceoryx2-ffi/ffi/BUILD.bazel
+++ b/iceoryx2-ffi/ffi/BUILD.bazel
@@ -20,9 +20,19 @@ filegroup(
     srcs = glob(["**"]),
 )
 
-filegroup(
+
+load("@rules_rust//rust:defs.bzl", "rust_binary")
+
+rust_binary(
     name = "cbindgen-cli",
-    srcs = ["@cbindgen//file"],
+    srcs = [
+        "external/cbindgen_source/src/main.rs",
+        "external/cbindgen_source/build.rs",
+    ],
+    data = [
+        "external/cbindgen_source/Cargo.toml",
+        "external/cbindgen_source/Cargo.lock",
+    ],
 )

3: enable_if_pointer_t not in std

I have encountered the issue listed below. I briefly searched it and looks like it's a compiler version issue.

external/iceoryx/iceoryx_platform/generic/include/iceoryx_platform/atomic.hpp:283:5: error: no template named 'enable_if_pointer_t'
    enable_if_pointer_t<U> fetch_sub(std::ptrdiff_t value, std::memory_order order = std::memory_order_seq_cst) noexcept

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions