Skip to contentSkip to conversation

rust: fix arm64 link failures when building rust apps

PATCH In review S. Lockwood-Childs 3 participants 4 messages Dec 16, 2021 – Dec 17, 2021

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 rust: fix arm64 link failures when building rust apps

Typical error when trying to build a rust app (for example, librsvg) for aarch64 targets looks like:
undefined references to `__aarch64_ldadd8_rel'

The upstream rust commit
"add target feature outline-atomics" 0f9f241aac21bc77fb9e757da18207abefdc841d has caused a number of such link failure regressions on platforms with aarch64 toolchains that are not able to cope with -moutline-atomics flag. This includes musl toolchains [1] but some glibc toolchains also are not able to handle this flag [2,3]

OE gcc-cross-aarch64 is currently one of the latter, but when it *is* able to handle outline-atomics this patch should go away, to take advantage of the reported performance benefit.

[1] https://github.com/rust-lang/git2-rs/issues/706
[2] https://www.mail-archive.com/[email protected]/msg661738.html
[3] https://bugzilla.redhat.com/show_bug.cgi?id=1830472

---
 meta/recipes-devtools/rust/rust-target.inc    |  2 +
 .../rust/rust-disable-outline-atomics.patch   | 50 +++++++++++++++++++
 2 files changed, 52 insertions(+)
 create mode 100644 meta/recipes-devtools/rust/rust/rust-disable-outline-atomics.patch
meta/recipes-devtools/rust/rust-target.inc +2 -0
index 3f637b3ba5..bac743f66d 100644
@@ -2,6 +2,8 @@ require rust.inc
 
 DEPENDS += "rust-llvm (=${PV})"
 
+SRC_URI += "file://rust-disable-outline-atomics.patch"
+
 # Otherwise we'll depend on what we provide
 INHIBIT_DEFAULT_RUST_DEPS:class-native = "1"
 # We don't need to depend on gcc-native because yocto assumes it exists
meta/recipes-devtools/rust/rust/rust-disable-outline-atomics.patch new file +50 -0

50 lines not on this page · raw message

Signature · 1 line
2.20.1
#1 lore raw

Discussion in https://github.com/rust-lang/git2-rs/pull/759 doesn't exactly fill one with confidence, but still, can this be handled and fixed in rust upstream? Non-upstreamable patches for what is a common use case aren't a good idea.

Alex

Quoted 129 lines · S. Lockwood-Childs

Typical error when trying to build a rust app (for example, librsvg) for aarch64 targets looks like:
undefined references to `__aarch64_ldadd8_rel'

The upstream rust commit
"add target feature outline-atomics" 0f9f241aac21bc77fb9e757da18207abefdc841d
has caused a number of such link failure regressions on platforms with aarch64
toolchains that are not able to cope with -moutline-atomics flag. This includes
musl toolchains [1] but some glibc toolchains also are not able to handle this
flag [2,3]

OE gcc-cross-aarch64 is currently one of the latter, but when it *is* able to
handle outline-atomics this patch should go away, to take advantage of the reported performance benefit.

[1] https://github.com/rust-lang/git2-rs/issues/706
[2] https://www.mail-archive.com/[email protected]/msg661738.html
[3] https://bugzilla.redhat.com/show_bug.cgi?id=1830472

---
 meta/recipes-devtools/rust/rust-target.inc    |  2 +
 .../rust/rust-disable-outline-atomics.patch   | 50 +++++++++++++++++++
 2 files changed, 52 insertions(+)
 create mode 100644

meta/recipes-devtools/rust/rust/rust-disable-outline-atomics.patch

meta/recipes-devtools/rust/rust-target.inc +2 -0
index 3f637b3ba5..bac743f66d 100644
@@ -2,6 +2,8 @@ require rust.inc
 
 DEPENDS += "rust-llvm (=${PV})"
 
+SRC_URI += "file://rust-disable-outline-atomics.patch"
+
 # Otherwise we'll depend on what we provide
 INHIBIT_DEFAULT_RUST_DEPS:class-native = "1"
 # We don't need to depend on gcc-native because yocto assumes it exists

diff --git a/meta/recipes-devtools/rust/rust/rust-disable-outline-atomics.patch b/meta/recipes-devtools/rust/rust/rust-disable-outline-atomics.patch new file mode 100644
index 0000000000..fc99a06a6a

