33
33
# whether the C++ driver and driver-driver are installed
34
34
LANGUAGES=${LANGUAGES-c,objc,c++,obj-c++}
35
35
36
- # The B&I build srcript (~rc/bin/buildit) accepts an '-othercflags'
36
+ # The B&I build script (~rc/bin/buildit) accepts an '-othercflags'
37
37
# command-line flag, and captures the argument to that flag in
38
38
# $RC_NONARCH_CFLAGS (and mysteriously prepends '-pipe' thereto).
39
39
# We will allow this to override the default $CFLAGS and $CXXFLAGS.
79
79
# to be built. It's VERS but only up to the second '.' (if there is one).
80
80
MAJ_VERS=` echo $VERS | sed ' s/\([0-9]*\.[0-9]*\)[.-].*/\1/' `
81
81
82
- # APPLE LOCAL begin ARM ARM_CONFIGFLAGS
83
- # For ARM, grab all system files from an SDK.
84
- ARM_SYSROOT=" /Developer/SDKs/Extra"
85
- ARM_LIBSTDCXX_VERSION=4.2.1
86
- ARM_CONFIGFLAGS=" --with-build-sysroot=\" $ARM_SYSROOT \" \
87
- --with-gxx-include-dir=\$ {prefix}/include/c++/$ARM_LIBSTDCXX_VERSION "
88
- # APPLE LOCAL end ARM ARM_CONFIGFLAGS
89
-
90
82
# This is the libstdc++ version to use.
91
83
LIBSTDCXX_VERSION=4.2.1
92
84
if [ ! -d " $DEST_ROOT /include/c++/$LIBSTDCXX_VERSION " ]; then
@@ -97,6 +89,66 @@ NON_ARM_CONFIGFLAGS="--with-gxx-include-dir=\${prefix}/include/c++/$LIBSTDCXX_VE
97
89
DARWIN_VERS=` uname -r | sed ' s/\..*//' `
98
90
echo DARWIN_VERS = $DARWIN_VERS
99
91
92
+ # APPLE LOCAL begin ARM
93
+ ARM_LIBSTDCXX_VERSION=4.2.1
94
+ ARM_CONFIGFLAGS=" --with-gxx-include-dir=/usr/include/c++/$ARM_LIBSTDCXX_VERSION "
95
+
96
+ if [ -n " $ARM_SDK " ]; then
97
+
98
+ ARM_PLATFORM=` xcodebuild -version -sdk $ARM_SDK PlatformPath`
99
+ ARM_SYSROOT=` xcodebuild -version -sdk $ARM_SDK Path`
100
+ ARM_TOOLROOT=$ARM_PLATFORM /Developer
101
+
102
+ elif [ " x$RC_TARGET_CONFIG " = " xiPhone" ]; then
103
+
104
+ # If the build target is iPhone, use the iPhone SDK as the build sysroot
105
+ # and use the tools from the iPhone platform directory. FIXME: This is a
106
+ # temporary fallback for builds where ARM_SDK is not set. It can be removed,
107
+ # along with the following bootstrap SDK fallback, when ARM_SDK is set for
108
+ # all builds.
109
+ ARM_PLATFORM=/Developer/Platforms/iPhoneOS.platform
110
+ ARM_IPHONE_SDK=iPhoneOS${IPHONEOS_DEPLOYMENT_TARGET} .Internal.sdk
111
+
112
+ ARM_SYSROOT=$ARM_PLATFORM /Developer/SDKs/$ARM_IPHONE_SDK
113
+ ARM_TOOLROOT=$ARM_PLATFORM /Developer
114
+
115
+ else
116
+
117
+ # Use bootstrap SDK if it is available.
118
+ if [ -d /Developer/SDKs/Extra ]; then
119
+ ARM_SYSROOT=/Developer/SDKs/Extra
120
+ else
121
+ ARM_SYSROOT=/
122
+ fi
123
+ ARM_TOOLROOT=/
124
+
125
+ fi
126
+ ARM_CONFIGFLAGS=" $ARM_CONFIGFLAGS --with-build-sysroot=\" $ARM_SYSROOT \" "
127
+
128
+ # If building an ARM target, check that the required directories exist
129
+ # and query the libSystem arm slices to determine which multilibs we should
130
+ # build.
131
+ if echo $TARGETS | grep arm; then
132
+ if [ ! -d $ARM_SYSROOT ]; then
133
+ echo " Error: cannot find ARM SDK to build ARM target"
134
+ exit 1
135
+ fi
136
+ if [ ! -d $ARM_TOOLROOT ]; then
137
+ echo " Error: $ARM_TOOLROOT directory is not installed"
138
+ exit 1
139
+ fi
140
+ if [ " x$ARM_MULTILIB_ARCHS " = " x" ] ; then
141
+ ARM_MULTILIB_ARCHS=` /usr/bin/lipo -info $ARM_SYSROOT /usr/lib/libSystem.dylib | cut -d' :' -f 3 | sed -e ' s/x86_64//' -e ' s/i386//' -e ' s/ppc7400//' -e ' s/ppc64//' -e ' s/^ *//' -e ' s/ $//' `
142
+ fi ;
143
+ if [ " x$ARM_MULTILIB_ARCHS " == " x" ] ; then
144
+ echo " Error: missing ARM slices in $ARM_SYSROOT "
145
+ exit 1
146
+ else
147
+ export ARM_MULTILIB_ARCHS
148
+ fi
149
+ fi
150
+ # APPLE LOCAL end ARM
151
+
100
152
# If the user has CC set in their environment unset it now
101
153
unset CC
102
154
@@ -159,9 +211,9 @@ unset LANGUAGES
159
211
mkdir -p $DIR /obj-$BUILD -$BUILD $DIR /dst-$BUILD -$BUILD || exit 1
160
212
cd $DIR /obj-$BUILD -$BUILD || exit 1
161
213
if [ \! -f Makefile ]; then
162
- $SRC_DIR /configure $bootstrap $CONFIGFLAGS \
163
- $NON_ARM_CONFIGFLAGS \
164
- --host= $BUILD -apple-darwin $DARWIN_VERS -- target=$BUILD -apple-darwin$DARWIN_VERS || exit 1
214
+ $SRC_DIR /configure $bootstrap $CONFIGFLAGS $NON_ARM_CONFIGFLAGS \
215
+ --host= $BUILD -apple-darwin $DARWIN_VERS \
216
+ --target=$BUILD -apple-darwin$DARWIN_VERS || exit 1
165
217
fi
166
218
# Unset RC_DEBUG_OPTIONS because it causes the bootstrap to fail.
167
219
# Also keep unset for cross compilers so that the cross built libraries are
@@ -187,18 +239,34 @@ mkdir $DIR/bin || exit 1
187
239
for prog in ar nm ranlib strip lipo ld ; do
188
240
for t in ` echo $TARGETS $HOSTS | sort -u` ; do
189
241
P=$DIR /bin/${t} -apple-darwin$DARWIN_VERS -${prog}
242
+ # APPLE LOCAL begin toolroot
243
+ if [ $t = " arm" ]; then
244
+ toolroot=$ARM_TOOLROOT
245
+ else
246
+ toolroot=
247
+ fi
248
+ # APPLE LOCAL end toolroot
190
249
echo ' #!/bin/sh' > $P || exit 1
191
- echo ' exec /usr/bin/' ${prog} ' "$@"' >> $P || exit 1
250
+ # APPLE LOCAL insert toolroot below
251
+ echo ' exec ' ${toolroot} ' /usr/bin/' ${prog} ' "$@"' >> $P || exit 1
192
252
chmod a+x $P || exit 1
193
253
done
194
254
done
195
255
for t in ` echo $1 $2 | sort -u` ; do
196
256
gt=` echo $t | $TRANSLATE_ARCH `
197
257
P=$DIR /bin/${gt} -apple-darwin$DARWIN_VERS -as
258
+ # APPLE LOCAL begin toolroot
259
+ if [ $gt = " arm" ]; then
260
+ toolroot=$ARM_TOOLROOT
261
+ else
262
+ toolroot=
263
+ fi
264
+ # APPLE LOCAL end toolroot
198
265
echo ' #!/bin/sh' > $P || exit 1
199
266
200
- echo ' for a; do case $a in -arch) exec /usr/bin/as "$@";; esac; done' >> $P || exit 1
201
- echo ' exec /usr/bin/as -arch ' ${t} ' "$@"' >> $P || exit 1
267
+ # APPLE LOCAL insert toolroot below
268
+ echo ' for a; do case $a in -arch) exec ' ${toolroot} ' /usr/bin/as "$@";; esac; done' >> $P || exit 1
269
+ echo ' exec ' ${toolroot} ' /usr/bin/as -arch ' ${t} ' "$@"' >> $P || exit 1
202
270
chmod a+x $P || exit 1
203
271
done
204
272
PATH=$DIR /bin:$PATH
@@ -219,17 +287,26 @@ for t in $CROSS_TARGETS ; do
219
287
cd $DIR /obj-$BUILD -$t || exit 1
220
288
if [ \! -f Makefile ]; then
221
289
# APPLE LOCAL begin ARM ARM_CONFIGFLAGS
222
- $SRC_DIR /configure $CONFIGFLAGS --enable-werror-always \
223
- ` if [ $t = ' arm' ] ; then echo $ARM_CONFIGFLAGS ; else echo $NON_ARM_CONFIGFLAGS ; fi` \
290
+ T_CONFIGFLAGS=" $CONFIGFLAGS --enable-werror-always \
224
291
--program-prefix=$t -apple-darwin$DARWIN_VERS - \
225
- --host=$BUILD -apple-darwin$DARWIN_VERS --target=$t -apple-darwin$DARWIN_VERS || exit 1
292
+ --host=$BUILD -apple-darwin$DARWIN_VERS \
293
+ --target=$t -apple-darwin$DARWIN_VERS "
294
+ if [ $t = ' arm' ] ; then
295
+ # Explicitly set AS_FOR_TARGET and LD_FOR_TARGET to avoid picking up
296
+ # older versions from the gcc installed in /usr. Radar 7230843.
297
+ AS_FOR_TARGET=$DIR /bin/${t} -apple-darwin$DARWIN_VERS -as \
298
+ LD_FOR_TARGET=$DIR /bin/${t} -apple-darwin$DARWIN_VERS -ld \
299
+ $SRC_DIR /configure $T_CONFIGFLAGS $ARM_CONFIGFLAGS || exit 1
300
+ else
301
+ $SRC_DIR /configure $T_CONFIGFLAGS $NON_ARM_CONFIGFLAGS || exit 1
302
+ fi
226
303
# APPLE LOCAL end ARM ARM_CONFIGFLAGS
227
304
fi
228
305
make $MAKEFLAGS all CFLAGS=" $CFLAGS " CXXFLAGS=" $CFLAGS " || exit 1
229
306
make $MAKEFLAGS DESTDIR=$DIR /dst-$BUILD -$t install-gcc install-target \
230
307
CFLAGS=" $CFLAGS " CXXFLAGS=" $CFLAGS " || exit 1
231
308
232
- # Add the compiler we just built to the path.
309
+ # Add the compiler we just built to the path.
233
310
PATH=$DIR /dst-$BUILD -$t /usr/bin:$PATH
234
311
fi
235
312
done
@@ -263,12 +340,25 @@ for h in $HOSTS ; do
263
340
264
341
if [ \! -f Makefile ]; then
265
342
# APPLE LOCAL begin ARM ARM_CONFIGFLAGS
266
- $SRC_DIR /configure $CONFIGFLAGS \
267
- ` if [ $t = ' arm' ] && [ $h != ' arm' ] ; then echo $ARM_CONFIGFLAGS ; else echo $NON_ARM_CONFIGFLAGS ; fi` \
268
- --program-prefix=$pp \
269
- --host=$h -apple-darwin$DARWIN_VERS --target=$t -apple-darwin$DARWIN_VERS || exit 1
343
+ T_CONFIGFLAGS=" $CONFIGFLAGS --program-prefix=$pp \
344
+ --host=$h -apple-darwin$DARWIN_VERS \
345
+ --target=$t -apple-darwin$DARWIN_VERS "
346
+ if [ $t = ' arm' ] && [ $h != ' arm' ] ; then
347
+ T_CONFIGFLAGS=" $T_CONFIGFLAGS $ARM_CONFIGFLAGS "
348
+ else
349
+ T_CONFIGFLAGS=" $T_CONFIGFLAGS $NON_ARM_CONFIGFLAGS "
350
+ fi
351
+ $SRC_DIR /configure $T_CONFIGFLAGS || exit 1
270
352
# APPLE LOCAL end ARM ARM_CONFIGFLAGS
271
353
fi
354
+
355
+ # For ARM, we need to make sure it picks up the ARM_TOOLROOT versions
356
+ # of the linker and cctools.
357
+ if [ $t = ' arm' ] ; then
358
+ ORIG_COMPILER_PATH=$COMPILER_PATH
359
+ export COMPILER_PATH=$ARM_TOOLROOT /usr/bin:$COMPILER_PATH
360
+ fi
361
+
272
362
if [ $h = $t ] ; then
273
363
make $MAKEFLAGS all CFLAGS=" $CFLAGS " CXXFLAGS=" $CFLAGS " || exit 1
274
364
make $MAKEFLAGS DESTDIR=$DIR /dst-$h -$t install-gcc install-target \
@@ -278,6 +368,11 @@ for h in $HOSTS ; do
278
368
make $MAKEFLAGS DESTDIR=$DIR /dst-$h -$t install-gcc \
279
369
CFLAGS=" $CFLAGS " CXXFLAGS=" $CFLAGS " || exit 1
280
370
fi
371
+
372
+ if [ $t = ' arm' ] ; then
373
+ export COMPILER_PATH=$ORIG_COMPILER_PATH
374
+ unset ORIG_COMPILER_PATH
375
+ fi
281
376
done
282
377
fi
283
378
done
0 commit comments