Skip to content

Conversation

@ntjohnson1
Copy link
Member

Related

Closes #9849

What

Basically mac has a fun combination where you can have clang/llvm components but not llvm-ar. Mac's ar pads bytes in way that make llvm barf. Our pixi env for c++ has the cxx-compiler package which has a more full fledged llvm install. On mac on activation set AR to point to llvm-ar. It works on my machine! I'm not sure if we should have a second person try or if we should setup a test for the web build on mac just for this weird edge case.

@ntjohnson1 ntjohnson1 added 🧑‍💻 dev experience developer experience (excluding CI) include in changelog 🍎 MacOS Issues specifically about MacOS support labels Aug 7, 2025
@github-actions
Copy link

github-actions bot commented Aug 7, 2025

Latest documentation preview deployed successfully.

Result Commit Link
ae04291 https://landing-qv1io6xa2-rerun.vercel.app/docs

Note: This comment is updated whenever you push a commit.

@github-actions
Copy link

github-actions bot commented Aug 7, 2025

Web viewer built successfully. If applicable, you should also test it:

  • I have tested the web viewer
Result Commit Link Manifest
ae04291 https://rerun.io/viewer/pr/10828 +nightly +main

Note: This comment is updated whenever you push a commit.

@emilk
Copy link
Member

emilk commented Aug 7, 2025

Thanks for working on this! I'll give it a spin

@emilk emilk self-assigned this Aug 7, 2025
@emilk
Copy link
Member

emilk commented Aug 7, 2025

I tested this by first running brew uninstall llvm to remove my old workaround for the issue. On main that indeed leads to LLVM error: section too large.

Checking out this branch and running pixi run rerun-web instead leads to a new exciting error:

❯ pr rerun-web        
✨ Pixi task (rerun-build-web in default): rustup target add wasm32-unknown-unknown && cargo run --quiet -p re_dev_tools -- build-web-viewer --no-default-features --features analytics,map_view --debug
info: component 'rust-std' for target 'wasm32-unknown-unknown' is up to date
Building web viewer…

Compiling Rust to wasm in /Users/emilk/code/rerun/rerun/target_wasm…
/Users/emilk/code/rerun/rerun> env -u CARGO_ENCODED_RUSTFLAGS -u RUSTFLAGS "cargo" "build" "--quiet" "--package=re_viewer" "--lib" "--target=wasm32-unknown-unknown" "--target-dir=/Users/emilk/code/rerun/rerun/target_wasm" "--no-default-features" "--features=analytics,map_view" "--config=.cargo/config.toml"
error: failed to run custom build command for `psm v0.1.26`

