From patchwork Thu Jul 7 17:19:02 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Otavio Salvador X-Patchwork-Id: 9988 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 44AF2CCA479 for ; Thu, 7 Jul 2022 17:19:17 +0000 (UTC) Received: from mail-vs1-f47.google.com (mail-vs1-f47.google.com [209.85.217.47]) by mx.groups.io with SMTP id smtpd.web10.394.1657214350074276955 for ; Thu, 07 Jul 2022 10:19:10 -0700 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: gmail.com, ip: 209.85.217.47, mailfrom: otavio.salvador@gmail.com) Received: by mail-vs1-f47.google.com with SMTP id k2so9327800vsc.5 for ; Thu, 07 Jul 2022 10:19:09 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=yxe8s8lRPRa9Cun1oAAEKkZDQb+UBmXIhJgkrd0P0Rg=; b=6/igEEP3HvATtgP6zAgZUv9tDxmYPR6v4qgRbZrb+PpYEs3YAvIuV81ysLvBS6o0t/ pYdvxc9j+O9TZEV5h/r0zMBqeY5B+7MdD5//bi7Uc2Y6q36DiDQBmj9ZHteYjQbJd0hH wpwhNRZrBSwDZXksX0guxXZnhdes6k74E8mD+oMtQ4IAP4gXQK/9vwgYfGcPVuea/ILf KeyTHQs6w2+vAnz8Uae1j9JHhqionBIpsxVJ0A2zA+tvK9x9EYnLX+K7KF2AqB89lyOq Bvj6dpK8t9ocoUD8v74df4B5LwqT+y/iS3WDXps3sFUgmpNFGoLmv8gAt0G1H39U/yMN sJ5g== X-Gm-Message-State: AJIora+OYUI+h124A8W5wvD8foh1z5NF7STS23HVVV1OyNNK/8wbJl/h OYugQtRjG0IMMt+dVkMDN8CJXq0XnXUm8mld X-Google-Smtp-Source: AGRyM1tb9Jec3F5Ld5wBJ68P34mSnv1wKVpFcSxgC/v80gNPgrJKZrZXKuAYx1UvL5EeaUhZ1WElWw== X-Received: by 2002:a05:6102:2407:b0:356:2318:b743 with SMTP id j7-20020a056102240700b003562318b743mr26327541vsi.61.1657214348677; Thu, 07 Jul 2022 10:19:08 -0700 (PDT) Received: from localhost (177-4-253-164.user3p.brasiltelecom.net.br. [177.4.253.164]) by smtp.gmail.com with ESMTPSA id y8-20020a67f248000000b00353f98c3f49sm9976668vsm.22.2022.07.07.10.19.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Jul 2022 10:19:07 -0700 (PDT) From: Otavio Salvador To: openembedded-core@lists.openembedded.org Cc: Otavio Salvador Subject: [PATCH 1/2] rust-common: Fix use of target definitions for SDK generation Date: Thu, 7 Jul 2022 14:19:02 -0300 Message-Id: <20220707171904.338441-1-otavio@ossystems.com.br> X-Mailer: git-send-email 2.36.1 MIME-Version: 1.0 List-Id: X-Webhook-Received: from li982-79.members.linode.com [45.33.32.79] by aws-us-west-2-korg-lkml-1.web.codeaurora.org with HTTPS for ; Thu, 07 Jul 2022 17:19:17 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/openembedded-core/message/167794 We need full target passed for build so we changed the rust-cross-canadian to use same code used in regular rust recipes and added support to use specific llvm-target for the building host. Fixes: ef566af964 ("rust: fix issue building cross-canadian tools for aarch64 on x86_64") Fixes: bd36593ba3 ("rust-common: Drop LLVM_TARGET and simplify") Fixes: 8ed000debb ("rust-common: Fix for target definitions returning 'NoneType' for arm") Signed-off-by: Otavio Salvador --- meta/recipes-devtools/rust/rust-common.inc | 21 ++++++++++++------ .../rust/rust-cross-canadian-common.inc | 22 ++++++++++++++++--- 2 files changed, 33 insertions(+), 10 deletions(-) diff --git a/meta/recipes-devtools/rust/rust-common.inc b/meta/recipes-devtools/rust/rust-common.inc index ef70c48d0f..f8d365ecf8 100644 --- a/meta/recipes-devtools/rust/rust-common.inc +++ b/meta/recipes-devtools/rust/rust-common.inc @@ -119,12 +119,12 @@ def llvm_features(d): ## arm-unknown-linux-gnueabihf -DATA_LAYOUT[arm] = "e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64" -TARGET_ENDIAN[arm] = "little" -TARGET_POINTER_WIDTH[arm] = "32" -TARGET_C_INT_WIDTH[arm] = "32" -MAX_ATOMIC_WIDTH[arm] = "64" -FEATURES[arm] = "+v6,+vfp2" +DATA_LAYOUT[arm-eabi] = "e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64" +TARGET_ENDIAN[arm-eabi] = "little" +TARGET_POINTER_WIDTH[arm-eabi] = "32" +TARGET_C_INT_WIDTH[arm-eabi] = "32" +MAX_ATOMIC_WIDTH[arm-eabi] = "64" +FEATURES[arm-eabi] = "+v6,+vfp2" ## armv7-unknown-linux-gnueabihf DATA_LAYOUT[armv7-eabi] = "e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64" @@ -304,12 +304,19 @@ def rust_gen_target(d, thing, wd, features, cpu, arch, abi=""): else: arch_abi = rust_arch + # When building for the building system we need to return the HOST target + # or wrong flags are used. + if thing is "BUILD": + llvm_target = d.getVar('RUST_HOST_SYS', arch_abi) + else: + llvm_target = d.getVar('RUST_TARGET_SYS', arch_abi) + features = features or d.getVarFlag('FEATURES', arch_abi) or "" features = features.strip() # build tspec tspec = {} - tspec['llvm-target'] = d.getVar('RUST_TARGET_SYS', arch_abi) + tspec['llvm-target'] = llvm_target tspec['data-layout'] = d.getVarFlag('DATA_LAYOUT', arch_abi) tspec['max-atomic-width'] = int(d.getVarFlag('MAX_ATOMIC_WIDTH', arch_abi)) tspec['target-pointer-width'] = d.getVarFlag('TARGET_POINTER_WIDTH', arch_abi) diff --git a/meta/recipes-devtools/rust/rust-cross-canadian-common.inc b/meta/recipes-devtools/rust/rust-cross-canadian-common.inc index 1f21c8af26..eff9212648 100644 --- a/meta/recipes-devtools/rust/rust-cross-canadian-common.inc +++ b/meta/recipes-devtools/rust/rust-cross-canadian-common.inc @@ -27,9 +27,23 @@ DEBUG_PREFIX_MAP = "-fdebug-prefix-map=${WORKDIR}=/usr/src/debug/${PN}/${EXTENDP python do_rust_gen_targets () { wd = d.getVar('WORKDIR') + '/targets/' - rust_gen_target(d, 'TARGET', wd, d.getVar('TARGET_LLVM_FEATURES') or "", d.getVar('TARGET_LLVM_CPU'), d.getVar('TARGET_ARCH')) - rust_gen_target(d, 'HOST', wd, "", "generic", d.getVar('HOST_ARCH')) - rust_gen_target(d, 'BUILD', wd, "", "generic", d.getVar('BUILD_ARCH')) + # It is important 'TARGET' is last here so that it overrides our less + # informed choices for BUILD & HOST if TARGET happens to be the same as + # either of them. + for thing in ['BUILD', 'HOST', 'TARGET']: + bb.debug(1, "rust_gen_target for " + thing) + features = "" + cpu = "generic" + arch = d.getVar('{}_ARCH'.format(thing)) + abi = "" + if thing is "TARGET": + abi = d.getVar('ABIEXTENSION') + # arm and armv7 have different targets in llvm + if arch == "arm" and target_is_armv7(d): + arch = 'armv7' + features = d.getVar('TARGET_LLVM_FEATURES') or "" + cpu = d.getVar('TARGET_LLVM_CPU') + rust_gen_target(d, thing, wd, features, cpu, arch, abi) } INHIBIT_DEFAULT_RUST_DEPS = "1" @@ -45,6 +59,8 @@ python do_configure:prepend() { hosts = ["{}-unknown-linux-gnu".format(d.getVar("HOST_ARCH", True))] } +INSANE_SKIP:${PN} = "libdir" + INSANE_SKIP:${RUSTLIB_TARGET_PN} = "file-rdeps arch ldflags" SKIP_FILEDEPS:${RUSTLIB_TARGET_PN} = "1" From patchwork Thu Jul 7 17:19:03 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Otavio Salvador X-Patchwork-Id: 9986 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 44AC3C43334 for ; Thu, 7 Jul 2022 17:19:17 +0000 (UTC) Received: from mail-vs1-f49.google.com (mail-vs1-f49.google.com [209.85.217.49]) by mx.groups.io with SMTP id smtpd.web08.378.1657214352977225548 for ; Thu, 07 Jul 2022 10:19:13 -0700 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: gmail.com, ip: 209.85.217.49, mailfrom: otavio.salvador@gmail.com) Received: by mail-vs1-f49.google.com with SMTP id j65so1644865vsc.3 for ; Thu, 07 Jul 2022 10:19:12 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=gPJ5uA6z95TScfa7IO9PfH66G5gRBDfHL7pSJrKqZ3U=; b=tY+RxqERBQaiFt1QhY7yn9CUBHacOZvTLEFXuhhFWA3uv1NgdqBQkeWoKTJ+mgHM1z SAjH6zU/e+SHvMPa0z9KijvQEYhsE1jhlELtT/CCxaU51srG7ctFMwyEQj5Xa0h55IfK sm3PHKXT0BAGBPBS3RKAApKnXv3THzHq5JHYVDxpw3ug3RAeCnpTTwC/repQzmtCTEcc AcH+vyVHQP8YJqcJSU26/0t+MxBM9PIXtu3MPgRgpqbWy5XljZUyfJAZMTfrcay15iDi YXUooFOTxcFr9T8H2T1hgjclEw9yMs7QQSBAel78YD4TuD9h8/MtrJsGqQx1C2cmkaqx okqA== X-Gm-Message-State: AJIora/eJyeICipKrUZfBsGXlgpzOEV5eMhVF2G4V/5tFcFmECVOohXl gx3P0ehGP5+24oCyaQCb+F2jmZsxX+9UZLan X-Google-Smtp-Source: AGRyM1ueJdr1Ts2S/FEmNw5egMoJXV13tdW9Rmkvxnj9qV26VcOrkSAbeDltQ+7Zg/s9P3T9/ESuCQ== X-Received: by 2002:a67:eb90:0:b0:356:511:ac46 with SMTP id e16-20020a67eb90000000b003560511ac46mr27541011vso.72.1657214351734; Thu, 07 Jul 2022 10:19:11 -0700 (PDT) Received: from localhost (177-4-253-164.user3p.brasiltelecom.net.br. [177.4.253.164]) by smtp.gmail.com with ESMTPSA id f3-20020a056102212300b00354582d95desm10427958vsg.4.2022.07.07.10.19.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Jul 2022 10:19:11 -0700 (PDT) From: Otavio Salvador To: openembedded-core@lists.openembedded.org Cc: Otavio Salvador Subject: [PATCH 2/2] cargo-cross-canadian: Use SDK's flags during target linking Date: Thu, 7 Jul 2022 14:19:03 -0300 Message-Id: <20220707171904.338441-2-otavio@ossystems.com.br> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220707171904.338441-1-otavio@ossystems.com.br> References: <20220707171904.338441-1-otavio@ossystems.com.br> MIME-Version: 1.0 List-Id: X-Webhook-Received: from li982-79.members.linode.com [45.33.32.79] by aws-us-west-2-korg-lkml-1.web.codeaurora.org with HTTPS for ; Thu, 07 Jul 2022 17:19:17 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/openembedded-core/message/167795 Signed-off-by: Otavio Salvador --- .../cargo/cargo-cross-canadian.inc | 20 ++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/meta/recipes-devtools/cargo/cargo-cross-canadian.inc b/meta/recipes-devtools/cargo/cargo-cross-canadian.inc index 7fc22a4128..01ba151d0a 100644 --- a/meta/recipes-devtools/cargo/cargo-cross-canadian.inc +++ b/meta/recipes-devtools/cargo/cargo-cross-canadian.inc @@ -39,6 +39,18 @@ do_compile:prepend () { PKG_CONFIG_PATH="${RECIPE_SYSROOT_NATIVE}/usr/lib/pkgconfig:${PKG_CONFIG_PATH}" } +create_sdk_wrapper () { + file="$1" + shift + + cat <<- EOF > "${file}" + #!/bin/sh + \$$1 \$@ + EOF + + chmod +x "$file" +} + do_install () { SYS_BINDIR=$(dirname ${D}${bindir}) install -d "${SYS_BINDIR}" @@ -47,6 +59,9 @@ do_install () { chrpath -r "\$ORIGIN/../lib" ${i} done + # Uses SDK's CC as linker so linked binaries works out of box. + create_sdk_wrapper "${SYS_BINDIR}/target-rust-ccld" "CC" + ENV_SETUP_DIR=${D}${base_prefix}/environment-setup.d mkdir "${ENV_SETUP_DIR}" ENV_SETUP_SH="${ENV_SETUP_DIR}/cargo.sh" @@ -58,7 +73,10 @@ do_install () { touch "\$CARGO_HOME/config" echo "[build]" >> "\$CARGO_HOME/config" echo 'target = "'${TARGET_SYS}'"' >> "\$CARGO_HOME/config" - fi + echo '# TARGET_SYS' >> "\$CARGO_HOME/config" + echo '[target.'${TARGET_SYS}']' >> "\$CARGO_HOME/config" + echo 'linker = "target-rust-ccld"' >> "\$CARGO_HOME/config" + fi # Keep the below off as long as HTTP/2 is disabled. export CARGO_HTTP_MULTIPLEXING=false