Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(203)

Side by Side Diff: ports/pnacl/build.sh

Issue 1607793004: Update pnacl toolchain version (Closed) Base URL: https://chromium.googlesource.com/webports.git@master
Patch Set: Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ports/pnacl-llvm-src/pkg_info ('k') | ports/pnacl/compiler_wrapper.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright (c) 2013 The Native Client Authors. All rights reserved. 1 # Copyright (c) 2013 The Native Client Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 EXECUTABLES="bin/arm-nacl-readelf bin/le32-nacl-strings bin/clang bin/clang++"
6 EnableGlibcCompat 5 EnableGlibcCompat
7 EnableCliMain 6 EnableCliMain
8 7
9 PatchStep() { 8 PatchStep() {
10 DefaultPatchStep 9 DefaultPatchStep
11 MakeDir ${SRC_DIR}/toolchain_build/src 10 MakeDir ${SRC_DIR}/toolchain_build/src
12 Remove ${SRC_DIR}/toolchain_build/src/llvm 11 Remove ${SRC_DIR}/toolchain_build/src/llvm
13 LogExecute ln -fs ${SRC_DIR}/../../pnacl-llvm-src/llvm \ 12 LogExecute ln -fs ${SRC_DIR}/../../pnacl-llvm-src/llvm \
14 ${SRC_DIR}/toolchain_build/src/llvm 13 ${SRC_DIR}/toolchain_build/src/llvm
15 Remove ${SRC_DIR}/toolchain_build/src/binutils 14 Remove ${SRC_DIR}/toolchain_build/src/binutils
16 LogExecute ln -fs ${SRC_DIR}/../../pnacl-binutils-src/binutils \ 15 LogExecute ln -fs ${SRC_DIR}/../../pnacl-binutils-src/binutils \
17 ${SRC_DIR}/toolchain_build/src/binutils 16 ${SRC_DIR}/toolchain_build/src/binutils
18 Remove ${SRC_DIR}/toolchain_build/src/clang 17 Remove ${SRC_DIR}/toolchain_build/src/clang
19 LogExecute ln -fs ${SRC_DIR}/../../pnacl-clang-src/clang \ 18 LogExecute ln -fs ${SRC_DIR}/../../pnacl-clang-src/clang \
20 ${SRC_DIR}/toolchain_build/src/clang 19 ${SRC_DIR}/toolchain_build/src/clang
21 Remove ${SRC_DIR}/toolchain_build/src/llvm/tools/clang 20 Remove ${SRC_DIR}/toolchain_build/src/llvm/tools/clang
22 LogExecute ln -fs ${SRC_DIR}/../../pnacl-clang-src/clang \ 21 LogExecute ln -fs ${SRC_DIR}/../../pnacl-clang-src/clang \
23 ${SRC_DIR}/toolchain_build/src/llvm/tools/clang 22 ${SRC_DIR}/toolchain_build/src/llvm/tools/clang
23 Remove ${SRC_DIR}/toolchain_build/src/binutils-x86
24 LogExecute ln -fs ${SRC_DIR}/../../pnacl-binutils-x86-src/binutils \
25 ${SRC_DIR}/toolchain_build/src/binutils-x86
24 } 26 }
25 27
26 ConfigureStep() { 28 ConfigureStep() {
27 return 29 return
28 } 30 }
29 31
30 OUT_DIR=${BUILD_DIR}/out 32 OUT_DIR=${BUILD_DIR}/out
31 OUT_BIN=${BUILD_DIR}/bin 33 OUT_INSTALL=${BUILD_DIR}/install
32 34
33 BuildStep() { 35 BuildStep() {
34 PNACL_DIR=${NACL_SDK_ROOT}/toolchain/linux_pnacl 36 PNACL_DIR=${NACL_SDK_ROOT}/toolchain/linux_pnacl
35 export PATH=${PNACL_DIR}/bin:${PATH} 37 export PATH=${PNACL_DIR}/bin:${PATH}
36 export LD_LIBRARY_PATH=${PNACL_DIR}/lib:${LD_LIBRARY_PATH:-} 38 export LD_LIBRARY_PATH=${PNACL_DIR}/lib:${LD_LIBRARY_PATH:-}
37 export BUILD_CC=clang 39 export BUILD_CC=clang
38 export BUILD_CXX=clang++ 40 export BUILD_CXX=clang++
39 41
40 export STRIPPROG=echo 42 export STRIPPROG=echo
41 43
(...skipping 18 matching lines...) Expand all
60 GOLD_LDADD+=" -lLLVMMCParser -lLLVMLinker -lLLVMipo -lLLVMObjCARCOpts" 62 GOLD_LDADD+=" -lLLVMMCParser -lLLVMLinker -lLLVMipo -lLLVMObjCARCOpts"
61 GOLD_LDADD+=" -lLLVMVectorize -lLLVMScalarOpts -lLLVMInstCombine" 63 GOLD_LDADD+=" -lLLVMVectorize -lLLVMScalarOpts -lLLVMInstCombine"
62 GOLD_LDADD+=" -lLLVMJSBackendCodeGen -lLLVMJSBackendDesc -lLLVMJSBackendInfo" 64 GOLD_LDADD+=" -lLLVMJSBackendCodeGen -lLLVMJSBackendDesc -lLLVMJSBackendInfo"
63 GOLD_LDADD+=" -lLLVMTransformUtils -lLLVMipa -lLLVMBitWriter" 65 GOLD_LDADD+=" -lLLVMTransformUtils -lLLVMipa -lLLVMBitWriter"
64 GOLD_LDADD+=" -lLLVMBitReader -lLLVMAnalysis -lLLVMTarget -lLLVMMC" 66 GOLD_LDADD+=" -lLLVMBitReader -lLLVMAnalysis -lLLVMTarget -lLLVMMC"
65 GOLD_LDADD+=" -lLLVMObject -lLLVMCore -lLLVMSupport" 67 GOLD_LDADD+=" -lLLVMObject -lLLVMCore -lLLVMSupport"
66 GOLD_LDADD+=" -Wl,--end-group" 68 GOLD_LDADD+=" -Wl,--end-group"
67 69
68 EXTRA_CONFIGURE="--extra-configure-arg=--disable-compiler-version-checks" 70 EXTRA_CONFIGURE="--extra-configure-arg=--disable-compiler-version-checks"
69 EXTRA_CONFIGURE+=" --extra-configure-arg=--enable-libcpp" 71 EXTRA_CONFIGURE+=" --extra-configure-arg=--enable-libcpp"
72 # Without this configure will detect vfork as missing and define
73 # vfork to fork which clobbers that define in "spawn.h".
74 EXTRA_CONFIGURE+=" --extra-configure-arg=ac_cv_func_vfork_works=yes"
75 EXTRA_CONFIGURE+=" --extra-configure-arg=ac_cv_func_getrusage=no"
76 if [[ ${NACL_DEBUG} == 1 ]]; then
77 EXTRA_CONFIGURE+=" --host-flavor=debug"
78 fi
70 79
71 # Some code in llvm uses intrisics not supported in the pnacl stable abi. 80 # Some code in llvm uses intrisics not supported in the pnacl stable abi.
72 if [[ ${TOOLCHAIN} == pnacl ]]; then 81 if [[ ${TOOLCHAIN} == pnacl ]]; then
73 EXTRA_CC_ARGS="-fgnu-inline-asm" 82 EXTRA_CC_ARGS="-fgnu-inline-asm"
74 EXTRA_CC_ARGS+=" --pnacl-disable-abi-check" 83 EXTRA_CC_ARGS+=" --pnacl-disable-abi-check"
75 fi 84 fi
76 if [[ ${TOOLCHAIN} != glibc ]]; then 85 if [[ ${TOOLCHAIN} != glibc ]]; then
77 EXTRA_CC_ARGS+=" -I${NACLPORTS_INCLUDE}/glibc-compat" 86 EXTRA_CC_ARGS+=" -I${NACLPORTS_INCLUDE}/glibc-compat"
78 fi 87 fi
79 88
80 LINUX_PNACL=${NACL_SDK_ROOT}/toolchain/linux_pnacl
81 EXTRA_CC_ARGS+=" -include spawn.h" 89 EXTRA_CC_ARGS+=" -include spawn.h"
82 EXTRA_CC_ARGS+=" -I${NACL_SDK_ROOT}/include" 90 EXTRA_CC_ARGS+=" -I${NACL_SDK_ROOT}/include"
83 EXTRA_CC_ARGS+=" -I${NACLPORTS_INCLUDE}" 91 EXTRA_CC_ARGS+=" -I${NACLPORTS_INCLUDE}"
84 92
85 # export EXTRA_LIBS so that compiler_wapper.py can access it 93 # export WEBPORTS_EXTRA_LIBS so that compiler_wapper.py can access it
86 export EXTRA_LIBS="${NACLPORTS_LDFLAGS} ${NACLPORTS_LIBS}" 94 export WEBPORTS_EXTRA_LIBS="${NACLPORTS_LDFLAGS} ${NACLPORTS_LIBS}"
87 echo "EXTRA_LIBS=${EXTRA_LIBS}" 95 echo "WEBPORTS_EXTRA_LIBS=${WEBPORTS_EXTRA_LIBS}"
88
89 # Without this configure will detect vfork as missing and define
90 # vfork to fork which clobbers that define in "spawn.h".
91 export ac_cv_func_vfork_works=yes
92 96
93 # Inject a shim that speed up pnacl invocations for configure. 97 # Inject a shim that speed up pnacl invocations for configure.
94 if [ "${NACL_ARCH}" = "pnacl" ]; then 98 if [ "${NACL_ARCH}" = "pnacl" ]; then
95 local PNACL_CONF_SHIM="${TOOLS_DIR}/pnacl-configure-shim.py" 99 local PNACL_CONF_SHIM="${TOOLS_DIR}/pnacl-configure-shim.py"
96 NACLCC="${PNACL_CONF_SHIM} ${NACLCC}" 100 NACLCC="${PNACL_CONF_SHIM} ${NACLCC}"
97 NACLCXX="${PNACL_CONF_SHIM} ${NACLCXX}" 101 NACLCXX="${PNACL_CONF_SHIM} ${NACLCXX}"
98 fi 102 fi
99 103
100 NACLCC="${START_DIR}/compiler_wrapper.py ${NACLCC}" 104 NACLCC="${START_DIR}/compiler_wrapper.py ${NACLCC}"
101 NACLCXX="${START_DIR}/compiler_wrapper.py ${NACLCXX}" 105 NACLCXX="${START_DIR}/compiler_wrapper.py ${NACLCXX}"
102 106
107 Remove ${OUT_INSTALL}
108 MakeDir ${OUT_INSTALL}
109
103 export CC=${NACLCC} 110 export CC=${NACLCC}
104 export CXX=${NACLCXX} 111 export CXX=${NACLCXX}
105 export AR=${NACLAR} 112 export AR=${NACLAR}
106 export RANLIB=${NACLRANLIB} 113 export RANLIB=${NACLRANLIB}
107 LogExecute ${SRC_DIR}/toolchain_build/toolchain_build_pnacl.py -v \ 114 LogExecute ${SRC_DIR}/toolchain_build/toolchain_build_pnacl.py -v \
108 --no-use-cached-results \ 115 --no-use-cached-results \
109 --no-use-remote-cache \ 116 --no-use-remote-cache \
110 --no-annotator \ 117 --no-annotator \
111 --pnacl-in-pnacl \ 118 --pnacl-in-pnacl \
112 --output=${OUT_DIR} \ 119 --output=${OUT_DIR} \
120 --install=${OUT_INSTALL} \
113 "--extra-cc-args=${EXTRA_CC_ARGS}" \ 121 "--extra-cc-args=${EXTRA_CC_ARGS}" \
114 ${EXTRA_CONFIGURE} \ 122 ${EXTRA_CONFIGURE} \
115 "--binutils-pnacl-extra-configure=${GOLD_LDADD}" 123 "--binutils-pnacl-extra-configure=${GOLD_LDADD}"
116 124
117 Remove ${OUT_BIN} 125 CreateHybridToolchain
118 MakeDir ${OUT_BIN} 126 }
119 LogExecute cp ${OUT_DIR}/llvm_le32_nacl_install/bin/* ${OUT_BIN} 127
120 LogExecute cp ${OUT_DIR}/binutils_pnacl_le32_nacl_install/bin/* \ 128 CreateHybridToolchain() {
121 ${OUT_BIN} 129 Banner "Creating Hybrid Toolchain"
122 # TODO(bradnelson): Drop this once shell script fix is done. 130
123 MakeDir ${OUT_BIN}/driver 131 # Build a full toolchain based on the one in NACL_SDK_ROOT, but overlayed
124 LogExecute cp ${SRC_DIR}/pnacl/driver/redirect.sh ${OUT_BIN}/driver/ 132 # with the one we just compiled.
125 LogExecute cp ${SRC_DIR}/pnacl/driver/*.py ${OUT_BIN}/driver/ 133 Remove toolchain
134 MakeDir toolchain
135
136 host_toolchain=${NACL_SDK_ROOT}/toolchain/linux_pnacl
137 LogExecute cp -r ${host_toolchain}/* toolchain
138
139 # Drop pyc files.
140 LogExecute find toolchain -name "*.pyc" -exec rm {} \;
141
142 # Overlay compiled toolchain
143 Remove ${OUT_INSTALL}/x86_64-nacl/lib/32
144 Remove ${OUT_INSTALL}/x86_64-nacl/lib64
145 LogExecute cp -r ${OUT_INSTALL}/* toolchain/
146
147 # Rename the nacl executables.
148 for f in $(cd ${host_toolchain} && find . -executable -type f); do
149 if [[ "$(file ${host_toolchain}/${f} | grep ELF)" != "" \
150 && ${f} != *pnacl-abicheck ]]; then
151 # We are dealing with an executable
152 local built_exe="${OUT_INSTALL}/${f}"
153 local exe="toolchain/${f}"
154 if [[ -f ${built_exe} ]]; then
155 LogExecute mv ${exe} ${exe}${NACL_EXEEXT}
156 elif [[ $f == *-clang* ]]; then
157 Remove ${exe}
158 LogExecute ln -sf clang${NACL_EXEEXT} ${exe}${NACL_EXEEXT}
159 else
160 echo "Warning: dropping ${f} without a nacl replacement."
161 LogExecute rm -f ${exe}
162 fi
163 fi
164 done
165
166 # Now create launcher scripts for each executable
167 for f in toolchain/bin/*${NACL_EXEEXT}; do
168 script=${f%.*}
169 if [[ ${TOOLCHAIN} == pnacl ]]; then
170 TranslateAndWriteLauncherScript "${f}" x86-64 "${script}.nexe" "${script}"
171 else
172 WriteLauncherScript "${script}" "$(basename ${f})"
173 fi
174 done
175
176 # Drop parts we don't care about
177 LogExecute rm -rf toolchain/translator
178 LogExecute rm -rf toolchain/mipsel-nacl
179 LogExecute rm -rf toolchain/*-nacl/usr
180 LogExecute rm -f toolchain/bin/mipsel-*
181 LogExecute rm -f toolchain/lib/*.so
126 } 182 }
127 183
128 InstallStep() { 184 InstallStep() {
129 local INSTALL_DIR=${DESTDIR}/${PREFIX}/pnacl 185 local INSTALL_DIR=${DESTDIR}/${PREFIX}/pnacl
130 Remove ${INSTALL_DIR}/ 186 Remove ${INSTALL_DIR}/
131 MakeDir ${INSTALL_DIR}/ 187 MakeDir ${INSTALL_DIR}/
132 188
133 LogExecute cp -r ${NACL_SDK_ROOT}/toolchain/linux_pnacl/* ${INSTALL_DIR} 189 LogExecute cp -r toolchain/* ${INSTALL_DIR}
134 190 for f in $(find ${INSTALL_DIR} -type l -name *-clang*${NACL_EXEEXT}); do
135 # Drop pyc files. 191 # link to clang binary
136 LogExecute find ${INSTALL_DIR} -name "*.pyc" -exec rm {} \; 192 Remove $f ${f%.*}
137 193 LogExecute ln -s clang ${f%.*}
138 LogExecute rm -rf ${INSTALL_DIR}/mipsel-nacl 194 done
139 LogExecute rm -rf ${INSTALL_DIR}/translator 195 for f in $(find ${INSTALL_DIR} -executable -type f -name *${NACL_EXEEXT}); do
140 LogExecute rm -rf ${INSTALL_DIR}/*-nacl/usr 196 LogExecute mv $f ${f%.*}
141
142 # TODO(bradnelson): Drop this once shell script fix is done.
143 LogExecute cp ${OUT_BIN}/driver/*.py ${INSTALL_DIR}/bin/pydir/
144
145 # Swap in nacl executables.
146 Remove ${INSTALL_DIR}/lib/*.so
147 for f in $(find ${INSTALL_DIR} -executable -type f); do
148 if [ "$(file ${f} | grep ELF)" != "" ]; then
149 local exe="${OUT_BIN}/$(basename ${f})"
150 if [[ -f ${exe} ]]; then
151 if [[ ${TOOLCHAIN} == pnacl ]]; then
152 echo "Finalizing ${exe}"
153 ${PNACLFINALIZE} ${exe} -o ${f}
154 else
155 echo "Copying ${exe}"
156 cp ${exe} ${f}
157 fi
158 elif [[ $f == *-clang* ]]; then
159 LogExecute ln -sf ${f} $(basename ${f})
160 else
161 echo "Warning: dropping ${f} without a nacl replacement."
162 LogExecute rm -f ${f}
163 fi
164 elif [ "$(head -n 1 ${f} | grep /bin/sh)" != "" ]; then
165 # TODO(bradnelson): Drop this once shell script fix is done.
166 LogExecute cp -f ${OUT_BIN}/driver/redirect.sh ${f}
167 LogExecute chmod a+x ${f}
168 fi
169 done 197 done
170 } 198 }
171 199
172 PostInstallTestStep() { 200 TestStep() {
173 # Verify that binaries at least load under sel_ldr 201 # Verify that binaries at least load under sel_ldr
174 LogExecute ./bin/le32-nacl-strings.sh --version 202 LogExecute toolchain/bin/le32-nacl-strings --version
175 LogExecute ./bin/arm-nacl-readelf.sh --version 203 LogExecute toolchain/bin/arm-nacl-readelf --version
176 LogExecute ./bin/clang.sh --version 204 LogExecute toolchain/bin/x86_64-nacl-as --version
205 LogExecute toolchain/bin/clang --version
206
207 # The end-to-end tests doesn't currently work for PNaCl
208 if [[ $TOOLCHAIN == pnacl ]]; then
209 return
210 fi
211 TestNaClClang
177 } 212 }
213
214 TestNaClClang() {
215 # Try compiling and running a simple hello world program. We have to
216 # use explicit compile, assemble and link commands since sel_ldr doesn't
217 # provide fork().
218
219 compile_command="toolchain/bin/x86_64-nacl-clang -cc1 -triple x86_64--nacl
220 -S -disable-free -main-file-name ${START_DIR}/hello.c -mrelocation-model
221 static -mthread-model posix -mdisable-fp-elim -fmath-errno -no-integrated-as
222 -mconstructor-aliases -munwind-tables -fuse-init-array -target-cpu x86-64
223 -target-linker-version 2.24 -v -dwarf-column-info
224 -resource-dir $PWD/toolchain/bin/../lib/clang/3.7.0
225 -internal-isystem $PWD/toolchain/bin/../lib/clang/3.7.0/include
226 -internal-isystem $PWD/toolchain/bin/../x86_64-nacl/usr/include
227 -internal-isystem $PWD/toolchain/bin/../x86_64-nacl/include
228 -fno-dwarf-directory-asm -ferror-limit 19 -fmessage-length 0 -mstackrealign
229 -fobjc-runtime=gcc -fdiagnostics-show-option -o hello.s -x c
230 ${START_DIR}/hello.c
231 "
232 LogExecute $compile_command
233
234 LogExecute toolchain/bin/x86_64-nacl-as --64 hello.s -o hello.o
235 link_command="toolchain/x86_64-nacl/bin/ld --build-id -m
236 elf_x86_64_nacl -static -o hello.nexe
237 $PWD/toolchain/bin/../x86_64-nacl/lib/crt1.o
238 $PWD/toolchain/bin/../x86_64-nacl/lib/crti.o
239 $PWD/toolchain/bin/../lib/clang/3.7.0/lib/x86_64-nacl/crtbeginT.o
240 -L$PWD/toolchain/bin/../x86_64-nacl/lib
241 -L$PWD/toolchain/bin/../x86_64-nacl/usr/lib
242 -L$PWD/toolchain/bin/../lib/clang/3.7.0/lib/x86_64-nacl
243 ./hello.o --start-group -lc -lgcc --as-needed -lgcc_eh --no-as-needed
244 --end-group
245 $PWD/toolchain/bin/../lib/clang/3.7.0/lib/x86_64-nacl/crtend.o
246 $PWD/toolchain/bin/../x86_64-nacl/lib/crtn.o
247 "
248 LogExecute $link_command
249 RunSelLdrCommand hello.nexe
250 }
OLDNEW
« no previous file with comments | « ports/pnacl-llvm-src/pkg_info ('k') | ports/pnacl/compiler_wrapper.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698