From e83aa35949dbdce1f042ed9aba739a5a77c52f76 Mon Sep 17 00:00:00 2001 From: Antoni Boucher Date: Fri, 10 Oct 2025 09:39:02 -0400 Subject: [PATCH 1/4] Remove remaining usage of EMBED_LTO_BITCODE --- .github/workflows/release.yml | 2 +- tests/cross_lang_lto/src/main.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index a577c2eed71..99cc123941f 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -99,7 +99,7 @@ jobs: ar rcs libadd.a add.o popd - EMBED_LTO_BITCODE=1 CHANNEL="release" CG_RUSTFLAGS="-L native=. -Clinker-plugin-lto -Clinker=gcc" ./y.sh cargo build --release --manifest-path tests/cross_lang_lto/Cargo.toml + CHANNEL="release" CG_RUSTFLAGS="-L native=. -Clinker-plugin-lto -Clinker=gcc" ./y.sh cargo build --release --manifest-path tests/cross_lang_lto/Cargo.toml call_found=$(objdump -dj .text tests/cross_lang_lto/target/release/cross_lang_lto | grep -c "call .*my_add" ) ||: if [ $call_found -gt 0 ]; then echo "ERROR: call my_add found in asm" diff --git a/tests/cross_lang_lto/src/main.rs b/tests/cross_lang_lto/src/main.rs index a7180b33396..3c64248ba2a 100644 --- a/tests/cross_lang_lto/src/main.rs +++ b/tests/cross_lang_lto/src/main.rs @@ -4,7 +4,7 @@ * ar rcs libadd.a add.o * * Compile the Rust code with: - * EMBED_LTO_BITCODE=1 CG_RUSTFLAGS="-L native=. -Clinker-plugin-lto -Clinker=gcc" y cargo run --release + * CG_RUSTFLAGS="-L native=. -Clinker-plugin-lto -Clinker=gcc" y cargo run --release */ #[link(name="add")] From a50f0b42ab57fdb4d97898ff96b872eb22a605c6 Mon Sep 17 00:00:00 2001 From: Antoni Boucher Date: Fri, 10 Oct 2025 09:39:50 -0400 Subject: [PATCH 2/4] Remove failing-lto-tests.txt --- .github/workflows/release.yml | 3 --- tests/failing-lto-tests.txt | 33 --------------------------------- 2 files changed, 36 deletions(-) delete mode 100644 tests/failing-lto-tests.txt diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 99cc123941f..7803230087f 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -72,9 +72,6 @@ jobs: git config --global user.name "User" ./y.sh prepare - - name: Add more failing tests because of undefined symbol errors (FIXME) - run: cat tests/failing-lto-tests.txt >> tests/failing-ui-tests.txt - - name: Run tests run: | # FIXME(antoyo): we cannot enable LTO for stdarch tests currently because of some failing LTO tests using proc-macros. diff --git a/tests/failing-lto-tests.txt b/tests/failing-lto-tests.txt deleted file mode 100644 index bf0633f7320..00000000000 --- a/tests/failing-lto-tests.txt +++ /dev/null @@ -1,33 +0,0 @@ -tests/ui/lint/unsafe_code/forge_unsafe_block.rs -tests/ui/lint/unused-qualification-in-derive-expansion.rs -tests/ui/macros/macro-quote-test.rs -tests/ui/macros/proc_macro.rs -tests/ui/panic-runtime/lto-unwind.rs -tests/ui/resolve/derive-macro-1.rs -tests/ui/resolve/derive-macro-2.rs -tests/ui/rfcs/rfc-2565-param-attrs/param-attrs-pretty.rs -tests/ui/rfcs/rfc-2565-param-attrs/issue-64682-dropping-first-attrs-in-impl-fns.rs -tests/ui/rfcs/rfc-3348-c-string-literals/edition-spans.rs -tests/ui/rust-2018/suggestions-not-always-applicable.rs -tests/ui/rust-2021/reserved-prefixes-via-macro.rs -tests/ui/underscore-imports/duplicate.rs -tests/ui/async-await/issues/issue-60674.rs -tests/ui/attributes/main-removed-2/main.rs -tests/ui/cfg/assume-incomplete-release/assume-incomplete.rs -tests/ui/crate-loading/cross-compiled-proc-macro.rs -tests/ui/derives/derive-marker-tricky.rs -tests/ui/diagnostic_namespace/existing_proc_macros.rs -tests/ui/fmt/format-args-capture-issue-106408.rs -tests/ui/fmt/indoc-issue-106408.rs -tests/ui/hygiene/issue-77523-def-site-async-await.rs -tests/ui/inherent-impls-overlap-check/no-overlap.rs -tests/ui/enum-discriminant/issue-46519.rs -tests/ui/issues/issue-45731.rs -tests/ui/lint/test-allow-dead-extern-static-no-warning.rs -tests/ui/macros/macro-comma-behavior-rpass.rs -tests/ui/macros/rfc-2011-nicer-assert-messages/assert-with-custom-errors-does-not-create-unnecessary-code.rs -tests/ui/macros/rfc-2011-nicer-assert-messages/feature-gate-generic_assert.rs -tests/ui/macros/stringify.rs -tests/ui/rfcs/rfc-1937-termination-trait/termination-trait-in-test.rs -tests/ui/binding/fn-arg-incomplete-pattern-drop-order.rs -tests/ui/lto/debuginfo-lto-alloc.rs From 784f11d17781774b775439699d5fef2f148e23e3 Mon Sep 17 00:00:00 2001 From: Antoni Boucher Date: Fri, 10 Oct 2025 15:02:25 -0400 Subject: [PATCH 3/4] Do not generate fat objects when not needed --- src/back/write.rs | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/back/write.rs b/src/back/write.rs index 9f3ac6f682e..b654b34992c 100644 --- a/src/back/write.rs +++ b/src/back/write.rs @@ -59,8 +59,6 @@ pub(crate) fn codegen( if lto_supported { context.add_command_line_option("-flto=auto"); context.add_command_line_option("-flto-partition=one"); - // TODO(antoyo): remove since we don't want fat objects when it is for Bitcode only. - context.add_command_line_option("-ffat-lto-objects"); } context .compile_to_file(OutputKind::ObjectFile, bc_out.to_str().expect("path to str")); From e44d493cee3654be0c01fd39f92140a5795bea56 Mon Sep 17 00:00:00 2001 From: Antoni Boucher Date: Fri, 10 Oct 2025 15:02:34 -0400 Subject: [PATCH 4/4] Correctly embed the bitcode when compiling the sysroot --- .github/workflows/release.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 7803230087f..52f94dc2970 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -75,9 +75,7 @@ jobs: - name: Run tests run: | # FIXME(antoyo): we cannot enable LTO for stdarch tests currently because of some failing LTO tests using proc-macros. - # FIXME(antoyo): this should probably not be needed since we embed the LTO bitcode. - printf '[profile.release]\nlto = "fat"\n' >> build/build_sysroot/sysroot_src/library/Cargo.toml - ./y.sh test --release --clean --release-sysroot --build-sysroot --keep-lto-tests ${{ matrix.commands }} + CG_RUSTFLAGS="-Cembed-bitcode=yes" ./y.sh test --release --clean --release-sysroot --build-sysroot --keep-lto-tests ${{ matrix.commands }} - name: LTO test run: |