@@ -90,6 +90,7 @@ python swift_do_configure() {
9090 import os
9191 import os . path
9292 import shutil
93+ import shlex
9394
9495 workdir = d . getVar ("WORKDIR" , True )
9596 recipe_sysroot = d . getVar ("STAGING_DIR_TARGET" , True )
@@ -114,13 +115,31 @@ python swift_do_configure() {
114115
115116 d . setVar ('SWIFT_CXX_VERSION' , cxx_version )
116117
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+
117135 swift_destination_template = """{
118136 "version":1,
119137 "sdk":"${STAGING_DIR_TARGET} /",
120138 "toolchain-bin-dir":"${STAGING_DIR_NATIVE} /usr/bin",
121139 "target":"${SWIFT_TARGET_NAME} ",
122140 "dynamic-library-extension":"so",
123141 "extra-cc-flags":[
142+ ${SWIFT_EXTRA_CC_FLAGS} ,
124143 "-fPIC",
125144 "-I${STAGING_INCDIR} ",
126145 "-I${STAGING_DIR_TARGET} /usr/include/c++/${SWIFT_CXX_VERSION} ",
@@ -166,9 +185,11 @@ python swift_do_configure() {
166185
167186 "-resource-dir", "${STAGING_DIR_TARGET} /usr/lib/swift",
168187 "-module-cache-path", "${B} /${BUILD_MODE} /ModuleCache",
188+
169189 "-Xclang-linker", "-B${STAGING_DIR_TARGET} /usr/lib/${TARGET_SYS} /${SWIFT_CXX_VERSION} ",
170190 "-Xclang-linker", "-B${STAGING_DIR_TARGET} /usr/lib",
171191
192+ ${SWIFT_EXTRA_SWIFTC_CC_FLAGS} ,
172193 "-Xcc", "--gcc-install-dir=${STAGING_DIR_TARGET} /usr/lib/gcc/${TARGET_SYS} /${SWIFT_CXX_VERSION} ",
173194
174195 "-sdk", "${STAGING_DIR_TARGET} "
@@ -182,6 +203,9 @@ python swift_do_configure() {
182203
183204 d . delVar ("SWIFT_CXX_VERSION" )
184205
206+ d . delVar ("SWIFT_EXTRA_CC_FLAGS" )
207+ d . delVar ("SWIFT_EXTRA_SWIFTC_CC_FLAGS" )
208+
185209 configJSON = open (workdir + "/destination.json" , "w" )
186210 configJSON . write (swift_destination )
187211 configJSON . close ()
0 commit comments