Skip to content

TEXTREL in i686 since 1.41.0 #68794

Closed

Description

@Cogitri

Hello,

I'm in the process of upgrading Rust to 1.41.0 on Alpine Linux and it appears that a TEXTREL has been introduced in 1.41.0:

TEXTREL /usr/lib/librustc_macros-4cbed8a36ab240e8.so

The full build log is located here if it's of interest: https://gitlab.alpinelinux.org/Cogitri/aports/-/jobs/44396

Activity

  1. added
    A-linkageArea: linking into static, shared libraries and binaries
    C-enhancementCategory: An issue proposing an enhancement or a PR with one.
    T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.
    on Feb 3, 2020
  2. jonas-schievink commented on Feb 5, 2020

    @jonas-schievink
    Contributor

    This apparently breaks Android builds, since that forbids text relocations

    https://users.rust-lang.org/t/cant-link-rust-code-on-i686-linux-android-with-rust-1-41/37807

  3. added
    C-bugCategory: This is a bug.
    O-androidOperating system: Android
    regression-from-stable-to-stablePerformance or correctness regression from one stable version to another.
    and removed
    C-enhancementCategory: An issue proposing an enhancement or a PR with one.
    on Feb 5, 2020
  4. awakecoding commented on Feb 5, 2020

    @awakecoding

    +1 I am one of the unfortunate winner of a release-blocking CI build failure for Android now that we've upgraded to 1.41.0. We've disabled android-x86 builds for now :(

  5. brainlock commented on Feb 6, 2020

    @brainlock
    Contributor

    I added a minimal repro to my repository here: https://github.com/brainlock/rust-1.41-android-linker-bug-repro, in the hope that it can help debugging this (and because I was curious to dig into this myself :-) ).

    You can clone the repo, then

    docker build -t repro .

    docker run --rm -it repro bash

    In the container you can run ./repro-min.sh.

    I bisected it using rustup and nightly releases, 2012-12-09 is good, 2019-12-10 is bad:

    root@dea5c1fdc0d5:/usr/src/repro# rustup default nightly-2019-12-09
    info: using existing install for 'nightly-2019-12-09-x86_64-unknown-linux-gnu'
    info: default toolchain set to 'nightly-2019-12-09-x86_64-unknown-linux-gnu'
    
      nightly-2019-12-09-x86_64-unknown-linux-gnu unchanged - rustc 1.41.0-nightly (59947fcae 2019-12-08)
    
    root@dea5c1fdc0d5:/usr/src/repro# ./repro-min.sh
       Compiling repro v0.1.0 (/usr/src/repro)
        Finished release [optimized] target(s) in 0.20s
    root@dea5c1fdc0d5:/usr/src/repro# rustup default nightly-2019-12-10
    info: using existing install for 'nightly-2019-12-10-x86_64-unknown-linux-gnu'
    info: default toolchain set to 'nightly-2019-12-10-x86_64-unknown-linux-gnu'
    
      nightly-2019-12-10-x86_64-unknown-linux-gnu unchanged - rustc 1.41.0-nightly (76a252ea9 2019-12-09)
    
    root@dea5c1fdc0d5:/usr/src/repro# ./repro-min.sh
       Compiling repro v0.1.0 (/usr/src/repro)
        Finished release [optimized] target(s) in 0.20s
    ld: target/i686-unknown-linux-gnu/release/librepro.a(std-c3eaafedbae89cb4.std.52ue7rpt-cgu.0.rcgu.o): warning: relocation against `__rust_probestack' in read-only section `.text._ZN3std3sys4unix2fs4copy17h783e034bf468da7dE'
    ld: warning: creating a DT_TEXTREL in a shared object
    root@dea5c1fdc0d5:/usr/src/repro#
    

    When using nightly-2019-12-10:

    root@28bb5be323b6:/usr/src/repro# rustc --version
    rustc 1.41.0-nightly (76a252ea9 2019-12-09)
    
  6. Mark-Simulacrum commented on Feb 6, 2020

    @Mark-Simulacrum
    Member

    Conveniently, no rollups!

    76a252e Auto merge of #67110 - tmandry:bump-compiler-builtins, r=alexcrichton
    7de9402 Auto merge of #67096 - mark-i-m:fix-rustc-guide-2, r=ehuss
    3ff17e7 Auto merge of #67016 - lqd:placeholder_loans, r=matthewjasper
    dbbe4f1 Auto merge of #67004 - estebank:issue-66958, r=eddyb
    2b0e6d2 Auto merge of #67003 - cjgillot:corrida, r=Mark-Simulacrum
    14195e1 Auto merge of #66984 - GuillaumeGomez:move-clean-types, r=kinnison

    I would personally suspect #67110.

    Can you try checking this via https://crates.io/crates/rustup-toolchain-install-master/?

    Specifically, comparing 76a252e and 7de9402?

  7. brainlock commented on Feb 6, 2020

    @brainlock
    Contributor

    While rustup-toolchain-install-master compiles ( 😅 ): I see that https://github.com/rust-lang/rust/pull/67110 upgrades compiler-builtins. I had a look at the commits in compiler-builtins which touch __rust_probestack, and I think we can likely narrow it down to rust-lang/compiler-builtins@2566aa6.

    At this point I'm too much out of my depth, this needs people more knowledgeable than me 😉 . I hope I could help debugging this, and will continue watching the issue as I'm learning a great deal just by investigating this.

    Besides the actual fix, there are two additional things I'd love to understand:

    1. why doesn't scanelf -qT std-c3eaafedbae89cb4.std.52ue7rpt-cgu.0.rcgu.o detect this? It looks like the obj file is not marked in any way has having a TEXTREL, but maybe the inline asm from that commit defines __rust_probestack in such a way that relocating it needs touching the .text section (wild guess)

    2. how would we go at testing this? Where in the rust project would I add a test for this? And given that scanelf can't detect this, maybe a good way to "integration test" this would be to build a minimal rust static lib, and try to link it into a shared object with --warn-shared-textrel --fatal-warnings like I'm doing in the repro code. Do I understand correctly that "all code produced by rustc should be relocatable" is a guaranteed property (thus worth testing), or am I completely mistaken?

  8. brainlock commented on Feb 6, 2020

    @brainlock
    Contributor

    Meanwhile, I can confirm that we got the right commit (76a252e):

    albe@myo ~/code/repro [master] % docker build -t repro .
    [...]
    albe@myo ~/code/repro [master] % docker run --rm -it repro bash
    root@c74a4c84b096:/usr/src/repro# rustup default 76a252ea9e7be93a61ffdf33b3533e24a9cf459d
    info: default toolchain set to '76a252ea9e7be93a61ffdf33b3533e24a9cf459d'
    root@c74a4c84b096:/usr/src/repro# rustc --version
    rustc 1.41.0-nightly (76a252ea9 2019-12-09)
    root@c74a4c84b096:/usr/src/repro# ./repro-min.sh
    ld: target/i686-unknown-linux-gnu/release/librepro.a(std-c3eaafedbae89cb4.std.52ue7rpt-cgu.0.rcgu.o): warning: relocation against `__rust_probestack' in read-only section `.text._ZN3std3sys4unix2fs4copy17h783e034bf468da7dE'
    ld: warning: creating a DT_TEXTREL in a shared object
    root@c74a4c84b096:/usr/src/repro#
    root@c74a4c84b096:/usr/src/repro#
    root@c74a4c84b096:/usr/src/repro# rustup default 7de9402b77ded0d8ec9e1c554521b2121449ef2b
    info: default toolchain set to '7de9402b77ded0d8ec9e1c554521b2121449ef2b'
    root@c74a4c84b096:/usr/src/repro# rustc --version
    rustc 1.41.0-nightly (7de9402b7 2019-12-09)
    root@c74a4c84b096:/usr/src/repro# ./repro-min.sh
    root@c74a4c84b096:/usr/src/repro# echo $?
    0
    root@c74a4c84b096:/usr/src/repro#
    
  9. pnkfelix commented on Feb 6, 2020

    @pnkfelix
    Contributor

    triage: P-high. Assigning to self. Leaving nominated because I'd like to discuss this at today's meeting.

  10. 22 remaining items

  11. added a commit that references this issue on Feb 15, 2020
  12. brainlock commented on Mar 2, 2020

    @brainlock
    Contributor

    I'm not sure this is the right place to bring it up, but without this fix it is impossible to deploy a rust static library to platforms that enforce properly-relocatable code (x86 android). It didn't make the cut for 1.41.1, is there any chance for 1.42? Can we help to make this happen?

    Thanks!

  13. mati865 commented on Mar 2, 2020

    @mati865
    Member

    #69086 is beta nominated, it will be backported soon and included in 1.42 release.

  14. brainlock commented on Mar 2, 2020

    @brainlock
    Contributor

    #69086 is beta nominated, it will be backported soon and included in 1.42 release.

    Fantastic, thanks. Do you think it would be worth it to also include the regression test (#69168) in the release?

  15. mati865 commented on Mar 2, 2020

    @mati865
    Member

    Do you think it would be worth it to also include the regression test (#69168) in the release?

    CCing the reviewers @tmandry @Mark-Simulacrum

  16. awakecoding commented on Mar 2, 2020

    @awakecoding

    awesome, I am waiting for a release with this fix. Any idea when 1.42 is planned?

  17. Cogitri commented on Mar 2, 2020

    @Cogitri
    Author

    Stable releases usually occur every 6 weeks, so it should land in ~2 weeks.

  18. Mark-Simulacrum commented on Mar 3, 2020

    @Mark-Simulacrum
    Member

    I've nominated the regression test as well!

  19. added
    O-x86_32Target: x86 processors, 32 bit (like i686-*) (also known as IA-32, i386, i586, i686)
    and removed on Oct 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

A-linkageArea: linking into static, shared libraries and binariesC-bugCategory: This is a bug.O-androidOperating system: AndroidO-x86_32Target: x86 processors, 32 bit (like i686-*) (also known as IA-32, i386, i586, i686)P-highHigh priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.regression-from-stable-to-stablePerformance or correctness regression from one stable version to another.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions