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

llvm-link issues when combining BC files. #141

Open
DStaelens opened this issue Oct 12, 2016 · 3 comments
Open

llvm-link issues when combining BC files. #141

DStaelens opened this issue Oct 12, 2016 · 3 comments

Comments

@DStaelens
Copy link

I am working on some opt transforms that require a monolithic ir file. Compiling the two simple .cpp files to .bc files and linking them with llvm-link causes the MSVC linker to fail with the error below. I do not have this issue if I use a compiled version of clang with MINGW, but for release I need the MSVC version.

Steps to reproduce:

clang.exe -emit-llvm -c one.cpp two.cpp
llvm-link.exe one.bc two.bc -o combined.bc
clang.exe combined.bc -o test3.exe
combined-2b91e8.o : fatal error LNK1243: invalid or corrupt file: COMDAT section 0x17B associated with following section 0x17E clang.exe: error: linker command failed with exit code 1243 (use -v to see invocation)

Note that if I just clang.exe the two bc files out to an executable it works.
one.cpp.txt
two.cpp.txt
two.h.txt

@aaronsm
Copy link

aaronsm commented Oct 13, 2016

Try clang-cl instead of clang since you are using the VS linker.

@DStaelens
Copy link
Author

DStaelens commented Oct 13, 2016

Seems to have the same issue, but maybe I'm doing something wrong.. Here's what I did:
clang-cl.exe -Xclang -emit-llvm -c one.cpp two.cpp
The above command created one.obj and two.obj, but they did seem to be bc files.
llvm-link.exe one.obj two.obj -o combined.bc
I could not figure out how to directly compile bc files with clang-cl, so I did..
llc.exe -filetype=obj combined.bc -o combined.obj
clang-cl.exe combined.obj -o test.exe
Received same COMDAT error as before.

@aaronsm
Copy link

aaronsm commented Oct 13, 2016

Your command line looks okay. If you use clang-cl it will generate bc files. If you use /FA it will generate ll files but clang-cl will also error out because its not setup properly to do that.

I was able to reproduce your problem but I don't think this is a VS linker issue. This is most likely a problem in llvm-link. You'd probably get a better response on the LLVM developer mailing list since Microsoft doesn't develop clang-cl or llvm-link or llc.

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

2 participants