Search code examples
buildgoogle-nativeclienttoolchain

How to build pnacl toolchain


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


Solution

  • 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.