Upstream version 7.36.149.0
[platform/framework/web/crosswalk.git] / src / native_client / pnacl / build.sh
index 2b95e14..4c8fae3 100755 (executable)
@@ -12,9 +12,9 @@
 ######################################################################
 #
 # All directories are relative to BASE which is
-# On Linux: native_client/toolchain/pnacl_linux_x86/
-# On Mac: native_client/toolchain/pnacl_mac_x86/
-# On Windows: native_client/toolchain/pnacl_win_x86/
+# On Linux: native_client/toolchain/linux_x86/pnacl_newlib/
+# On Mac: native_client/toolchain/mac_x86/pnacl_newlib/
+# On Windows: native_client/toolchain/win_x86/pnacl_newlib/
 #
 ######################################################################
 
@@ -75,10 +75,10 @@ readonly ARM_ARCH=armv7-a
 readonly ARM_FPU=vfp
 
 readonly TOOLCHAIN_ROOT="${NACL_ROOT}/toolchain"
+readonly TOOLCHAIN_BASE="${TOOLCHAIN_ROOT}/${SCONS_BUILD_PLATFORM}_x86"
 
-readonly NNACL_BASE="${TOOLCHAIN_ROOT}/${SCONS_BUILD_PLATFORM}_x86"
-readonly NNACL_NEWLIB_ROOT="${NNACL_BASE}_newlib"
-readonly NNACL_ARM_NEWLIB_ROOT="${TOOLCHAIN_ROOT}/linux_arm_newlib"
+readonly NNACL_NEWLIB_ROOT="${TOOLCHAIN_BASE}/nacl_x86_newlib"
+readonly NNACL_ARM_NEWLIB_ROOT="${TOOLCHAIN_BASE}/nacl_arm_newlib"
 
 readonly PNACL_MAKE_OPTS="${PNACL_MAKE_OPTS:-}"
 readonly MAKE_OPTS="-j${PNACL_CONCURRENCY} VERBOSE=1 ${PNACL_MAKE_OPTS}"
@@ -124,8 +124,7 @@ readonly NACL_HEADERS_TS="${TC_BUILD}/nacl.sys.timestamp"
 readonly TIMESTAMP_FILENAME="make-timestamp"
 
 # PNaCl toolchain installation directories (absolute paths)
-readonly TOOLCHAIN_LABEL="${TOOLCHAIN_LABEL:-pnacl_${BUILD_PLATFORM}_x86}"
-readonly INSTALL_ROOT="${TOOLCHAIN_ROOT}/${TOOLCHAIN_LABEL}"
+readonly INSTALL_ROOT="${TOOLCHAIN_BASE}/pnacl_newlib"
 readonly INSTALL_BIN="${INSTALL_ROOT}/bin"
 
 # Bitcode lib directories (including static bitcode libs)
@@ -140,7 +139,7 @@ readonly INSTALL_LIB_X8664="${INSTALL_LIB_NATIVE}x86-64"
 readonly INSTALL_LIB_MIPS32="${INSTALL_LIB_NATIVE}mips32"
 
 # PNaCl client-translators (sandboxed) binary locations
-readonly INSTALL_TRANSLATOR="${TOOLCHAIN_ROOT}/pnacl_translator"
+readonly INSTALL_TRANSLATOR="${TOOLCHAIN_BASE}/pnacl_translator"
 
 
 # The INSTALL_HOST directory has host binaries and libs which
@@ -247,13 +246,13 @@ setup-biased-bitcode-env() {
       LIB_CPP_INSTALL_DIR="${INSTALL_ROOT}/usr-bc-${arch}"
       ;;
     x86-32)
-      BIASED_BC_CFLAGS="--target=i686-nacl"
+      BIASED_BC_CFLAGS="--target=i686-unknown-nacl"
       NEWLIB_INSTALL_DIR="${INSTALL_ROOT}/usr-bc-${arch}"
       INSTALL_LIB="${INSTALL_ROOT}/lib-bc-${arch}"
       LIB_CPP_INSTALL_DIR="${INSTALL_ROOT}/usr-bc-${arch}"
       ;;
     x86-64)