Caused by:
  process didn't exit successfully: `/Users/emilk/code/rerun/rerun/target_wasm/debug/build/psm-6f11cdb04821ff68/build-script-build` (exit status: 1)
  --- stdout
  cargo:rustc-check-cfg=cfg(switchable_stack,asm,link_asm)
  OPT_LEVEL = Some(2)
  OUT_DIR = Some(/Users/emilk/code/rerun/rerun/target_wasm/wasm32-unknown-unknown/debug/build/psm-a753c07d8387c98b/out)
  TARGET = Some(wasm32-unknown-unknown)
  HOST = Some(aarch64-apple-darwin)
  cargo:rerun-if-env-changed=CC_wasm32-unknown-unknown
  CC_wasm32-unknown-unknown = None
  cargo:rerun-if-env-changed=CC_wasm32_unknown_unknown
  CC_wasm32_unknown_unknown = None
  cargo:rerun-if-env-changed=TARGET_CC
  TARGET_CC = None
  cargo:rerun-if-env-changed=CC
  CC = None
  cargo:rerun-if-env-changed=CC_ENABLE_DEBUG_OUTPUT
  RUSTC_WRAPPER = None
  cargo:rerun-if-env-changed=CRATE_CC_NO_DEFAULTS
  CRATE_CC_NO_DEFAULTS = None
  DEBUG = Some(false)
  cargo:rerun-if-env-changed=CFLAGS
  CFLAGS = None
  cargo:rerun-if-env-changed=TARGET_CFLAGS
  TARGET_CFLAGS = None
  cargo:rerun-if-env-changed=CFLAGS_wasm32_unknown_unknown
  CFLAGS_wasm32_unknown_unknown = None
  cargo:rerun-if-env-changed=CFLAGS_wasm32-unknown-unknown
  CFLAGS_wasm32-unknown-unknown = None
  CARGO_ENCODED_RUSTFLAGS = Some(--cfg=web_sys_unstable_apis--cfg=getrandom_backend="wasm_js"--cfg=web_sys_unstable_apis--cfg=getrandom_backend="wasm_js")
  cargo:rustc-cfg=asm
  cargo:rustc-cfg=link_asm
  cargo:rustc-cfg=switchable_stack
  cargo:rerun-if-env-changed=AR_wasm32-unknown-unknown
  AR_wasm32-unknown-unknown = None
  cargo:rerun-if-env-changed=AR_wasm32_unknown_unknown
  AR_wasm32_unknown_unknown = None
  cargo:rerun-if-env-changed=TARGET_AR
  TARGET_AR = None
  cargo:rerun-if-env-changed=AR
  AR = Some(/.pixi/envs/cpp/bin/llvm-ar)
  cargo:rerun-if-env-changed=CC_KNOWN_WRAPPER_CUSTOM
  CC_KNOWN_WRAPPER_CUSTOM = None
  cargo:rerun-if-env-changed=ARFLAGS
  ARFLAGS = None
  cargo:rerun-if-env-changed=TARGET_ARFLAGS
  TARGET_ARFLAGS = None
  cargo:rerun-if-env-changed=ARFLAGS_wasm32_unknown_unknown
  ARFLAGS_wasm32_unknown_unknown = None
  cargo:rerun-if-env-changed=ARFLAGS_wasm32-unknown-unknown
  ARFLAGS_wasm32-unknown-unknown = None

  --- stderr


  error occurred in cc-rs: failed to find tool "/.pixi/envs/cpp/bin/llvm-ar": No such file or directory (os error 2)


Error: Failed to build Wasm

I do have .pixi/envs/cpp/bin/llvm-ar, but the above error has an extra slash 🤔

❯ pixi --version
pixi 0.46.0

Looks like ${PIXI_HOME} is "" on my machine O.o

Just removing ${PIXI_HOME}/ doesn't work either:

[target.osx-arm64.activation.env]
AR = ".pixi/envs/cpp/bin/llvm-ar"

->

error occurred in cc-rs: failed to find tool ".pixi/envs/cpp/bin/llvm-ar": No such file or directory (os error 2)

@emilk
Copy link
Member

emilk commented Aug 7, 2025

@ntjohnson1
Copy link
Member Author

UGH I thought I tested it when I changed from PWD to PIXI_HOME but I didn't (shame)

PWD doesn't work because pixi knows where home is so we don't need to run commands from project root.

pixi shell-hook shows all the magic variable pixi manages https://pixi.sh/dev/workspace/environment/
So PIXI_PROJECT_ROOT is the right fully defined home path. Will push in a sec.

@emilk
Copy link
Member

emilk commented Aug 7, 2025

That got us to a new place!

Compiling Rust to wasm in /Users/emilk/code/rerun/rerun/target_wasm…
/Users/emilk/code/rerun/rerun> env -u CARGO_ENCODED_RUSTFLAGS -u RUSTFLAGS "cargo" "build" "--quiet" "--package=re_viewer" "--lib" "--target=wasm32-unknown-unknown" "--target-dir=/Users/emilk/code/rerun/rerun/target_wasm" "--no-default-features" "--features=analytics,map_view" "--config=.cargo/config.toml"
rustc-LLVM ERROR: malformed uleb128, extends past end
error: could not compile `ring` (lib)

