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

how to run x86 programs? #764

Closed
gurachan opened this issue Jul 5, 2018 · 16 comments
Closed

how to run x86 programs? #764

gurachan opened this issue Jul 5, 2018 · 16 comments

Comments

@gurachan
Copy link

gurachan commented Jul 5, 2018

I was wondering if i can run x86 on termux...I have 64 bit system. is there 86_64 version of termux?

@ghost
Copy link

ghost commented Jul 5, 2018

@Dj-jom2x Which CPU architecture on your device ? Post output of uname -m.

@gurachan
Copy link
Author

gurachan commented Jul 5, 2018

Linux localhost 3.18.22+ #1 SMP PREEMPT Wed Dec 20 22:32:29 CST 2017 aarch64 Android

I really wanted to execute 32bit on this thing instead of installing on limbo :(

@ghost
Copy link

ghost commented Jul 5, 2018

@Dj-jom2x You need a QEMU to run x86 programs which is available in my repository currently.

If your program is not complex (e.g. statically compiled binary), you can use qemu in user-mode:

  1. qemu-user-i386: https://termux.xeffyr.ml/dists/extra/main/binary-aarch64/qemu-user-i386_2.12.0-2_aarch64.deb
  2. qemu-user-x86_64: https://termux.xeffyr.ml/dists/extra/main/binary-aarch64/qemu-user-x86_64_2.12.0-2_aarch64.deb

I have used them to make fasm and pandoc available for Termux:

If your program is complex - use a qemu-system* packages, Limbo, or you need different device.
Termux can't execute programs for architectures different from host.

@gurachan
Copy link
Author

gurachan commented Jul 5, 2018

yes its static

btw i install it inside termux how to run it ?
using qemu?

@ghost
Copy link

ghost commented Jul 5, 2018

For x86_64: qemu-x86_64 ./path/to/binary
For x86 (32bit): qemu-i386 ./path/to/binary

As shown, just prefix it with qemu executable.

@gurachan
Copy link
Author

gurachan commented Jul 5, 2018

omg your the best man... 10/10 thanks thanks.. you save me a lot of space.

@gurachan gurachan closed this as completed Jul 5, 2018
@tigran123
Copy link

Are those qemu binaries still available (or newer versions of them)? I can't access them.

@ghost
Copy link

ghost commented Aug 8, 2019

qemu is available in unstable-repo.

@tigran123
Copy link

tigran123 commented Aug 8, 2019

@xeffyr Thank you. I knew that, but I wasn't sure if it contained your fixes. I assumed it was "plain vanilla" version :)

@ghost
Copy link

ghost commented Aug 8, 2019

There no "plain vanilla" version for Termux. It just can't be compiled.
For vanilla version you will need to setup a chroot environment of Ubuntu/Debian/etc...

@tigran123
Copy link

tigran123 commented Aug 8, 2019

Thanks. I compiled statically a hello world program in C on x86_64 and then run qemu-x86_64 hello (on Android 9 Termux) and it is still consuming CPU cycles (5 minutes already) but no sign of "Hello, world!" output yet...

@tigran123
Copy link

strace shows a loop like this:

futex(0x58ba03ef00, FUTEX_WAKE_PRIVATE, 2147483647) = 0
futex(0x58ba03eecc, FUTEX_WAKE_PRIVATE, 2147483647) = 0
futex(0x58ba03ef00, FUTEX_WAKE_PRIVATE, 2147483647) = 0
futex(0x58ba03eecc, FUTEX_WAKE_PRIVATE, 2147483647) = 0
futex(0x58ba03ef00, FUTEX_WAKE_PRIVATE, 2147483647) = 0
futex(0x58ba03eecc, FUTEX_WAKE_PRIVATE, 2147483647) = 0

@ghost
Copy link

ghost commented Aug 8, 2019

That why qemu is in "unstable packages". It works differently on different devices.
The most stable qemu packages are only that compiled for aarch64.

Probably I will need to downgrade qemu to 3.1.0 like was done for X11 packages, as v4.0.0 has really strange behaviour. Or try the newer 4.1.0 rc.

@ghost
Copy link

ghost commented Aug 8, 2019

I have following (on ARM Termux installation):

(process:21183): GLib-CRITICAL **: 22:38:17.366: g_tree_ref: assertion 'tree != NULL' failed

(process:21183): GLib-CRITICAL **: 22:38:17.366: g_tree_destroy: assertion 'tree != NULL' failed

Didn't observed this previously...

@ByRussX
Copy link

ByRussX commented Nov 4, 2020

Qemu is not running my 32 bits code

@Rhythm113
Copy link

@xeffyr I'm getting Memory Allocation Error Any Solution?

@ghost ghost locked and limited conversation to collaborators Oct 17, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants