How to build pnacl toolchain

最后都变了- 提交于 2020-02-06 07:24:58

问题


My goal is to make some new function to pnacl toolchain. Before I doing so, I think I should build the pnacl toolchain successfully first.

[11/04 Update]

Finally it works. Some package(bison, byacc, flex) I did't install and caused this problem.

[11/03 Update]

I use ubuntu-14.04.1-desktop-amd64 as my system

Also, ubuntu-12.04.5-desktop-amd64 is now testing [11/03 updated]

I've followed the step of the document all the way. Everything goes just fine until I run the toolchain_build_pnacl script

So I add the new error message here :

if I run the script using gcc to compile

toolchain_build/toolchain_build_pnacl.py --gcc --verbose --sync --clobber --install toolchain/linux_x86/pnacl_newlib

then the following error message is

gcc -DHAVE_CONFIG_H -I. -I../../../src/binutils/gold -I../../../src/binutils/gold -I../../../src/binutils/gold/../include - I../../../src/binutils/gold/../elfcpp -DLOCALEDIR="\"/share/locale\"" -DBINDIR="\"/bin\"" -DTOOLBINDIR="\"/arm-pc-nacl/bin\"" -DTOOLLIBDIR="\"/arm-pc-nacl/lib\"" -W -Wall -Wstrict-prototypes -Wmissing-prototypes -Wshadow -Werror -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -frandom-seed=yyscript.o -Wno-extended-offsetof -Wno-absolute-value -Wno-unused-function -Wno-unused-const-variable -Wno-unneeded-internal-declaration -Wno-unused-private-field -Wno-format-security -MT yyscript.o -MD -MP -MF .deps/yyscript.Tpo -c -o yyscript.o yyscript.c yyscript.c:1:1: error: return type defaults to ‘int’ [-Werror=return-type] yyscript.c:1:1: error: function

declaration isn’t a prototype [-Werror=strict-prototypes] cc1: error: unrecognized command line option "-Wno-unused-private-field" [-Werror] cc1: error: unrecognized command line option "-Wno-unneeded-internal-declaration" [-Werror] cc1: error: unrecognized command line option "-Wno-unused-const-variable" [-Werror] cc1: error: unrecognized command line option "-Wno-absolute-value" [-Werror] cc1: error: unrecognized command line option "-Wno-extended-offsetof" [-Werror] cc1: all warnings being treated as errors make[4]: *** [yyscript.o] Error 1

if I run it with default clang to compile

toolchain_build/toolchain_build_pnacl.py --verbose --clobber --install toolchain/linux_x86/pnacl_newlib

then following error message is generated

/home/albaforia/SVN/nativeclient/third_party/llvm-build/Release+Asserts/bin/clang -DHAVE_CONFIG_H -I. -I../../../src/binutils/gold -I../../../src/binutils/gold -I../../../src/binutils/gold/../include -I../../../src/binutils/gold/../elfcpp -DLOCALEDIR="\"/share/locale\"" -DBINDIR="\"/bin\"" -DTOOLBINDIR="\"/arm-pc-nacl/bin\"" -DTOOLLIBDIR="\"/arm-pc-nacl/lib\"" -W -Wall -Wstrict-prototypes -Wmissing-prototypes -Wshadow -Werror -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -frandom-seed=yyscript.o -Wno-extended-offsetof -Wno-absolute-value -Wno-unused-function -Wno-unused-const-variable -Wno-unneeded-internal-declaration -Wno-unused-private-field -Wno-format-security -MT yyscript.o -MD -MP -MF .deps/yyscript.Tpo -c -o yyscript.o yyscript.c yyscript.c:1:1: error: type specifier missing, defaults to 'int' [-Werror,-Wimplicit-int] main() { return 0; } ^~~~ 1 error generated. make[4]: *** [yyscript.o] Error 1


回答1:


By default the PNaCl toolchain builds with a downloaded binary of clang because Google's automated builders run Ubuntu 12.04, and the gcc on those systems cannot build recent versions of LLVM. So there are 2 options: If you used Chromium's depot_tools to get the Native Client sources, you can easily get a copy of the same compiler the builders use: from the parent directory of native_client run tools/clang/scripts/update.sh which will download and install clang in the directory where toolchain_build_pnacl.py expects it. Once it is installed, it will be kept up to date automatically by Native Clients DEPS hooks if you use gclient from depot_tools.

Otherwise you can use the system gcc to compile the PNaCl toolchain using the --gcc option. This should definitely work on Ubuntu 14.04 as that the system we develop PNaCl on.

As an aside I've started another document that has a few more details on the build process (even if its focus isn't exactly what you are interested in) and of course there is the -h flag of toolchain_build_pnacl.py and its sources.




回答2:


Could you post more information on what the error is? You probably need to scroll up a bit (the errors are interleaved with other parts of the build because it builds in parallel). To help debug this you could also run toolchain_build/toolchain_build_pnacl.py on specific targets and reduce the amount of building that goes on, e.g. you could do:

toolchain_build/toolchain_build_pnacl.py llvm_x86_64_linux --verbose --install toolchain/linux_x86/pnacl_newlib

FYI, when you re-run the toolchain_build/toolchain_build_pnacl.py script you don't need to re-specify --sync and --clobber.

You can also run the make command manually as you debug the issue. In any case we'd like to fix the issue you're running into!




回答3:


To use system compiler instead of compiler from third_party/llvm_build/... you may want to pass the --gcc option to the build script. Though, it's still unlikely that you'll succeed in building toolchain under Ubuntu 14.04.

I'm using Ubuntu 14.04 and in order to build pnacl toolchain I have set up Ubuntu 12.04 chroot environment. Inside it I can successfully build the toolchain using the following commands:

# get sources for NaCl itself
gclient config http://src.chromium.org/native_client/trunk/src/native_client@13992 --name native_client
gclient sync -j16

cd native_client
# sync sources for binutils, llvm, etc.
toolchain_build/toolchain_build_pnacl.py --verbose --sync-only
# build and install toolchain
toolchain_build/toolchain_build_pnacl.py --verbose --gcc --install install_dir

PS: I mount /proc, /dev, /dev/pts, /sys, /run, /run/shm, /tmp into my chroot environment and everything runs smoothly. Without mounting some of these directories some build scripts may fail, though I'm not sure about it.



来源:https://stackoverflow.com/questions/26609252/how-to-build-pnacl-toolchain

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!