Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rust: update from 1.53.0 to 1.54.0 #7261

Closed
wants to merge 11 commits into from
Closed

rust: update from 1.53.0 to 1.54.0 #7261

wants to merge 11 commits into from

Conversation

finagolfin
Copy link
Member

Since rust has to be bumped after changing the LLVM version, let's try updating the version again, as in #7211.

@@ -1,13 +1,12 @@
TERMUX_PKG_HOMEPAGE=https://www.rust-lang.org/
TERMUX_PKG_DESCRIPTION="Systems programming language focused on safety, speed and concurrency"
TERMUX_PKG_LICENSE="MIT"
TERMUX_PKG_MAINTAINER="Kevin Cotugno @kcotugno"
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm removing @kcotugno as maintainer, since he hasn't been doing it for a couple years. No slight, Kevin, but I think it's better if this line were accurate, and we fully understand if you're too busy to volunteer for this. If you'd like me to keep this line the way it is, just let me know.

max_level_info = ['tracing/max_level_info']
+
+[target.armv7-linux-androideabi]
+ldflags = "-lgcc"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, that is for mac, there is no such lib in the NDK. The one that has it for armv7 in the NDK is libgcc_real.a, with -lgcc forwarding to that.

I'm not sure it's forwarding this linker flag, so having it blow up with fake flags now so I can check it went through.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, cargo throws out the ldflags I'm passing in, as I suspected:

warning: /home/builder/.termux-build/rust/src/compiler/rustc_driver/Cargo.toml: unused manifest key: target.armv7-linux-androideabi.ldflags

@finagolfin
Copy link
Member Author

@its-pointless, got a clue here? My guess is that one of the rust driver's dependencies started using thread-local storage (on ARM only?), which requires libgcc for emulated thread-locals on Android, but this rust compiler build always passed -nodefaultlibs when linking, which disables clang from linking against runtime libraries like libgcc.

The question is how do we add in linker flags to compensate for this, as the rust compiler build throws out this flag no matter how I pass it in to the arm build.

@finagolfin finagolfin marked this pull request as draft August 11, 2021 06:27
@coolreader18
Copy link
Contributor

@buttaface that's the wrong place to put linker flags - try setting a ARMV7_LINUX_ANDROIDEABI_RUSTFLAGS=-Clink-arg=-lgcc, or take a look at the cargo config doc page - maybe a .cargo/config.toml file with [target.armv7-linux-androideabi] rustc-flags = ["-Clink-args", "-lgcc"]

@finagolfin
Copy link
Member Author

OK, trying out rustflags = ["-Clink-arg=-lgcc"] now.

@finagolfin
Copy link
Member Author

Nope, the rust compiler build is undefeated at spitting our puny flags back at us:

warning: /home/builder/.termux-build/rust/src/compiler/rustc_driver/Cargo.toml: unused manifest key: target.armv7-linux-androideabi.rustflags

@Grimler91
Copy link
Member

I am seeing some -lgcc issues with ndk r23 as well. Maybe updating both of them in the same PR would work (I'll try)

@finagolfin
Copy link
Member Author

Since this is failing with NDK 21, I don't think the NDK is the reason. Something changed in one of the Rust compiler driver's files on armv7 with this 1.54.0 bump, to where it's using emulated thread-locals now and therefore needs libgcc on Android.

The question is how to pass that into the Rust compiler build, which is now built by Cargo but doesn't accept the same build flags as other Cargo builds.

@Grimler91
Copy link
Member

You are for sure more familiar with what is happening here, just note that the NDK r23 changed so that libunwind is used instead of libgcc on arm as well (so no more libgcc). Maybe it is easier to get it to work for arm on r23, as arm there behaves more like the other arches

@finagolfin
Copy link
Member Author

Oh, you may be right that this problem goes away with NDK 23: I didn't see that the new NDK removed libgcc when I said the NDK wouldn't make a difference earlier.

@coolreader18
Copy link
Contributor

Ah, sorry I missed the comment five days ago- rustflags doesn't go in Cargo.toml, it goes in .cargo/config.toml

@coolreader18
Copy link
Contributor

Maybe that's not the issue anyway though ¯\_(ツ)_/¯

@finagolfin
Copy link
Member Author

Btw, I rebased on your updated ndk 23 branch because the armv7 build failed in the ndk packages, and I want to see if rust builds for armv7 now.

@Grimler91
Copy link
Member

@buttaface I understand. I'll stop force pushing now to not interfer with your work. It will most likely fail when it tries to link some hostbuilt thing with libz from device now (if it behaves as when I tried local build)

@finagolfin
Copy link
Member Author

Heh, no, your change to the config.toml got it to finally work now.

I don't use rust, so if @coolreader18 could test this once the zip is uploaded, we'll know if this is ready to go once we switch to NDK 23.

@coolreader18
Copy link
Contributor

Not sure why, and maybe I'm doing this wrong, but the rust deb is empty - the only binary in usr/bin is rust-lld

@coolreader18
Copy link
Contributor

Also ndk-sysroot can't install, usr/include/unicode/umachine.h is also provided by libicu

@Grimler91
Copy link
Member

Grimler91 commented Aug 19, 2021

@coolreader18 thanks, will remove it from ndk-23 (and thereby ndk-sysroot).

Grimler91 and others added 10 commits August 21, 2021 22:27
To fix error:

In file included from /termux-build/_cache/android-r23-api-24-v0/bin/../sysroot/usr/include/termios.h:154:
In file included from /termux-build/_cache/android-r23-api-24-v0/bin/../sysroot/usr/include/android/legacy_termios_inlines.h:43:
/termux-build/_cache/android-r23-api-24-v0/bin/../sysroot/usr/include/bits/termios_inlines.h:120:10: error: duplicate case value '0'
    case TCSAFLUSH: cmd = TCSETSF; break;
         ^
/termux-build/_cache/android-r23-api-24-v0/bin/../sysroot/usr/include/asm-generic/termbits.h:194:19: note: expanded from macro 'TCSAFLUSH'
                  ^
/termux-build/_cache/android-r23-api-24-v0/bin/../sysroot/usr/include/bits/termios_inlines.h:118:10: note: previous case defined here
    case TCSANOW: cmd = TCSETS; break;
         ^
/termux-build/_cache/android-r23-api-24-v0/bin/../sysroot/usr/include/asm-generic/termbits.h:191:17: note: expanded from macro 'TCSANOW'
                ^
Compiler and tool names need to be updated in Makefile.

Also fix some patch offsets while we are at it
It does not build with ndk r23, it uses its own stdio.h file, which
does not seem to be compatible with the ndk headers.
Error:

ld: error: duplicate symbol: debug
>>> defined at rr.c
>>>            rr.o:(debug)
>>> defined at main.c
>>>            main.o:(.bss+0x0)

happen when trying to build with android-ndk r22 or r23.
More info: https://go-review.googlesource.com/c/go/+/280312
@finagolfin
Copy link
Member Author

Closing for the NDK 23 update in #7339, which finally gets this build to finish.

@finagolfin finagolfin closed this Aug 21, 2021
@finagolfin finagolfin deleted the rust branch August 21, 2021 18:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants