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

Package request: Rust and Cargo #261

Closed
hinmatth opened this issue May 10, 2016 · 51 comments · Fixed by #2998
Closed

Package request: Rust and Cargo #261

hinmatth opened this issue May 10, 2016 · 51 comments · Fixed by #2998
Labels
package request A new package was requested

Comments

@hinmatth
Copy link

As the popularity of Rust grows, Rust support in Termux would be extremely helpful to both Rust experts and beginners.

The binaries and libraries of Rust and Cargo are also shown to be compilable and buildable in ARM despite the fact that they should be compiled in Rust instead of C. Hence, building Rust and Cargo packages for Termux would seem highly feasible. A link towards the corresponding Github repo is provided below.

Thanks.

RustBuild: https://github.com/warricksothr/RustBuild

@Neo-Oli Neo-Oli added the package request A new package was requested label May 10, 2016
@flukejones
Copy link

I was about to request this. I also would love to see rust added to the collection. In fact, termux with a full compiler collection is becoming a very valuable tool.

@hinmatth
Copy link
Author

Good news for cross-compilation of Rust and Cargo on termux :)
http://blog.rust-lang.org/2016/05/13/rustup.html

@andreiw
Copy link

andreiw commented May 21, 2016

Rustup doesn't work on termux (which is not a termux bug, just pointing out that rustup is not a solution)

$ curl -sSf https://static.rust-lang.org/rustup.sh | sh
rustup: gpg available. signatures will be verified
rustup: unknown CPU type: aarch64

@flukejones
Copy link

flukejones commented May 22, 2016

@andreiw, sure, but using rustup on a pc os, you can easily compile the rust compiler for arm architectures i presume 😄

@gut5
Copy link

gut5 commented Jun 21, 2016

The link is pointing to the wrong place in the OP comment

https://github.com/warricksothr/RustBuild

Same with this one

http://blog.rust-lang.org/2016/05/13/rustup.html

@gut5
Copy link

gut5 commented Dec 21, 2016

Has anyone tested if rustup is working for ARM7 cpus? @andreiw seemed to try it on ARM64

@gut5
Copy link

gut5 commented Jan 3, 2017

Getting a permission denied error on rustup.sh in termux, chmod a+x doesn't help

@insunaa
Copy link

insunaa commented Jan 6, 2017

Rust isn't a bad match. It's also using the LLVM backend, which should already be installed since Termux comes with the clang toolchain.

@gut5
Copy link

gut5 commented Jan 31, 2017

screenshot_20170131-233723

This happens when I run the latest rustup.sh

@vext01
Copy link

vext01 commented Feb 15, 2017

Edit the script and insert the correct shell path in the shebang. I think it's /system/bin/sh under android (although please check).

@gut5
Copy link

gut5 commented Feb 15, 2017

Trying a different approach which is still relevant to the topic:

Downloaded rustup-init (the arm7 build), copied it to /data/local, switched to su and chmod +x rustup-init, then tried to run it. I now get a different error but I think this may be more relevant.

shamu:/data/local # sh rustup-init
rustup-init: line 1: syntax error: unexpected word (expecting ")")

Edit: used this build rustup-init

@gheoan
Copy link

gheoan commented Feb 16, 2017

I get the same error as @wrsg.

@vishalbiswas
Copy link
Contributor

The rustup-init tool isn't available to android, yet. The only way to get rust on android will be through cross compiling it. I have tried it but I am not that familiar with their build system.

@flukejones
Copy link

@vishalbiswas The next version of rust is switching to a new build system that requires Python, so it may be wise to wait until that version before doing any serious packaging.

@kirillrdy
Copy link

