xiph / rav1e

The fastest and safest AV1 encoder.
BSD 2-Clause "Simplified" License
3.69k stars 252 forks source link

Precompiled binaries fail to state they target musl on linux #3242

Closed homm closed 10 months ago

homm commented 1 year ago

Describe the bug

I'm trying to use precompiled binaries: https://github.com/xiph/rav1e/releases/tag/v0.6.6 and get the following error while compiling libheif with this binaries:

...
[ 84%] Linking CXX executable heif-test
/usr/bin/ld: warning: libc.so, needed by //usr/local/lib/librav1e.so.0, not found (try using -rpath or -rpath-link)
/usr/local/lib/librav1e.so.0: undefined reference to `fstat64'
/usr/local/lib/librav1e.so.0: undefined reference to `stat64'
collect2: error: ld returned 1 exit status

Inspecting .so file:

# tar xvf librav1e-0.6.6-linux-aarch64.tar.gz 
include/
include/rav1e/
include/rav1e/rav1e.h
lib/
lib/librav1e.a
lib/librav1e.so
lib/librav1e.so.0.6.1
lib/librav1e.so.0
lib/pkgconfig/
lib/pkgconfig/rav1e.pc

# ldd ./lib/librav1e.so
./lib/librav1e.so: error while loading shared libraries: /usr/lib/aarch64-linux-gnu/libc.so: invalid ELF header

# dpkg -S libc.so
libc6-dev:arm64: /usr/lib/aarch64-linux-gnu/libc.so
libc6:arm64: /lib/aarch64-linux-gnu/libc.so.6

# cat /usr/lib/aarch64-linux-gnu/libc.so
/* GNU ld script
   Use the shared library, but some functions are only in
   the static library, so try that secondarily.  */
OUTPUT_FORMAT(elf64-littleaarch64)
GROUP ( /lib/aarch64-linux-gnu/libc.so.6 /usr/lib/aarch64-linux-gnu/libc_nonshared.a  AS_NEEDED ( /lib/aarch64-linux-gnu/ld-linux-aarch64.so.1 ) )

# rm /usr/lib/aarch64-linux-gnu/libc.so
# ldd ./lib/librav1e.so
    linux-vdso.so.1 (0x0000ffff95b61000)
    libgcc_s.so.1 => /lib/aarch64-linux-gnu/libgcc_s.so.1 (0x0000ffff9590d000)
    libc.so => not found
    libc.so.6 => /lib/aarch64-linux-gnu/libc.so.6 (0x0000ffff957b4000)
    /lib/ld-linux-aarch64.so.1 (0x0000ffff95b35000)

So, librav1e.so is compiled with two libc.so dependencies. One of them is correct libc.so.6, while another points to libc.so without ABI version, which is likely incorrect. When libc.so without version is available, it is GNU ld script, not a link to the actual ELF file.

More info about linking libraries: https://stackoverflow.com/a/76657677/253146

Required Information Version: v0.6.6 Operating system: Ubuntu 18.04 aarch64

lu-zero commented 1 year ago

I even wonder how a build made for musl fared that much on a glibc system...

see the CI

  linux-binaries:
    strategy:
      fail-fast: false
      matrix:
        target:
         - i686-unknown-linux-musl
         - x86_64-unknown-linux-musl
         - aarch64-unknown-linux-musl

We can probably be more clear on what we are providing.

homm commented 1 year ago

Ok. Are you planning provide glibc builds? :-)

fdintino commented 9 months ago

@homm I was mistaken in my attempt to address this. But your original issue, where librav1e.so is linked against libc.so, is no longer a problem in the weekly prereleases. You should be able to link against the dynamic library on glibc linux without any issues. Though, depending on how you're planning to distributing these binaries, you might be better off linking against librav1e.a.