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

Unable to build for wasm32-unknown-unknown on macOS with Apple Clang #1824

Closed
dignifiedquire opened this issue Nov 25, 2023 · 2 comments
Closed

Comments

@dignifiedquire
Copy link

I am trying to build ring for wasm32-unknown-unknown, and it works fine on my linux based machines (x68_64) but when trying to build on my mac (aarch64) it fails with the following error

ring on main is 📦 v0.17.5 via 🦀 v1.74.0
❯ cargo build --target wasm32-unknown-unknown --features wasm32_unknown_unknown_js
   Compiling proc-macro2 v1.0.69
   Compiling unicode-ident v1.0.12
   Compiling wasm-bindgen-shared v0.2.88
   Compiling log v0.4.20
   Compiling bumpalo v3.14.0
   Compiling once_cell v1.18.0
   Compiling wasm-bindgen v0.2.88
   Compiling libc v0.2.150
   Compiling cc v1.0.83
   Compiling ring v0.17.5 (/Users/dignifiedquire/opensource/ring)
   Compiling quote v1.0.33
   Compiling syn v2.0.39
The following warnings were emitted during compilation:

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

error: failed to run custom build command for `ring v0.17.5 (/Users/dignifiedquire/opensource/ring)`

Caused by:
  process didn't exit successfully: `/Users/dignifiedquire/opensource/ring/target/debug/build/ring-4263c6975b978b5a/build-script-build` (exit status: 1)
  --- stdout
  cargo:rerun-if-env-changed=RING_PREGENERATE_ASM
  cargo:rustc-env=RING_CORE_PREFIX=ring_core_0_17_5_
  OPT_LEVEL = Some("0")
  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("clang")
  cargo:rerun-if-env-changed=CRATE_CC_NO_DEFAULTS
  CRATE_CC_NO_DEFAULTS = None
  DEBUG = Some("true")
  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
  running: "clang" "-O0" "-ffunction-sections" "-fdata-sections" "-fPIC" "-g" "-fno-omit-frame-pointer" "--target=wasm32-unknown-unknown" "-I" "include" "-I" "/Users/dignifiedquire/opensource/ring/target/wasm32-unknown-unknown/debug/build/ring-f6842382147d2afa/out" "-Wall" "-Wextra" "-fvisibility=hidden" "-std=c1x" "-pedantic" "-Wall" "-Wextra" "-Wbad-function-cast" "-Wcast-align" "-Wcast-qual" "-Wconversion" "-Wenum-compare" "-Wfloat-equal" "-Wformat=2" "-Winline" "-Winvalid-pch" "-Wmissing-field-initializers" "-Wmissing-include-dirs" "-Wnested-externs" "-Wredundant-decls" "-Wshadow" "-Wsign-compare" "-Wsign-conversion" "-Wstrict-prototypes" "-Wundef" "-Wuninitialized" "-Wwrite-strings" "-g3" "-nostdlibinc" "-DRING_CORE_NOSTDLIBINC=1" "-Werror" "-o" "/Users/dignifiedquire/opensource/ring/target/wasm32-unknown-unknown/debug/build/ring-f6842382147d2afa/out/crypto/curve25519/curve25519.o" "-c" "crypto/curve25519/curve25519.c"
  cargo:warning=error: unable to create target: 'No available targets are compatible with triple "wasm32-unknown-unknown"'

  cargo:warning=1 error generated.

  exit status: 1

  --- stderr


  error occurred: Command "clang" "-O0" "-ffunction-sections" "-fdata-sections" "-fPIC" "-g" "-fno-omit-frame-pointer" "--target=wasm32-unknown-unknown" "-I" "include" "-I" "/Users/dignifiedquire/opensource/ring/target/wasm32-unknown-unknown/debug/build/ring-f6842382147d2afa/out" "-Wall" "-Wextra" "-fvisibility=hidden" "-std=c1x" "-pedantic" "-Wall" "-Wextra" "-Wbad-function-cast" "-Wcast-align" "-Wcast-qual" "-Wconversion" "-Wenum-compare" "-Wfloat-equal" "-Wformat=2" "-Winline" "-Winvalid-pch" "-Wmissing-field-initializers" "-Wmissing-include-dirs" "-Wnested-externs" "-Wredundant-decls" "-Wshadow" "-Wsign-compare" "-Wsign-conversion" "-Wstrict-prototypes" "-Wundef" "-Wuninitialized" "-Wwrite-strings" "-g3" "-nostdlibinc" "-DRING_CORE_NOSTDLIBINC=1" "-Werror" "-o" "/Users/dignifiedquire/opensource/ring/target/wasm32-unknown-unknown/debug/build/ring-f6842382147d2afa/out/crypto/curve25519/curve25519.o" "-c" "crypto/curve25519/curve25519.c" with args "clang" did not execute successfully (status code exit status: 1).


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

I tried to find sth in the issues, but was unable to find any hints of what I am doing wrong/not setting. Appreciate any help!

@briansmith briansmith changed the title Unable to build for wasm32-unknown-unkwon on macos (aarch64) Unable to build for wasm32-unknown-unkwon on macos (aarch64) with Apple Clang Nov 26, 2023
@briansmith
Copy link
Owner

Apple Clang is a fork of Clang that is specialized to Apple's wishes. It doesn't support wasm32-unknown-unknown, at least when I tried. You need to download and use llvm.org Clang instead.

@briansmith briansmith changed the title Unable to build for wasm32-unknown-unkwon on macos (aarch64) with Apple Clang Unable to build for wasm32-unknown-unknown on macos (aarch64) with Apple Clang Dec 4, 2023
@briansmith briansmith changed the title Unable to build for wasm32-unknown-unknown on macos (aarch64) with Apple Clang Unable to build for wasm32-unknown-unknown on macOS with Apple Clang Dec 4, 2023
@simbleau
Copy link

For anyone who has had this issue and is arriving here in the future, here's what you need to do:

Install Homebrew (if you haven't already):

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

Install LLVM Clang:

brew install llvm

Verify the installation:

llvm-config --version

Export the correct PATH:

echo 'export PATH="/opt/homebrew/opt/llvm/bin:$PATH"' >> ~/.zshrc

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

3 participants