Clang链接器问题(从源到gcc-snapshot) [英] Clang linker issues (from source, to gcc-snapshot)

查看:1327
本文介绍了Clang链接器问题(从源到gcc-snapshot)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我似乎无法使此工作。我配置了 - with-gcc-toolchain = 其中在equals之后我把gcc的目录( / usr / lib / gcc-快照/ bin )。



我还查看了 clang链接器问题<​​/a>但我不知道如何可以得到接受的答案找到正确的位置,并且符号链接答案将有效,除了所有的目录它正在搜索存在(将 lib 文件夹从gcc-snapshot复制到其中一个include位置似乎没有帮助)。



正如另一个问题所建议的, clang ++ test.cpp -v


bob @ bob:〜/ programming $ clang ++ test.cpp -v

clang版本3.3(trunk 171350)

目标:x86_64-unknown-linux-gnu

线程模型:posix

/ home / bob / programming / build / Release + Asserts / bin / clang-cc1 -triple x86_64-unknown-linux-gnu -emit- obj -mrelax-all -disable-free -main-file-name test.cpp -mrelocation-model static -mdisable-fp-elim -fmath-errno -masm-verbose -mconstructor-aliases -munwind-tables -target-cpu x86 -64 -target-linker-version 2.22 -momit-leaf-frame-pointer -v -resource-dir /home/bob/programming/build/Release+Asserts/bin/../lib/clang/3.3 -fmodule-cache -path / var / tmp / clang-module-cache -internal-isystem / usr / local / include -internal-isystem /home/bob/programming/build/Release+Asserts/bin/../lib/clang/3.3/ include -internal-externc-isystem / usr / include / x86_64-linux-gnu -internal-externc-isystem / include -internal-externc-isystem / usr / include -fdeprecated-macro -fdebug-compilation-dir / home / bob /编程-ferror-limit 19 -fmessage-length 80 -mstackrealign -fobjc-runtime = gcc -fcxx-exceptions -fexceptions -fdiagnostics-show-option -fcolor-diagnostics -backend-option -vectorize-loops -o / tmp / test- PWiB4M.o -x c ++ test.cpp

clang -cc1 3.3基于LLVM 3.3svn默认目标x86_64-unknown-linux-gnu

忽略不存在的目录/ include< br>
#include...搜索从这里开始:

#include< ...>搜索从这里开始:

/ usr / local / include < br>
/home/bob/programming/build/Release+Asserts/bin/../lib/clang/3.3/include

/ usr / include / x86_64-linux-gnu

/ usr / include

搜索结束列表。

test.cpp:1:10:致命错误:找不到'iostream'文件

#include
^

产生1个错误。


clang version 3.3(trunk revision 171350 )



编辑:<$ c $中没有 .o c> Release + Asserts 文件夹。这是正常吗?如果不是,为什么是这种情况,如何解决它(如果我可以指出它的俚语的stdlib,那么工作以及)。



编辑2:它也无法编译 int main(){return 0;} ,因为它找不到 crtbegin.o 。完整输出如下:


/ usr / bin / ld:找不到crtbegin.o:没有这样的文件或目录

/ usr / bin / ld:找不到-lgcc

/ usr / bin / ld:找不到-lgcc_s

clang:错误:linker命令失败,退出代码为1 (使用-v查看调用)


-v 后的结果

Config.log:

完整文件可在
此处找到,但第一个(非注释)行是: $ .. / llvm / configure --with-gcc-toolchain = / usr / lib / gcc-snapshot / gcc

解决方案>

我们发现的问题是gcc安装了--prefix = / usr / lib / gcc-snapshot configure参数。并且llvm配置了--with-gcc-toolchain = / usr / lib / gcc-snapshot / gcc参数。它应该与gcc安装前缀相同,即--with-gcc-toolchain = / usr / lib / gcc-snapshot。



问题的当前第一行说我配置了--with-gcc-toolchain =其中在equals之后我把gcc的目录(/ usr / lib / gcc-snapshot / bin)。,当前最后一行说注释)行是:$ ../llvm/configure --with-gcc-toolchain = / usr / lib / gcc-snapshot / gcc



这很奇怪,你可能以为你把标志--with-gcc-toolchain = / usr / lib / gcc-snapshot / bin,但你实际上把--with-gcc-toolchain = / usr / lib / gcc-snapshot / gcc



无论如何,我认为您应该尝试以下操作。


  1. 删除或重命名构建目录(运行configure命令的目录,即您发现config.log文件的目录)我假定它是/ home / bob / programming / build目录。

  2. 现在再次创建/ home / bob / programming / build目录。现在应该为空。

  3. cd / home / bob / programming / build

  4. 运行以下configure命令
    ../llvm / configure>


/ configure --with-gcc-toolchain = / usr / lib / gcc-snapshot >