meta/recipes-devtools/rust/rust/rust-disable-outline-atomics.patch new file +7 -0
@@ -0,0 +1,50 @@
+rust: fix arm64 link failures when building rust apps
+
+Typical error when trying to build a rust app looks like:
+  undefined references to `__aarch64_ldadd8_rel'
+
+The upstream rust commit
+"add target feature outline-atomics"

0f9f241aac21bc77fb9e757da18207abefdc841d
+has caused a number of such link failure regressions on platforms with aarch64
+toolchains that are not able to cope with -moutline-atomics flag. This includes
+musl toolchains [1] but some glibc toolchains also are not able to handle this

meta/recipes-devtools/rust/rust/rust-disable-outline-atomics.patch new file +3 -0
+flag [2,3]
+
+OE gcc-cross-aarch64 is currently one of the latter, but when it *is*

able to

meta/recipes-devtools/rust/rust/rust-disable-outline-atomics.patch new file +12 -0
+handle outline-atomics this patch should go away, to take advantage of the
+reported performance benefit.
+
+[1] https://github.com/rust-lang/git2-rs/issues/706
+[2] https://www.mail-archive.com/[email protected]/msg661738.html
+[3] https://bugzilla.redhat.com/show_bug.cgi?id=1830472
+
+Upstream-Status: Inappropriate [other]
+
+Signed-off-by: S. Lockwood-Childs <[email protected]>
+
+diff --git a/compiler/rustc_codegen_llvm/src/llvm_util.rs

b/compiler/rustc_codegen_llvm/src/llvm_util.rs
+index c2136f161..ca221eb4a 100644
+--- a/compiler/rustc_codegen_llvm/src/llvm_util.rs
++++ b/compiler/rustc_codegen_llvm/src/llvm_util.rs
+@@ -416,13 +416,14 @@ pub fn llvm_global_features(sess: &Session) -> Vec<String> {

meta/recipes-devtools/rust/rust/rust-disable-outline-atomics.patch new file +2 -0
+     // -Ctarget-features
+     features.extend(sess.opts.cg

.target_feature.split(',').flat_map(&filter));
+
+- // FIXME: Move outline-atomics to target definition when earliest
supported LLVM is 12.

+-    if get_version() >= (12, 0, 0)
+-        && sess.target.llvm_target.contains("aarch64-unknown-linux")
+-        && sess.target.llvm_target != "aarch64-unknown-linux-musl"
+-    {
+-        features.push("+outline-atomics".to_string());
+-    }
++//    // FIXME: Move outline-atomics to target definition when earliest

supported LLVM is 12.
++// if get_version() >= (12, 0, 0)
++// && sess.target.llvm_target.contains("aarch64-unknown-linux")
++// && sess.target.llvm_target != "aarch64-unknown-linux-musl"
++// {
++// features.push("+outline-atomics".to_string());
++// }
++

meta/recipes-devtools/rust/rust/rust-disable-outline-atomics.patch new file +3 -1
+
+     features
+ }
--

2.20.1

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group. View/Reply Online (#159774):
https://lists.openembedded.org/g/openembedded-core/message/159774
Mute This Topic: https://lists.openembedded.org/mt/87763768/1686489
Group Owner: [email protected]
Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [ [email protected]]
-=-=-=-=-=-=-=-=-=-=-=-

#2 lore raw
In reply to S. Lockwood-Childs

Patch withdrawn: turns out meta-tegra was pulling in an old toolchain for CUDA reasons, and that just got fixed. Probably there isn't another aarch64 platform still using a non-fixed toolchain, and if there happens to be one maybe they will run across this patch to carry it in their own layer.

Note: apologies for not CC-ing Alexander Kanavin, but I couldn't figure out how to directly reply to his question from this list's web UI & I don't have a copy of his email in my inbox.
https://lists.openembedded.org/g/openembedded-core/message/159775

Quoted 98 lines · S. Lockwood-Childs

Typical error when trying to build a rust app (for example, librsvg) for aarch64 targets looks like:
undefined references to `__aarch64_ldadd8_rel'

The upstream rust commit
"add target feature outline-atomics" 0f9f241aac21bc77fb9e757da18207abefdc841d has caused a number of such link failure regressions on platforms with aarch64 toolchains that are not able to cope with -moutline-atomics flag. This includes musl toolchains [1] but some glibc toolchains also are not able to handle this flag [2,3]

OE gcc-cross-aarch64 is currently one of the latter, but when it *is* able to handle outline-atomics this patch should go away, to take advantage of the reported performance benefit.

[1] https://github.com/rust-lang/git2-rs/issues/706
[2] https://www.mail-archive.com/[email protected]/msg661738.html
[3] https://bugzilla.redhat.com/show_bug.cgi?id=1830472

