NixOS / nix

Nix, the purely functional package manager
https://nixos.org/
GNU Lesser General Public License v2.1
12.86k stars 1.52k forks source link

Nix doesn't build on musl libc anymore #11931

Open theoparis opened 1 day ago

theoparis commented 1 day ago

Describe the bug

I discovered the following issues when trying to build Nix on Chimera Linux:

Issue 1

FAILED: src/libutil/libnixutil.so.p/unix_file-descriptor.cc.o
sccache c++ -Isrc/libutil/libnixutil.so.p -Isrc/libutil -I../src/libutil -Isrc/libutil/linux -I../src/libutil/linux -Isrc/libutil/unix -I../src/libutil/unix -fdiagnostics-color=always -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -std=c++2a -O0 -g -include config-util.hh -Wdeprecated-copy -Werror=suggest-override -Werror=switch -Werror=switch-enum -Werror=unused-result -Wignored-qualifiers -Wimplicit-fallthrough -Wno-deprecated-declarations -fPIC -DBOOST_CONTEXT_DYN_LINK=1 -DBOOST_COROUTINES_DYN_LINK=1 -DBOOST_ALL_NO_LIB -pthread -MD -MQ src/libutil/libnixutil.so.p/unix_file-descriptor.cc.o -MF src/libutil/libnixutil.so.p/unix_file-descriptor.cc.o.d -o src/libutil/libnixutil.so.p/unix_file-descriptor.cc.o -c ../src/libutil/unix/file-descriptor.cc
../src/libutil/unix/file-descriptor.cc:131:20: error: use of undeclared identifier 'SYS_close_range'
  131 |     return syscall(SYS_close_range, first, last, (unsigned int)flags);
      |                    ^
1 error generated.
[57/400] Compiling C++ object src/libstore/libnixstore.so.p/binary-cache-store.cc.o
ninja: build stopped: subcommand failed

Issue 2 (I installed rapidcheck with cmake and ninja)

src/libutil-test-support/build-utils-meson/export/meson.build:14:20: ERROR: requires argument not a string, library with pkgconfig-generated file or pkgconfig-dependency object, got <CMakeDependency rapidcheck: True None>

Issue 3

d -o src/libfetchers/libnixfetchers.so.p/git-utils.cc.o -c ../src/libfetchers/git-utils.cc
../src/libfetchers/git-utils.cc:288:13: error: use of undeclared identifier 'git_mempack_write_
thin_pack'
  288 |             git_mempack_write_thin_pack(mempack_backend, packBuilder.get())
      |             ^
1 error generated.

Steps To Reproduce

Build Nix on chimera linux or a musl libc system

Expected behavior

Successful build of the nix cli

nix-env --version output

Additional context

Related discussion on the musl mailing list from 2022: https://www.openwall.com/lists/musl/2022/08/18/3 https://github.com/search?q=repo%3Abminor%2Fmusl+sys_close_range&type=code returns nothing

Priorities

Add :+1: to issues you find important.

theoparis commented 1 day ago

It seems like the alpine maintainers also encountered issue 3... Why is Nix using an unstable version of libgit2???

https://gitlab.alpinelinux.org/alpine/aports/-/merge_requests/75312

theoparis commented 16 hours ago

Related https://github.com/NixOS/nix/issues/11925

Ericson2314 commented 9 hours ago

We contributed that change to libgit2. You'll need to grab the patch. Hopefully they'll release soon.