Двоичный файл Swift, встроенный в докер, вызывает сбой «незаконной инструкции» в реальном LinuxLinux

Ответить
Гость
 Двоичный файл Swift, встроенный в докер, вызывает сбой «незаконной инструкции» в реальном Linux

Сообщение Гость »


Я создаю серверное приложение, написанное на Swift, и впервые пытаюсь развернуть его в Linux. Обычно я следую этому руководству и некоторым другим, найденным в Интернете.
Моя команда докера:

Код: Выделить всё

docker run --rm -v "$PWD:/code" -w /code --platform linux/amd64 \
-e QEMU_CPU=max swift:latest 
I then pack the binary along with the required shared Swift libs and upload them to my Ubuntu 23.10 server, and the binary crashes with "illegal instruction" before it gets a chance to do anything.
The shared libs are copied from the container, so they are the ones the binary was compiled against. Also, without them on my linux server my binary crashes with a missing .so message, so they are in the right place.

Код: Выделить всё

file mybinary
prints this:

Код: Выделить всё

ELF 64-bit LSB pie executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 3.2.0, with debug_info, not stripped
which seems correct.
I also tried to build the app with

Код: Выделить всё

--static-swift-stdlibs
and got the same result.
I know that I should probably run it in a container on the server too, but I was trying to avoid that to minimize overhead.
What am I doing wrong? Is this even possible to do at all, i.e. run this binary without a container on the server?


Источник: https://stackoverflow.com/questions/781 ... real-linux
Ответить

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

Вернуться в «Linux»