-      BIASED_BC_CFLAGS="--target=x86_64-nacl"
+      BIASED_BC_CFLAGS="--target=x86_64-unknown-nacl"
       NEWLIB_INSTALL_DIR="${INSTALL_ROOT}/usr-bc-${arch}"
       INSTALL_LIB="${INSTALL_ROOT}/lib-bc-${arch}"
       LIB_CPP_INSTALL_DIR="${INSTALL_ROOT}/usr-bc-${arch}"
@@ -452,7 +451,7 @@ libs() {
     newlib ${arch}
   done
   libs-support
-  for arch in arm x86-32 x86-64 mips32 x86-32-nonsfi; do
+  for arch in arm x86-32 x86-64 mips32 arm-nonsfi x86-32-nonsfi; do
     dummy-irt-shim ${arch}
   done
   compiler-rt-all
@@ -515,58 +514,6 @@ everything-translator() {
   driver-install-translator
 }
 
-#@ translator-archive-pexes <tarball> -archive gold and llc pexes
-#@                      <tarball> should be an absolute pathname,
-#@                      and should have tar.bz2 as the suffix (as that is
-#@                      what will be produced).
-#@
-#@                      This must run before pexes are pruned.
-translator-archive-pexes() {
-  local tarball=$1
-
-  if [[ "${tarball#*.}" != "tar.bz2" ]]; then
-    echo "translator-archive-pexes: ${tarball} not named with .tar.bz2 suffix"
-    exit 1
-  fi
-  local tarball_no_bz2=${tarball%.*}
-
-  # Clear tarball before appending files to it.
-  rm -f ${tarball}
-
-  # Archive LD
-  for arch in ${SBTC_ARCHES_ALL} ; do
-    local pexe_dir="$(GetTranslatorInstallDir ${arch})/bin"
-    echo "pexe_dir is ${pexe_dir}"
-    # Label the pexes by architecture.
-    local pexe_ld="${pexe_dir}/ld.${arch}"
-    cp "${pexe_dir}/ld.pexe" "${pexe_ld}.nonfinal.pexe"
-    ${PNACL_FINALIZE} "${pexe_ld}.nonfinal.pexe" -o "${pexe_ld}.final.pexe"
-    local all="${pexe_ld}.final.pexe"
-    file ${all}
-    ls -l ${all}
-    # strip all path components
-    tar rf ${tarball_no_bz2}  --transform 's!^.*/!!' ${all}
-  done
-
-  # Archive LLC (which combines x86 and x86_64).
-  for arch in ${SBTC_ARCHES_LLVM} ; do
-    local pexe_dir="$(GetTranslatorInstallDir ${arch})/bin"
-    echo "pexe_dir is ${pexe_dir}"
-    # Label the pexes by architecture.
-    local pexe_llc="${pexe_dir}/pnacl-llc.${arch}"
-    cp "${pexe_dir}/pnacl-llc.pexe" "${pexe_llc}.nonfinal.pexe"
-    ${PNACL_FINALIZE} "${pexe_llc}.nonfinal.pexe" \
-      -o "${pexe_llc}.final.pexe"
-    local all="${pexe_llc}.final.pexe"
-    file ${all}
-    ls -l ${all}
-    # strip all path components
-    tar rf ${tarball_no_bz2}  --transform 's!^.*/!!' ${all}
-  done
-  bzip2 ${tarball_no_bz2}
-}
-
-
 #+ translator-clean-all  - Clean all translator install/build directories
 translator-clean-all() {
   StepBanner "TRANSLATOR" "Clean all"
@@ -967,6 +914,7 @@ llvm-configure-ninja() {
       -DLLVM_TARGETS_TO_BUILD="X86;ARM;Mips" \
       -DLLVM_ENABLE_ASSERTIONS=ON \
       -ULLVM_ENABLE_ZLIB \
+      -DLLVM_ENABLE_TERMINFO=OFF \
       -DLLVM_BUILD_TESTS=ON \
       -DLLVM_APPEND_VC_REV=ON \
       -DLLVM_BINUTILS_INCDIR="${binutils_include}" \
@@ -1172,6 +1120,7 @@ compiler-rt-all() {
   compiler-rt mips32
   compiler-rt x86-32
   compiler-rt x86-64
+  compiler-rt arm-nonsfi
   compiler-rt x86-32-nonsfi
 }
 
@@ -1306,6 +1255,7 @@ lib-cpp-configure() {
       cmake -G "Unix Makefiles" \
       -DCMAKE_CXX_COMPILER_WORKS=1 \
       -DCMAKE_C_COMPILER_WORKS=1 \
+      -DCMAKE_SYSTEM_NAME=nacl \
       -DCMAKE_INSTALL_PREFIX="${LIB_CPP_INSTALL_DIR}" \
       -DCMAKE_BUILD_TYPE=Release \
       -DCMAKE_C_COMPILER="${PNACL_CC}" \
@@ -1563,8 +1513,8 @@ binutils-configure() {
   # c.f.:  http://sourceware.org/ml/binutils/2009-05/msg00252.html
   # all we try to do here is to add "$ORIGIN/../lib to "rpath".
   # If you ever touch this please make sure that rpath is correct via:
-  # objdump -p toolchain/${TOOLCHAIN_LABEL}/host/bin/le32-nacl-ld.gold
-  # objdump -p toolchain/${TOOLCHAIN_LABEL}/host/bin/le32-nacl-objdump
+  # objdump -p ${TOOLCHAIN_BASE}/pnacl_newlib/host/bin/le32-nacl-ld.gold
+  # objdump -p ${TOOLCHAIN_BASE}/pnacl_newlib/host/bin/le32-nacl-objdump
   if ${BUILD_PLATFORM_LINUX} ; then
       local flags='-Xlinker -rpath -Xlinker '"'"'$\\$$\$$\\$$\$$ORIGIN/../lib'"'"
       local shared='yes'
@@ -2381,7 +2331,7 @@ libs-support() {
   libs-support-bitcode x86-64
 
   local arch
-  for arch in arm x86-32 x86-64 mips32 x86-32-nonsfi; do
+  for arch in arm x86-32 x86-64 mips32 arm-nonsfi x86-32-nonsfi; do
     libs-support-native ${arch}
   done
 
@@ -2479,6 +2429,8 @@ libs-support-native() {
   local setjmp_arch="$arch"
   if [ "$setjmp_arch" = "x86-32-nonsfi" ]; then
     setjmp_arch=x86-32
+  elif [ "$setjmp_arch" = "arm-nonsfi" ]; then
+    setjmp_arch=arm
   fi
   ${cc_cmd} -c setjmp_${setjmp_arch/-/_}.S -o "${tmpdir}"/setjmp.o
 
@@ -2510,13 +2462,19 @@ libs-support-native() {
 }
 
 libs-support-unsandboxed() {
-  if ${BUILD_PLATFORM_LINUX}; then
-    local arch=x86-32-linux
+  if ${BUILD_PLATFORM_LINUX} || ${BUILD_PLATFORM_MAC}; then
+    local arch="x86-32-${BUILD_PLATFORM}"
     StepBanner "LIBS-SUPPORT (${arch})" "Install unsandboxed_irt.o"
     local destdir="${INSTALL_LIB_NATIVE}"${arch}
     mkdir -p ${destdir}
-    gcc -m32 -O2 -Wall -Werror -I${NACL_ROOT}/.. -DNACL_LINUX=1 -c \
-        ${PNACL_SUPPORT}/unsandboxed_irt.c -o ${destdir}/unsandboxed_irt.o
+    # The NaCl headers insist on having a platform macro such as
+    # NACL_LINUX defined, but nonsfi/irt/irt_interfaces.c does not
+    # itself use any of these macros, so defining NACL_LINUX here even
+    # on non-Linux systems is OK.
+    gcc -m32 -O2 -Wall -Werror -I${NACL_ROOT}/.. -c \
+        -DNACL_LINUX=1 -DDEFINE_MAIN \
+        ${NACL_ROOT}/src/nonsfi/irt/irt_interfaces.c \
+        -o ${destdir}/unsandboxed_irt.o
   fi
 }
 
@@ -2597,15 +2555,12 @@ sdk-headers() {
 
   StepBanner "SDK" "Install headers"
   spushd "${NACL_ROOT}"
-  # TODO(pnacl-team): remove this pnaclsdk_mode once we have a better story
-  # about host binary type (x86-32 vs x86-64).  SCons only knows how to use
-  # x86-32 host binaries right now, so we need pnaclsdk_mode to override that.
   RunWithLog "sdk.headers" \
       ./scons \
       "${SCONS_ARGS[@]}" \
       ${extra_flags} \
       platform=${neutral_platform} \
-      pnaclsdk_mode="custom:${INSTALL_ROOT}" \
+      pnacl_newlib_dir="${INSTALL_ROOT}" \
       install_headers \
       includedir="$(PosixToSysPath "${SDK_INSTALL_INCLUDE}")"
   spopd
@@ -2620,13 +2575,12 @@ sdk-libs() {
   local neutral_platform="x86-32"
 
   spushd "${NACL_ROOT}"
-  # See above TODO about pnaclsdk_mode.
   RunWithLog "sdk.libs.bitcode" \
       ./scons \
       "${SCONS_ARGS[@]}" \
       ${extra_flags} \
       platform=${neutral_platform} \
-      pnaclsdk_mode="custom:${INSTALL_ROOT}" \
+      pnacl_newlib_dir="${INSTALL_ROOT}" \
       install_lib \
       libdir="$(PosixToSysPath "${SDK_INSTALL_LIB}")"
   spopd
@@ -2640,13 +2594,12 @@ sdk-private-libs() {
   spushd "${NACL_ROOT}"
 
   local neutral_platform="x86-32"
-  # See above TODO about pnaclsdk_mode.
   RunWithLog "sdk.libs_private.bitcode" \
     ./scons \
     -j${PNACL_CONCURRENCY} \
     bitcode=1 \
     platform=${neutral_platform} \
-    pnaclsdk_mode="custom:${INSTALL_ROOT}" \
+    pnacl_newlib_dir="${INSTALL_ROOT}" \
     --verbose \
     libnacl_sys_private \
     libpthread_private \
@@ -2795,7 +2748,7 @@ feature-version-file-install() {
   #
   # If you are adding a test that depends on a toolchain change, you
   # can increment this version number manually.
-  echo 4 > "${INSTALL_ROOT}/FEATURE_VERSION"
+  echo 5 > "${INSTALL_ROOT}/FEATURE_VERSION"
 }
 
 # The driver is a simple python script which changes its behavior
@@ -2863,7 +2816,7 @@ driver-install-translator() {
 
 DumpAllRevisions() {
   one-line-rev-info ${NACL_ROOT}
-  for d in ${PNACL_ROOT}/git/*/ ; do
+  for d in ${PNACL_GIT_ROOT}/*/ ; do
     one-line-rev-info $d
   done
 }
@@ -3111,7 +3064,7 @@ verify-archive-x86-64() {
 }
 
 #@-------------------------------------------------------------------------
-#+ verify                - Verifies that toolchain/pnacl-untrusted ELF files
+#+ verify                - Verifies that the pnacl-untrusted ELF files
 #+                         are of the correct architecture.
 verify() {
   StepBanner "VERIFY"
@@ -3195,8 +3148,6 @@ show-config() {
   env | grep PNACL
   Banner "uname info for builder:"
   uname -a
-  Banner "Revisions:"
-  DumpAllRevisions
 }
 
 #@ help                  - Usage information.
@@ -3210,7 +3161,7 @@ help-full() {
 }
 
 has-trusted-toolchain() {
-  if [ -f ${TOOLCHAIN_ROOT}/linux_arm-trusted/ld_script_arm_trusted ]; then
+  if [ -f ${TOOLCHAIN_BASE}/arm_trusted/ld_script_arm_trusted ]; then
     return 0
   else
     return 1
@@ -3390,7 +3341,6 @@ function-completions() {
 ######################################################################
 
 mkdir -p "${INSTALL_ROOT}"
-PackageCheck
 
 if [ $# = 0 ]; then set -- help; fi  # Avoid reference to undefined $1.