Handle env and llvm-target for musl
Further changes needed for musl to work. env needs to be set to "musl" for unwinding work properly. Also the llvm target should end with "-musl" and not "-gnu".
This commit is contained in:
@@ -11,8 +11,27 @@ RUSTLIB_DEP ?= "libstd-rs"
|
|||||||
RUST_TARGET_PATH = "${STAGING_LIBDIR_NATIVE}/rustlib"
|
RUST_TARGET_PATH = "${STAGING_LIBDIR_NATIVE}/rustlib"
|
||||||
RUST_PANIC_STRATEGY ?= "unwind"
|
RUST_PANIC_STRATEGY ?= "unwind"
|
||||||
|
|
||||||
# Responsible for taking Yocto triples and converting it to Rust triples
|
# Native builds are not effected by TCLIBC. Without this, rust-native
|
||||||
|
# thinks it's "target" (i.e. x86_64-linux) is a musl target.
|
||||||
|
RUST_LIBC = "${TCLIBC}"
|
||||||
|
RUST_LIBC_class-native = "glibc"
|
||||||
|
|
||||||
|
def determine_libc(d, thing):
|
||||||
|
'''Determine which libc something should target'''
|
||||||
|
|
||||||
|
# BUILD is never musl, TARGET may be musl or glibc,
|
||||||
|
# HOST could be musl, but only if a compiler is built to be run on
|
||||||
|
# target in which case HOST_SYS != BUILD_SYS.
|
||||||
|
if thing == 'TARGET':
|
||||||
|
libc = d.getVar('RUST_LIBC')
|
||||||
|
elif thing == 'BUILD' and (d.getVar('HOST_SYS') != d.getVar('BUILD_SYS')):
|
||||||
|
libc = d.getVar('RUST_LIBC')
|
||||||
|
else:
|
||||||
|
libc = d.getVar('RUST_LIBC_class-native')
|
||||||
|
|
||||||
|
return libc
|
||||||
|
|
||||||
|
# Responsible for taking Yocto triples and converting it to Rust triples
|
||||||
def rust_base_triple(d, thing):
|
def rust_base_triple(d, thing):
|
||||||
'''
|
'''
|
||||||
Mangle bitbake's *_SYS into something that rust might support (see
|
Mangle bitbake's *_SYS into something that rust might support (see
|
||||||
@@ -25,7 +44,7 @@ def rust_base_triple(d, thing):
|
|||||||
# All the Yocto targets are Linux and are 'unknown'
|
# All the Yocto targets are Linux and are 'unknown'
|
||||||
vendor = "-unknown"
|
vendor = "-unknown"
|
||||||
os = d.getVar('{}_OS'.format(thing))
|
os = d.getVar('{}_OS'.format(thing))
|
||||||
libc = d.getVar('TCLIBC')
|
libc = determine_libc(d, thing)
|
||||||
|
|
||||||
# Prefix with a dash and convert glibc -> gnu
|
# Prefix with a dash and convert glibc -> gnu
|
||||||
if libc == "glibc":
|
if libc == "glibc":
|
||||||
|
|||||||
@@ -142,39 +142,39 @@ TARGET_C_INT_WIDTH[arm] = "32"
|
|||||||
MAX_ATOMIC_WIDTH[arm] = "64"
|
MAX_ATOMIC_WIDTH[arm] = "64"
|
||||||
FEATURES[arm] = "+v6,+vfp2"
|
FEATURES[arm] = "+v6,+vfp2"
|
||||||
|
|
||||||
## aarch64-unknown-linux-gnu
|
## aarch64-unknown-linux-{gnu, musl}
|
||||||
DATA_LAYOUT[aarch64] = "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128"
|
DATA_LAYOUT[aarch64] = "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128"
|
||||||
LLVM_TARGET[aarch64] = "aarch64-unknown-linux-gnu"
|
LLVM_TARGET[aarch64] = "${RUST_TARGET_SYS}"
|
||||||
TARGET_ENDIAN[aarch64] = "little"
|
TARGET_ENDIAN[aarch64] = "little"
|
||||||
TARGET_POINTER_WIDTH[aarch64] = "64"
|
TARGET_POINTER_WIDTH[aarch64] = "64"
|
||||||
TARGET_C_INT_WIDTH[aarch64] = "32"
|
TARGET_C_INT_WIDTH[aarch64] = "32"
|
||||||
MAX_ATOMIC_WIDTH[aarch64] = "128"
|
MAX_ATOMIC_WIDTH[aarch64] = "128"
|
||||||
|
|
||||||
## x86_64-unknown-linux-gnu
|
## x86_64-unknown-linux-{gnu, musl}
|
||||||
DATA_LAYOUT[x86_64] = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
|
DATA_LAYOUT[x86_64] = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
|
||||||
LLVM_TARGET[x86_64] = "x86_64-unknown-linux-gnu"
|
LLVM_TARGET[x86_64] = "${RUST_TARGET_SYS}"
|
||||||
TARGET_ENDIAN[x86_64] = "little"
|
TARGET_ENDIAN[x86_64] = "little"
|
||||||
TARGET_POINTER_WIDTH[x86_64] = "64"
|
TARGET_POINTER_WIDTH[x86_64] = "64"
|
||||||
TARGET_C_INT_WIDTH[x86_64] = "32"
|
TARGET_C_INT_WIDTH[x86_64] = "32"
|
||||||
MAX_ATOMIC_WIDTH[x86_64] = "64"
|
MAX_ATOMIC_WIDTH[x86_64] = "64"
|
||||||
|
|
||||||
## i686-unknown-linux-gnu
|
## i686-unknown-linux-{gnu, musl}
|
||||||
DATA_LAYOUT[i686] = "e-m:e-p:32:32-f64:32:64-f80:32-n8:16:32-S128"
|
DATA_LAYOUT[i686] = "e-m:e-p:32:32-f64:32:64-f80:32-n8:16:32-S128"
|
||||||
LLVM_TARGET[i686] = "i686-unknown-linux-gnu"
|
LLVM_TARGET[i686] = "${RUST_TARGET_SYS}"
|
||||||
TARGET_ENDIAN[i686] = "little"
|
TARGET_ENDIAN[i686] = "little"
|
||||||
TARGET_POINTER_WIDTH[i686] = "32"
|
TARGET_POINTER_WIDTH[i686] = "32"
|
||||||
TARGET_C_INT_WIDTH[i686] = "32"
|
TARGET_C_INT_WIDTH[i686] = "32"
|
||||||
MAX_ATOMIC_WIDTH[i686] = "64"
|
MAX_ATOMIC_WIDTH[i686] = "64"
|
||||||
|
|
||||||
## XXX: a bit of a hack so qemux86 builds, clone of i686-unknown-linux-gnu above
|
## XXX: a bit of a hack so qemux86 builds, clone of i686-unknown-linux-{gnu, musl} above
|
||||||
DATA_LAYOUT[i586] = "e-m:e-p:32:32-f64:32:64-f80:32-n8:16:32-S128"
|
DATA_LAYOUT[i586] = "e-m:e-p:32:32-f64:32:64-f80:32-n8:16:32-S128"
|
||||||
LLVM_TARGET[i586] = "i586-unknown-linux-gnu"
|
LLVM_TARGET[i586] = "${RUST_TARGET_SYS}"
|
||||||
TARGET_ENDIAN[i586] = "little"
|
TARGET_ENDIAN[i586] = "little"
|
||||||
TARGET_POINTER_WIDTH[i586] = "32"
|
TARGET_POINTER_WIDTH[i586] = "32"
|
||||||
TARGET_C_INT_WIDTH[i586] = "32"
|
TARGET_C_INT_WIDTH[i586] = "32"
|
||||||
MAX_ATOMIC_WIDTH[i586] = "64"
|
MAX_ATOMIC_WIDTH[i586] = "64"
|
||||||
|
|
||||||
## mips-unknown-linux-gnu
|
## mips-unknown-linux-{gnu, musl}
|
||||||
DATA_LAYOUT[mips] = "E-m:m-p:32:32-i8:8:32-i16:16:32-i64:64-n32-S64"
|
DATA_LAYOUT[mips] = "E-m:m-p:32:32-i8:8:32-i16:16:32-i64:64-n32-S64"
|
||||||
LLVM_TARGET[mips] = "${RUST_TARGET_SYS}"
|
LLVM_TARGET[mips] = "${RUST_TARGET_SYS}"
|
||||||
TARGET_ENDIAN[mips] = "big"
|
TARGET_ENDIAN[mips] = "big"
|
||||||
@@ -182,7 +182,7 @@ TARGET_POINTER_WIDTH[mips] = "32"
|
|||||||
TARGET_C_INT_WIDTH[mips] = "32"
|
TARGET_C_INT_WIDTH[mips] = "32"
|
||||||
MAX_ATOMIC_WIDTH[mips] = "32"
|
MAX_ATOMIC_WIDTH[mips] = "32"
|
||||||
|
|
||||||
## mipsel-unknown-linux-gnu
|
## mipsel-unknown-linux-{gnu, musl}
|
||||||
DATA_LAYOUT[mipsel] = "e-m:m-p:32:32-i8:8:32-i16:16:32-i64:64-n32-S64"
|
DATA_LAYOUT[mipsel] = "e-m:m-p:32:32-i8:8:32-i16:16:32-i64:64-n32-S64"
|
||||||
LLVM_TARGET[mipsel] = "${RUST_TARGET_SYS}"
|
LLVM_TARGET[mipsel] = "${RUST_TARGET_SYS}"
|
||||||
TARGET_ENDIAN[mipsel] = "little"
|
TARGET_ENDIAN[mipsel] = "little"
|
||||||
@@ -267,7 +267,10 @@ def rust_gen_target(d, thing, wd):
|
|||||||
tspec['target-endian'] = d.getVarFlag('TARGET_ENDIAN', arch)
|
tspec['target-endian'] = d.getVarFlag('TARGET_ENDIAN', arch)
|
||||||
tspec['arch'] = arch_to_rust_target_arch(arch)
|
tspec['arch'] = arch_to_rust_target_arch(arch)
|
||||||
tspec['os'] = "linux"
|
tspec['os'] = "linux"
|
||||||
tspec['env'] = "gnu"
|
if "musl" in tspec['llvm-target']:
|
||||||
|
tspec['env'] = "musl"
|
||||||
|
else:
|
||||||
|
tspec['env'] = "gnu"
|
||||||
tspec['vendor'] = "unknown"
|
tspec['vendor'] = "unknown"
|
||||||
tspec['target-family'] = "unix"
|
tspec['target-family'] = "unix"
|
||||||
tspec['linker'] = "{}{}gcc".format(d.getVar('CCACHE'), prefix)
|
tspec['linker'] = "{}{}gcc".format(d.getVar('CCACHE'), prefix)
|
||||||
|
|||||||
Reference in New Issue
Block a user