From d5ab20d23b48407dc8dcc1c65b36d341d8e33b7b Mon Sep 17 00:00:00 2001 From: Dan Callaghan Date: Fri, 5 Feb 2021 09:01:02 +1000 Subject: [PATCH] rust-hello-world: enable LTO in the build If the libstd-rs recipe is not correctly embedding LVM bitcode in its output, then it can produce a toolchain that appears to work until you try building a project that requests LTO: error: failed to get bitcode from object file for LTO (Bitcode section not found in object file) Enable LTO for rust-hello-world to give us an easy watch to catch such problems. --- .../rust-hello-world/0001-enable-LTO.patch | 23 +++++++++++++++++++ .../rust-hello-world/rust-hello-world_git.bb | 4 ++++ 2 files changed, 27 insertions(+) create mode 100644 recipes-example/rust-hello-world/rust-hello-world/0001-enable-LTO.patch diff --git a/recipes-example/rust-hello-world/rust-hello-world/0001-enable-LTO.patch b/recipes-example/rust-hello-world/rust-hello-world/0001-enable-LTO.patch new file mode 100644 index 0000000..56ef9e7 --- /dev/null +++ b/recipes-example/rust-hello-world/rust-hello-world/0001-enable-LTO.patch @@ -0,0 +1,23 @@ +From fa40b874f6470ec11a8fd7b0c9909d0cdd2d6feb Mon Sep 17 00:00:00 2001 +From: Dan Callaghan +Date: Fri, 5 Feb 2021 08:56:34 +1000 +Subject: [PATCH] enable LTO + +--- + Cargo.toml | 3 +++ + 1 file changed, 3 insertions(+) + +diff --git a/Cargo.toml b/Cargo.toml +index 7a2f6c8..cdb6b5d 100644 +--- a/Cargo.toml ++++ b/Cargo.toml +@@ -3,3 +3,6 @@ + name = "rust-hello-world" + version = "0.0.1" + authors = ["Cody P Schafer "] ++ ++[profile.release] ++lto = true +-- +2.28.0 + diff --git a/recipes-example/rust-hello-world/rust-hello-world_git.bb b/recipes-example/rust-hello-world/rust-hello-world_git.bb index ba88548..4e2c1a5 100644 --- a/recipes-example/rust-hello-world/rust-hello-world_git.bb +++ b/recipes-example/rust-hello-world/rust-hello-world_git.bb @@ -4,6 +4,10 @@ SRC_URI = "git://github.com/jmesmon/rust-hello-world.git;protocol=https" SRCREV="e0fa23f1a3cb1eb1407165bd2fc36d2f6e6ad728" LIC_FILES_CHKSUM="file://COPYRIGHT;md5=e6b2207ac3740d2d01141c49208c2147" +SRC_URI += "\ + file://0001-enable-LTO.patch \ + " + SUMMARY = "Hello World by Cargo for Rust" HOMEPAGE = "https://github.com/jmesmon/rust-hello-world" LICENSE = "MIT | Apache-2.0"