just my 2 cents on my attempts at building rust,
rust requires a boot strap compiler that it downloads from rust website, but that compiler doesnt run ( I am suspecting that their build aarm64 OS has dynamic linker in different location to termux.
Hoping people can confirm or comment on my findings.
ps, i have tried new python build system as well.

@vishalbiswas
Copy link
Contributor

@Luke-Nukem you mean 1.16 or 1.17?

@flukejones
Copy link

@vishalbiswas I think 1.16, iirc.

You can build it without the python based build system (rustbuild) via ./configure --disable-rustbuild, so it uses a pure makefile based compilation - but this is what is being pulled out soon.

@kirillrdy

It may be worth grabbing a precompiled binary from https://static.rust-lang.org/dist/index.html to try, if this works, then you can use that to build rust with

./configure \
    --build=%{rust_triple} \
    --host=%{rust_triple} \
    --target=%{rust_triple} \
    --enable-local-rust \
    --local-rust-root=%{_prefix} \
    --prefix=%{_prefix} \
    --libdir=%{_prefix}/lib \
    --docdir=%{_docdir}/%{name} \
    --disable-rpath \
    --disable-codegen-tests \
    --disable-rustbuild \
    --enable-vendor \
    --release-channel=stable

%{xyz} is an rpm spec macro used by distros using rpm (I copy pasted this from my spec for openSUSE). rust_triple is basically the target, eg aarch64-unknown-linux-gnu. prefix is generally /usr, but this may well be different for termux.

@kirillrdy
Copy link

@Luke-Nukem thanks for your reply.
the pre-compiled binary didn't work, and that's the same binary that it downloads to bootstrap itself.
here is why i think it something to do with dynamic linker.

file rustup-init
rustup-init: ELF 64-bit LSB shared object, ARM aarch64, version 1 (SYSV), dynamically linked, interpreter /lib/ld-linux-aarch64.so.1, for GNU/Linux 4.2.6, not stripped, with debug_info
$ ./rustup-init
-bash: ./rustup-init: No such file or directory

btw same happens when i try to run precompiled rustc, which is again what it tries to run when bootstrapping itself

@vishalbiswas
Copy link
Contributor

@kirillrdy That rustup binary was compiled for aarch64-linux-gnueabi not aarch64-linux-androideabi.
Thats why we need to cross compile it.

@RitamDey
Copy link

RitamDey commented Feb 27, 2017

I am getting this error in the latest rustup script

sTux at cmbox in ~
➜ zsh rustup.sh
info: downloading installer
run:1: no such file or directory: /data/data/com.termux/files/usr/tmp/tmp.vSrLht/rustup-init
rustup: command failed: /data/data/com.termux/files/usr/tmp/tmp.vSrLht/rustup-init
sTux at cmbox in ~

@brinsche
Copy link

But there is no latest rustup script that works on android is there? I tried to manually cross-compile rustup but that seems to be blocked by rust-lang/libc#511

I don't know if that only affects rustup itself and there is another way to install rustc + cargo or if that means it just doesn't work at the moment.

@gut5
Copy link

gut5 commented Feb 27, 2017

Seems like this may be easier once the Rust devs actually enable this as they plan to

rust-lang/rfcs#1903
rust-lang/rfcs#1795

@MineFuehrer
Copy link

It seems mozilla is providing an armv7-linux-androideabi target (but no binary release of rustc) so the only viable option at the moment is cross-compilation of rustc.

Cross-compilation of individual programs, like ripgrep, should be doable, provided you already had a working cross-compiler/ndk.

I believe the person to go to for help could be @japaric

bors added a commit to rust-lang/rustup that referenced this issue Mar 22, 2017
Add android build support

We do not have rustc and cargo binary for Android yet, but I'm working on it (there is some interest on this - termux/termux-packages#261)
bors added a commit to rust-lang/rustup that referenced this issue Mar 23, 2017
Add android build support

We do not have rustc and cargo binary for Android yet, but I'm working on it (there is some interest on this - termux/termux-packages#261)
bors added a commit to rust-lang/rustup that referenced this issue Mar 23, 2017
Add android build support

We do not have rustc and cargo binary for Android yet, but I'm working on it (there is some interest on this - termux/termux-packages#261)
@vishalbiswas
Copy link
Contributor

Requires #879

@gut5
Copy link

gut5 commented Apr 3, 2017

Great news

@japaric
Copy link

japaric commented Apr 6, 2017

Disclaimer: I know nothing about termux packaging. In fact, I just learned about this project recently. So I'm approaching the problem of making Cargo / rustc available on Android (and Chrome books?) by having official binaries installable via rustup. But if the official Rust build systems support building Cargo and rustc for Android then it should be easy to have the Termux packaging system leverage that build system to create proper Termux packages

I got both Cargo and rustc working on my Android phone (used Cross (*) and the vanilla Rust build system to build them, respectively) but I can't compile Hello World because gcc (what rustc uses to link binaries, by default) is not available for installation. clang may work but I can't try it right now because I seem to have borked my termux install and can't install anything (packages install clang does nothing)

(*) Thanks @malbarbo for adding Android support to Cross! ❤️

If clang and gcc have the exact same CLI when used as linkers then rustc should work fine when paired with clang. But if that's not the case then we'll have to patch rustc to support both gcc and clang to link Android binaries. There's some groundwork to support that scenario in rust-lang/rust#40018.

yay

wut

@vishalbiswas
Copy link
Contributor

vishalbiswas commented Apr 6, 2017

@japaric little hint, you can use termux-elf-cleaner to get rid of those "Unused DT entries" warnings
And try installing directly with apt install clang
So, this links against custom built llvm libs built during rust compilation?

@malbarbo
Copy link

malbarbo commented Apr 6, 2017

@japaric Nice work! I have rustc and cargo working in my phone and it is capable of producing binaries (I assume it is using clang linker, because gcc in termux calls clang).

I have some PR to send to rust that adds android host builds. I'm just waiting some other changes to get merged. There is also a discussion of the minimum android api level that rust must support.

rustup 1.1 was released yesterday with android builds. To install rustup run curl https://sh.rustup.rs -sSf | sh or download and run rustup-init (arm, armv7, aarch64, i686).

When we got rust and cargo nightly for android, we will be able to install them using rustup!

@japaric
Copy link

japaric commented Apr 6, 2017

@vishalbiswas Thanks for the termux-elf-cleaner hint! It removed some warnings but I'm still getting a bunch that look like this:

WARNING: linker: libterm-8aa0f90fec124b0d.so: unused DT entry: type 0xf arg 0x2f68
WARNING: linker: libterm-8aa0f90fec124b0d.so: unused DT entry: type 0x6ffffffe arg 0x418c
WARNING: linker: libterm-8aa0f90fec124b0d.so: unused DT entry: type 0x6fffffff arg 0x1

packages install clang is now working. I had messed with LD_LIBRARY_PATH and didn't realized it was already set in the termux environment. Linking is working now out of the box now! 🎉

So, this links against custom built llvm libs built during rust compilation?

Yes, I produced rustc via cross compilation and that also cross compiles LLVM as part of the build process. So this rustc is statically linked to Rust's fork of LLVM. There's an option to link against system LLVM but I think that can only be used with native builds.

@malbarbo Excellent! Can confirm that using clang as a linker works without a hitch 👍.

@vishalbiswas
Copy link
Contributor

@japaric
#879
LLVM should build a native llvm-config while cross compiling it. This does not work as expected for our libllvm package.
Rust uses llvm-config to get llvm libs and paths to link against. I think we could probably write a shell script to emulate its behaviour at this point. I'm getting nowhere debugging that one.
I would really like rustc to use system llvm. Otherwise, the package size is probably massive?

@malbarbo
Copy link

I made a PR to add host builders for android. This would allow installing rustc and cargo using rustup. We have a capacity issue and it is not possible to build rustc for all android archs. So I would like to ask:

Which arch support is more important to you?

Are you interest in rustc running in your phone or chomebook?

Maybe some of you can go to the PR page and write why rustc support on android is important to you.

@gut5
Copy link

gut5 commented Apr 13, 2017

armv7-a seems to be the most ubiquitous/compatible

@kirillrdy
Copy link

my vote would be for aarch64 and if possible x86_64 ( lenovo tablet)

@MineFuehrer
Copy link

@ssokolow emitted this gem of wisdom:

Congrats to them. I don't see how it's relevant to mention it here though.

She's a little slow, isn't she? (on the uptake probably)

@ssokolow
Copy link

ssokolow commented Apr 22, 2017

@MineFuehrer
I don't know who the "she" you're referring to is (Languages don't have genders in English and it's pretty clear from my avatar that I'm a guy), but that has the appearance of an ad hominem attack, which won't win you many allies in here.

As for my comment, in case you need clarification, whatever competition Rust may have with Nim is of the "other programming languages do exist" variety, not the "Oh my God! Stop the presses! My high school rival got a point on me! I must react!" variety.

I got the impression your goal was to manipulate people to hurry up with packaging Rust by saying "Look! Your rival is beating you!" but Nim is not Rust and what Nim does has no more bearing on how the mature adults in this thread will behave than what Brainf*ck, INTERCAL, or Ook! do.... so I repeat: "They were first to be packaged? Good on them, but it's off-topic."

@MineFuehrer
Copy link

Ah, my mistake! I thought it was a ship about to hit an iceberg. Can't wait, carry on!

@Serkan-devel
Copy link

What prevents me from installing via the shellscript?

@bugQ
Copy link

bugQ commented May 2, 2018

@Serkan-devel you can try, it seems to work for some people and not others. even if it were working, this is a package request to get working binaries of rust into the termux repo.

@fdb
Copy link

fdb commented Jul 21, 2018

I'm trying to install Rust via the its-pointless repo. This worked well last time I tried it, but now I get the following error:

$ pkg install rustc cargo
[...snip...]
The following packages have unmet dependencies:
 cargo : Depends: libssh2 but is not installable
E: Unable to correct problems, you have held broken packages.

This is on a Dell Chromebook 7310 (ChromeOS version 67.0.3396.99) with Intel Core i3 processor with a clean install of Termux version 0.64.

How can I install libssh2? I get the error Package libssh2 is not available, but is referred to by another package.

@its-pointless
Copy link
Contributor

Fixed it
Try updating

@fdb
Copy link

fdb commented Jul 22, 2018

Thanks! It works now!

@Avi-hs
Copy link

Avi-hs commented Apr 24, 2021

error: can't find Rust compiler
If you are using an outdated pip version, it is possible a prebuilt wheel is available for this package but pip is not able to install from it. Installing from the wheel would avoid the need for a Rust compiler. To update pip, run:
pip install --upgrade pip
and then retry package installation.
If you did intend to build this package from source, try installing a Rust compiler from your system package manager and ensure it is on the PATH during installation. Alternatively, rustup (available at https://rustup.rs) is the recommended way to download and update the Rust compiler toolchain.

This package requires Rust >=1.41.0. ---------------------------------------- ERROR: Failed building wheel for cryptography Failed to build cryptography
ERROR: Could not build wheels for cryptography which use PEP 517 and cannot be installed directly
WARNING: You are using pip version 20.2.3; however, version 21.0.1 is available.
You should consider upgrading via the '/data/data/com.termux/files/usr/bin/python3 -m pip install --upgrade pip' command.

Anyone show me the solution of this error
I had tried installing pip latest version & installing rust 1.51.0-1 but still it is showing error

@ghost
Copy link

ghost commented Apr 24, 2021

I had tried installing pip latest version & installing rust 1.51.0-1 but still it is showing error

It doesn't show error for me after installing rust.

@Avi-hs
Copy link

Avi-hs commented Apr 24, 2021

I am using termux @xeffyr
Check again in termux

@ghost
Copy link

ghost commented Apr 24, 2021

@Avi-hs Well, I'm using Termux too and doesn't have error.
Screenshot_20210424-152640

@Avi-hs
Copy link

Avi-hs commented Apr 24, 2021

@xeffyr thanks for giving your answer

@ghost ghost locked and limited conversation to collaborators Oct 9, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
package request A new package was requested
Projects
None yet
Development

Successfully merging a pull request may close this issue.