---
 meta/recipes-devtools/rust/rust-target.inc    |  2 +
 .../rust/rust-disable-outline-atomics.patch   | 50 +++++++++++++++++++
 2 files changed, 52 insertions(+)
 create mode 100644 meta/recipes-devtools/rust/rust/rust-disable-outline-atomics.patch
meta/recipes-devtools/rust/rust-target.inc +2 -0
index 3f637b3ba5..bac743f66d 100644
@@ -2,6 +2,8 @@ require rust.inc
 
 DEPENDS += "rust-llvm (=${PV})"
 
+SRC_URI += "file://rust-disable-outline-atomics.patch"
+
 # Otherwise we'll depend on what we provide
 INHIBIT_DEFAULT_RUST_DEPS:class-native = "1"
 # We don't need to depend on gcc-native because yocto assumes it exists
meta/recipes-devtools/rust/rust/rust-disable-outline-atomics.patch new file +50 -0
new file mode 100644
index 0000000000..fc99a06a6a
@@ -0,0 +1,50 @@
+rust: fix arm64 link failures when building rust apps
+
+Typical error when trying to build a rust app looks like: 
+  undefined references to `__aarch64_ldadd8_rel'
+
+The upstream rust commit 
+"add target feature outline-atomics" 0f9f241aac21bc77fb9e757da18207abefdc841d
+has caused a number of such link failure regressions on platforms with aarch64
+toolchains that are not able to cope with -moutline-atomics flag. This includes
+musl toolchains [1] but some glibc toolchains also are not able to handle this
+flag [2,3]
+
+OE gcc-cross-aarch64 is currently one of the latter, but when it *is* able to
+handle outline-atomics this patch should go away, to take advantage of the
+reported performance benefit.
+
+[1] https://github.com/rust-lang/git2-rs/issues/706
+[2] https://www.mail-archive.com/[email protected]/msg661738.html
+[3] https://bugzilla.redhat.com/show_bug.cgi?id=1830472
+
+Upstream-Status: Inappropriate [other]
+
+Signed-off-by: S. Lockwood-Childs <[email protected]>
+
+diff --git a/compiler/rustc_codegen_llvm/src/llvm_util.rs b/compiler/rustc_codegen_llvm/src/llvm_util.rs
+index c2136f161..ca221eb4a 100644
+--- a/compiler/rustc_codegen_llvm/src/llvm_util.rs
++++ b/compiler/rustc_codegen_llvm/src/llvm_util.rs
+@@ -416,13 +416,14 @@ pub fn llvm_global_features(sess: &Session) -> Vec<String> {
+     // -Ctarget-features
+     features.extend(sess.opts.cg.target_feature.split(',').flat_map(&filter));
+ 
+-    // FIXME: Move outline-atomics to target definition when earliest supported LLVM is 12.
+-    if get_version() >= (12, 0, 0)
+-        && sess.target.llvm_target.contains("aarch64-unknown-linux")
+-        && sess.target.llvm_target != "aarch64-unknown-linux-musl"
+-    {
+-        features.push("+outline-atomics".to_string());
+-    }
++//    // FIXME: Move outline-atomics to target definition when earliest supported LLVM is 12.
++//    if get_version() >= (12, 0, 0)
++//        && sess.target.llvm_target.contains("aarch64-unknown-linux")
++//        && sess.target.llvm_target != "aarch64-unknown-linux-musl"
++//    {
++//        features.push("+outline-atomics".to_string());
++//    }
++
+ 
+     features
+ }
Signature · 1 line
2.20.1
#3 lore raw

We're stuck on thud (vendor related), I ended up backporting these two commits from upstream, to address this issue:

https://github.com/zuma-array/meta-rust/commit/5631d561f16d88acf9cd6a014dd292cf20668501

But I don't think the issue appears in master because of the newer gcc.

Quoted 120 lines · S. Lockwood-Childs

Patch withdrawn: turns out meta-tegra was pulling in an old toolchain for CUDA reasons, and that just got fixed. Probably there isn't another aarch64 platform still using a non-fixed toolchain, and if there happens to be one maybe they will run across this patch to carry it in their own layer.

Note: apologies for not CC-ing Alexander Kanavin, but I couldn't figure out how to directly reply to his question from this list's web UI & I don't have a copy of his email in my inbox.
https://lists.openembedded.org/g/openembedded-core/message/159775

Quoted 96 lines · S. Lockwood-Childs

Typical error when trying to build a rust app (for example, librsvg) for aarch64 targets looks like:
undefined references to `__aarch64_ldadd8_rel'

