Clang LLVM找不到二进制文件

Clang LLVM找不到二进制文件,clang,llvm,llvm-clang,Clang,Llvm,Llvm Clang,我刚刚用compiler-rt构建并安装了LLVM Clang 3.5.0。Clang binary似乎可以工作,但无法构建简单的测试程序: $ cat hello.c #include <stdio.h> int main(int argc, char **argv) { printf("Hello World\n"); return 0; } 可执行文件“”?有趣的 调试它进一步揭示了clang试图调用自己来构建.o对象文件,然后ld来链接它,但显然不知道它自

我刚刚用compiler-rt构建并安装了LLVM Clang 3.5.0。Clang binary似乎可以工作,但无法构建简单的测试程序:

$ cat hello.c 
#include <stdio.h>
int main(int argc, char **argv) {
    printf("Hello World\n");
    return 0;
}
可执行文件“”?有趣的

调试它进一步揭示了clang试图调用自己来构建
.o
对象文件,然后ld来链接它,但显然不知道它自己存在于何处

$ clang -### hello.c -o hello
clang version 3.5.0 (tags/RELEASE_350/final)
Target: x86_64-alpine-linux-musl
Thread model: posix
 "" "-cc1" "-triple" "x86_64-alpine-linux-musl" "-emit-obj" "-mrelax-all" "-disable-free" "-main-file-name" "hello.c" "-mrelocation-model" "static" "-mdisable-fp-elim" "-fmath-errno" "-masm-verbose" "-mconstructor-aliases" "-munwind-tables" "-fuse-init-array" "-target-cpu" "x86-64" "-target-linker-version" "2.24" "-dwarf-column-info" "-resource-dir" "../lib/clang/3.5.0" "-internal-isystem" "/usr/local/include" "-internal-isystem" "../lib/clang/3.5.0/include" "-internal-externc-isystem" "/include" "-internal-externc-isystem" "/usr/include" "-fdebug-compilation-dir" "/" "-ferror-limit" "19" "-fmessage-length" "158" "-mstackrealign" "-fobjc-runtime=gcc" "-fdiagnostics-show-option" "-o" "/tmp/hello-37746e.o" "-x" "c" "hello.c"
 "/usr/bin/ld" "-z" "relro" "--eh-frame-hdr" "-m" "elf_x86_64" "-dynamic-linker" "/lib/ld-musl-x86_64.so.1" "-o" "hello" "/usr/bin/../lib/gcc/x86_64-alpine-linux-musl/4.8.3/../../../crt1.o" "/usr/bin/../lib/gcc/x86_64-alpine-linux-musl/4.8.3/../../../crti.o" "/usr/bin/../lib/gcc/x86_64-alpine-linux-musl/4.8.3/crtbegin.o" "-L/usr/bin/../lib/gcc/x86_64-alpine-linux-musl/4.8.3" "-L/usr/bin/../lib/gcc/x86_64-alpine-linux-musl/4.8.3/../../../../x86_64-alpine-linux-musl/lib" "-L/usr/bin/../lib/gcc/x86_64-alpine-linux-musl/4.8.3/../../.." "-L/../lib" "-L/lib" "-L/usr/lib" "/tmp/hello-37746e.o" "-lgcc" "--as-needed" "-lgcc_s" "--no-as-needed" "-lc" "-lgcc" "--as-needed" "-lgcc_s" "--no-as-needed" "/usr/bin/../lib/gcc/x86_64-alpine-linux-musl/4.8.3/crtend.o" "/usr/bin/../lib/gcc/x86_64-alpine-linux-musl/4.8.3/../../../crtn.o"
当我运行第一行并将
/usr/bin/clang
作为第一项时,它构建得很好:

$ /usr/bin/clang "-cc1" "-triple" "x86_64-alpine-linux-musl" "-emit-obj" "-mrelax-all" "-disable-free" "-main-file-name" "hello.c" "-mrelocation-model" "static" "-mdisable-fp-elim" "-fmath-errno" "-masm-verbose" "-mconstructor-aliases" "-munwind-tables" "-target-cpu" "x86-64" "-target-linker-version" "2.24" "-dwarf-column-info" "-resource-dir" "../lib/clang/3.5.0" "-internal-isystem" "/usr/local/include" "-internal-isystem" "../lib/clang/3.5.0/include" "-internal-externc-isystem" "/include" "-internal-externc-isystem" "/usr/include" "-fdebug-compilation-dir" "/" "-ferror-limit" "19" "-fmessage-length" "158" "-mstackrealign" "-fobjc-runtime=gcc" "-fdiagnostics-show-option" "-o" "/tmp/hello-4f64bb.o" "-x" "c" "hello.c"
$ 
下面的
/usr/bin/ld
能够很好地链接它,从而导致:

$ ./hello
Hello World

Anny suggestions我在配置/构建过程中犯了什么错误?

clang源代码分析显示Linux上的“clang”程序使用
/proc/self/exe
查找其二进制文件的实际路径。我在chroot中运行时没有安装/proc,因此它失败了

mount -t proc proc /proc

解决了这个问题

那么您是如何获得这个clang版本的呢?你使用的是什么操作系统?
哪个叮当声产生了什么?我自己建造的。我使用的是Alpine Linux 3.1<代码>哪一个铃声
报告
/usr/bin/clang
mount -t proc proc /proc