llvm.org GIT mirror llvm / 1b8eeb3
Update Apple's build script for llvmCore. <rdar://problem/12914321> This change is basically just copying changes that we've used for Apple's clang builds to the script used for building llvmCore. Besides cleaning it up to use xcrun to locate the proper versions of tools, especially for cross compiling, it fixes the build to work with newer versions of clang that honor SDKROOT settings in the environment. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@172138 91177308-0d34-0410-b5e6-96231b3b80d8 Bob Wilson 6 years ago
1 changed file(s) with 69 addition(s) and 67 deletion(s). Raw diff Collapse all Expand all
7676 # Now create our own by editing the top-level Makefile, deleting every line marked "Apple-style":
7777 sed -e '/[Aa]pple-style/d' -e '/include.*GNUmakefile/d' $ORIG_SRC_DIR/Makefile > $SRC_DIR/Makefile || exit 1
7878
79 SUBVERSION=`echo $RC_ProjectSourceVersion | sed -e 's/.*\.\([0-9]*\).*/\1/'`
80 if [ "x$SUBVERSION" != "x$RC_ProjectSourceVersion" ]; then
81 LLVM_SUBMIT_SUBVERSION=`printf "%02d" $SUBVERSION`
82 RC_ProjectSourceVersion=`echo $RC_ProjectSourceVersion | sed -e 's/\..*//'`
83 LLVM_SUBMIT_VERSION=$RC_ProjectSourceVersion
84 fi
85 if [ "x$LLVM_SUBMIT_SUBVERSION" = "x00" -o "x$LLVM_SUBMIT_SUBVERSION" = "x0" ]; then
86 LLVM_VERSION="$LLVM_SUBMIT_VERSION"
87 else
88 LLVM_VERSION="$LLVM_SUBMIT_VERSION-$LLVM_SUBMIT_SUBVERSION"
89 fi
90 LLVM_VERSION_INFO="'\" Apple Build #$LLVM_VERSION\"'"
91
92 # Figure out how many make processes to run.
93 SYSCTL=`sysctl -n hw.activecpu`
94 # sysctl -n hw.* does not work when invoked via B&I chroot /BuildRoot.
95 # Builders can default to 2, since even if they are single processor,
96 # nothing else is running on the machine.
97 if [ -z "$SYSCTL" ]; then
98 SYSCTL=2
99 fi
100 JOBS_FLAG="-j $SYSCTL"
101
102 COMMON_CONFIGURE_OPTS="\
103 --prefix=$DEST_DIR$DEST_ROOT \
104 --enable-assertions=$LLVM_ASSERTIONS \
105 --enable-optimized=$LLVM_OPTIMIZED \
106 --disable-bindings"
107
108 COMMON_MAKEFLAGS=$JOBS_FLAG $OPTIMIZE_OPTS UNIVERSAL=1 UNIVERSAL_ARCH="$HOSTS" UNIVERSAL_SDK_PATH=$SDKROOT NO_RUNTIME_LIBS=1 DISABLE_EDIS=1 REQUIRES_RTTI=1 DEBUG_SYMBOLS=1 LLVM_SUBMIT_VERSION=$LLVM_SUBMIT_VERSION LLVM_SUBMIT_SUBVERSION=$LLVM_SUBMIT_SUBVERSION CXXFLAGS=-DLLVM_VERSION_INFO="$LLVM_VERSION_INFO" VERBOSE=1
109
79110 # Build the LLVM tree universal.
80111 mkdir -p $DIR/obj-llvm || exit 1
81112 cd $DIR/obj-llvm || exit 1
88119 for prog in ar nm ranlib strip lipo ld as ; do
89120 P=$DIR/bin/arm-apple-darwin$DARWIN_VERS-${prog}
90121 T=`xcrun -sdk $SDKROOT -find ${prog}`
122 ln -s $T $DIR/bin/$prog
91123 echo '#!/bin/sh' > $P || exit 1
92124 echo 'exec '$T' "$@"' >> $P || exit 1
93125 chmod a+x $P || exit 1
96128 for prog in clang clang++ ; do
97129 P=$DIR/bin/arm-apple-darwin$DARWIN_VERS-${prog}
98130 T=`xcrun -sdk $SDKROOT -find ${prog}`
131 ln -s $T $DIR/bin/$prog
99132 echo '#!/bin/sh' > $P || exit 1
100133 echo 'exec '$T' -arch armv7 -isysroot '${SDKROOT}' "$@"' >> $P || exit 1
101134 chmod a+x $P || exit 1
102135 done
103136
104137 PATH=$DIR/bin:$PATH
105 fi
106
107 if [ "$ARM_HOSTED_BUILD" = yes ]; then
108 configure_opts="--enable-targets=arm --host=arm-apple-darwin10 \
109 --target=arm-apple-darwin10 --build=i686-apple-darwin10"
110 elif [ "$IOS_SIM_BUILD" = yes ]; then
111 # Use a non-standard "darwin_sim" host triple to trigger a cross-build.
112 configure_opts="--enable-targets=x86 --host=i686-apple-darwin_sim \
113 --build=i686-apple-darwin10"
138
139 unset SDKROOT && \
140 $SRC_DIR/configure $COMMON_CONFIGURE_OPTS \
141 --enable-targets=arm \
142 --host=arm-apple-darwin10 \
143 --target=arm-apple-darwin10 \
144 --build=i686-apple-darwin10 \
145 --program-prefix="" \
146 || exit 1
147
148 make $COMMON_MAKEFLAGS SDKROOT=
149 if [ $? != 0 ] ; then
150 echo "error: LLVM 'make' failed!"
151 exit 1
152 fi
153
114154 else
115 configure_opts="--enable-targets=arm,x86"
116 fi
117
118 if [ "$ARM_HOSTED_BUILD" != yes ]; then
155 # not $ARM_HOSTED_BUILD
156
157 if [ "$IOS_SIM_BUILD" = yes ]; then
158 # Use a non-standard "darwin_sim" host triple to trigger a cross-build.
159 configure_opts="--enable-targets=x86 --host=i686-apple-darwin_sim \
160 --build=i686-apple-darwin10"
161 else
162 configure_opts="--enable-targets=arm,x86"
163 fi
164
119165 if [ $SDKROOT ]; then
120166 CPPFLAGS="$CPPFLAGS -isysroot $SDKROOT"
121167 fi
122168 for host in $HOSTS; do :; done
123169 CPPFLAGS="$CPPFLAGS -arch $host"
124 fi
125
126 if [ \! -f Makefile.config ]; then
127 $SRC_DIR/configure --prefix=$DEST_DIR$DEST_ROOT $configure_opts \
128 --enable-assertions=$LLVM_ASSERTIONS \
129 --enable-optimized=$LLVM_OPTIMIZED \
130 --disable-bindings \
170
171 $SRC_DIR/configure $COMMON_CONFIGURE_OPTS $configure_opts \
172 --program-prefix="" \
131173 CPPFLAGS="$CPPFLAGS" \
132174 || exit 1
133 fi
134
135 SUBVERSION=`echo $RC_ProjectSourceVersion | sed -e 's/.*\.\([0-9]*\).*/\1/'`
136
137 if [ "x$SUBVERSION" != "x$RC_ProjectSourceVersion" ]; then
138 LLVM_SUBMIT_SUBVERSION=`printf "%02d" $SUBVERSION`
139 RC_ProjectSourceVersion=`echo $RC_ProjectSourceVersion | sed -e 's/\..*//'`
140 LLVM_SUBMIT_VERSION=$RC_ProjectSourceVersion
141 fi
142
143 if [ "x$LLVM_SUBMIT_SUBVERSION" = "x00" -o "x$LLVM_SUBMIT_SUBVERSION" = "x0" ]; then
144 LLVM_VERSION="$LLVM_SUBMIT_VERSION"
145 else
146 LLVM_VERSION="$LLVM_SUBMIT_VERSION-$LLVM_SUBMIT_SUBVERSION"
147 fi
148
149 # Figure out how many make processes to run.
150 SYSCTL=`sysctl -n hw.activecpu`
151 # sysctl -n hw.* does not work when invoked via B&I chroot /BuildRoot.
152 # Builders can default to 2, since even if they are single processor,
153 # nothing else is running on the machine.
154 if [ -z "$SYSCTL" ]; then
155 SYSCTL=2
156 fi
157 JOBS_FLAG="-j $SYSCTL"
158
159 make $JOBS_FLAG $OPTIMIZE_OPTS UNIVERSAL=1 UNIVERSAL_ARCH="$HOSTS" \
160 UNIVERSAL_SDK_PATH=$SDKROOT \
161 NO_RUNTIME_LIBS=1 \
162 DISABLE_EDIS=1 \
163 REQUIRES_RTTI=1 \
164 DEBUG_SYMBOLS=1 \
165 LLVM_SUBMIT_VERSION=$LLVM_SUBMIT_VERSION \
166 LLVM_SUBMIT_SUBVERSION=$LLVM_SUBMIT_SUBVERSION \
167 CXXFLAGS="-DLLVM_VERSION_INFO='\" Apple Build #$LLVM_VERSION\"'" \
168 VERBOSE=1
169
170 if [ $? != 0 ] ; then
175
176 make $COMMON_MAKEFLAGS
177 if [ $? != 0 ] ; then
171178 echo "error: LLVM 'make' failed!"
172179 exit 1
180 fi
173181 fi
174182
175183 ################################################################################
184192 cd $DIR/obj-llvm || exit 1
185193
186194 # Install the tree into the destination directory.
187 make $LOCAL_MAKEFLAGS $OPTIMIZE_OPTS UNIVERSAL=1 UNIVERSAL_ARCH="$HOSTS" \
188 NO_RUNTIME_LIBS=1 \
189 DISABLE_EDIS=1 \
190 DEBUG_SYMBOLS=1 \
191 LLVM_SUBMIT_VERSION=$LLVM_SUBMIT_VERSION \
192 LLVM_SUBMIT_SUBVERSION=$LLVM_SUBMIT_SUBVERSION \
193 OPTIMIZE_OPTION='-O3' VERBOSE=1 install
194
195 make $COMMON_MAKEFLAGS install
195196 if ! test $? == 0 ; then
196197 echo "error: LLVM 'make install' failed!"
197198 exit 1
262263 rm -rf * || exit 1
263264
264265 # Generate .dSYM files
266 DSYMUTIL=`xcrun -find dsymutil`
265267 find $DEST_DIR -perm -0111 -type f \
266268 ! \( -name '*.la' -o -name gccas -o -name gccld -o -name llvm-config -o -name '*.a' \) \
267 -print | xargs -n 1 -P ${SYSCTL} dsymutil
269 -print | xargs -n 1 -P ${SYSCTL} ${DSYMUTIL}
268270
269271 # Save .dSYM files and .a archives
270272 cd $DEST_DIR || exit 1