The upstream rust commit
"add target feature outline-atomics" 0f9f241aac21bc77fb9e757da18207abefdc841d has caused a number of such link failure regressions on platforms with aarch64 toolchains that are not able to cope with -moutline-atomics flag. This includes musl toolchains [1] but some glibc toolchains also are not able to handle this flag [2,3]

OE gcc-cross-aarch64 is currently one of the latter, but when it *is* able to handle outline-atomics this patch should go away, to take advantage of the reported performance benefit.

[1] https://github.com/rust-lang/git2-rs/issues/706
[2] https://www.mail-archive.com/[email protected]/msg661738.html
[3] https://bugzilla.redhat.com/show_bug.cgi?id=1830472

---
 meta/recipes-devtools/rust/rust-target.inc    |  2 +
 .../rust/rust-disable-outline-atomics.patch   | 50 +++++++++++++++++++
 2 files changed, 52 insertions(+)
 create mode 100644 meta/recipes-devtools/rust/rust/rust-disable-outline-atomics.patch
meta/recipes-devtools/rust/rust-target.inc +2 -0
index 3f637b3ba5..bac743f66d 100644
@@ -2,6 +2,8 @@ require rust.inc
 
 DEPENDS += "rust-llvm (=${PV})"
 
+SRC_URI += "file://rust-disable-outline-atomics.patch"
+
 # Otherwise we'll depend on what we provide
 INHIBIT_DEFAULT_RUST_DEPS:class-native = "1"
 # We don't need to depend on gcc-native because yocto assumes it exists
meta/recipes-devtools/rust/rust/rust-disable-outline-atomics.patch new file +50 -1
new file mode 100644
index 0000000000..fc99a06a6a
@@ -0,0 +1,50 @@
+rust: fix arm64 link failures when building rust apps
+
+Typical error when trying to build a rust app looks like:
+  undefined references to `__aarch64_ldadd8_rel'
+
+The upstream rust commit
+"add target feature outline-atomics" 0f9f241aac21bc77fb9e757da18207abefdc841d
+has caused a number of such link failure regressions on platforms with aarch64
+toolchains that are not able to cope with -moutline-atomics flag. This includes
+musl toolchains [1] but some glibc toolchains also are not able to handle this
+flag [2,3]
+
+OE gcc-cross-aarch64 is currently one of the latter, but when it *is* able to
+handle outline-atomics this patch should go away, to take advantage of the
+reported performance benefit.
+
+[1] https://github.com/rust-lang/git2-rs/issues/706
+[2] https://www.mail-archive.com/[email protected]/msg661738.html
+[3] https://bugzilla.redhat.com/show_bug.cgi?id=1830472
+
+Upstream-Status: Inappropriate [other]
+
+Signed-off-by: S. Lockwood-Childs <[email protected]>
+
+diff --git a/compiler/rustc_codegen_llvm/src/llvm_util.rs b/compiler/rustc_codegen_llvm/src/llvm_util.rs
+index c2136f161..ca221eb4a 100644
+--- a/compiler/rustc_codegen_llvm/src/llvm_util.rs
++++ b/compiler/rustc_codegen_llvm/src/llvm_util.rs
+@@ -416,13 +416,14 @@ pub fn llvm_global_features(sess: &Session) -> Vec<String> {
+     // -Ctarget-features
+     features.extend(sess.opts.cg.target_feature.split(',').flat_map(&filter));
+
+-    // FIXME: Move outline-atomics to target definition when earliest supported LLVM is 12.
+-    if get_version() >= (12, 0, 0)
+-        && sess.target.llvm_target.contains("aarch64-unknown-linux")
+-        && sess.target.llvm_target != "aarch64-unknown-linux-musl"
+-    {
+-        features.push("+outline-atomics".to_string());
+-    }
++//    // FIXME: Move outline-atomics to target definition when earliest supported LLVM is 12.
++//    if get_version() >= (12, 0, 0)
++//        && sess.target.llvm_target.contains("aarch64-unknown-linux")
++//        && sess.target.llvm_target != "aarch64-unknown-linux-musl"
++//    {
++//        features.push("+outline-atomics".to_string());
++//    }
++
+
+     features
+ }
--
Quoted 2 lines

2.20.1

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#159810): https://lists.openembedded.org/g/openembedded-core/message/159810
Mute This Topic: https://lists.openembedded.org/mt/87763768/3618097
Group Owner: [email protected]
Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-

Signature · 1 line
Alex Kiernan