OLD | NEW |
1 #!/bin/bash | 1 #!/bin/bash |
2 # Copyright (c) 2012 The Native Client Authors. All rights reserved. | 2 # Copyright (c) 2012 The Native Client Authors. All rights reserved. |
3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
5 # | 5 # |
6 #@ PNaCl toolchain build script | 6 #@ PNaCl toolchain build script |
7 #@------------------------------------------------------------------- | 7 #@------------------------------------------------------------------- |
8 #@ This script builds the ARM and PNaCl untrusted toolchains. | 8 #@ This script builds the ARM and PNaCl untrusted toolchains. |
9 #@ It MUST be run from the native_client/ directory. | 9 #@ It MUST be run from the native_client/ directory. |
10 ###################################################################### | 10 ###################################################################### |
(...skipping 665 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
676 | 676 |
677 #+ translator-clean <arch> - | 677 #+ translator-clean <arch> - |
678 #+ Clean one translator install/build | 678 #+ Clean one translator install/build |
679 translator-clean() { | 679 translator-clean() { |
680 local arch=$1 | 680 local arch=$1 |
681 StepBanner "TRANSLATOR" "Clean ${arch}" | 681 StepBanner "TRANSLATOR" "Clean ${arch}" |
682 rm -rf "$(GetTranslatorInstallDir ${arch})" | 682 rm -rf "$(GetTranslatorInstallDir ${arch})" |
683 rm -rf "$(GetTranslatorBuildDir ${arch})" | 683 rm -rf "$(GetTranslatorBuildDir ${arch})" |
684 } | 684 } |
685 | 685 |
686 newlib-shared() { | |
687 StepBanner "NEWLIB-SHARED" | |
688 local naclgcc_base="${NNACL_GLIBC_ROOT}/${NACL64_TARGET}" | |
689 mkdir -p "${INSTALL_LIB_X8632}" | |
690 mkdir -p "${INSTALL_LIB_X8664}" | |
691 mkdir -p "${INSTALL_LIB_ARM}" | |
692 | |
693 StepBanner "NEWLIB-SHARED" "clean out glibc stuff" | |
694 local LIBS_TO_CLEAN="libstdc++.so.6 \ | |
695 libgcc_s.so.1 \ | |
696 libc_nonshared.a \ | |
697 libc.so.* \ | |
698 libm.so.* \ | |
699 libdl.so.* \ | |
700 librt.so.* \ | |
701 libmemusage.so \ | |
702 libpthread_nonshared.a \ | |
703 libpthread.so.* \ | |
704 runnable-ld.so \ | |
705 ld-2.9.so" | |
706 for lib in ${LIBS_TO_CLEAN} ; do | |
707 echo "${lib}" | |
708 # TODO(robertm): fix relaxed quoting due to wildcard usage | |
709 rm -rf ${INSTALL_LIB_X8664}/${lib} | |
710 rm -rf ${INSTALL_LIB_X8632}/${lib} | |
711 done | |
712 | |
713 StepBanner "NEWLIB-SHARED" "stealing shared loader" | |
714 local glibc_libs_to_copy="runnable-ld.so ld-2.9.so ld-nacl-x86-*.so.1" | |
715 local lib | |
716 for lib in ${glibc_libs_to_copy} ; do | |
717 # TODO(robertm): fix relaxed quoting due to wildcard usage | |
718 echo "${lib}" | |
719 cp -a ${naclgcc_base}/lib32/${lib} "${INSTALL_LIB_X8632}" | |
720 cp -a ${naclgcc_base}/lib/${lib} "${INSTALL_LIB_X8664}" | |
721 done | |
722 | |
723 StepBanner "NEWLIB-SHARED" "build native libgcc_eh" | |
724 # TBD | |
725 | |
726 StepBanner "NEWLIB-SHARED" "building newlib shared libs" | |
727 local newlib_libs_to_convert="libc libg libm libstdc++" | |
728 for lib in ${newlib_libs_to_convert} ; do | |
729 echo "translating ${lib}" | |
730 archive_in=${NEWLIB_INSTALL_DIR}/lib/${lib}.a | |
731 pso_out=${NEWLIB_INSTALL_DIR}/lib/${lib}.pso | |
732 soname=${lib}.so | |
733 ${PNACL_CC_GLIBC} \ | |
734 -nodefaultlibs \ | |
735 -shared \ | |
736 -Wl,--whole-archive \ | |
737 ${archive_in} \ | |
738 -Wl,--no-whole-archive \ | |
739 -Wl,-soname=${soname} \ | |
740 -o ${pso_out} | |
741 # This is not a long term solution we probably should not | |
742 # translate stuff we have in pso form in this script. | |
743 # However, it allow some reuse of the glibc infrastructure. | |
744 # NOTE: arm support missing | |
745 # NOTE: This overwrites glibc libraries as we done not have | |
746 # separate directories for native libs | |
747 ${PNACL_TRANSLATE} \ | |
748 --newlib-shared-experiment -nostdlib -shared -fPIC \ | |
749 -arch x86-32 ${pso_out} -o ${INSTALL_LIB_X8632}/${soname} | |
750 ${PNACL_TRANSLATE} \ | |
751 --newlib-shared-experiment -nostdlib -shared -fPIC \ | |
752 -arch x86-64 ${pso_out} -o ${INSTALL_LIB_X8664}/${soname} | |
753 done | |
754 } | |
755 | |
756 # Builds crt1.bc for GlibC, which is just sysdeps/nacl/start.c and csu/init.c | 686 # Builds crt1.bc for GlibC, which is just sysdeps/nacl/start.c and csu/init.c |
757 glibc-crt1() { | 687 glibc-crt1() { |
758 StepBanner "GLIBC" "Building crt1.bc" | 688 StepBanner "GLIBC" "Building crt1.bc" |
759 local tmpdir="${TC_BUILD}/glibc-crt1" | 689 local tmpdir="${TC_BUILD}/glibc-crt1" |
760 local flags="-DUSE_IN_LIBIO -I${TC_SRC_GLIBC}/sysdeps/gnu" | 690 local flags="-DUSE_IN_LIBIO -I${TC_SRC_GLIBC}/sysdeps/gnu" |
761 local cc_cmd="${PNACL_CC_GLIBC} ${flags}" | 691 local cc_cmd="${PNACL_CC_GLIBC} ${flags}" |
762 local ld_cmd="${PNACL_LD_GLIBC}" | 692 local ld_cmd="${PNACL_LD_GLIBC}" |
763 | 693 |
764 rm -rf "${tmpdir}" | 694 rm -rf "${tmpdir}" |
765 mkdir -p "${tmpdir}" | 695 mkdir -p "${tmpdir}" |
(...skipping 2313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3079 # has not already been built, just symlink the bin dirs together. | 3009 # has not already been built, just symlink the bin dirs together. |
3080 if [[ ! -d "${INSTALL_NEWLIB_BIN}" ]]; then | 3010 if [[ ! -d "${INSTALL_NEWLIB_BIN}" ]]; then |
3081 mkdir -p "${INSTALL_NEWLIB}" | 3011 mkdir -p "${INSTALL_NEWLIB}" |
3082 ln -s ${bindir} "${INSTALL_NEWLIB_BIN}" | 3012 ln -s ${bindir} "${INSTALL_NEWLIB_BIN}" |
3083 fi | 3013 fi |
3084 fi | 3014 fi |
3085 # This directory (the ${INSTALL_ROOT}/${libmode} part) | 3015 # This directory (the ${INSTALL_ROOT}/${libmode} part) |
3086 # should be kept in sync with INSTALL_NEWLIB_BIN et al. | 3016 # should be kept in sync with INSTALL_NEWLIB_BIN et al. |
3087 local destdir="${INSTALL_ROOT}/${libmode}/${bindir}" | 3017 local destdir="${INSTALL_ROOT}/${libmode}/${bindir}" |
3088 | 3018 |
3089 driver-install-python "${destdir}" "pnacl-*.py" "wrapper-*.py" | 3019 driver-install-python "${destdir}" "pnacl-*.py" |
3090 | 3020 |
3091 # Tell the driver the library mode and host arch | 3021 # Tell the driver the library mode and host arch |
3092 echo """LIBMODE=${libmode} | 3022 echo """LIBMODE=${libmode} |
3093 HAS_FRONTEND=1 | 3023 HAS_FRONTEND=1 |
3094 HOST_ARCH=${HOST_ARCH}""" > "${destdir}"/driver.conf | 3024 HOST_ARCH=${HOST_ARCH}""" > "${destdir}"/driver.conf |
3095 | 3025 |
3096 # On windows, copy the cygwin DLLs needed by the driver tools | 3026 # On windows, copy the cygwin DLLs needed by the driver tools |
3097 if ${BUILD_PLATFORM_WIN}; then | 3027 if ${BUILD_PLATFORM_WIN}; then |
3098 StepBanner "DRIVER" "Copying cygwin libraries" | 3028 StepBanner "DRIVER" "Copying cygwin libraries" |
3099 local deps="gcc_s-1 iconv-2 win1 intl-8 stdc++-6 z" | 3029 local deps="gcc_s-1 iconv-2 win1 intl-8 stdc++-6 z" |
(...skipping 583 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3683 | 3613 |
3684 if [ "$(type -t $1)" != "function" ]; then | 3614 if [ "$(type -t $1)" != "function" ]; then |
3685 #Usage | 3615 #Usage |
3686 echo "ERROR: unknown function '$1'." >&2 | 3616 echo "ERROR: unknown function '$1'." >&2 |
3687 echo "For help, try:" | 3617 echo "For help, try:" |
3688 echo " $0 help" | 3618 echo " $0 help" |
3689 exit 1 | 3619 exit 1 |
3690 fi | 3620 fi |
3691 | 3621 |
3692 "$@" | 3622 "$@" |
OLD | NEW |