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

Support for emulating AVX for x86 programs #530

Open
mindreframer opened this issue Aug 12, 2023 · 16 comments
Open

Support for emulating AVX for x86 programs #530

mindreframer opened this issue Aug 12, 2023 · 16 comments
Labels
f/containers Affects container users f/machines Affects Linux machine users t/feature New feature

Comments

@mindreframer
Copy link

Describe the bug

The binary for FlashMQ is not starting up.

$ flashmq
qemu: uncaught target signal 4 (Illegal instruction) - core dumped
Illegal instruction

To Reproduce

Install via following instructions

$ sudo su
$ curl https://www.flashmq.org/wp-content/uploads/2021/10/flashmq-repo.gpg > /usr/share/keyrings/flashmq-repo.gpg
$ echo "deb [signed-by=/usr/share/keyrings/flashmq-repo.gpg] http://repo.flashmq.org/apt focal main" > /etc/apt/sources.list.d/flashmq.list
$ echo "deb [signed-by=/usr/share/keyrings/flashmq-repo.gpg] http://repo.flashmq.org/apt jammy main" > /etc/apt/sources.list.d/flashmq.list
$ apt-get update 
$ apt install flashmq

Expected behavior

It should start up without issues.

Diagnostic report (required)

OrbStack info:
Version: 0.16.0 (160000)
Commit: b92cc5239da462d9918d844fc5b04ec110a35e1a (v0.16.0)

System info:
macOS: 12.3.1 (21E258)
CPU: arm64, 8 cores
CPU model: Apple M1

Full report: https://orbstack.dev/_admin/diag/orbstack-diagreport_2023-08-12T08-47-39.137319Z.zip

Screenshots and additional context (optional)

No response

@mindreframer mindreframer added the t/bug Something isn't working label Aug 12, 2023
@halfgaar
Copy link

Author of FlashMQ here. I guess I need to configure the repo better, because it's amd64 only, not ARM. There is a Architectures: amd64 line in it, but apparently that's not enough for your apt to reject it. I'll look into that, but it won't solve your issues as of yet.

FlashMQ can be built on ARM though. If not using build.sh, which I can imagine if you're including it inside another build infra, be sure to build with cmake's -DCMAKE_BUILD_TYPE=Release.

@kdrag0n
Copy link
Member

kdrag0n commented Aug 13, 2023

I'd have to investigate more but the most likely cause of this crash is that FlashMQ assumes support for AVX instructions, and QEMU doesn't support emulating AVX. (But of course, running a native ARM build is better if possible.)

@mindreframer
Copy link
Author

@halfgaar Thanks for the quick response! I'll try to compile it, maybe this solves it.

@mindreframer
Copy link
Author

@kdrag0n Thanks! I had the same problem with signal 4 also with some other software binaries. Like this one:

@mindreframer
Copy link
Author

@halfgaar I have managed to compile it myself. Still it fails with the same error message.

root@ubuntu:/Users/roman/Desktop/work/linux/FlashMQ/FlashMQBuildRelease# ls
CMakeCache.txt  CMakeFiles  cmake_install.cmake  CPackConfig.cmake  _CPack_Packages  CPackSourceConfig.cmake  flashmq  flashmq_1.6.5-1691940405+jammy_amd64.deb  install_manifest.txt  Makefile
root@ubuntu:/Users/roman/Desktop/work/linux/FlashMQ/FlashMQBuildRelease# ./flashmq
qemu: uncaught target signal 4 (Illegal instruction) - core dumped
Illegal instruction
root@ubuntu:/Users/roman/Desktop/work/linux/FlashMQ/FlashMQBuildRelease#

@mindreframer
Copy link
Author

@kdrag0n If QEMU doesn't support emulating AVX, we're out of luck, I guess? I just love the convenience of having a snappy Linux ENV with a single bash command. But well... If there is no other way, I would have to fallback to VirtualBox or Parallels Desktop.

Thanks for Orbstack, amazing piece of software!

@halfgaar
Copy link

If you remove the following from CMakeLists.txt, it may work:

check_cxx_compiler_flag("-msse4.2"   COMPILER_RT_HAS_MSSE4_2_FLAG)
if (${COMPILER_RT_HAS_MSSE4_2_FLAG})
    SET(CMAKE_CXX_FLAGS "-msse4.2")