问题似乎是您没有正确指定gcc-toolchain前缀。它应该与配置gcc时使用的--prefix参数相同。



在这里报告结果。



此外,请参阅 Clang 3.2 build gcc 4.7


I cannot seem to get this to work. I configured with the --with-gcc-toolchain= where after the equals I put the directory where gcc was (/usr/lib/gcc-snapshot/bin).

I also looked into the answers to " clang linker problem" but I do not see how I can get the accepted answer to find the correct location, and the symlink answer would have worked, except that all of the directories that it is searching exist (copying the lib folder from gcc-snapshot to one of the include locations does not seem to help).

As suggested in the other question, the output of clang++ test.cpp -v:

bob@bob:~/programming$ clang++ test.cpp -v
clang version 3.3 (trunk 171350)
Target: x86_64-unknown-linux-gnu
Thread model: posix
"/home/bob/programming/build/Release+Asserts/bin/clang" -cc1 -triple x86_64-unknown-linux-gnu -emit-obj -mrelax-all -disable-free -main-file-name test.cpp -mrelocation-model static -mdisable-fp-elim -fmath-errno -masm-verbose -mconstructor-aliases -munwind-tables -target-cpu x86-64 -target-linker-version 2.22 -momit-leaf-frame-pointer -v -resource-dir /home/bob/programming/build/Release+Asserts/bin/../lib/clang/3.3 -fmodule-cache-path /var/tmp/clang-module-cache -internal-isystem /usr/local/include -internal-isystem /home/bob/programming/build/Release+Asserts/bin/../lib/clang/3.3/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -fdeprecated-macro -fdebug-compilation-dir /home/bob/programming -ferror-limit 19 -fmessage-length 80 -mstackrealign -fobjc-runtime=gcc -fcxx-exceptions -fexceptions -fdiagnostics-show-option -fcolor-diagnostics -backend-option -vectorize-loops -o /tmp/test-PWiB4M.o -x c++ test.cpp
clang -cc1 version 3.3 based upon LLVM 3.3svn default target x86_64-unknown-linux-gnu
ignoring nonexistent directory "/include"
#include "..." search starts here:
#include <...> search starts here:
/usr/local/include
/home/bob/programming/build/Release+Asserts/bin/../lib/clang/3.3/include
/usr/include/x86_64-linux-gnu
/usr/include
End of search list.
test.cpp:1:10: fatal error: 'iostream' file not found
#include ^
1 error generated.

clang version 3.3 (trunk revision 171350)

EDIT: There are no .o files in the Release+Asserts folder for the build. Is this normal? If not, why is this the case, and how can I fix it (if I can point it as clang's stdlib, then that works as well).

Edit 2: It also fails to compile int main(){return 0;} as it can't find crtbegin.o. Full output is as follows:

/usr/bin/ld: cannot find crtbegin.o: No such file or directory
/usr/bin/ld: cannot find -lgcc
/usr/bin/ld: cannot find -lgcc_s
clang: error: linker command failed with exit code 1 (use -v to see invocation)

The results after -v are the same as the above, but with the ending error being different.

Config.log:
The full file can be found here, but the first (non-comment) line is: $ ../llvm/configure --with-gcc-toolchain=/usr/lib/gcc-snapshot/gcc

解决方案

The issue that we've identified is that gcc was installed with --prefix=/usr/lib/gcc-snapshot configure argument. and llvm was configured with --with-gcc-toolchain=/usr/lib/gcc-snapshot/gcc argument. It should be the same as the gcc installation prefix, i.e. --with-gcc-toolchain=/usr/lib/gcc-snapshot.

The question's current first line says " I configured with the --with-gcc-toolchain= where after the equals I put the directory where gcc was (/usr/lib/gcc-snapshot/bin).", and the current last line says "first (non-comment) line is: $ ../llvm/configure --with-gcc-toolchain=/usr/lib/gcc-snapshot/gcc"

That's puzzling, you might have thought that you had put the flag --with-gcc-toolchain=/usr/lib/gcc-snapshot/bin but you had actually put --with-gcc-toolchain=/usr/lib/gcc-snapshot/gcc

Regardless, I think you should try the following.

  1. remove or rename the build directory (the directory where you ran the configure command, i.e. the directory where you found the config.log file) I assume it's the /home/bob/programming/build directory.
  2. now create /home/bob/programming/build directory again. it should be empty now.
  3. cd /home/bob/programming/build
  4. run the following configure command ../llvm/configure --with-gcc-toolchain=/usr/lib/gcc-snapshot
  5. follow through with the rest of your build process.

The issue seems to be that you didn't specify the gcc-toolchain prefix correctly. It should be the same as the --prefix parameter you used while configuring the gcc.

Report back the results here.

Also see Clang 3.2 build broken after building gcc 4.7

这篇关于Clang链接器问题(从源到gcc-snapshot)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