emscripten-core / emscripten

Emscripten: An LLVM-to-WebAssembly Compiler
Other
25.76k stars 3.3k forks source link

macOS: emcc fails to find llc, keeps looking at /usr/bin/llc #8862

Closed Aurora12 closed 5 years ago

Aurora12 commented 5 years ago

Hi! I'm stuck with not being able to execute emcc --version.

The error message says shared:ERROR: llc exectuable not found at /usr/bin/llc. (Btw, note the typo in 'exectuable'.)

I've just installed emscripten and everything from brew to make me some WASM from C code.

macOS Mojave 10.14.5

llc is at /usr/local/opt/llvm/bin/llc and symlinked from /usr/local/bin/llc. /usr/local/opt/llvm/bin is allso in the PATH and comes first.

clang --version
clang version 8.0.0 (tags/RELEASE_800/final)
Target: x86_64-apple-darwin18.6.0
Thread model: posix
InstalledDir: /usr/local/opt/llvm/bin
llc -version
LLVM (http://llvm.org/):
  LLVM version 8.0.0
  Optimized build.
  Default target: x86_64-apple-darwin18.6.0
  Host CPU: haswell

  Registered Targets:
    aarch64    - AArch64 (little endian)
    aarch64_be - AArch64 (big endian)
    amdgcn     - AMD GCN GPUs
    arm        - ARM
    arm64      - ARM64 (little endian)
    armeb      - ARM (big endian)
    bpf        - BPF (host endian)
    bpfeb      - BPF (big endian)
    bpfel      - BPF (little endian)
    hexagon    - Hexagon
    lanai      - Lanai
    mips       - MIPS (32-bit big endian)
    mips64     - MIPS (64-bit big endian)
    mips64el   - MIPS (64-bit little endian)
    mipsel     - MIPS (32-bit little endian)
    msp430     - MSP430 [experimental]
    nvptx      - NVIDIA PTX 32-bit
    nvptx64    - NVIDIA PTX 64-bit
    ppc32      - PowerPC 32
    ppc64      - PowerPC 64
    ppc64le    - PowerPC 64 LE
    r600       - AMD GPUs HD2XXX-HD6XXX
    sparc      - Sparc
    sparcel    - Sparc LE
    sparcv9    - Sparc V9
    systemz    - SystemZ
    thumb      - Thumb
    thumbeb    - Thumb (big endian)
    wasm32     - WebAssembly 32-bit
    wasm64     - WebAssembly 64-bit
    x86        - 32-bit X86: Pentium-Pro and above
    x86-64     - 64-bit X86: EM64T and AMD64
    xcore      - XCore
emcc --version
shared:ERROR: llc exectuable not found at `/usr/bin/llc`

I can't symlink from there because this location is not allowed (even for root) since El Capitan, as far as I know. I did extensive googling and couldn't find a solution so far. The only similar thing I've found is a recent bugreport for Linux.

sbc100 commented 5 years ago

Check you LLVM_ROOT settings in your .emscripten file. It looks like it it might be pointed at "/usr/bin".. but it should be pointed at build of either fastcomp or upstream llvm tip of tree build.

How did you install emscripten?

Aurora12 commented 5 years ago

Oh thanks, I should've figured it out. 🤦‍♂️I've installed everything from brew and didn't do anything else. I didn't have LLVM in env, and /usr/bin/llc is the default value (which would always fail on macOS, I presume).

Exporting LLVM (and BINARYEN for good measure) in .bash_profile solved the issue.

export LLVM="/usr/local/opt/llvm/bin"
export BINARYEN="/usr/local/opt/binaryen/bin"
sbc100 commented 5 years ago

Sounds like an issue with the brew packaging.

MaBecker commented 4 years ago

macOS Cataline Version 10.15.3

brew install emscripten installed version 1.39.9

export LLVM="/usr/local/Cellar/emscripten/1.39.9/libexec/llvm/bin"

emcc -v emcc (Emscripten gcc/clang-like replacement + linker emulating GNU ld) 1.39.9 clang version 6.0.1 (emscripten 1.39.9 : 1.39.9) Target: x86_64-apple-darwin19.3.0 Thread model: posix InstalledDir: /usr/local/Cellar/emscripten/1.39.9/libexec/llvm/bin shared:INFO: (Emscripten: Running sanity checks)

Not sure if this is the correct way to do it, but it works for me ;-)

MattWilliamsDev commented 4 years ago

I just ran into this issue initially after brew install but then I rechecked the console output from the install process and it has the following message at the very end of the process:

==> emscripten
Manually set LLVM_ROOT to
  /usr/local/opt/emscripten/libexec/llvm/bin
and BINARYEN_ROOT to
  /usr/local/opt/binaryen
in ~/.emscripten after running `emcc` for the first time.

After I set the values to the suggested values in my .emscripten file, it worked out just fine.