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

Bug: doesn't compile on Apple M1? #41

Open
2 tasks done
pedropuchalski opened this issue Oct 10, 2023 · 8 comments
Open
2 tasks done

Bug: doesn't compile on Apple M1? #41

pedropuchalski opened this issue Oct 10, 2023 · 8 comments
Labels
bug Something isn't working

Comments

@pedropuchalski
Copy link

Describe the bug

After running compilation on rust level, that can be ivoced also by npm run build command after downloading sources from git, I get:
`...
Compiling cipher v0.4.4
error: failed to build archive: 'wasm32.o': section too large

The following warnings were emitted during compilation:

warning: warning: /Library/Developer/CommandLineTools/usr/bin/ranlib: archive library: /Users/(...)/surrealdb.wasm/target/wasm32-unknown-unknown/release/build/psm-e7fd6e39c2c90a79/out/libpsm_s.a the table of contents is empty (no object file members in the library define global symbols)

error: could not compile psm (lib) due to previous error
warning: build failed, waiting for other jobs to finish...
Error: Compiling your crate to WebAssembly failed
Caused by: Compiling your crate to WebAssembly failed
Caused by: failed to execute cargo build: exited with exit status: 101
full command: cd "/Users/pedropuchalski/Documents/praca/FirmaNext/sceneMgm/surrealdb.wasm" && "cargo" "build" "--lib" "--release" "--target" "wasm32-unknown-unknown" "--no-default-features" "--features" "protocol-ws,protocol-http,kv-indxdb,kv-mem,rustls"`

Steps to reproduce

Try to compile on Apple MacBook Air with M1, Ventura.

Expected behaviour

Compiled *.wasm file.

SurrealDB version

"1.0.0", default-features = false

Contact Details

[email protected]

Is there an existing issue for this?

  • I have searched the existing issues

Code of Conduct

  • I agree to follow this project's Code of Conduct
@pedropuchalski pedropuchalski added the bug Something isn't working label Oct 10, 2023
@bambooyuh
Copy link

I have a near identical issue with M1 chip on Sonoma

@Luxbit
Copy link

Luxbit commented Oct 19, 2023

You need to manually set AR and CC.
If you installed LLVM via homebrew, add this to your env:

echo 'export AR=/opt/homebrew/opt/llvm/bin/llvm-ar' >> ~/.zshrc
echo 'export CC=/opt/homebrew/opt/llvm/bin/clang' >> ~/.zshrc

Also make sure to run cargo clean before rebuilding

@bambooyuh
Copy link

Thank you. This worked.

@bambooyuh
Copy link

Except now I'm getting this error, which seems to be related...

error: failed to run custom build command for ring v0.16.20

--- stdout
OPT_LEVEL = Some("0")
TARGET = Some("aarch64-apple-darwin")
HOST = Some("aarch64-apple-darwin")
cargo:rerun-if-env-changed=CC_aarch64-apple-darwin
CC_aarch64-apple-darwin = None
cargo:rerun-if-env-changed=CC_aarch64_apple_darwin
CC_aarch64_apple_darwin = None
cargo:rerun-if-env-changed=HOST_CC
HOST_CC = None
cargo:rerun-if-env-changed=CC
CC = Some("/opt/homebrew/opt/llvm/bin/clang")
cargo:rerun-if-env-changed=CRATE_CC_NO_DEFAULTS
CRATE_CC_NO_DEFAULTS = None
DEBUG = Some("true")
cargo:rerun-if-env-changed=CFLAGS_aarch64-apple-darwin
CFLAGS_aarch64-apple-darwin = None
cargo:rerun-if-env-changed=CFLAGS_aarch64_apple_darwin
CFLAGS_aarch64_apple_darwin = None
cargo:rerun-if-env-changed=HOST_CFLAGS
HOST_CFLAGS = None
cargo:rerun-if-env-changed=CFLAGS
CFLAGS = None

