jmacdonald / amp

A complete text editor for your terminal.

Home Page:https://amp.rs

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Provide binary releases (with musl)

dufferzafar opened this issue · comments

Can you please provide binary releases? I saw that there's already a GitHub workflow that builds via cargo, if we could also upload the build artifacts with the releases, that would be great.

Having a library linked with musl would be great as I'd be able to run it on systems with older GLIBC.

On a sidenote, I was trying to build amp on an Ubuntu box, but since I don't have root access on the box, I can't use apt to install packages, and can only build it under a conda managed environment, which means I can only install conda packages.

Anyway, here's the error I got:

  = note: /spare/local/szafar/.conda/envs/rules-engine/bin/ld: warning: libXdmcp.so.6, needed by /usr/lib/x86_64-linux-gnu/libxcb.so, not found (try using -rpa
th or -rpath-link)
          /spare/local/szafar/.conda/envs/rules-engine/bin/ld: /usr/lib/x86_64-linux-gnu/libxcb.so: undefined reference to `XdmcpWrap'
          collect2: error: ld returned 1 exit status

  = help: some `extern` functions couldn't be found; some native libraries may need to be installed or have their path specified
  = note: use the `-l` flag to specify native libraries to link
  = note: use the `cargo:rustc-link-lib` directive to specify the native libraries to link with Cargo (see https://doc.rust-lang.org/cargo/reference/build-scri
pts.html#cargorustc-link-libkindname)

error: could not compile `amp` due to previous error

@lincolnauster I'd tried installing that conda library already, and all the errors that I reported were after this.

Anyway, I was able to get a VM running Ubuntu Xenial (I'm doing all of this on a box at work, which is why all these restrictions.) I had root access on the VM so was able to install libxcb, and was able to successfully build amp YAY!

I brought the binary built on Ubuntu Xenial back to my machine which is Ubuntu Focal, and the binary worked without any issues.

BUT!

I wanted to use the same binary on remote production boxes as well (some of which are CentOS, RHEL 6 etc.)

There I get this:

❯ amp
amp: /lib64/libc.so.6: version `GLIBC_2.14' not found (required by amp)
amp: /lib64/libc.so.6: version `GLIBC_2.18' not found (required by amp)

Which is expected as well. In other rust tools, I avoid this by using a musl static build. So I tried to compile amp with musl as well, by running: cargo build --release --target x86_64-unknown-linux-musl

The build finishes successfully, no errors!

BUT!

The binary just doesn't run, not on the Xenial VM, not on my Focal box. I get the following error:

❯ target/x86_64-unknown-linux-musl/release/amp
-su: target/x86_64-unknown-linux-musl/release/amp: No such file or directory

I could be wrong, but this probably has something to do with a bad interpreter: https://www.baeldung.com/linux/bad-elf-interpreter

❯ ldd target/x86_64-unknown-linux-musl/release/amp
        linux-vdso.so.1 =>  (0x00007ffd3b9f5000)
        libxcb.so.1 => /usr/lib/x86_64-linux-gnu/libxcb.so.1 (0x00007f6c2c918000)
        libXau.so.6 => /usr/lib/x86_64-linux-gnu/libXau.so.6 (0x00007f6c2c714000)
        libXdmcp.so.6 => /usr/lib/x86_64-linux-gnu/libXdmcp.so.6 (0x00007f6c2c50e000)
        libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f6c2c144000)
        /lib/ld64.so.1 => /lib64/ld-linux-x86-64.so.2 (0x00007f6c2cb3a000)

❯ file target/x86_64-unknown-linux-musl/release/amp
target/x86_64-unknown-linux-musl/release/amp: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib/ld6, BuildID[sha1]=f09e0324a664b764d1cf0751384b70a7ae597bfd, not stripped

❯ ls -la /lib/ld6
ls: cannot access '/lib/ld6': No such file or directory

If anyone has any more thoughts on this, any help would be appreciated.

Similar error seen by someone else while building a musl binary: https://stackoverflow.com/questions/64849196/executing-script-with-musl-built-tclsh8-6-gives-no-such-file-or-directory

Have already tried what they did (simlinking musl libc, to the interpreter path that binary expects) but it didn't work for me.

I found a reddit thread with similar errors:
https://www.reddit.com/r/rust/comments/s1f6gu/how_to_get_rust_to_compile_an_a_purely_muslbased/

It suggested this: export RUSTFLAGS="-Clink-arg=-Wl,--dynamic-linker=/lib/ld-musl-x86_64.so.1" before running cargo build so I tried it, the build finished, but I got new errors when running the binary.

❯ target/x86_64-unknown-linux-musl/release/amp
Error loading shared library libxcb.so.1: No such file or directory (needed by target/x86_64-unknown-linux-musl/release/amp)
Error relocating target/x86_64-unknown-linux-musl/release/amp: xcb_get_maximum_request_length: symbol not found
Error relocating target/x86_64-unknown-linux-musl/release/amp: xcb_wait_for_event: symbol not found
Error relocating target/x86_64-unknown-linux-musl/release/amp: xcb_get_setup: symbol not found
Error relocating target/x86_64-unknown-linux-musl/release/amp: xcb_poll_for_event: symbol not found
Error relocating target/x86_64-unknown-linux-musl/release/amp: xcb_flush: symbol not found
Error relocating target/x86_64-unknown-linux-musl/release/amp: xcb_get_property_value_length: symbol not found
Error relocating target/x86_64-unknown-linux-musl/release/amp: xcb_get_property_reply: symbol not found
Error relocating target/x86_64-unknown-linux-musl/release/amp: xcb_connection_has_error: symbol not found
Error relocating target/x86_64-unknown-linux-musl/release/amp: xcb_delete_property: symbol not found
Error relocating target/x86_64-unknown-linux-musl/release/amp: xcb_intern_atom: symbol not found
Error relocating target/x86_64-unknown-linux-musl/release/amp: xcb_disconnect: symbol not found
Error relocating target/x86_64-unknown-linux-musl/release/amp: xcb_setup_roots_iterator: symbol not found
Error relocating target/x86_64-unknown-linux-musl/release/amp: xcb_change_property: symbol not found
Error relocating target/x86_64-unknown-linux-musl/release/amp: xcb_send_event: symbol not found
Error relocating target/x86_64-unknown-linux-musl/release/amp: xcb_get_selection_owner_reply: symbol not found
Error relocating target/x86_64-unknown-linux-musl/release/amp: xcb_change_window_attributes: symbol not found
Error relocating target/x86_64-unknown-linux-musl/release/amp: xcb_generate_id: symbol not found
Error relocating target/x86_64-unknown-linux-musl/release/amp: xcb_screen_next: symbol not found
Error relocating target/x86_64-unknown-linux-musl/release/amp: xcb_intern_atom_reply: symbol not found
Error relocating target/x86_64-unknown-linux-musl/release/amp: xcb_get_selection_owner: symbol not found
Error relocating target/x86_64-unknown-linux-musl/release/amp: xcb_create_window: symbol not found
Error relocating target/x86_64-unknown-linux-musl/release/amp: xcb_convert_selection: symbol not found
Error relocating target/x86_64-unknown-linux-musl/release/amp: xcb_get_property: symbol not found
Error relocating target/x86_64-unknown-linux-musl/release/amp: xcb_get_property_value: symbol not found
Error relocating target/x86_64-unknown-linux-musl/release/amp: xcb_set_selection_owner: symbol not found
Error relocating target/x86_64-unknown-linux-musl/release/amp: xcb_connect: symbol not found

But ldd doesn't show any missing library. Odd?

❯ ldd target/x86_64-unknown-linux-musl/release/amp
        linux-vdso.so.1 =>  (0x00007ffc6b0c3000)
        libxcb.so.1 => /usr/lib/x86_64-linux-gnu/libxcb.so.1 (0x00007fe5071e7000)
        libXau.so.6 => /usr/lib/x86_64-linux-gnu/libXau.so.6 (0x00007fe506fe3000)
        libXdmcp.so.6 => /usr/lib/x86_64-linux-gnu/libXdmcp.so.6 (0x00007fe506ddd000)
        libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fe506a13000)
        /lib/ld-musl-x86_64.so.1 => /lib64/ld-linux-x86-64.so.2 (0x00007fe507409000)