Caused by:
  process didn't exit successfully: `/Users/emilk/.rustup/toolchains/1.85.0-aarch64-apple-darwin/bin/rustc --crate-name ring --edition=2021 /Users/emilk/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/ring-0.17.14/src/lib.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --diagnostic-width=173 --crate-type lib --emit=dep-info,metadata,link -C opt-level=2 -C embed-bitcode=no -C debug-assertions=on --cfg 'feature="alloc"' --cfg 'feature="default"' --cfg 'feature="dev_urandom_fallback"' --cfg 'feature="std"' --cfg 'feature="wasm32_unknown_unknown_js"' --check-cfg 'cfg(docsrs,test)' --check-cfg 'cfg(feature, values("alloc", "default", "dev_urandom_fallback", "less-safe-getrandom-custom-or-rdrand", "less-safe-getrandom-espidf", "slow_tests", "std", "test_logging", "unstable-testing-arm-no-hw", "unstable-testing-arm-no-neon", "wasm32_unknown_unknown_js"))' -C metadata=2ed7839866b4c257 -C extra-filename=-1ab34e33765a28b1 --out-dir /Users/emilk/code/rerun/rerun/target_wasm/wasm32-unknown-unknown/debug/deps --target wasm32-unknown-unknown -C strip=debuginfo -L dependency=/Users/emilk/code/rerun/rerun/target_wasm/wasm32-unknown-unknown/debug/deps -L dependency=/Users/emilk/code/rerun/rerun/target_wasm/debug/deps --extern cfg_if=/Users/emilk/code/rerun/rerun/target_wasm/wasm32-unknown-unknown/debug/deps/libcfg_if-d842852db5826de0.rmeta --extern getrandom=/Users/emilk/code/rerun/rerun/target_wasm/wasm32-unknown-unknown/debug/deps/libgetrandom-a8d9ea6ac5b6fec0.rmeta --extern untrusted=/Users/emilk/code/rerun/rerun/target_wasm/wasm32-unknown-unknown/debug/deps/libuntrusted-cfe878d4eca71261.rmeta --cap-lints allow --cfg=web_sys_unstable_apis '--cfg=getrandom_backend="wasm_js"' --cfg=web_sys_unstable_apis '--cfg=getrandom_backend="wasm_js"' -L native=/Users/emilk/code/rerun/rerun/target_wasm/wasm32-unknown-unknown/debug/build/ring-38da87773bd67974/out -l static=ring_core_0_17_14_ -l static=ring_core_0_17_14__test` (exit status: 101)
Error: Failed to build Wasm

@ntjohnson1
Copy link
Member Author

ntjohnson1 commented Aug 7, 2025

That got us to a new place!

Umm
versions

$ cargo --version
cargo 1.87.0 (99624be96 2025-05-06)
$ rustup --version
rustup 1.28.2 (e4f3ad6f8 2025-04-28)
$ rustc --version
rustc 1.87.0 (17067e9ac 2025-05-09)
$ clang --version
clang --version
Apple clang version 17.0.0 (clang-1700.0.13.5)
Target: arm64-apple-darwin24.5.0
Thread model: posix

commands

$ rm -rf target_wasm/
$ rm -rf target/ # for fun
$ pixi run rerun-build-web
...snip
Finished /Users/nick/repos/rerun/web_viewer/re_viewer_bg.wasm

@emilk
Copy link
Member

emilk commented Aug 7, 2025

rm -rf target_wasm/ was the answer! It works!

Copy link
Member

@emilk emilk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Woohoo!

@emilk emilk changed the title Fix Mac Web Viewer Build With Workaround Fix building Web Viewer on macOS Aug 7, 2025
@emilk emilk merged commit 08b8464 into main Aug 7, 2025
48 checks passed
@emilk emilk deleted the nick/mac_wasm_build branch August 7, 2025 15:35
@ntjohnson1
Copy link
Member Author

Woohoo!

should we setup a test for the web build on mac just for this weird edge case?

@emilk
Copy link
Member

emilk commented Aug 8, 2025

should we setup a test for the web build on mac just for this weird edge case?

We already do, but not on every PR, unless we explicitly opt-in to the full test suite with @rerun-bot full-check

grtlr pushed a commit that referenced this pull request Aug 12, 2025
### Related
Closes #9849

### What
Basically mac has a fun combination where you can have `clang`/`llvm`
components but not `llvm-ar`. Mac's `ar` pads bytes in way that make
llvm barf. Our pixi env for c++ has the `cxx-compiler` package which has
a more full fledged llvm install. On mac on activation set `AR` to point
to `llvm-ar`. It works on my machine! I'm not sure if we should have a
second person try or if we should setup a test for the web build on mac
just for this weird edge case.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🍎 MacOS Issues specifically about MacOS support 🧑‍💻 dev experience developer experience (excluding CI) include in changelog

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Web build fails on macOS ("LLVM error: section too large")

3 participants