endif()

@kdrag0n
Copy link
Member

kdrag0n commented Aug 14, 2023

The latest version of QEMU does support emulating AVX so you can try installing your own copy in the machine. OrbStack uses an older version for stability reasons.

@mindreframer
Copy link
Author

@halfgaar Removing those lines from CMakeLists.txt worked!

root@ubuntu:/Users/roman/Desktop/work/linux/FlashMQ/FlashMQBuildRelease# ./flashmq
[2023-08-14 13:27:14] [INFO] Setting rlimit nofile to 1000000.
[2023-08-14 13:27:14] [NOTICE] 8 CPUs are detected, making as many threads. Use 'thread_count' setting to override.
[2023-08-14 13:27:14] [INFO] Loading '/var/lib/flashmq/retained.db'
[2023-08-14 13:27:14] [INFO] Loading '/var/lib/flashmq/sessions.db'
[2023-08-14 13:27:14] [NOTICE] Starting FlashMQ version 1.6.5, release build without SSE support.
[2023-08-14 13:27:14] [NOTICE] Creating IPv4 non-SSL TCP listener on [0.0.0.0]:1883
[2023-08-14 13:27:14] [NOTICE] Creating IPv6 non-SSL TCP listener on [::]:1883
[2023-08-14 13:27:14] [INFO] Switching logging from stdout to logfile '/var/log/flashmq/flashmq.log'

Thank, will continue playing with it!

@mindreframer
Copy link
Author

@kdrag0n are you speaking about 8.0.4 ? 8.0.4 I had 8.0.2 via homebrew before. Upgraded now to 8.0.4.

Do I need to restart OrbStack? Configure something, so that it picks up the system QEMU version?
Would it be possible to make the diagnostics zip file accessible to the user?

@rkomu
Copy link

rkomu commented Aug 16, 2023

I had the same issue when using the docker image from milvus. . However, it worked fine when I switched to Docker desktop that uses the rosetta2 to emulate x86 architecture. I assume, in orbstack, qemu is used to emulate and it's the cause of the error. Is there any way to use rosetta on orbstack instead of qemu?

@kdrag0n kdrag0n changed the title FlashMQ on ubuntu fails with qemu: uncaught target signal 4 (Illegal instruction) - core dumped Support for emulating AVX for x86 programs Aug 18, 2023
@kdrag0n
Copy link
Member

kdrag0n commented Aug 18, 2023

@rkomu OrbStack uses Rosetta by default unless you disable it in Settings, but neither one supports emulating AVX. Follow the upstream issue instead: milvus-io/milvus#21483

@mindreframer This is about QEMU on the Linux side, not on macOS. Ubuntu's QEMU is also too old to support AVX so unfortunately there aren't many options here.

Diagnostic reports are already available at ~/.orbstack/diag, but they won't help with this.

@mindreframer
Copy link
Author

@kdrag0n Thanks for the response! Let's hope it will be possible to upgrade sometime soon.

@kdrag0n kdrag0n added t/feature New feature f/containers Affects container users f/machines Affects Linux machine users and removed t/bug Something isn't working labels Aug 18, 2023
@jav-12
Copy link

jav-12 commented Mar 8, 2024

I have the same situation but for the MongoDB package. I need to emulate the amd64 installation and Mongo failed to start due to missing AVX support. I know mongo has an arm64 package but I specifically need to test something for the amd64 package. The emulation of AVX using orbstack VMs will come in handy...

@dobegor
Copy link

dobegor commented May 27, 2024

@kdrag0n thanks for identifying the same issue with AlloyDB. However, some feature are not available for the native ARM build of AlloyDB, therefore I can't use OrbStack with it at all if I need these features.

The latest version of QEMU does support emulating AVX so you can try installing your own copy in the machine. OrbStack uses an older version for stability reasons.

is there a way to access OrbStack's docker machine to try to update the QEMU as an experimental workaround?

@190n
Copy link

190n commented Nov 4, 2024

Rosetta in macOS 15 Sequoia has added AVX and AVX2 support, which seems to work on macOS binaries but not within OrbStack. Is there a way for OrbStack to take advantage of this support, or does Rosetta for Linux still not support those instructions?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
f/containers Affects container users f/machines Affects Linux machine users t/feature New feature
Projects
None yet
Development

No branches or pull requests

7 participants