Reputation: 12700
I want to compile the hello_world driver using PNacl; the only problem is that I don't know which options to pass to the compiler.
To recap, the intention here is to go from .cc (C++ file) to .bc (some llvm format I don't know much about) and from there to .pexe.
Here is what I try:
$ TC_PATH=/opt/nacl/pepper_26/toolchain/linux_x86_pnacl/host_x86_64/bin
$ $(TC_PATH)/clang++ hello_world.cc -o hello_world.bc -I/opt/nacl/pepper_26/include
That much works. Now, the linking step fails:
$ $(TC_PATH)/clang++ hello_world.bc -o hello_world
/tmp/hello_world-l8UCWM.o: file not recognized: File format not recognized
If I do
$ $(TC_PATH)/clang++ hello_world.bc -o hello_world.pexe --verbose
I see that the driver is trying to link with my system linker, which of course won't work:
...
"/usr/bin/ld" --eh-frame-hdr "
...
I've tried to dig some Makefiles using the thing,but so far I have only found this one and seems outdated. Which flags should I pass to the tools?
Upvotes: 1
Views: 1406
Reputation: 12700
Ok, here is what I found. First the new Makefiles distributed with the SDK know exactly how to do the whole build.... I had not found those. Basically the clang++ invoked is $(SDK_ROOT)/toolchain/linux_x86_pnacl/newlib/bin/pnacl-clang++
instead of the one at host_x86_64
.
Upvotes: 0
Reputation: 793
As you mentioned in your answer, the Makefiles in the SDK have support for invoking the pnacl compiler. All of the user-facing tools are in
$(SDK_ROOT)/toolchain/linux_x86_pnacl/newlib/bin
or its equivalent on Windows or Mac. When used like a normal compiler/linker driver pnacl-clang
(and pnacl-clang++
) will generate portable object files when compiling and portable executables (called .pexe files) when linking. You can use the pnacl-translate
tool to translate the pexe to an x86-64, x86-32 or arm native client executable (nexe), which is usable in the same way as nexe files generated by nacl-gcc. There will also soon be support for direct use of pexe files for in-browser translation.
Upvotes: 3