NixOS / nixpkgs

Nix Packages collection & NixOS
MIT License
17.15k stars 13.42k forks source link

Package request: libimobiledevice support for Windows #326700

Open Frontear opened 1 month ago

Frontear commented 1 month ago

According to upstream this is completely possible, though currently not available via nixpkgs.

Attempting to force a build with NIXPKGS_ALLOW_UNSUPPORTED_SYSTEM=1 with mingwW64 fails at the linking stage with:

error: builder for '/nix/store/7j4f0g5da66gnj3gcvwyn07ygrg1809q-libimobiledevice-glue-x86_64-w64-mingw32-1.2.0.drv' failed with exit code 2;
       last 25 log lines:
       >   CC       glue.lo
       >   CC       socket.lo
       >   CC       thread.lo
       >   CC       utils.lo
       > utils.c: In function 'stpcpy':
       > utils.c:58:16: warning: 'nonnull' argument 's1' compared to NULL [8;;https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html#index-Wnonnull-compare-Wnonnull-compare8;;]
       >    58 |         if (s1 == NULL || s2 == NULL)
       >       |                ^
       > utils.c:58:30: warning: 'nonnull' argument 's2' compared to NULL [8;;https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html#index-Wnonnull-compare-Wnonnull-compare8;;]
       >    58 |         if (s1 == NULL || s2 == NULL)
       >       |                              ^
       >   CC       nskeyedarchive.lo
       >   CC       collection.lo
       >   CC       termcolors.lo
       >   CC       cbuf.lo
       >   CC       opack.lo
       >   CC       tlv.lo
       >   CCLD     libimobiledevice-glue-1.0.la
       > /nix/store/svixaxk47x2zfzgk67v3lsa873ghyxma-x86_64-w64-mingw32-binutils-2.41/bin/x86_64-w64-mingw32-ld: cannot find -lIphlpapi: No such file or directory
       > collect2: error: ld returned 1 exit status
       > make[2]: *** [Makefile:448: libimobiledevice-glue-1.0.la] Error 1
       > make[2]: Leaving directory '/build/source/src'
       > make[1]: *** [Makefile:417: all-recursive] Error 1
       > make[1]: Leaving directory '/build/source'
       > make: *** [Makefile:349: all] Error 2

Full logs can be found in the dropdown:

Full logs ``` @nix { "action": "setPhase", "phase": "unpackPhase" } Running phase: unpackPhase unpacking source archive /nix/store/rc13hds5grrgqpip5k1r8vb666l5lnny-source source root is source @nix { "action": "setPhase", "phase": "patchPhase" } Running phase: patchPhase @nix { "action": "setPhase", "phase": "autoreconfPhase" } Running phase: autoreconfPhase autoreconf: export WARNINGS= autoreconf: Entering directory '.' autoreconf: configure.ac: not using Gettext autoreconf: running: aclocal --force -I m4 autoreconf: configure.ac: tracing autoreconf: running: libtoolize --copy --force libtoolize: putting auxiliary files in '.'. libtoolize: copying file './ltmain.sh' libtoolize: putting macros in AC_CONFIG_MACRO_DIRS, 'm4'. libtoolize: copying file 'm4/libtool.m4' libtoolize: copying file 'm4/ltoptions.m4' libtoolize: copying file 'm4/ltsugar.m4' libtoolize: copying file 'm4/ltversion.m4' libtoolize: copying file 'm4/lt~obsolete.m4' autoreconf: configure.ac: not using Intltool autoreconf: configure.ac: not using Gtkdoc autoreconf: running: aclocal --force -I m4 autoreconf: running: /nix/store/i2i7a6k6759gfayyxm8jl7mr184vz2qs-autoconf-2.72/bin/autoconf --force autoreconf: running: /nix/store/i2i7a6k6759gfayyxm8jl7mr184vz2qs-autoconf-2.72/bin/autoheader --force autoreconf: running: automake --add-missing --copy --force-missing configure.ac:32: installing './compile' configure.ac:35: installing './config.guess' configure.ac:35: installing './config.sub' configure.ac:6: installing './install-sh' configure.ac:6: installing './missing' src/Makefile.am: installing './depcomp' autoreconf: './install-sh' is updated autoreconf: Leaving directory '.' @nix { "action": "setPhase", "phase": "updateAutotoolsGnuConfigScriptsPhase" } Running phase: updateAutotoolsGnuConfigScriptsPhase Updating Autotools / GNU config script to a newer upstream version: ./config.sub Updating Autotools / GNU config script to a newer upstream version: ./config.guess @nix { "action": "setPhase", "phase": "configurePhase" } Running phase: configurePhase fixing libtool script ./ltmain.sh ./configure patching script interpreter paths in ./configure ./configure: interpreter directive changed from "#! /bin/sh" to "/nix/store/agkxax48k35wdmkhmmija2i2sxg8i7ny-bash-5.2p26/bin/sh" configure flags: --disable-static --disable-dependency-tracking --prefix=/nix/store/zzd7r95az0cj4gp7k3zkdjpsbg8m539c-libimobiledevice-glue-x86_64-w64-mingw32-1.2.0 --bindir=/nix/store/zzd7r95az0cj4gp7k3zkdjpsbg8m539c-libimobiledevice-glue-x86_64-w64-mingw32-1.2.0/bin --sbindir=/nix/store/zzd7r95az0cj4gp7k3zkdjpsbg8m539c-libimobiledevice-glue-x86_64-w64-mingw32-1.2.0/sbin --includedir=/nix/store/saq1j3pn23i5nvw2b9mq4xfs3409zs1g-libimobiledevice-glue-x86_64-w64-mingw32-1.2.0-dev/include --oldincludedir=/nix/store/saq1j3pn23i5nvw2b9mq4xfs3409zs1g-libimobiledevice-glue-x86_64-w64-mingw32-1.2.0-dev/include --mandir=/nix/store/zzd7r95az0cj4gp7k3zkdjpsbg8m539c-libimobiledevice-glue-x86_64-w64-mingw32-1.2.0/share/man --infodir=/nix/store/zzd7r95az0cj4gp7k3zkdjpsbg8m539c-libimobiledevice-glue-x86_64-w64-mingw32-1.2.0/share/info --docdir=/nix/store/zzd7r95az0cj4gp7k3zkdjpsbg8m539c-libimobiledevice-glue-x86_64-w64-mingw32-1.2.0/share/doc/libimobiledevice-glue --libdir=/nix/store/zzd7r95az0cj4gp7k3zkdjpsbg8m539c-libimobiledevice-glue-x86_64-w64-mingw32-1.2.0/lib --libexecdir=/nix/store/zzd7r95az0cj4gp7k3zkdjpsbg8m539c-libimobiledevice-glue-x86_64-w64-mingw32-1.2.0/libexec --localedir=/nix/store/zzd7r95az0cj4gp7k3zkdjpsbg8m539c-libimobiledevice-glue-x86_64-w64-mingw32-1.2.0/share/locale --build=x86_64-unknown-linux-gnu --host=x86_64-w64-mingw32 checking for a BSD-compatible install... /nix/store/i7qhgc0bs725qw3wdanznfkdna4z2ns2-coreutils-9.5/bin/install -c checking whether build environment is sane... yes checking for x86_64-w64-mingw32-strip... x86_64-w64-mingw32-strip checking for a race-free mkdir -p... /nix/store/i7qhgc0bs725qw3wdanznfkdna4z2ns2-coreutils-9.5/bin/mkdir -p checking for gawk... gawk checking whether make sets $(MAKE)... yes checking whether make supports nested variables... yes checking whether make supports nested variables... (cached) yes checking for x86_64-w64-mingw32-gcc... x86_64-w64-mingw32-gcc checking whether the C compiler works... yes checking for C compiler default output file name... a.exe checking for suffix of executables... .exe checking whether we are cross compiling... yes checking for suffix of object files... o checking whether the compiler supports GNU C... yes checking whether x86_64-w64-mingw32-gcc accepts -g... yes checking for x86_64-w64-mingw32-gcc option to enable C11 features... none needed checking whether x86_64-w64-mingw32-gcc understands -c and -o together... yes checking whether make supports the include directive... yes (GNU style) checking dependency style of x86_64-w64-mingw32-gcc... none checking build system type... x86_64-unknown-linux-gnu checking host system type... x86_64-w64-mingw32 checking how to print strings... printf checking for a sed that does not truncate output... /nix/store/ks6c62g0m3gqrs5i7m0cv6d6aqhdvirn-gnused-4.9/bin/sed checking for grep that handles long lines and -e... /nix/store/md9apn3290h7kv0x198ihaaa3k6icg4b-gnugrep-3.11/bin/grep checking for egrep... /nix/store/md9apn3290h7kv0x198ihaaa3k6icg4b-gnugrep-3.11/bin/grep -E checking for fgrep... /nix/store/md9apn3290h7kv0x198ihaaa3k6icg4b-gnugrep-3.11/bin/grep -F checking for ld used by x86_64-w64-mingw32-gcc... x86_64-w64-mingw32-ld checking if the linker (x86_64-w64-mingw32-ld) is GNU ld... yes checking for BSD- or MS-compatible name lister (nm)... x86_64-w64-mingw32-nm checking the name lister (x86_64-w64-mingw32-nm) interface... BSD nm checking whether ln -s works... yes checking the maximum length of command line arguments... 32768 checking how to convert x86_64-unknown-linux-gnu file names to x86_64-w64-mingw32 format... func_convert_file_nix_to_w32 checking how to convert x86_64-unknown-linux-gnu file names to toolchain format... func_convert_file_noop checking for x86_64-w64-mingw32-ld option to reload object files... -r checking for x86_64-w64-mingw32-file... no checking for file... file configure: WARNING: using cross tools not prefixed with host triplet checking for x86_64-w64-mingw32-objdump... x86_64-w64-mingw32-objdump checking how to recognize dependent libraries... (cached) pass_all checking for x86_64-w64-mingw32-dlltool... x86_64-w64-mingw32-dlltool checking how to associate runtime and link libraries... func_cygming_dll_for_implib checking for x86_64-w64-mingw32-ar... x86_64-w64-mingw32-ar checking for archiver @FILE support... @ checking for x86_64-w64-mingw32-strip... (cached) x86_64-w64-mingw32-strip checking for x86_64-w64-mingw32-ranlib... x86_64-w64-mingw32-ranlib checking command to parse x86_64-w64-mingw32-nm output from x86_64-w64-mingw32-gcc object... ok checking for sysroot... no checking for a working dd... /nix/store/i7qhgc0bs725qw3wdanznfkdna4z2ns2-coreutils-9.5/bin/dd checking how to truncate binary pipes... /nix/store/i7qhgc0bs725qw3wdanznfkdna4z2ns2-coreutils-9.5/bin/dd bs=4096 count=1 checking for x86_64-w64-mingw32-mt... no checking for mt... no checking if : is a manifest tool... no checking for stdio.h... yes checking for stdlib.h... yes checking for string.h... yes checking for inttypes.h... yes checking for stdint.h... yes checking for strings.h... yes checking for sys/stat.h... yes checking for sys/types.h... yes checking for unistd.h... yes checking for dlfcn.h... no checking for objdir... .libs checking if x86_64-w64-mingw32-gcc supports -fno-rtti -fno-exceptions... no checking for x86_64-w64-mingw32-gcc option to produce PIC... -DDLL_EXPORT -DPIC checking if x86_64-w64-mingw32-gcc PIC flag -DDLL_EXPORT -DPIC works... yes checking if x86_64-w64-mingw32-gcc static flag -static works... no checking if x86_64-w64-mingw32-gcc supports -c -o file.o... yes checking if x86_64-w64-mingw32-gcc supports -c -o file.o... (cached) yes checking whether the x86_64-w64-mingw32-gcc linker (x86_64-w64-mingw32-ld) supports shared libraries... yes checking whether -lc should be explicitly linked in... yes checking dynamic linker characteristics... Win32 ld.exe checking how to hardcode library paths into programs... immediate checking whether stripping libraries is possible... yes checking if libtool supports shared libraries... yes checking whether to build shared libraries... yes checking whether to build static libraries... no checking pkg-config is at least version 0.9.0... yes checking for libplist-2.0 >= 2.3.0... yes checking for stdint.h... (cached) yes checking for stdlib.h... (cached) yes checking for string.h... (cached) yes checking for an ANSI C-conforming const... yes checking for size_t... yes checking for ssize_t... yes checking for uint16_t... yes checking for uint32_t... yes checking for uint8_t... yes checking for asprintf... yes checking for strcasecmp... yes checking for strdup... yes checking for strerror... yes checking for strndup... no checking for stpcpy... no checking for vasprintf... yes checking for getifaddrs... no checking for poll... no checking for endian.h... no checking whether byte ordering is bigendian... no checking for platform-specific build settings... mingw32 checking wether the C compiler supports constructor/destructor attributes... yes checking for struct dirent.d_type... no checking for supported compiler flags... -Wall -Wextra -Wmissing-declarations -Wredundant-decls -Wshadow -Wpointer-arith -Wwrite-strings -Wswitch-default -Wno-unused-parameter -fsigned-char -fvisibility=hidden checking for x86_64-w64-mingw32-gcc option to enable large file support... -D_FILE_OFFSET_BITS=64 checking whether make supports nested variables... (cached) yes checking that generated files are newer than configure... done configure: creating ./config.status config.status: creating Makefile config.status: creating src/Makefile config.status: creating src/libimobiledevice-glue-1.0.pc config.status: creating include/Makefile config.status: creating config.h config.status: executing depfiles commands config.status: executing libtool commands Configuration for libimobiledevice-glue 1.2.0: ------------------------------------------- Install prefix: .........: /nix/store/zzd7r95az0cj4gp7k3zkdjpsbg8m539c-libimobiledevice-glue-x86_64-w64-mingw32-1.2.0 Now type 'make' to build libimobiledevice-glue 1.2.0, and then 'make install' for installation. @nix { "action": "setPhase", "phase": "buildPhase" } Running phase: buildPhase build flags: SHELL=/nix/store/agkxax48k35wdmkhmmija2i2sxg8i7ny-bash-5.2p26/bin/bash make all-recursive make[1]: Entering directory '/build/source' Making all in src make[2]: Entering directory '/build/source/src' CC glue.lo CC socket.lo CC thread.lo CC utils.lo utils.c: In function 'stpcpy': utils.c:58:16: warning: 'nonnull' argument 's1' compared to NULL []8;;https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html#index-Wnonnull-compare-Wnonnull-compare]8;;] 58 | if (s1 == NULL || s2 == NULL) | ^ utils.c:58:30: warning: 'nonnull' argument 's2' compared to NULL []8;;https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html#index-Wnonnull-compare-Wnonnull-compare]8;;] 58 | if (s1 == NULL || s2 == NULL) | ^ CC nskeyedarchive.lo CC collection.lo CC termcolors.lo CC cbuf.lo CC opack.lo CC tlv.lo CCLD libimobiledevice-glue-1.0.la /nix/store/svixaxk47x2zfzgk67v3lsa873ghyxma-x86_64-w64-mingw32-binutils-2.41/bin/x86_64-w64-mingw32-ld: cannot find -lIphlpapi: No such file or directory collect2: error: ld returned 1 exit status make[2]: *** [Makefile:448: libimobiledevice-glue-1.0.la] Error 1 make[2]: Leaving directory '/build/source/src' make[1]: *** [Makefile:417: all-recursive] Error 1 make[1]: Leaving directory '/build/source' make: *** [Makefile:349: all] Error 2 ```
Frontear commented 1 month ago

Upon further investigating, this is due to a missing iphlpapi.h header + lib that is required. Apparently its intended to be provided through mingw itself, but seems to be missing. The main packages I see that contain it are zig and the wine packages.

EDIT: Might be possible this requires MSVC for compilation :/ so much for Nix-ing it up.

EDIT 2: I find it in an MSYS2 environment. So it definitely exists. It just seems they are missing from the pkgsCross.mingwW64 environment. Any ideas why, not very familiar in this territory as you can probably guess

eclairevoyant commented 1 month ago

What exact command did you run to build?

Frontear commented 1 month ago

I actually just forced a build in the repl:

NIXPKGS_ALLOW_UNSUPPORTED_SYSTEM=1 nix repl --impure

nix-repl> :l <nixpkgs>
nix-repl> :b pkgsCross.mingwW64.libimobiledevice
Frontear commented 1 month ago

Further update, even a mingw devshell possesses this library. I'm a little confused as to why the builder isn't capable of finding it, since this should be sourced directly from the stdenv.

EDIT: Is it because the builder is invoking -lIphl and not -liphl? I doubt the capitalization matters

$ $CC -o main -liphlpapi main.c
$ file main.exe
main.exe: PE32+ executable (console) x86-64 (stripped to external PDB), for MS Windows, 10 sections
# shell.nix
{
  pkgs ? (import <nixpkgs> {}).pkgsCross.mingwW64
}:
pkgs.mkShell {}
// main.c
#include <iphlpapi.h>

int main(void) {
    return 0;
}
eclairevoyant commented 1 month ago

C and unix filesystems are case-sensitive, so naturally it makes a difference

Frontear commented 1 month ago

C and unix filesystems are case-sensitive, so naturally it makes a difference

oof okay makes a lot of sense. guess now we know :p