|
1 | 1 | #!/bin/sh
|
2 | 2 |
|
3 |
| -TARGET_PLATFORM=`xcrun --show-sdk-path --sdk iphoneos` |
4 |
| -TARGET_GCC=`xcrun -f clang` |
5 |
| -TARGET_CFLAGS="-isysroot $TARGET_PLATFORM -miphoneos-version-min=7.0" |
| 3 | +SDK=iphoneos |
| 4 | +ARCH=armv7 |
6 | 5 |
|
7 |
| -args=$@ |
8 |
| - |
9 |
| -# When we see a .s output file: |
10 |
| -# -o ABC.s |
11 |
| - |
12 |
| -# replace with two calls: |
13 |
| -# -o ABC-armv7.s -arch armv7 |
14 |
| -# -o ABC-armv7s.s -arch armv7s |
15 |
| - |
16 |
| -# When we see a .s input file and a .o output file: |
17 |
| -# -c ABC.s -o DEF.o |
18 |
| - |
19 |
| -# replace with two calls: |
20 |
| -# -c ABC-armv7.s -o DEF-armv7.o -arch armv7 |
21 |
| -# -c ABC-armv7s.s -o DEF-armv7s.o -arch armv7s |
22 |
| -# and then: |
23 |
| -# lipo DEF-armv7.o DEF-armv7s.o to DEF.o |
24 |
| - |
25 |
| -# When we see |
26 |
| -# -o ABC.o |
27 |
| -# replace with two calls: |
28 |
| -# -o ABC-armv7.o -arch armv7 |
29 |
| -# -o ABC-armv7s.o -arch armv7s |
30 |
| -# and then: |
31 |
| -# lipo ABC-armv7.o ABC-armv7s.o to ABC.o |
32 |
| - |
33 |
| -# Check if we're building an object file by looking for "-o file.o", and find its filename |
34 |
| -# we use s|_|\1|p where _ is the match, \1 replaces it with the group in the match |
35 |
| -# sed's -E allows extended regexes (cleaner syntax), -n suppresses non-matching input, the |p flag prints matches. |
36 |
| - |
37 |
| -# Support for profiling libraries used by ghc |
38 |
| -# Only need lipo when we're outputting object files |
39 |
| - |
40 |
| -#generate -armv7 and -armv7s variants of any .s and .o (and ghc's variants of .o) |
41 |
| -argsArmv7=${args/.s/-armv7.s} |
42 |
| -argsArmv7s=${args/.s/-armv7s.s} |
43 |
| - |
44 |
| -for ext in o p_o l_o debug_o thr_o thr_debug_o thr_l_o thr_p_o |
45 |
| -do |
46 |
| - argsArmv7=${argsArmv7/.$ext/-armv7.$ext} |
47 |
| - argsArmv7s=${argsArmv7s/.$ext/-armv7s.$ext} |
48 |
| -done |
49 |
| - |
50 |
| -for ext in o p_o l_o debug_o thr_o thr_debug_o thr_l_o thr_p_o |
51 |
| -do |
52 |
| - match="s|.*-o ([^.]*)\.$ext.*|\1|p" |
53 |
| - outFileName=$(echo "$args" | sed -En "$match") |
54 |
| - if [[ -n $outFileName ]]; then |
55 |
| - objectExt=$ext |
56 |
| - needLipo=true |
57 |
| - needFatCall=true |
58 |
| - break |
59 |
| - fi |
60 |
| -done |
61 |
| - |
62 |
| -outFileNameS=$(echo "$args" | sed -En 's|.*-o ([^.]*)\.s.*|\1|p') |
63 |
| - |
64 |
| -# A silly hack: |
65 |
| -# If the .s file is generated by llc rather than us, llc won't generate the -armv7 and -armv7s variants |
66 |
| -# (we could write a arm-apple-darwin10-llc to do that, and then we could correctly pass '-mattr=+v7,+vfp3' to armv7 and '-mattr=+v7,+vfp4' to armv7s) |
67 |
| -# So we just copy its output here. |
68 |
| -inFileNameS=$(echo "$args" | sed -En 's|.*-c ([^.]*)\.s.*|\1|p') |
69 |
| -if [[ -f $inFileNameS.s ]]; then |
70 |
| - cp $inFileNameS.s $inFileNameS-armv7.s |
71 |
| - cp $inFileNameS.s $inFileNameS-armv7s.s |
72 |
| -fi |
73 |
| - |
74 |
| -# Need fat calls for generating either .s or .o files |
75 |
| -if [[ -n $outFileNameS ]]; then |
76 |
| - needFatCall=true |
77 |
| -fi |
78 |
| - |
79 |
| -if [[ $needFatCall == true ]]; then |
80 |
| - # Call clang twice, once for each architecture, outputting to our filename variants |
81 |
| - $TARGET_GCC $TARGET_CFLAGS -arch armv7 $argsArmv7 |
82 |
| - $TARGET_GCC $TARGET_CFLAGS -arch armv7s $argsArmv7s |
83 |
| -else |
84 |
| - # echo "Non-object-generating compile command: $TARGET_GCC $TARGET_CFLAGS -arch armv7s $@" |
85 |
| - # If not building object files, call regularly. Still need to include an arch to configure clang for arm mode. |
86 |
| - exec $TARGET_GCC $TARGET_CFLAGS -arch armv7s "$@" |
87 |
| -fi |
88 |
| - |
89 |
| -if [[ $needLipo == true ]]; then |
90 |
| - outFileNameOArmv7=$outFileName-armv7.$objectExt |
91 |
| - outFileNameOArmv7s=$outFileName-armv7s.$objectExt |
92 |
| - |
93 |
| - # Lipo the two filename variants together |
94 |
| - lipo $outFileNameOArmv7 $outFileNameOArmv7s -create -output $outFileName.$objectExt |
95 |
| - |
96 |
| - # Clean up |
97 |
| - rm $outFileNameOArmv7 $outFileNameOArmv7s |
98 |
| -fi |
| 6 | +exec xcrun --sdk ${SDK} clang -arch ${ARCH} -miphoneos-version-min=7.0 "$@" |
0 commit comments