| Index: ports/pnacl/build.sh
|
| diff --git a/ports/pnacl/build.sh b/ports/pnacl/build.sh
|
| index 21e8cc71f3aad8d1d42b67f8711a3a8f601ee08d..60d193771f51cf82bd2909f4792730d864a93ef8 100644
|
| --- a/ports/pnacl/build.sh
|
| +++ b/ports/pnacl/build.sh
|
| @@ -2,7 +2,6 @@
|
| # Use of this source code is governed by a BSD-style license that can be
|
| # found in the LICENSE file.
|
|
|
| -EXECUTABLES="bin/arm-nacl-readelf bin/le32-nacl-strings bin/clang bin/clang++"
|
| EnableGlibcCompat
|
| EnableCliMain
|
|
|
| @@ -21,6 +20,9 @@ PatchStep() {
|
| Remove ${SRC_DIR}/toolchain_build/src/llvm/tools/clang
|
| LogExecute ln -fs ${SRC_DIR}/../../pnacl-clang-src/clang \
|
| ${SRC_DIR}/toolchain_build/src/llvm/tools/clang
|
| + Remove ${SRC_DIR}/toolchain_build/src/binutils-x86
|
| + LogExecute ln -fs ${SRC_DIR}/../../pnacl-binutils-x86-src/binutils \
|
| + ${SRC_DIR}/toolchain_build/src/binutils-x86
|
| }
|
|
|
| ConfigureStep() {
|
| @@ -28,7 +30,7 @@ ConfigureStep() {
|
| }
|
|
|
| OUT_DIR=${BUILD_DIR}/out
|
| -OUT_BIN=${BUILD_DIR}/bin
|
| +OUT_INSTALL=${BUILD_DIR}/install
|
|
|
| BuildStep() {
|
| PNACL_DIR=${NACL_SDK_ROOT}/toolchain/linux_pnacl
|
| @@ -67,6 +69,13 @@ BuildStep() {
|
|
|
| EXTRA_CONFIGURE="--extra-configure-arg=--disable-compiler-version-checks"
|
| EXTRA_CONFIGURE+=" --extra-configure-arg=--enable-libcpp"
|
| + # Without this configure will detect vfork as missing and define
|
| + # vfork to fork which clobbers that define in "spawn.h".
|
| + EXTRA_CONFIGURE+=" --extra-configure-arg=ac_cv_func_vfork_works=yes"
|
| + EXTRA_CONFIGURE+=" --extra-configure-arg=ac_cv_func_getrusage=no"
|
| + if [[ ${NACL_DEBUG} == 1 ]]; then
|
| + EXTRA_CONFIGURE+=" --host-flavor=debug"
|
| + fi
|
|
|
| # Some code in llvm uses intrisics not supported in the pnacl stable abi.
|
| if [[ ${TOOLCHAIN} == pnacl ]]; then
|
| @@ -77,18 +86,13 @@ BuildStep() {
|
| EXTRA_CC_ARGS+=" -I${NACLPORTS_INCLUDE}/glibc-compat"
|
| fi
|
|
|
| - LINUX_PNACL=${NACL_SDK_ROOT}/toolchain/linux_pnacl
|
| EXTRA_CC_ARGS+=" -include spawn.h"
|
| EXTRA_CC_ARGS+=" -I${NACL_SDK_ROOT}/include"
|
| EXTRA_CC_ARGS+=" -I${NACLPORTS_INCLUDE}"
|
|
|
| - # export EXTRA_LIBS so that compiler_wapper.py can access it
|
| - export EXTRA_LIBS="${NACLPORTS_LDFLAGS} ${NACLPORTS_LIBS}"
|
| - echo "EXTRA_LIBS=${EXTRA_LIBS}"
|
| -
|
| - # Without this configure will detect vfork as missing and define
|
| - # vfork to fork which clobbers that define in "spawn.h".
|
| - export ac_cv_func_vfork_works=yes
|
| + # export WEBPORTS_EXTRA_LIBS so that compiler_wapper.py can access it
|
| + export WEBPORTS_EXTRA_LIBS="${NACLPORTS_LDFLAGS} ${NACLPORTS_LIBS}"
|
| + echo "WEBPORTS_EXTRA_LIBS=${WEBPORTS_EXTRA_LIBS}"
|
|
|
| # Inject a shim that speed up pnacl invocations for configure.
|
| if [ "${NACL_ARCH}" = "pnacl" ]; then
|
| @@ -100,6 +104,9 @@ BuildStep() {
|
| NACLCC="${START_DIR}/compiler_wrapper.py ${NACLCC}"
|
| NACLCXX="${START_DIR}/compiler_wrapper.py ${NACLCXX}"
|
|
|
| + Remove ${OUT_INSTALL}
|
| + MakeDir ${OUT_INSTALL}
|
| +
|
| export CC=${NACLCC}
|
| export CXX=${NACLCXX}
|
| export AR=${NACLAR}
|
| @@ -110,68 +117,134 @@ BuildStep() {
|
| --no-annotator \
|
| --pnacl-in-pnacl \
|
| --output=${OUT_DIR} \
|
| + --install=${OUT_INSTALL} \
|
| "--extra-cc-args=${EXTRA_CC_ARGS}" \
|
| ${EXTRA_CONFIGURE} \
|
| "--binutils-pnacl-extra-configure=${GOLD_LDADD}"
|
|
|
| - Remove ${OUT_BIN}
|
| - MakeDir ${OUT_BIN}
|
| - LogExecute cp ${OUT_DIR}/llvm_le32_nacl_install/bin/* ${OUT_BIN}
|
| - LogExecute cp ${OUT_DIR}/binutils_pnacl_le32_nacl_install/bin/* \
|
| - ${OUT_BIN}
|
| - # TODO(bradnelson): Drop this once shell script fix is done.
|
| - MakeDir ${OUT_BIN}/driver
|
| - LogExecute cp ${SRC_DIR}/pnacl/driver/redirect.sh ${OUT_BIN}/driver/
|
| - LogExecute cp ${SRC_DIR}/pnacl/driver/*.py ${OUT_BIN}/driver/
|
| + CreateHybridToolchain
|
| }
|
|
|
| -InstallStep() {
|
| - local INSTALL_DIR=${DESTDIR}/${PREFIX}/pnacl
|
| - Remove ${INSTALL_DIR}/
|
| - MakeDir ${INSTALL_DIR}/
|
| +CreateHybridToolchain() {
|
| + Banner "Creating Hybrid Toolchain"
|
|
|
| - LogExecute cp -r ${NACL_SDK_ROOT}/toolchain/linux_pnacl/* ${INSTALL_DIR}
|
| + # Build a full toolchain based on the one in NACL_SDK_ROOT, but overlayed
|
| + # with the one we just compiled.
|
| + Remove toolchain
|
| + MakeDir toolchain
|
| +
|
| + host_toolchain=${NACL_SDK_ROOT}/toolchain/linux_pnacl
|
| + LogExecute cp -r ${host_toolchain}/* toolchain
|
|
|
| # Drop pyc files.
|
| - LogExecute find ${INSTALL_DIR} -name "*.pyc" -exec rm {} \;
|
| -
|
| - LogExecute rm -rf ${INSTALL_DIR}/mipsel-nacl
|
| - LogExecute rm -rf ${INSTALL_DIR}/translator
|
| - LogExecute rm -rf ${INSTALL_DIR}/*-nacl/usr
|
| -
|
| - # TODO(bradnelson): Drop this once shell script fix is done.
|
| - LogExecute cp ${OUT_BIN}/driver/*.py ${INSTALL_DIR}/bin/pydir/
|
| -
|
| - # Swap in nacl executables.
|
| - Remove ${INSTALL_DIR}/lib/*.so
|
| - for f in $(find ${INSTALL_DIR} -executable -type f); do
|
| - if [ "$(file ${f} | grep ELF)" != "" ]; then
|
| - local exe="${OUT_BIN}/$(basename ${f})"
|
| - if [[ -f ${exe} ]]; then
|
| - if [[ ${TOOLCHAIN} == pnacl ]]; then
|
| - echo "Finalizing ${exe}"
|
| - ${PNACLFINALIZE} ${exe} -o ${f}
|
| - else
|
| - echo "Copying ${exe}"
|
| - cp ${exe} ${f}
|
| - fi
|
| + LogExecute find toolchain -name "*.pyc" -exec rm {} \;
|
| +
|
| + # Overlay compiled toolchain
|
| + Remove ${OUT_INSTALL}/x86_64-nacl/lib/32
|
| + Remove ${OUT_INSTALL}/x86_64-nacl/lib64
|
| + LogExecute cp -r ${OUT_INSTALL}/* toolchain/
|
| +
|
| + # Rename the nacl executables.
|
| + for f in $(cd ${host_toolchain} && find . -executable -type f); do
|
| + if [[ "$(file ${host_toolchain}/${f} | grep ELF)" != "" \
|
| + && ${f} != *pnacl-abicheck ]]; then
|
| + # We are dealing with an executable
|
| + local built_exe="${OUT_INSTALL}/${f}"
|
| + local exe="toolchain/${f}"
|
| + if [[ -f ${built_exe} ]]; then
|
| + LogExecute mv ${exe} ${exe}${NACL_EXEEXT}
|
| elif [[ $f == *-clang* ]]; then
|
| - LogExecute ln -sf ${f} $(basename ${f})
|
| + Remove ${exe}
|
| + LogExecute ln -sf clang${NACL_EXEEXT} ${exe}${NACL_EXEEXT}
|
| else
|
| echo "Warning: dropping ${f} without a nacl replacement."
|
| - LogExecute rm -f ${f}
|
| + LogExecute rm -f ${exe}
|
| fi
|
| - elif [ "$(head -n 1 ${f} | grep /bin/sh)" != "" ]; then
|
| - # TODO(bradnelson): Drop this once shell script fix is done.
|
| - LogExecute cp -f ${OUT_BIN}/driver/redirect.sh ${f}
|
| - LogExecute chmod a+x ${f}
|
| fi
|
| done
|
| +
|
| + # Now create launcher scripts for each executable
|
| + for f in toolchain/bin/*${NACL_EXEEXT}; do
|
| + script=${f%.*}
|
| + if [[ ${TOOLCHAIN} == pnacl ]]; then
|
| + TranslateAndWriteLauncherScript "${f}" x86-64 "${script}.nexe" "${script}"
|
| + else
|
| + WriteLauncherScript "${script}" "$(basename ${f})"
|
| + fi
|
| + done
|
| +
|
| + # Drop parts we don't care about
|
| + LogExecute rm -rf toolchain/translator
|
| + LogExecute rm -rf toolchain/mipsel-nacl
|
| + LogExecute rm -rf toolchain/*-nacl/usr
|
| + LogExecute rm -f toolchain/bin/mipsel-*
|
| + LogExecute rm -f toolchain/lib/*.so
|
| +}
|
| +
|
| +InstallStep() {
|
| + local INSTALL_DIR=${DESTDIR}/${PREFIX}/pnacl
|
| + Remove ${INSTALL_DIR}/
|
| + MakeDir ${INSTALL_DIR}/
|
| +
|
| + LogExecute cp -r toolchain/* ${INSTALL_DIR}
|
| + for f in $(find ${INSTALL_DIR} -type l -name *-clang*${NACL_EXEEXT}); do
|
| + # link to clang binary
|
| + Remove $f ${f%.*}
|
| + LogExecute ln -s clang ${f%.*}
|
| + done
|
| + for f in $(find ${INSTALL_DIR} -executable -type f -name *${NACL_EXEEXT}); do
|
| + LogExecute mv $f ${f%.*}
|
| + done
|
| }
|
|
|
| -PostInstallTestStep() {
|
| +TestStep() {
|
| # Verify that binaries at least load under sel_ldr
|
| - LogExecute ./bin/le32-nacl-strings.sh --version
|
| - LogExecute ./bin/arm-nacl-readelf.sh --version
|
| - LogExecute ./bin/clang.sh --version
|
| + LogExecute toolchain/bin/le32-nacl-strings --version
|
| + LogExecute toolchain/bin/arm-nacl-readelf --version
|
| + LogExecute toolchain/bin/x86_64-nacl-as --version
|
| + LogExecute toolchain/bin/clang --version
|
| +
|
| + # The end-to-end tests doesn't currently work for PNaCl
|
| + if [[ $TOOLCHAIN == pnacl ]]; then
|
| + return
|
| + fi
|
| + TestNaClClang
|
| +}
|
| +
|
| +TestNaClClang() {
|
| + # Try compiling and running a simple hello world program. We have to
|
| + # use explicit compile, assemble and link commands since sel_ldr doesn't
|
| + # provide fork().
|
| +
|
| + compile_command="toolchain/bin/x86_64-nacl-clang -cc1 -triple x86_64--nacl
|
| + -S -disable-free -main-file-name ${START_DIR}/hello.c -mrelocation-model
|
| + static -mthread-model posix -mdisable-fp-elim -fmath-errno -no-integrated-as
|
| + -mconstructor-aliases -munwind-tables -fuse-init-array -target-cpu x86-64
|
| + -target-linker-version 2.24 -v -dwarf-column-info
|
| + -resource-dir $PWD/toolchain/bin/../lib/clang/3.7.0
|
| + -internal-isystem $PWD/toolchain/bin/../lib/clang/3.7.0/include
|
| + -internal-isystem $PWD/toolchain/bin/../x86_64-nacl/usr/include
|
| + -internal-isystem $PWD/toolchain/bin/../x86_64-nacl/include
|
| + -fno-dwarf-directory-asm -ferror-limit 19 -fmessage-length 0 -mstackrealign
|
| + -fobjc-runtime=gcc -fdiagnostics-show-option -o hello.s -x c
|
| + ${START_DIR}/hello.c
|
| + "
|
| + LogExecute $compile_command
|
| +
|
| + LogExecute toolchain/bin/x86_64-nacl-as --64 hello.s -o hello.o
|
| + link_command="toolchain/x86_64-nacl/bin/ld --build-id -m
|
| + elf_x86_64_nacl -static -o hello.nexe
|
| + $PWD/toolchain/bin/../x86_64-nacl/lib/crt1.o
|
| + $PWD/toolchain/bin/../x86_64-nacl/lib/crti.o
|
| + $PWD/toolchain/bin/../lib/clang/3.7.0/lib/x86_64-nacl/crtbeginT.o
|
| + -L$PWD/toolchain/bin/../x86_64-nacl/lib
|
| + -L$PWD/toolchain/bin/../x86_64-nacl/usr/lib
|
| + -L$PWD/toolchain/bin/../lib/clang/3.7.0/lib/x86_64-nacl
|
| + ./hello.o --start-group -lc -lgcc --as-needed -lgcc_eh --no-as-needed
|
| + --end-group
|
| + $PWD/toolchain/bin/../lib/clang/3.7.0/lib/x86_64-nacl/crtend.o
|
| + $PWD/toolchain/bin/../x86_64-nacl/lib/crtn.o
|
| + "
|
| + LogExecute $link_command
|
| + RunSelLdrCommand hello.nexe
|
| }
|
|
|