@@ -90,6 +90,7 @@ python swift_do_configure() {
90
90
import os
91
91
import os . path
92
92
import shutil
93
+ import shlex
93
94
94
95
workdir = d . getVar ("WORKDIR" , True )
95
96
recipe_sysroot = d . getVar ("STAGING_DIR_TARGET" , True )
@@ -114,13 +115,31 @@ python swift_do_configure() {
114
115
115
116
d . setVar ('SWIFT_CXX_VERSION' , cxx_version )
116
117
118
+ def expand_swiftc_cc_flags (flags ):
119
+ flags = [['-Xcc' , flag ] for flag in flags ]
120
+ return sum (flags , [])
121
+
122
+ def concat_flags (flags ):
123
+ flags = [f '"{flag}"' for flag in flags ]
124
+ return ", " . join (flags )
125
+
126
+ # ensure target-specific tune CC flags are propagated to clang and swiftc.
127
+ # Note we are not doing this at present for LD flags, as there are none in
128
+ # the architectures we support (and it would make the string expansion more
129
+ # complicated).
130
+ target_cc_arch = shlex . split (d . getVar ("TARGET_CC_ARCH" ))
131
+
132
+ d . setVar ("SWIFT_EXTRA_CC_FLAGS" , concat_flags (target_cc_arch ))
133
+ d . setVar ("SWIFT_EXTRA_SWIFTC_CC_FLAGS" , concat_flags (expand_swiftc_cc_flags (target_cc_arch )))
134
+
117
135
swift_destination_template = """{
118
136
"version":1,
119
137
"sdk":"${STAGING_DIR_TARGET} /",
120
138
"toolchain-bin-dir":"${STAGING_DIR_NATIVE} /usr/bin",
121
139
"target":"${SWIFT_TARGET_NAME} ",
122
140
"dynamic-library-extension":"so",
123
141
"extra-cc-flags":[
142
+ ${SWIFT_EXTRA_CC_FLAGS} ,
124
143
"-fPIC",
125
144
"-I${STAGING_INCDIR} ",
126
145
"-I${STAGING_DIR_TARGET} /usr/include/c++/${SWIFT_CXX_VERSION} ",
@@ -166,9 +185,11 @@ python swift_do_configure() {
166
185
167
186
"-resource-dir", "${STAGING_DIR_TARGET} /usr/lib/swift",
168
187
"-module-cache-path", "${B} /${BUILD_MODE} /ModuleCache",
188
+
169
189
"-Xclang-linker", "-B${STAGING_DIR_TARGET} /usr/lib/${TARGET_SYS} /${SWIFT_CXX_VERSION} ",
170
190
"-Xclang-linker", "-B${STAGING_DIR_TARGET} /usr/lib",
171
191
192
+ ${SWIFT_EXTRA_SWIFTC_CC_FLAGS} ,
172
193
"-Xcc", "--gcc-install-dir=${STAGING_DIR_TARGET} /usr/lib/gcc/${TARGET_SYS} /${SWIFT_CXX_VERSION} ",
173
194
174
195
"-sdk", "${STAGING_DIR_TARGET} "
@@ -182,6 +203,9 @@ python swift_do_configure() {
182
203
183
204
d . delVar ("SWIFT_CXX_VERSION" )
184
205
206
+ d . delVar ("SWIFT_EXTRA_CC_FLAGS" )
207
+ d . delVar ("SWIFT_EXTRA_SWIFTC_CC_FLAGS" )
208
+
185
209
configJSON = open (workdir + "/destination.json" , "w" )
186
210
configJSON . write (swift_destination )
187
211
configJSON . close ()
0 commit comments