--- stderr
running "/opt/homebrew/opt/llvm/bin/clang" "-O0" "-ffunction-sections" "-fdata-sections" "-fPIC" "-gdwarf-2" "-fno-omit-frame-pointer" "--target=arm64-apple-darwin" "-I" "include" "-Wall" "-Wextra" "-std=c1x" "-Wbad-function-cast" "-Wnested-externs" "-Wstrict-prototypes" "-pedantic" "-pedantic-errors" "-Wall" "-Wextra" "-Wcast-align" "-Wcast-qual" "-Wconversion" "-Wenum-compare" "-Wfloat-equal" "-Wformat=2" "-Winline" "-Winvalid-pch" "-Wmissing-field-initializers" "-Wmissing-include-dirs" "-Wredundant-decls" "-Wshadow" "-Wsign-compare" "-Wsign-conversion" "-Wundef" "-Wuninitialized" "-Wwrite-strings" "-fno-strict-aliasing" "-fvisibility=hidden" "-fstack-protector" "-gfull" "-DNDEBUG" "-c"
In file included from crypto/fipsmodule/aes/aes_nohw.c:17:
In file included from crypto/fipsmodule/aes/../../internal.h:114:
include/GFp/check.h:27:11: fatal error: 'assert.h' file not found
27 | # include <assert.h>
| ^~~~~~~~~~
1 error generated.

@bambooyuh
Copy link

@Luxbit

After the ring update I'm still getting a similar error as posted above.

Using a Mac m1 chip.

warning: [email protected]: error: unable to create target: 'No available targets are compatible with triple "wasm32-unknown-unknown"'
warning: [email protected]: 1 error generated.

error: failed to run custom build command for ring v0.17.5

@Luxbit
Copy link

Luxbit commented Nov 10, 2023

@roachj9 Sorry, but I can't reproduce this issue. Everything compiles fine for me using rustc 1.71.0 (8ede3aae2 2023-07-12) on M1 running macOS 13.6.1 (22G313)

@Korolen
Copy link

Korolen commented Dec 17, 2023

Documenting my experience. On M1 Pro, MacOS 12.5.1

Initially I had the same error as @roachj9.

Now, after setting the flags and cleaning, I'm stuck on:

cargo build --target wasm32-unknown-unknown --release
   Compiling proc-macro2 v1.0.70
.......
   Compiling unicode-normalization v0.1.22
error: failed to run custom build command for `psm v0.1.21`

Caused by:
  process didn't exit successfully: `/Users/tom/c/rs-bench-compile-times-surreal-dioxus/target/release/build/psm-620eb07fafc6a24c/build-script-build` (exit status: 1)
  --- stdout
  OPT_LEVEL = Some("3")
  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 = Some("/opt/homebrew/opt/llvm/bin/clang")
  cargo:rerun-if-env-changed=CRATE_CC_NO_DEFAULTS
  CRATE_CC_NO_DEFAULTS = None
  DEBUG = Some("false")
  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:rerun-if-env-changed=TARGET_CFLAGS
  TARGET_CFLAGS = None
  cargo:rerun-if-env-changed=CFLAGS
  CFLAGS = None
  cargo:rustc-cfg=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("/opt/homebrew/opt/llvm/bin/llvm-ar")
  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
  cargo:rerun-if-env-changed=TARGET_ARFLAGS
  TARGET_ARFLAGS = None
  cargo:rerun-if-env-changed=ARFLAGS
  ARFLAGS = None
  running: ZERO_AR_DATE="1" "/opt/homebrew/opt/llvm/bin/llvm-ar" "cq" "/Users/tom/c/rs-bench-compile-times-surreal-dioxus/target/wasm32-unknown-unknown/release/build/psm-78afdcbbd9743968/out/libpsm_s.a" "src/arch/wasm32.o"

  --- stderr


  error occurred: Failed to find tool. Is `` installed?


warning: build failed, waiting for other jobs to finish...

This is with a repo that has nothing but cargo init and adding this git repo by URL with, in Cargo.toml:

[dependencies]
surrealdb = { git = "https://github.com/surrealdb/surrealdb.wasm", branch = "main"<<this didn't help either: , default-features = false>> }

Maybe it's unrelated to being on M1, though I do notice it's the same psm crate that's generating the error, still.

@DrewRidley
Copy link

Hi all,

The issue can still be reproduced on an M3 Pro.

echo 'export AR=/opt/homebrew/opt/llvm/bin/llvm-ar' >> ~/.zshrc
echo 'export CC=/opt/homebrew/opt/llvm/bin/clang' >> ~/.zshrc

With homebrew installed LLVM seems to have fixed the issue. There is a weird side-effect where it no longer caches SurrealDB, and has to rebuild it on every incremental change.

Any solutions to this would be much appreciated!

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
None yet
Development

No branches or pull requests

5 participants