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 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 | 59 |
60 readonly PNACL_MAKE_OPTS="${PNACL_MAKE_OPTS:-}" | 60 readonly PNACL_MAKE_OPTS="${PNACL_MAKE_OPTS:-}" |
61 readonly MAKE_OPTS="-j${PNACL_CONCURRENCY} VERBOSE=1 ${PNACL_MAKE_OPTS}" | 61 readonly MAKE_OPTS="-j${PNACL_CONCURRENCY} VERBOSE=1 ${PNACL_MAKE_OPTS}" |
62 | 62 |
63 readonly NONEXISTENT_PATH="/going/down/the/longest/road/to/nowhere" | 63 readonly NONEXISTENT_PATH="/going/down/the/longest/road/to/nowhere" |
64 | 64 |
65 # Git sources | 65 # Git sources |
66 readonly PNACL_GIT_ROOT="${NACL_ROOT}/toolchain_build/src" | 66 readonly PNACL_GIT_ROOT="${NACL_ROOT}/toolchain_build/src" |
67 readonly TC_SRC_BINUTILS="${PNACL_GIT_ROOT}/binutils" | 67 readonly TC_SRC_BINUTILS="${PNACL_GIT_ROOT}/binutils" |
68 readonly TC_SRC_LLVM="${PNACL_GIT_ROOT}/llvm" | 68 readonly TC_SRC_LLVM="${PNACL_GIT_ROOT}/llvm" |
| 69 readonly TC_SRC_SUBZERO="${PNACL_GIT_ROOT}/subzero" |
69 | 70 |
70 readonly TOOLCHAIN_BUILD_OUT="${NACL_ROOT}/toolchain_build/out" | 71 readonly TOOLCHAIN_BUILD_OUT="${NACL_ROOT}/toolchain_build/out" |
71 | 72 |
72 readonly TIMESTAMP_FILENAME="make-timestamp" | 73 readonly TIMESTAMP_FILENAME="make-timestamp" |
73 | 74 |
74 # PNaCl toolchain installation directories (absolute paths) | 75 # PNaCl toolchain installation directories (absolute paths) |
75 readonly SDK_INSTALL_ROOT="${TOOLCHAIN_BASE}/pnacl_newlib" | 76 readonly SDK_INSTALL_ROOT="${TOOLCHAIN_BASE}/pnacl_newlib" |
76 readonly INSTALL_ROOT="${TOOLCHAIN_BUILD_OUT}/translator_compiler_install" | 77 readonly INSTALL_ROOT="${TOOLCHAIN_BUILD_OUT}/translator_compiler_install" |
77 readonly INSTALL_BIN="${INSTALL_ROOT}/bin" | 78 readonly INSTALL_BIN="${INSTALL_ROOT}/bin" |
78 | 79 |
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
344 | 345 |
345 # llvm-sb-make - Make llvm tools (sandboxed) | 346 # llvm-sb-make - Make llvm tools (sandboxed) |
346 llvm-sb-make() { | 347 llvm-sb-make() { |
347 local arch=$1 | 348 local arch=$1 |
348 StepBanner "LLVM-SB" "Make ${arch}" | 349 StepBanner "LLVM-SB" "Make ${arch}" |
349 local objdir="${LLVM_SB_OBJDIR}" | 350 local objdir="${LLVM_SB_OBJDIR}" |
350 | 351 |
351 spushd "${objdir}" | 352 spushd "${objdir}" |
352 ts-touch-open "${objdir}" | 353 ts-touch-open "${objdir}" |
353 | 354 |
354 local tools_to_build="pnacl-llc" | 355 local tools_to_build="pnacl-llc subzero" |
355 local export_dyn_env="llvm_cv_link_use_export_dynamic=no" | 356 local export_dyn_env="llvm_cv_link_use_export_dynamic=no" |
356 local isjit=0 | 357 local isjit=0 |
357 RunWithLog ${LLVM_SB_LOG_PREFIX}.make \ | 358 RunWithLog ${LLVM_SB_LOG_PREFIX}.make \ |
358 env -i PATH="/usr/bin:/bin:${HOST_CLANG_PATH}" \ | 359 env -i PATH="/usr/bin:/bin:${HOST_CLANG_PATH}" \ |
359 LD_LIBRARY_PATH="${HOST_LIBCXX}/lib" \ | 360 LD_LIBRARY_PATH="${HOST_LIBCXX}/lib" \ |
360 ONLY_TOOLS="${tools_to_build}" \ | 361 ONLY_TOOLS="${tools_to_build}" \ |
361 PNACL_BROWSER_TRANSLATOR=1 \ | 362 PNACL_BROWSER_TRANSLATOR=1 \ |
362 KEEP_SYMBOLS=1 \ | 363 KEEP_SYMBOLS=1 \ |
363 NO_DEAD_STRIP=1 \ | 364 NO_DEAD_STRIP=1 \ |
364 VERBOSE=1 \ | 365 VERBOSE=1 \ |
365 BUILD_CC="${HOST_CLANG}" \ | 366 SUBZERO_SRC_ROOT="${TC_SRC_SUBZERO}" \ |
366 BUILD_CXX="${HOST_CLANG}++" \ | 367 BUILD_CC="${HOST_CLANG}" \ |
367 BUILD_CXXFLAGS="-stdlib=libc++ -I${HOST_LIBCXX}/include/c++/v1" \ | 368 BUILD_CXX="${HOST_CLANG}++" \ |
368 BUILD_LDFLAGS="-L${HOST_LIBCXX}/lib" \ | 369 BUILD_CXXFLAGS="-stdlib=libc++ -I${HOST_LIBCXX}/include/c++/v1" \ |
| 370 BUILD_LDFLAGS="-L${HOST_LIBCXX}/lib" \ |
369 ${export_dyn_env} \ | 371 ${export_dyn_env} \ |
370 make ${MAKE_OPTS} tools-only | 372 make ${MAKE_OPTS} tools-only |
371 | 373 |
372 ts-touch-commit "${objdir}" | 374 ts-touch-commit "${objdir}" |
373 | 375 |
374 spopd | 376 spopd |
375 } | 377 } |
376 | 378 |
377 # llvm-sb-install - Install llvm tools (sandboxed) | 379 # llvm-sb-install - Install llvm tools (sandboxed) |
378 llvm-sb-install() { | 380 llvm-sb-install() { |
379 local arch=$1 | 381 local arch=$1 |
380 StepBanner "LLVM-SB" "Install ${arch}" | 382 StepBanner "LLVM-SB" "Install ${arch}" |
381 | 383 |
382 local toolname="pnacl-llc" | |
383 local installdir="$(GetTranslatorInstallDir ${arch})"/bin | 384 local installdir="$(GetTranslatorInstallDir ${arch})"/bin |
384 mkdir -p "${installdir}" | 385 mkdir -p "${installdir}" |
385 spushd "${installdir}" | 386 spushd "${installdir}" |
386 local objdir="${LLVM_SB_OBJDIR}" | 387 local objdir="${LLVM_SB_OBJDIR}" |
387 cp -f "${objdir}"/Release*/bin/${toolname} . | 388 |
388 mv -f ${toolname} ${toolname}.pexe | 389 local tools="pnacl-llc" |
389 local arches=${arch} | 390 if [[ "${arch}" == "i686" ]]; then |
390 if [[ "${arch}" == "universal" ]]; then | 391 tools+=" pnacl-sz" |
391 arches="${SBTC_ARCHES_ALL}" | |
392 elif [[ "${arch}" == "i686" ]]; then | |
393 # LLVM does not separate the i686 and x86_64 backends. | |
394 # Translate twice to get both nexes. | |
395 arches="i686 x86_64" | |
396 fi | 392 fi |
397 local have_segment_gap="false" | 393 for toolname in ${tools}; do |
398 translate-sb-tool ${toolname} "${arches}" "${have_segment_gap}" | 394 cp -f "${objdir}"/Release*/bin/${toolname} . |
399 install-sb-tool ${toolname} "${arches}" | 395 mv -f ${toolname} ${toolname}.pexe |
| 396 local arches=${arch} |
| 397 if [[ "${arch}" == "universal" ]]; then |
| 398 arches="${SBTC_ARCHES_ALL}" |
| 399 elif [[ "${arch}" == "i686" ]]; then |
| 400 # LLVM does not separate the i686 and x86_64 backends. |
| 401 # Translate twice to get both nexes. |
| 402 arches="i686 x86_64" |
| 403 fi |
| 404 local have_segment_gap="false" |
| 405 if [ "${toolname}" == "pnacl-sz" ]; then |
| 406 have_segment_gap="true" |
| 407 fi |
| 408 translate-sb-tool ${toolname} "${arches}" "${have_segment_gap}" |
| 409 install-sb-tool ${toolname} "${arches}" |
| 410 done |
400 spopd | 411 spopd |
401 } | 412 } |
402 | 413 |
403 # translate-sb-tool <toolname> <arches> <have_segment_gap> | 414 # translate-sb-tool <toolname> <arches> <have_segment_gap> |
404 # | 415 # |
405 # Translate <toolname>.pexe to <toolname>.<arch>.nexe in the current directory. | 416 # Translate <toolname>.pexe to <toolname>.<arch>.nexe in the current directory. |
406 translate-sb-tool() { | 417 translate-sb-tool() { |
407 local toolname=$1 | 418 local toolname=$1 |
408 local arches=$2 | 419 local arches=$2 |
409 local have_segment_gap=$3 | 420 local have_segment_gap=$3 |
(...skipping 594 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1004 | 1015 |
1005 if [ "$(type -t $1)" != "function" ]; then | 1016 if [ "$(type -t $1)" != "function" ]; then |
1006 #Usage | 1017 #Usage |
1007 echo "ERROR: unknown function '$1'." >&2 | 1018 echo "ERROR: unknown function '$1'." >&2 |
1008 echo "For help, try:" | 1019 echo "For help, try:" |
1009 echo " $0 help" | 1020 echo " $0 help" |
1010 exit 1 | 1021 exit 1 |
1011 fi | 1022 fi |
1012 | 1023 |
1013 "$@" | 1024 "$@" |
OLD | NEW |