Nixpkgs: devilutionx fails to build on master and release-20.09

Created on 19 Sep 2020  路  10Comments  路  Source: NixOS/nixpkgs

Describe the bug
A clear and concise description of what the bug is.

devilutionx fails to build on master and release-20.09.

To Reproduce
Steps to reproduce the behavior:

  1. nix-build -A devilutionx

Expected behavior
A clear and concise description of what you expected to happen.

Screenshots
If applicable, add screenshots to help explain your problem.

Additional context
Add any other context about the problem here.

Build failure ends with...

[ 98%] Building CXX object CMakeFiles/devilutionx.dir/SourceX/dvlnet/tcp_server.cpp.o
make[2]: *** No rule to make target '/nix/store/gs1y2f04ljx7gy7cz8l4nqad5zxlb47x-SDL2-2.0.12/lib/libSDL2main.a', needed by 'devilutionx'.  Stop.
make[2]: *** Waiting for unfinished jobs....
[ 99%] Building CXX object CMakeFiles/devilutionx.dir/SourceX/dvlnet/udp_p2p.cpp.o
make[1]: *** [CMakeFiles/Makefile2:109: CMakeFiles/devilutionx.dir/all] Error 2
make: *** [Makefile:103: all] Error 2
builder for '/nix/store/10kkkhdvfziz408xf28vs4z52sshkx3v-devilutionx-1.0.1.drv' failed with exit code 2
error: build of '/nix/store/10kkkhdvfziz408xf28vs4z52sshkx3v-devilutionx-1.0.1.drv' failed

Also see https://hydra.nixos.org/build/126792976

Notify maintainers

ping @karolchmist

Metadata
Please run nix-shell -p nix-info --run "nix-info -m" and paste the result.

Maintainer information:

# a list of nixpkgs attributes affected by the problem
attribute: devilutionx
# a list of nixos modules affected by the problem
module:
bug

Most helpful comment

Hello @dtzWill , thanks for your comments. I never came to propose an upstream fix for dymamic SDL linking... I'll try to take care of it in the following days.

All 10 comments

Well, looks like SDL2 is silly in a few ways:

  • There's no libSDL2main.a in any outputs, despite .la (libtool) mentioning it, likely to cause problems?
  • SDL2.dev has a cmake file that contains explicit paths that don't exist:
$ tail -n20 /nix/store/1b6vhbymp2aj48kf3dazf275ad2kyshs-SDL2-2.0.12-dev/lib/cmake/SDL2/sdl2-config.cmake
  add_library(SDL2::SDL2 SHARED IMPORTED)
  set_target_properties(SDL2::SDL2 PROPERTIES
    INTERFACE_INCLUDE_DIRECTORIES "/nix/store/1b6vhbymp2aj48kf3dazf275ad2kyshs-SDL2-2.0.12-dev/include/SDL2"
    IMPORTED_LINK_INTERFACE_LANGUAGES "C"
    IMPORTED_LOCATION "/nix/store/gs1y2f04ljx7gy7cz8l4nqad5zxlb47x-SDL2-2.0.12/lib/libSDL2.so"
    INTERFACE_LINK_LIBRARIES "${SDL2_EXTRA_LINK_FLAGS}")

  add_library(SDL2::SDL2-static STATIC IMPORTED)
  set_target_properties(SDL2::SDL2-static PROPERTIES
    INTERFACE_INCLUDE_DIRECTORIES "/nix/store/1b6vhbymp2aj48kf3dazf275ad2kyshs-SDL2-2.0.12-dev/include/SDL2"
    IMPORTED_LINK_INTERFACE_LANGUAGES "C"
    IMPORTED_LOCATION "/nix/store/gs1y2f04ljx7gy7cz8l4nqad5zxlb47x-SDL2-2.0.12/lib/libSDL2.a"
    INTERFACE_LINK_LIBRARIES "${SDL2_EXTRA_LINK_FLAGS_STATIC}")

  add_library(SDL2::SDL2main STATIC IMPORTED)
  set_target_properties(SDL2::SDL2main PROPERTIES
    IMPORTED_LINK_INTERFACE_LANGUAGES "C"
    IMPORTED_LOCATION "/nix/store/gs1y2f04ljx7gy7cz8l4nqad5zxlb47x-SDL2-2.0.12/lib/libSDL2main.a")

The last two blocks mention ".a" files that don't exist! :(

I'm not sure what might have caused this, but thought I'd share at least this much in case it helps!
(perhaps I should file an issue about this explicitly?)


Checker idea: post-build scan for /nix/store/.../ paths and stat them--
files that don't exist in available outputs indicate (possible?) problem as what is happening with SDL2 here.

Actually, paths that aren't in the store at all (or in the build inputs, aka available for use by the builder) indicate some badness? (nix maybe already does this, IIRC?)
Well, anyway... :).

Hello @dtzWill , thanks for your comments. I never came to propose an upstream fix for dymamic SDL linking... I'll try to take care of it in the following days.

Thanks @karolchmist! Hopefully we can land this before the 20.09 release.

Please disregard this comment.


If we want to have a fix for devilutionx, AFAIK we can:
a) propose an upstream PR and wait for it being accepted and merged. In this case, a snapshot version of the project would be used (they release rarely now).
b) fix the static build of devilutionx on my forked branch and use it as a source in nixpkgs. This I can do (relatively) quickly.
c) use immediately my proposed PR for 20.09 and then propose an upstream solution later.

Sorry I'm not very active, I have a lot of other stuff on my head right now :( But I want to fix it.

Please disregard this comment.

~I opened a PR for the option b)~

Please disregard my previous messages, I think I misunderstood the problem.

To sum up: Building devilutionx with static SDL2 is to be avoided, but build with dynamic SDL2 is currently broken.

I tried different ideas:

  • reverting the commit that broke the build
  • setting different flags in CMake (set(SDL2_DYNAMIC TRUE) in FindSDL2.cmake),

But I always get this message:

make[2]: *** No rule to make target '/nix/store/gs1y2f04ljx7gy7cz8l4nqad5zxlb47x-SDL2-2.0.12/lib/libSDL2main.a', needed by 'devilutionx'.  Stop.

Finally and in desperation, I modified SDL2/default.nix to look like this:

  postInstall = ''
    moveToOutput lib/libSDL2main.a "$dev"
    if [ "$dontDisableStatic" -eq "1" ]; then
      rm $out/lib/*.la
    else
      rm $out/lib/*.a
    fi
    moveToOutput bin/sdl2-config "$dev"
    cp $dev/lib/libSDL2main.a $out/lib/
  '';

So I added the first and the last line, and it works.

Does any one has a better idea?

This comment in devilutionx project may be useful.

I tried the latest master from devilutionx and it builds with dynamic SDL2, thx to this commit.

I tested it and everything seems to be working well.

Is it ok if I create a PR that builds this version, referenced by this particular commit? Or should we wait for a new release of devilutionx?

Something that builds and runs is better than anything that doesn't build and run, right :wink:

Thanks for all your investigation into this @karolchmist :tada:

Was this page helpful?
0 / 5 - 0 ratings