trofi / nix-guix-gentoo

Gentoo overlay for nix and guix functional package managers.
107 stars 9 forks source link

Missing dependency USE flag #28

Closed soleera closed 1 year ago

soleera commented 1 year ago

sys-apps/busybox-nix-sandbox-shell requires sys-libs/llvm-libunwind to be built with the "static-libs" USE flag (for llvm based systems), however this is not enforced by the ebuild and has to be added manually.

trofi commented 1 year ago
  1. Please attach failing build.log
  2. Please attach emerge --info from your system.

I don't have sys-libs/llvm-libunwind installed and can build sys-apps/busybox-nix-sandbox-shell. Thus I suspect you are using clang-based profile. Here is the full dependency list sys-apps/busybox-nix-sandbox-shell specifies:

DEPEND=">=sys-kernel/linux-headers-2.6.39
        virtual/libcrypt[static-libs]"
RDEPEND=""

This probably means it's either a missing dependency of some other package or we need something like llvm-libunwind? ( sys-libs/llvm-libunwind ).

It should be a stripped-down version of sys-apps/busybox. Can you build USE=static sys-apps/busybox for comparison?

trofi commented 1 year ago

Reproduced on default/linux/amd64/17.1/systemd/clang/merged-usr profile from stage3-arm64-desktop-systemd seed files:

$ printf "int main(){}" | gcc -x c - -o a -static && ./a

$ printf "int main(){}" | clang -x c - -o a -static && ./a
ld.lld: error: unable to find library -l:libunwind.a
clang-15: error: linker command failed with exit code 1 (use -v to see invocation)

Thus clang provides an incomplete environment for static linking even against minimal programs. That's unfortunate. libunwind.a is minuscule in size compared to the toolchain size.

Trying to just remove seemingly unused library breaks C library linking:

$ touch libunwind.a
$  printf "int main(){}" | clang -x c - -o a -static -L.
ld.lld: error: undefined symbol: __unordtf2
>>> referenced by printf_fphex.o:(__printf_fphex) in archive /usr/lib/gcc/x86_64-pc-linux-gnu/12/../../../../lib64/libc.a
>>> referenced by printf_fphex.o:(__printf_fphex) in archive /usr/lib/gcc/x86_64-pc-linux-gnu/12/../../../../lib64/libc.a
>>> referenced by printf_fp.o:(__printf_fp_l) in archive /usr/lib/gcc/x86_64-pc-linux-gnu/12/../../../../lib64/libc.a
>>> referenced 1 more times

Normally I would expect something like virtual/libc[static-libs] or sys-libs/glibc[static-libs] to pull in enough required dependencies. Looks like neither will do here and we'll need to copy implementation details of clang runtime.

Let's start from adding libunwind? ( sys-libs/llvm-libunwind[static-libs] ) workaround and see where we get in unstream bug report.

trofi commented 1 year ago

Filed https://bugs.gentoo.org/892956 upstream to consider providing needed dependencies.

trofi commented 1 year ago

Should be fixed by https://github.com/trofi/nix-guix-gentoo/commit/6266dc7a6037f4c2125b4313ab95e899269887e4. Please give it a try.