-
Couldn't load subscription status.
- Fork 42
Compiling application with clang and linking with x86_64-hermit-ld #116
Description
Hello.
For evaluation purpose, I would like to compile an application with clang compiler, and let the hermit toolchain link the compiled files correctly.
To show you my problem, I try to compile a simple C++ hello world application :
#include <iostream>
using namespace std;
int main(int argc, char ** argv)
{
std::cout << "Hello world !" << std::endl;
return 0;
}This little program compiles with the x86_64-hermit-g++ compiler, and runs fine on the proxy.
But when I try to compile this code to a .o file using clang, and then link it with x86_64-hermit-g++, I get the following error :
$ clang -c hello.cpp
$ /opt/hermit/bin/x86_64-hermit-g++ -o hello hello.o
/opt/hermit/lib/gcc/x86_64-hermit/6.3.0/../../../../x86_64-hermit/bin/ld: hello.o: Relocations in generic ELF (EM: 62)
/opt/hermit/lib/gcc/x86_64-hermit/6.3.0/../../../../x86_64-hermit/bin/ld: hello.o: Relocations in generic ELF (EM: 62)
/opt/hermit/lib/gcc/x86_64-hermit/6.3.0/../../../../x86_64-hermit/bin/ld: hello.o: Relocations in generic ELF (EM: 62)
/opt/hermit/lib/gcc/x86_64-hermit/6.3.0/../../../../x86_64-hermit/bin/ld: hello.o: Relocations in generic ELF (EM: 62)
/opt/hermit/lib/gcc/x86_64-hermit/6.3.0/../../../../x86_64-hermit/bin/ld: hello.o: error adding symbols: file in wrong format
collect2: error: ld returned 1 exit status
I'm not sure about what means "file in wrong format" here. I read on the internet that this error could be related to a .o compiled for ARM architecture, while we're trying to link it into a x86 binary executable for example. But I think it's not the case here, since I'm compiling for the same architecture. file command shows that the .o is compiled for the correct architecture (I think ?) :
$ file hello.o
hello.o: ELF 64-bit LSB relocatable, x86-64, version 1 (SYSV), not stripped
Is there something that prevent us from using the hermit toolchain only for linking everything ?