Patrick Williams | 92b42cb | 2022-09-03 06:53:57 -0500 | [diff] [blame] | 1 | # |
| 2 | # Copyright OpenEmbedded Contributors |
| 3 | # |
| 4 | # SPDX-License-Identifier: MIT |
| 5 | # |
| 6 | |
| 7 | # Right now this is focused on arm-specific tune features. |
| 8 | # We get away with this for now as one can only use x86-64 as the build host |
| 9 | # (not arm). |
| 10 | # Note that TUNE_FEATURES is _always_ refering to the target, so we really |
| 11 | # don't want to use this for the host/build. |
| 12 | def llvm_features_from_tune(d): |
| 13 | f = [] |
| 14 | feat = d.getVar('TUNE_FEATURES') |
| 15 | if not feat: |
| 16 | return [] |
| 17 | feat = frozenset(feat.split()) |
| 18 | |
| 19 | mach_overrides = d.getVar('MACHINEOVERRIDES') |
| 20 | mach_overrides = frozenset(mach_overrides.split(':')) |
| 21 | |
| 22 | if 'vfpv4' in feat: |
| 23 | f.append("+vfp4") |
| 24 | if 'vfpv3' in feat: |
| 25 | f.append("+vfp3") |
| 26 | if 'vfpv3d16' in feat: |
| 27 | f.append("+d16") |
| 28 | |
| 29 | if 'vfpv2' in feat or 'vfp' in feat: |
| 30 | f.append("+vfp2") |
| 31 | |
| 32 | if 'neon' in feat: |
| 33 | f.append("+neon") |
| 34 | |
| 35 | if 'mips32' in feat: |
| 36 | f.append("+mips32") |
| 37 | |
| 38 | if 'mips32r2' in feat: |
| 39 | f.append("+mips32r2") |
| 40 | |
| 41 | if target_is_armv7(d): |
| 42 | f.append('+v7') |
| 43 | |
| 44 | if ('armv6' in mach_overrides) or ('armv6' in feat): |
| 45 | f.append("+v6") |
| 46 | if 'armv5te' in feat: |
| 47 | f.append("+strict-align") |
| 48 | f.append("+v5te") |
| 49 | elif 'armv5' in feat: |
| 50 | f.append("+strict-align") |
| 51 | f.append("+v5") |
| 52 | |
| 53 | if ('armv4' in mach_overrides) or ('armv4' in feat): |
| 54 | f.append("+strict-align") |
| 55 | |
| 56 | if 'dsp' in feat: |
| 57 | f.append("+dsp") |
| 58 | |
| 59 | if 'thumb' in feat: |
| 60 | if d.getVar('ARM_THUMB_OPT') == "thumb": |
| 61 | if target_is_armv7(d): |
| 62 | f.append('+thumb2') |
| 63 | f.append("+thumb-mode") |
| 64 | |
| 65 | if 'cortexa5' in feat: |
| 66 | f.append("+a5") |
| 67 | if 'cortexa7' in feat: |
| 68 | f.append("+a7") |
| 69 | if 'cortexa9' in feat: |
| 70 | f.append("+a9") |
| 71 | if 'cortexa15' in feat: |
| 72 | f.append("+a15") |
| 73 | if 'cortexa17' in feat: |
| 74 | f.append("+a17") |
| 75 | if ('riscv64' in feat) or ('riscv32' in feat): |
| 76 | f.append("+a,+c,+d,+f,+m") |
| 77 | return f |
| 78 | llvm_features_from_tune[vardepvalue] = "${@llvm_features_from_tune(d)}" |
| 79 | |
| 80 | # TARGET_CC_ARCH changes from build/cross/target so it'll do the right thing |
| 81 | # this should go away when https://github.com/rust-lang/rust/pull/31709 is |
| 82 | # stable (1.9.0?) |
| 83 | def llvm_features_from_cc_arch(d): |
| 84 | f = [] |
| 85 | feat = d.getVar('TARGET_CC_ARCH') |
| 86 | if not feat: |
| 87 | return [] |
| 88 | feat = frozenset(feat.split()) |
| 89 | |
| 90 | if '-mmmx' in feat: |
| 91 | f.append("+mmx") |
| 92 | if '-msse' in feat: |
| 93 | f.append("+sse") |
| 94 | if '-msse2' in feat: |
| 95 | f.append("+sse2") |
| 96 | if '-msse3' in feat: |
| 97 | f.append("+sse3") |
| 98 | if '-mssse3' in feat: |
| 99 | f.append("+ssse3") |
| 100 | if '-msse4.1' in feat: |
| 101 | f.append("+sse4.1") |
| 102 | if '-msse4.2' in feat: |
| 103 | f.append("+sse4.2") |
| 104 | if '-msse4a' in feat: |
| 105 | f.append("+sse4a") |
| 106 | if '-mavx' in feat: |
| 107 | f.append("+avx") |
| 108 | if '-mavx2' in feat: |
| 109 | f.append("+avx2") |
| 110 | |
| 111 | return f |
| 112 | |
| 113 | def llvm_features_from_target_fpu(d): |
| 114 | # TARGET_FPU can be hard or soft. +soft-float tell llvm to use soft float |
| 115 | # ABI. There is no option for hard. |
| 116 | |
Patrick Williams | 864cc43 | 2023-02-09 14:54:44 -0600 | [diff] [blame] | 117 | fpu = d.getVar('TARGET_FPU') |
Patrick Williams | 92b42cb | 2022-09-03 06:53:57 -0500 | [diff] [blame] | 118 | return ["+soft-float"] if fpu == "soft" else [] |
| 119 | |
| 120 | def llvm_features(d): |
| 121 | return ','.join(llvm_features_from_tune(d) + |
| 122 | llvm_features_from_cc_arch(d) + |
| 123 | llvm_features_from_target_fpu(d)) |
| 124 | |
| 125 | llvm_features[vardepvalue] = "${@llvm_features(d)}" |
| 126 | |
| 127 | ## arm-unknown-linux-gnueabihf |
| 128 | DATA_LAYOUT[arm-eabi] = "e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64" |
| 129 | TARGET_ENDIAN[arm-eabi] = "little" |
| 130 | TARGET_POINTER_WIDTH[arm-eabi] = "32" |
| 131 | TARGET_C_INT_WIDTH[arm-eabi] = "32" |
| 132 | MAX_ATOMIC_WIDTH[arm-eabi] = "64" |
| 133 | FEATURES[arm-eabi] = "+v6,+vfp2" |
| 134 | |
| 135 | ## armv7-unknown-linux-gnueabihf |
| 136 | DATA_LAYOUT[armv7-eabi] = "e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64" |
| 137 | TARGET_ENDIAN[armv7-eabi] = "little" |
| 138 | TARGET_POINTER_WIDTH[armv7-eabi] = "32" |
| 139 | TARGET_C_INT_WIDTH[armv7-eabi] = "32" |
| 140 | MAX_ATOMIC_WIDTH[armv7-eabi] = "64" |
| 141 | FEATURES[armv7-eabi] = "+v7,+vfp2,+thumb2" |
| 142 | |
| 143 | ## aarch64-unknown-linux-{gnu, musl} |
| 144 | DATA_LAYOUT[aarch64] = "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128" |
| 145 | TARGET_ENDIAN[aarch64] = "little" |
| 146 | TARGET_POINTER_WIDTH[aarch64] = "64" |
| 147 | TARGET_C_INT_WIDTH[aarch64] = "32" |
| 148 | MAX_ATOMIC_WIDTH[aarch64] = "128" |
| 149 | |
| 150 | ## x86_64-unknown-linux-{gnu, musl} |
| 151 | DATA_LAYOUT[x86_64] = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" |
| 152 | TARGET_ENDIAN[x86_64] = "little" |
| 153 | TARGET_POINTER_WIDTH[x86_64] = "64" |
| 154 | TARGET_C_INT_WIDTH[x86_64] = "32" |
| 155 | MAX_ATOMIC_WIDTH[x86_64] = "64" |
| 156 | |
| 157 | ## x86_64-unknown-linux-gnux32 |
| 158 | DATA_LAYOUT[x86_64-x32] = "e-m:e-p:32:32-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" |
| 159 | TARGET_ENDIAN[x86_64-x32] = "little" |
| 160 | TARGET_POINTER_WIDTH[x86_64-x32] = "32" |
| 161 | TARGET_C_INT_WIDTH[x86_64-x32] = "32" |
| 162 | MAX_ATOMIC_WIDTH[x86_64-x32] = "64" |
| 163 | |
| 164 | ## i686-unknown-linux-{gnu, musl} |
| 165 | DATA_LAYOUT[i686] = "e-m:e-p:32:32-f64:32:64-f80:32-n8:16:32-S128" |
| 166 | TARGET_ENDIAN[i686] = "little" |
| 167 | TARGET_POINTER_WIDTH[i686] = "32" |
| 168 | TARGET_C_INT_WIDTH[i686] = "32" |
| 169 | MAX_ATOMIC_WIDTH[i686] = "64" |
| 170 | |
| 171 | ## XXX: a bit of a hack so qemux86 builds, clone of i686-unknown-linux-{gnu, musl} above |
| 172 | DATA_LAYOUT[i586] = "e-m:e-p:32:32-f64:32:64-f80:32-n8:16:32-S128" |
| 173 | TARGET_ENDIAN[i586] = "little" |
| 174 | TARGET_POINTER_WIDTH[i586] = "32" |
| 175 | TARGET_C_INT_WIDTH[i586] = "32" |
| 176 | MAX_ATOMIC_WIDTH[i586] = "64" |
| 177 | |
| 178 | ## mips-unknown-linux-{gnu, musl} |
| 179 | DATA_LAYOUT[mips] = "E-m:m-p:32:32-i8:8:32-i16:16:32-i64:64-n32-S64" |
| 180 | TARGET_ENDIAN[mips] = "big" |
| 181 | TARGET_POINTER_WIDTH[mips] = "32" |
| 182 | TARGET_C_INT_WIDTH[mips] = "32" |
| 183 | MAX_ATOMIC_WIDTH[mips] = "32" |
| 184 | |
| 185 | ## mipsel-unknown-linux-{gnu, musl} |
| 186 | DATA_LAYOUT[mipsel] = "e-m:m-p:32:32-i8:8:32-i16:16:32-i64:64-n32-S64" |
| 187 | TARGET_ENDIAN[mipsel] = "little" |
| 188 | TARGET_POINTER_WIDTH[mipsel] = "32" |
| 189 | TARGET_C_INT_WIDTH[mipsel] = "32" |
| 190 | MAX_ATOMIC_WIDTH[mipsel] = "32" |
| 191 | |
| 192 | ## mips64-unknown-linux-{gnu, musl} |
| 193 | DATA_LAYOUT[mips64] = "E-m:e-i8:8:32-i16:16:32-i64:64-n32:64-S128" |
| 194 | TARGET_ENDIAN[mips64] = "big" |
| 195 | TARGET_POINTER_WIDTH[mips64] = "64" |
| 196 | TARGET_C_INT_WIDTH[mips64] = "64" |
| 197 | MAX_ATOMIC_WIDTH[mips64] = "64" |
| 198 | |
| 199 | ## mips64-n32-unknown-linux-{gnu, musl} |
| 200 | DATA_LAYOUT[mips64-n32] = "E-m:e-p:32:32-i8:8:32-i16:16:32-i64:64-n32:64-S128" |
| 201 | TARGET_ENDIAN[mips64-n32] = "big" |
| 202 | TARGET_POINTER_WIDTH[mips64-n32] = "32" |
| 203 | TARGET_C_INT_WIDTH[mips64-n32] = "32" |
| 204 | MAX_ATOMIC_WIDTH[mips64-n32] = "64" |
| 205 | |
| 206 | ## mips64el-unknown-linux-{gnu, musl} |
| 207 | DATA_LAYOUT[mips64el] = "e-m:e-i8:8:32-i16:16:32-i64:64-n32:64-S128" |
| 208 | TARGET_ENDIAN[mips64el] = "little" |
| 209 | TARGET_POINTER_WIDTH[mips64el] = "64" |
| 210 | TARGET_C_INT_WIDTH[mips64el] = "64" |
| 211 | MAX_ATOMIC_WIDTH[mips64el] = "64" |
| 212 | |
| 213 | ## powerpc-unknown-linux-{gnu, musl} |
| 214 | DATA_LAYOUT[powerpc] = "E-m:e-p:32:32-i64:64-n32" |
| 215 | TARGET_ENDIAN[powerpc] = "big" |
| 216 | TARGET_POINTER_WIDTH[powerpc] = "32" |
| 217 | TARGET_C_INT_WIDTH[powerpc] = "32" |
| 218 | MAX_ATOMIC_WIDTH[powerpc] = "32" |
| 219 | |
| 220 | ## powerpc64-unknown-linux-{gnu, musl} |
| 221 | DATA_LAYOUT[powerpc64] = "E-m:e-i64:64-n32:64-S128-v256:256:256-v512:512:512" |
| 222 | TARGET_ENDIAN[powerpc64] = "big" |
| 223 | TARGET_POINTER_WIDTH[powerpc64] = "64" |
| 224 | TARGET_C_INT_WIDTH[powerpc64] = "64" |
| 225 | MAX_ATOMIC_WIDTH[powerpc64] = "64" |
| 226 | |
| 227 | ## powerpc64le-unknown-linux-{gnu, musl} |
| 228 | DATA_LAYOUT[powerpc64le] = "e-m:e-i64:64-n32:64-v256:256:256-v512:512:512" |
| 229 | TARGET_ENDIAN[powerpc64le] = "little" |
| 230 | TARGET_POINTER_WIDTH[powerpc64le] = "64" |
| 231 | TARGET_C_INT_WIDTH[powerpc64le] = "64" |
| 232 | MAX_ATOMIC_WIDTH[powerpc64le] = "64" |
| 233 | |
Patrick Williams | 2390b1b | 2022-11-03 13:47:49 -0500 | [diff] [blame] | 234 | ## riscv32gc-unknown-linux-{gnu, musl} |
| 235 | DATA_LAYOUT[riscv32gc] = "e-m:e-p:32:32-i64:64-n32-S128" |
| 236 | TARGET_ENDIAN[riscv32gc] = "little" |
| 237 | TARGET_POINTER_WIDTH[riscv32gc] = "32" |
| 238 | TARGET_C_INT_WIDTH[riscv32gc] = "32" |
| 239 | MAX_ATOMIC_WIDTH[riscv32gc] = "32" |
Patrick Williams | 92b42cb | 2022-09-03 06:53:57 -0500 | [diff] [blame] | 240 | |
Patrick Williams | 2390b1b | 2022-11-03 13:47:49 -0500 | [diff] [blame] | 241 | ## riscv64gc-unknown-linux-{gnu, musl} |
| 242 | DATA_LAYOUT[riscv64gc] = "e-m:e-p:64:64-i64:64-i128:128-n64-S128" |
| 243 | TARGET_ENDIAN[riscv64gc] = "little" |
| 244 | TARGET_POINTER_WIDTH[riscv64gc] = "64" |
| 245 | TARGET_C_INT_WIDTH[riscv64gc] = "64" |
| 246 | MAX_ATOMIC_WIDTH[riscv64gc] = "64" |
Patrick Williams | 92b42cb | 2022-09-03 06:53:57 -0500 | [diff] [blame] | 247 | |
Andrew Geissler | fc113ea | 2023-03-31 09:59:46 -0500 | [diff] [blame^] | 248 | ## loongarch64-unknown-linux-{gnu, musl} |
| 249 | DATA_LAYOUT[loongarch64] = "e-m:e-i8:8:32-i16:16:32-i64:64-n32:64-S128" |
| 250 | TARGET_ENDIAN[loongarch64] = "little" |
| 251 | TARGET_POINTER_WIDTH[loongarch64] = "64" |
| 252 | TARGET_C_INT_WIDTH[loongarch64] = "32" |
| 253 | MAX_ATOMIC_WIDTH[loongarch64] = "64" |
| 254 | FEATURES[loongarch64] = "+d" |
| 255 | |
Patrick Williams | 92b42cb | 2022-09-03 06:53:57 -0500 | [diff] [blame] | 256 | # Convert a normal arch (HOST_ARCH, TARGET_ARCH, BUILD_ARCH, etc) to something |
| 257 | # rust's internals won't choke on. |
| 258 | def arch_to_rust_target_arch(arch): |
| 259 | if arch == "i586" or arch == "i686": |
| 260 | return "x86" |
| 261 | elif arch == "mipsel": |
| 262 | return "mips" |
| 263 | elif arch == "mip64sel": |
| 264 | return "mips64" |
| 265 | elif arch == "armv7": |
| 266 | return "arm" |
| 267 | elif arch == "powerpc64le": |
| 268 | return "powerpc64" |
Patrick Williams | 2390b1b | 2022-11-03 13:47:49 -0500 | [diff] [blame] | 269 | elif arch == "riscv32gc": |
| 270 | return "riscv32" |
| 271 | elif arch == "riscv64gc": |
| 272 | return "riscv64" |
Patrick Williams | 92b42cb | 2022-09-03 06:53:57 -0500 | [diff] [blame] | 273 | else: |
| 274 | return arch |
| 275 | |
Patrick Williams | 2390b1b | 2022-11-03 13:47:49 -0500 | [diff] [blame] | 276 | # Convert a rust target string to a llvm-compatible triplet |
| 277 | def rust_sys_to_llvm_target(sys): |
| 278 | if sys.startswith('riscv32gc-'): |
| 279 | return sys.replace('riscv32gc-', 'riscv32-', 1) |
| 280 | if sys.startswith('riscv64gc-'): |
| 281 | return sys.replace('riscv64gc-', 'riscv64-', 1) |
| 282 | return sys |
| 283 | |
Patrick Williams | 92b42cb | 2022-09-03 06:53:57 -0500 | [diff] [blame] | 284 | # generates our target CPU value |
| 285 | def llvm_cpu(d): |
| 286 | cpu = d.getVar('PACKAGE_ARCH') |
| 287 | target = d.getVar('TRANSLATED_TARGET_ARCH') |
| 288 | |
| 289 | trans = {} |
| 290 | trans['corei7-64'] = "corei7" |
| 291 | trans['core2-32'] = "core2" |
| 292 | trans['x86-64'] = "x86-64" |
| 293 | trans['i686'] = "i686" |
| 294 | trans['i586'] = "i586" |
| 295 | trans['mips64'] = "mips64" |
| 296 | trans['mips64el'] = "mips64" |
| 297 | trans['riscv64'] = "generic-rv64" |
| 298 | trans['riscv32'] = "generic-rv32" |
Andrew Geissler | fc113ea | 2023-03-31 09:59:46 -0500 | [diff] [blame^] | 299 | trans['loongarch64'] = "la464" |
Patrick Williams | 92b42cb | 2022-09-03 06:53:57 -0500 | [diff] [blame] | 300 | |
| 301 | if target in ["mips", "mipsel", "powerpc"]: |
| 302 | feat = frozenset(d.getVar('TUNE_FEATURES').split()) |
| 303 | if "mips32r2" in feat: |
| 304 | trans['mipsel'] = "mips32r2" |
| 305 | trans['mips'] = "mips32r2" |
| 306 | elif "mips32" in feat: |
| 307 | trans['mipsel'] = "mips32" |
| 308 | trans['mips'] = "mips32" |
| 309 | elif "ppc7400" in feat: |
| 310 | trans['powerpc'] = "7400" |
| 311 | |
| 312 | try: |
| 313 | return trans[cpu] |
| 314 | except: |
| 315 | return trans.get(target, "generic") |
| 316 | |
| 317 | llvm_cpu[vardepvalue] = "${@llvm_cpu(d)}" |
| 318 | |
| 319 | def rust_gen_target(d, thing, wd, arch): |
| 320 | import json |
| 321 | |
| 322 | build_sys = d.getVar('BUILD_SYS') |
| 323 | target_sys = d.getVar('TARGET_SYS') |
| 324 | |
| 325 | sys = d.getVar('{}_SYS'.format(thing)) |
| 326 | prefix = d.getVar('{}_PREFIX'.format(thing)) |
| 327 | rustsys = d.getVar('RUST_{}_SYS'.format(thing)) |
| 328 | |
| 329 | abi = None |
| 330 | cpu = "generic" |
| 331 | features = "" |
| 332 | |
| 333 | # Need to apply the target tuning consitently, only if the triplet applies to the target |
| 334 | # and not in the native case |
| 335 | if sys == target_sys and sys != build_sys: |
| 336 | abi = d.getVar('ABIEXTENSION') |
| 337 | cpu = llvm_cpu(d) |
| 338 | if bb.data.inherits_class('native', d): |
| 339 | features = ','.join(llvm_features_from_cc_arch(d)) |
| 340 | else: |
| 341 | features = llvm_features(d) or "" |
| 342 | # arm and armv7 have different targets in llvm |
| 343 | if arch == "arm" and target_is_armv7(d): |
| 344 | arch = 'armv7' |
| 345 | |
| 346 | rust_arch = oe.rust.arch_to_rust_arch(arch) |
| 347 | |
| 348 | if abi: |
| 349 | arch_abi = "{}-{}".format(rust_arch, abi) |
| 350 | else: |
| 351 | arch_abi = rust_arch |
| 352 | |
| 353 | features = features or d.getVarFlag('FEATURES', arch_abi) or "" |
| 354 | features = features.strip() |
| 355 | |
| 356 | # build tspec |
| 357 | tspec = {} |
Patrick Williams | 2390b1b | 2022-11-03 13:47:49 -0500 | [diff] [blame] | 358 | tspec['llvm-target'] = rust_sys_to_llvm_target(rustsys) |
Patrick Williams | 92b42cb | 2022-09-03 06:53:57 -0500 | [diff] [blame] | 359 | tspec['data-layout'] = d.getVarFlag('DATA_LAYOUT', arch_abi) |
| 360 | if tspec['data-layout'] is None: |
| 361 | bb.fatal("No rust target defined for %s" % arch_abi) |
| 362 | tspec['max-atomic-width'] = int(d.getVarFlag('MAX_ATOMIC_WIDTH', arch_abi)) |
| 363 | tspec['target-pointer-width'] = d.getVarFlag('TARGET_POINTER_WIDTH', arch_abi) |
| 364 | tspec['target-c-int-width'] = d.getVarFlag('TARGET_C_INT_WIDTH', arch_abi) |
| 365 | tspec['target-endian'] = d.getVarFlag('TARGET_ENDIAN', arch_abi) |
| 366 | tspec['arch'] = arch_to_rust_target_arch(rust_arch) |
Andrew Geissler | 517393d | 2023-01-13 08:55:19 -0600 | [diff] [blame] | 367 | if "baremetal" in d.getVar('TCLIBC'): |
| 368 | tspec['os'] = "none" |
| 369 | else: |
| 370 | tspec['os'] = "linux" |
Patrick Williams | 92b42cb | 2022-09-03 06:53:57 -0500 | [diff] [blame] | 371 | if "musl" in tspec['llvm-target']: |
| 372 | tspec['env'] = "musl" |
| 373 | else: |
| 374 | tspec['env'] = "gnu" |
| 375 | if "riscv64" in tspec['llvm-target']: |
| 376 | tspec['llvm-abiname'] = "lp64d" |
| 377 | if "riscv32" in tspec['llvm-target']: |
| 378 | tspec['llvm-abiname'] = "ilp32d" |
Andrew Geissler | fc113ea | 2023-03-31 09:59:46 -0500 | [diff] [blame^] | 379 | if "loongarch64" in tspec['llvm-target']: |
| 380 | tspec['llvm-abiname'] = "lp64d" |
Patrick Williams | 92b42cb | 2022-09-03 06:53:57 -0500 | [diff] [blame] | 381 | tspec['vendor'] = "unknown" |
| 382 | tspec['target-family'] = "unix" |
| 383 | tspec['linker'] = "{}{}gcc".format(d.getVar('CCACHE'), prefix) |
| 384 | tspec['cpu'] = cpu |
| 385 | if features != "": |
| 386 | tspec['features'] = features |
| 387 | tspec['dynamic-linking'] = True |
| 388 | tspec['executables'] = True |
| 389 | tspec['linker-is-gnu'] = True |
| 390 | tspec['linker-flavor'] = "gcc" |
| 391 | tspec['has-rpath'] = True |
| 392 | tspec['position-independent-executables'] = True |
| 393 | tspec['panic-strategy'] = d.getVar("RUST_PANIC_STRATEGY") |
| 394 | |
| 395 | # write out the target spec json file |
| 396 | with open(wd + rustsys + '.json', 'w') as f: |
| 397 | json.dump(tspec, f, indent=4) |
| 398 | |
| 399 | # These are accounted for in tmpdir path names so don't need to be in the task sig |
| 400 | rust_gen_target[vardepsexclude] += "ABIEXTENSION llvm_cpu" |
| 401 | |
| 402 | do_rust_gen_targets[vardeps] += "DATA_LAYOUT TARGET_ENDIAN TARGET_POINTER_WIDTH TARGET_C_INT_WIDTH MAX_ATOMIC_WIDTH FEATURES" |
| 403 | |
| 404 | RUST_TARGETS_DIR = "${WORKDIR}/rust-targets/" |
| 405 | export RUST_TARGET_PATH = "${RUST_TARGETS_DIR}" |
| 406 | |
| 407 | python do_rust_gen_targets () { |
| 408 | wd = d.getVar('RUST_TARGETS_DIR') |
| 409 | # Order of BUILD, HOST, TARGET is important in case the files overwrite, most specific last |
| 410 | rust_gen_target(d, 'BUILD', wd, d.getVar('BUILD_ARCH')) |
| 411 | rust_gen_target(d, 'HOST', wd, d.getVar('HOST_ARCH')) |
| 412 | rust_gen_target(d, 'TARGET', wd, d.getVar('TARGET_ARCH')) |
| 413 | } |
| 414 | |
| 415 | addtask rust_gen_targets after do_patch before do_compile |
| 416 | do_rust_gen_targets[dirs] += "${RUST_TARGETS_DIR}" |
| 417 | |
Andrew Geissler | 517393d | 2023-01-13 08:55:19 -0600 | [diff] [blame] | 418 | # For building target C dependecies use only compiler parameters defined in OE |
| 419 | # and ignore the CC crate defaults which conflicts with OE ones in some cases. |
| 420 | # https://github.com/rust-lang/cc-rs#external-configuration-via-environment-variables |
| 421 | # Some CC crate compiler flags are still required. |
| 422 | # We apply them conditionally in rust wrappers. |
| 423 | |
| 424 | CRATE_CC_FLAGS:class-native = "" |
| 425 | CRATE_CC_FLAGS:class-nativesdk = "" |
| 426 | CRATE_CC_FLAGS:class-target = " -ffunction-sections -fdata-sections -fPIC" |
| 427 | |
| 428 | do_compile:prepend:class-target() { |
| 429 | export CRATE_CC_NO_DEFAULTS=1 |
| 430 | } |
| 431 | do_install:prepend:class-target() { |
| 432 | export CRATE_CC_NO_DEFAULTS=1 |
| 433 | } |