clang-2.9 crt1 не найдена ошибка - PullRequest
2 голосов
/ 12 апреля 2011

Только что скомпилированный релиз clang-2.9, и он не может связать пример Hello World. Есть ошибка:

crt1.o: No such file: No such file or directory

LLVM настроен по умолчанию + --enable-shared. Сборка llvm-2.8 с такими же параметрами работает нормально на той же машине.

$ clang -v a.c
clang version 2.9 (tags/RELEASE_29/final)
Target: i386-pc-linux-gnu
Thread model: posix
 "/root/bin/clang" -cc1 -triple i386-pc-linux-gnu -emit-obj -mrelax-all -disable-free -disable-llvm-verifier -main-file-name a.c -mrelocation-model static -mdisable-fp-elim -masm-verbose -mconstructor-aliases -target-cpu pentium4 -target-linker-version 2.18 -momit-leaf-frame-pointer -v -resource-dir /root/lib/clang/2.9 -ferror-limit 19 -fmessage-length 157 -fgnu-runtime -fdiagnostics-show-option -fcolor-diagnostics -o /tmp/cc-2ueoYy.o -x c a.c
clang -cc1 version 2.9 based upon llvm 2.9 hosted on i386-pc-linux-gnu
ignoring nonexistent directory "/usr/local/include"
#include "..." search starts here:
#include <...> search starts here:
 /root/lib/clang/2.9/include
 /usr/include
End of search list.
a.c:1:1: warning: type specifier missing, defaults to 'int' [-Wimplicit-int]
main(){}
^~~~
1 warning generated.
 "/usr/bin/ld" --eh-frame-hdr -m elf_i386 -dynamic-linker /lib/ld-linux.so.2 -o a.out crt1.o crti.o crtbegin.o -L -L/../../.. /tmp/cc-2ueoYy.o -lgcc --as-needed -lgcc_s --no-as-needed -lc -lgcc --as-needed -lgcc_s --no-as-needed crtend.o crtn.o
/usr/bin/ld: crt1.o: No such file: No such file or directory
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Та же ошибка была здесь http://permalink.gmane.org/gmane.comp.compilers.clang.devel/12101 и http://comments.gmane.org/gmane.comp.compilers.clang.devel/14269 и http://permalink.gmane.org/gmane.comp.compilers.llvm.bugs/11352

Что я могу узнать при сравнении с llvm-2.8 - более новая версия пытается собрать сам файл, а более старая версия вызывает gcc для выполнения шагов сборки и связывания.

Пожалуйста, это не дубликат проблемы clang linker , поскольку я не могу редактировать источники LLVM, поэтому принятое решение мне не полезно.

1 Ответ

1 голос
/ 12 апреля 2011

Как указано в http://permalink.gmane.org/gmane.comp.compilers.llvm.bugs/11352 (ошибка llvm 8897), это потому, что

gcc used to build clang is not in a standard location

или

system gcc is not listed in the ToolChains.cpp GccVersions list:

./tools/clang/lib/Driver/ToolChains.cpp:  const char* GccVersions[] = {"4.5.2", "4.5.1", "4.5", "4.4.5", "4.4.4",
./tools/clang/lib/Driver/ToolChains.cpp-                               "4.4.3", "4.4", "4.3.4", "4.3.3", "4.3.2",
./tools/clang/lib/Driver/ToolChains.cpp-                               "4.3", "4.2.4", "4.2.3", "4.2.2", "4.2.1",
./tools/clang/lib/Driver/ToolChains.cpp-                               "4.2"};

Оба случая верны для моей установки.

Чтобы это исправить, я попытаюсь добавить свою версию gcc в список GccVersions[].

Это мне помогает.

...