NixOS / nixpkgs

Nix Packages collection & NixOS
MIT License
17.76k stars 13.88k forks source link

gringo fails to build in master #19950

Closed Zimmi48 closed 7 years ago

Zimmi48 commented 7 years ago

gringo-4.5-4 fails to build in the master branch

@cleverca22 helped me find out the commit creating the problem. It is f42a7068. gringo depends on scons and for some reason the update of scons broke gringo. Tagging @FRidh as well since he is the author of the commit.

If I understood the trace correctly, the error reported is call of overloaded 'to_string(unsigned int)' is ambiguous. It happens in a function defined as such:

FWString AuxGen::uniqueName(char const *prefix) {
    return FWString(prefix + std::to_string((*auxNum)++));
}

and @cleverca22 suggests to patch this definition in the following way

FWString AuxGen::uniqueName(char const *prefix) {
    unsigned long x = (*auxNum)++;
    return FWString(prefix + std::to_string(x));
}

It still remains to understand how this commit could have created this problem...

FRidh commented 7 years ago

Building against that specific commit is indeed unsuccessful:

nix-shell -p gringo -I nixpkgs=https://github.com/NixOS/nixpkgs/archive/f42a7068da8956a86a4e71018022222d63cf2b7a.tar.gz

however, building against current nixpkgs-unstable (de3860229ae1dee77a2e04015e590801befafa25) , which is more recent, works

nix-shell -p gringo -I nixpkgs=https://github.com/NixOS/nixpkgs-channels/archive/nixpkgs-unstable.tar.gz

Yet building against master fails again.

Building against the parent of the scons change succeeds. scons might have broken gringo, but why did it build successfully in between then?

FRidh commented 7 years ago

After undoing the commit the build of gringo is successful again, so it definitely seems scons related. None of the other packages that use scons fails building though.

The documented method to install was how it was before, although nowadays all Python packages are build as a wheel and then installed. Somehow something is different there. I did remove two options in that commit, one which was a compiler optimization. When I do pass those, the error still occurs.

If the patch makes it build again, I suggest using it and reporting it upstream.

Zimmi48 commented 7 years ago

I have not tested the patch.

Le Ven 28 Oct 2016 19:38, Frederik Rietdijk notifications@github.com a écrit :

After undoing the commit the build of gringo is successful again, so it definitely seems scons related. None of the other packages that use scons fails building though.

The documented method to install was how it was before, although nowadays all Python packages are build as a wheel and then installed. Somehow something is different there. I did remove two options in that commit, one which was a compiler optimization. When I do pass those, the error still occurs.

If the patch makes it build again, I suggest using it and reporting it upstream.

— You are receiving this because you authored the thread.

Reply to this email directly, view it on GitHub https://github.com/NixOS/nixpkgs/issues/19950#issuecomment-256982013, or mute the thread https://github.com/notifications/unsubscribe-auth/ABDpZdtgNtgKPREGu2_fbSPkeiUV5POzks5q4jMEgaJpZM4KjmJA .

sternenseemann commented 7 years ago

I have tested the patch just now and it doesn't fix the problem.

diff -r gringo-4.5.4-source/libgringo/src/term.cc gringo-4.5.4-source-patched/libgringo/src/term.cc
562c562,563
<     return FWString(prefix + std::to_string((*auxNum)++));
---
>     unsigned long x = (*auxNum)++;
>     return FWString(prefix + std::to_string(x));
scons: Reading SConscript files ...
Checking for bison 2.5... yes
Checking for re2c... yes
Checking whether the C++ compiler works... yes
Checking whether the (shared) C++ compiler works... yes
Auto-detecting python (python-config)... no
Auto-detecting python (pkg-config)... no
Auto-detecting lua (pkg-config)... no
Checking for C++ function snprintf()... no
Checking for C++ function __builtin_snprintf()... no
Checking for C++ function vsnprintf()... no
Checking for C++ function __builtin_vsnprintf()... no
Checking for C++ function std::to_string()... no
Auto-detecting tbb (pkg-config)... no
Auto-detecting cppunit (pkg-config)... no
scons: done reading SConscript files.
scons: Building targets ...
g++ -o build/debug/app/gringo/main.o -c -std=c++11 -O0 -g -Wall -W -pedantic -DMISSING_STD_TO_STRING=1 -I/nix/store/jlds9bqhgyag03rzk3sipj7g3qi930gd-python-2.7.12/include/python2.7 -Ilibgringo -Ibuild/debug/libgringo/src -Ilibgringo/src -Ilibprogram_opts -Ilibprogram_opts/src app/gringo/main.cc
In file included from libprogram_opts/program_opts/application.h:31:0,
                 from app/gringo/main.cc:40:
libprogram_opts/program_opts/program_options.h:123:22: warning: 'template<class> class std::auto_ptr' is deprecated [-Wdeprecated-declarations]
  void addOption(std::auto_ptr<Option> option);
                      ^
In file included from /nix/store/psmdlfqys1031hhyjhky4qphgyscmgdg-gcc-5.4.0/include/c++/5.4.0/memory:81:0,
                 from libgringo/gringo/utility.hh:24,
                 from libgringo/gringo/flyweight.hh:33,
                 from libgringo/gringo/input/programbuilder.hh:24,
                 from libgringo/gringo/input/nongroundparser.hh:24,
                 from app/gringo/main.cc:27:
/nix/store/psmdlfqys1031hhyjhky4qphgyscmgdg-gcc-5.4.0/include/c++/5.4.0/bits/unique_ptr.h:49:28: note: declared here
   template<typename> class auto_ptr;
                            ^
In file included from app/gringo/main.cc:41:0:
libprogram_opts/program_opts/typed_value.h: In member function 'bool ProgramOptions::NotifiedValue<T>::doParse(const string&, const string&)':
libprogram_opts/program_opts/typed_value.h:118:8: warning: 'template<class> class std::auto_ptr' is deprecated [-Wdeprecated-declarations]
   std::auto_ptr<T> holder;
        ^
In file included from /nix/store/psmdlfqys1031hhyjhky4qphgyscmgdg-gcc-5.4.0/include/c++/5.4.0/memory:81:0,
                 from libgringo/gringo/utility.hh:24,
                 from libgringo/gringo/flyweight.hh:33,
                 from libgringo/gringo/input/programbuilder.hh:24,
                 from libgringo/gringo/input/nongroundparser.hh:24,
                 from app/gringo/main.cc:27:
/nix/store/psmdlfqys1031hhyjhky4qphgyscmgdg-gcc-5.4.0/include/c++/5.4.0/bits/unique_ptr.h:49:28: note: declared here
   template<typename> class auto_ptr;
                            ^
g++ -o build/debug/libgringo/src/python.o -c -std=c++11 -O0 -g -Wall -W -pedantic -DMISSING_STD_TO_STRING=1 -I/nix/store/jlds9bqhgyag03rzk3sipj7g3qi930gd-python-2.7.12/include/python2.7 -Ilibgringo -Ibuild/debug/libgringo/src -Ilibgringo/src -Ilibprogram_opts -Ilibprogram_opts/src libgringo/src/python.cc
g++ -o build/debug/libgringo/src/lua.o -c -std=c++11 -O0 -g -Wall -W -pedantic -DMISSING_STD_TO_STRING=1 -I/nix/store/jlds9bqhgyag03rzk3sipj7g3qi930gd-python-2.7.12/include/python2.7 -Ilibgringo -Ibuild/debug/libgringo/src -Ilibgringo/src -Ilibprogram_opts -Ilibprogram_opts/src libgringo/src/lua.cc
g++ -o build/debug/libgringo/src/terms.o -c -std=c++11 -O0 -g -Wall -W -pedantic -DMISSING_STD_TO_STRING=1 -I/nix/store/jlds9bqhgyag03rzk3sipj7g3qi930gd-python-2.7.12/include/python2.7 -Ilibgringo -Ibuild/debug/libgringo/src -Ilibgringo/src -Ilibprogram_opts -Ilibprogram_opts/src libgringo/src/terms.cc
g++ -o build/debug/libgringo/src/scripts.o -c -std=c++11 -O0 -g -Wall -W -pedantic -DMISSING_STD_TO_STRING=1 -I/nix/store/jlds9bqhgyag03rzk3sipj7g3qi930gd-python-2.7.12/include/python2.7 -Ilibgringo -Ibuild/debug/libgringo/src -Ilibgringo/src -Ilibprogram_opts -Ilibprogram_opts/src libgringo/src/scripts.cc
g++ -o build/debug/libgringo/src/term.o -c -std=c++11 -O0 -g -Wall -W -pedantic -DMISSING_STD_TO_STRING=1 -I/nix/store/jlds9bqhgyag03rzk3sipj7g3qi930gd-python-2.7.12/include/python2.7 -Ilibgringo -Ibuild/debug/libgringo/src -Ilibgringo/src -Ilibprogram_opts -Ilibprogram_opts/src libgringo/src/term.cc
libgringo/src/term.cc: In member function 'Gringo::FWString Gringo::AuxGen::uniqueName(const char*)':
libgringo/src/term.cc:563:46: error: call of overloaded 'to_string(long unsigned int&)' is ambiguous
     return FWString(prefix + std::to_string(x));
                                              ^
In file included from libgringo/gringo/term.hh:24:0,
                 from libgringo/src/term.cc:21:
libgringo/gringo/bug.hh:41:15: note: candidate: std::__cxx11::string std::to_string(int)
 inline string to_string(int x) {
               ^
libgringo/gringo/bug.hh:47:15: note: candidate: std::__cxx11::string std::to_string(unsigned int)
 inline string to_string(unsigned x) {
               ^
libgringo/gringo/bug.hh:53:15: note: candidate: std::__cxx11::string std::to_string(long int)
 inline string to_string(long x) {
               ^
libgringo/gringo/bug.hh:59:15: note: candidate: std::__cxx11::string std::to_string(long unsigned int)
 inline string to_string(unsigned long x) {
               ^
libgringo/gringo/bug.hh:65:15: note: candidate: std::__cxx11::string std::to_string(long long int)
 inline string to_string(long long x) {
               ^
libgringo/gringo/bug.hh:71:15: note: candidate: std::__cxx11::string std::to_string(long long unsigned int)
 inline string to_string(unsigned long long x) {
               ^
In file included from /nix/store/psmdlfqys1031hhyjhky4qphgyscmgdg-gcc-5.4.0/include/c++/5.4.0/string:52:0,
                 from /nix/store/psmdlfqys1031hhyjhky4qphgyscmgdg-gcc-5.4.0/include/c++/5.4.0/bits/locale_classes.h:40,
                 from /nix/store/psmdlfqys1031hhyjhky4qphgyscmgdg-gcc-5.4.0/include/c++/5.4.0/bits/ios_base.h:41,
                 from /nix/store/psmdlfqys1031hhyjhky4qphgyscmgdg-gcc-5.4.0/include/c++/5.4.0/ios:42,
                 from /nix/store/psmdlfqys1031hhyjhky4qphgyscmgdg-gcc-5.4.0/include/c++/5.4.0/ostream:38,
                 from /nix/store/psmdlfqys1031hhyjhky4qphgyscmgdg-gcc-5.4.0/include/c++/5.4.0/iterator:64,
                 from libgringo/gringo/bug.hh:24,
                 from libgringo/gringo/term.hh:24,
                 from libgringo/src/term.cc:21:
/nix/store/psmdlfqys1031hhyjhky4qphgyscmgdg-gcc-5.4.0/include/c++/5.4.0/bits/basic_string.h:5351:3: note: candidate: std::__cxx11::string std::__cxx11::to_string(long double)
   to_string(long double __val)
   ^
/nix/store/psmdlfqys1031hhyjhky4qphgyscmgdg-gcc-5.4.0/include/c++/5.4.0/bits/basic_string.h:5342:3: note: candidate: std::__cxx11::string std::__cxx11::to_string(double)
   to_string(double __val)
   ^
/nix/store/psmdlfqys1031hhyjhky4qphgyscmgdg-gcc-5.4.0/include/c++/5.4.0/bits/basic_string.h:5333:3: note: candidate: std::__cxx11::string std::__cxx11::to_string(float)
   to_string(float __val)
   ^
/nix/store/psmdlfqys1031hhyjhky4qphgyscmgdg-gcc-5.4.0/include/c++/5.4.0/bits/basic_string.h:5327:3: note: candidate: std::__cxx11::string std::__cxx11::to_string(long long unsigned int)
   to_string(unsigned long long __val)
   ^
/nix/store/psmdlfqys1031hhyjhky4qphgyscmgdg-gcc-5.4.0/include/c++/5.4.0/bits/basic_string.h:5321:3: note: candidate: std::__cxx11::string std::__cxx11::to_string(long long int)
   to_string(long long __val)
   ^
/nix/store/psmdlfqys1031hhyjhky4qphgyscmgdg-gcc-5.4.0/include/c++/5.4.0/bits/basic_string.h:5315:3: note: candidate: std::__cxx11::string std::__cxx11::to_string(long unsigned int)
   to_string(unsigned long __val)
   ^
/nix/store/psmdlfqys1031hhyjhky4qphgyscmgdg-gcc-5.4.0/include/c++/5.4.0/bits/basic_string.h:5310:3: note: candidate: std::__cxx11::string std::__cxx11::to_string(long int)
   to_string(long __val)
   ^
/nix/store/psmdlfqys1031hhyjhky4qphgyscmgdg-gcc-5.4.0/include/c++/5.4.0/bits/basic_string.h:5304:3: note: candidate: std::__cxx11::string std::__cxx11::to_string(unsigned int)
   to_string(unsigned __val)
   ^
/nix/store/psmdlfqys1031hhyjhky4qphgyscmgdg-gcc-5.4.0/include/c++/5.4.0/bits/basic_string.h:5299:3: note: candidate: std::__cxx11::string std::__cxx11::to_string(int)
   to_string(int __val)
   ^
libgringo/src/term.cc: In member function 'virtual Gringo::UTerm Gringo::VarTerm::renameVars(Gringo::Term::RenameMap&) const':
libgringo/src/term.cc:963:91: error: call of overloaded 'to_string(std::unordered_map<Gringo::Flyweight<std::__cxx11::basic_string<char> >, std::pair<Gringo::Flyweight<std::__cxx11::basic_string<char> >, std::shared_ptr<Gringo::Value> > >::size_type)' is ambiguous
         ret.first->second.first  = (bindRef ? "X" : "Y") + std::to_string(names.size() - 1); 
                                                                                           ^
In file included from libgringo/gringo/term.hh:24:0,
                 from libgringo/src/term.cc:21:
libgringo/gringo/bug.hh:41:15: note: candidate: std::__cxx11::string std::to_string(int)
 inline string to_string(int x) {
               ^
libgringo/gringo/bug.hh:47:15: note: candidate: std::__cxx11::string std::to_string(unsigned int)
 inline string to_string(unsigned x) {
               ^
libgringo/gringo/bug.hh:53:15: note: candidate: std::__cxx11::string std::to_string(long int)
 inline string to_string(long x) {
               ^
libgringo/gringo/bug.hh:59:15: note: candidate: std::__cxx11::string std::to_string(long unsigned int)
 inline string to_string(unsigned long x) {
               ^
libgringo/gringo/bug.hh:65:15: note: candidate: std::__cxx11::string std::to_string(long long int)
 inline string to_string(long long x) {
               ^
libgringo/gringo/bug.hh:71:15: note: candidate: std::__cxx11::string std::to_string(long long unsigned int)
 inline string to_string(unsigned long long x) {
               ^
In file included from /nix/store/psmdlfqys1031hhyjhky4qphgyscmgdg-gcc-5.4.0/include/c++/5.4.0/string:52:0,
                 from /nix/store/psmdlfqys1031hhyjhky4qphgyscmgdg-gcc-5.4.0/include/c++/5.4.0/bits/locale_classes.h:40,
                 from /nix/store/psmdlfqys1031hhyjhky4qphgyscmgdg-gcc-5.4.0/include/c++/5.4.0/bits/ios_base.h:41,
                 from /nix/store/psmdlfqys1031hhyjhky4qphgyscmgdg-gcc-5.4.0/include/c++/5.4.0/ios:42,
                 from /nix/store/psmdlfqys1031hhyjhky4qphgyscmgdg-gcc-5.4.0/include/c++/5.4.0/ostream:38,
                 from /nix/store/psmdlfqys1031hhyjhky4qphgyscmgdg-gcc-5.4.0/include/c++/5.4.0/iterator:64,
                 from libgringo/gringo/bug.hh:24,
                 from libgringo/gringo/term.hh:24,
                 from libgringo/src/term.cc:21:
/nix/store/psmdlfqys1031hhyjhky4qphgyscmgdg-gcc-5.4.0/include/c++/5.4.0/bits/basic_string.h:5351:3: note: candidate: std::__cxx11::string std::__cxx11::to_string(long double)
   to_string(long double __val)
   ^
/nix/store/psmdlfqys1031hhyjhky4qphgyscmgdg-gcc-5.4.0/include/c++/5.4.0/bits/basic_string.h:5342:3: note: candidate: std::__cxx11::string std::__cxx11::to_string(double)
   to_string(double __val)
   ^
/nix/store/psmdlfqys1031hhyjhky4qphgyscmgdg-gcc-5.4.0/include/c++/5.4.0/bits/basic_string.h:5333:3: note: candidate: std::__cxx11::string std::__cxx11::to_string(float)
   to_string(float __val)
   ^
/nix/store/psmdlfqys1031hhyjhky4qphgyscmgdg-gcc-5.4.0/include/c++/5.4.0/bits/basic_string.h:5327:3: note: candidate: std::__cxx11::string std::__cxx11::to_string(long long unsigned int)
   to_string(unsigned long long __val)
   ^
/nix/store/psmdlfqys1031hhyjhky4qphgyscmgdg-gcc-5.4.0/include/c++/5.4.0/bits/basic_string.h:5321:3: note: candidate: std::__cxx11::string std::__cxx11::to_string(long long int)
   to_string(long long __val)
   ^
/nix/store/psmdlfqys1031hhyjhky4qphgyscmgdg-gcc-5.4.0/include/c++/5.4.0/bits/basic_string.h:5315:3: note: candidate: std::__cxx11::string std::__cxx11::to_string(long unsigned int)
   to_string(unsigned long __val)
   ^
/nix/store/psmdlfqys1031hhyjhky4qphgyscmgdg-gcc-5.4.0/include/c++/5.4.0/bits/basic_string.h:5310:3: note: candidate: std::__cxx11::string std::__cxx11::to_string(long int)
   to_string(long __val)
   ^
/nix/store/psmdlfqys1031hhyjhky4qphgyscmgdg-gcc-5.4.0/include/c++/5.4.0/bits/basic_string.h:5304:3: note: candidate: std::__cxx11::string std::__cxx11::to_string(unsigned int)
   to_string(unsigned __val)
   ^
/nix/store/psmdlfqys1031hhyjhky4qphgyscmgdg-gcc-5.4.0/include/c++/5.4.0/bits/basic_string.h:5299:3: note: candidate: std::__cxx11::string std::__cxx11::to_string(int)
   to_string(int __val)
   ^
libgringo/src/term.cc: In member function 'virtual double Gringo::FunctionTerm::estimate(double, const VarSet&) const':
libgringo/src/term.cc:1849:37: error: 'pow' is not a member of 'std'
         double root = std::max(1.0, std::pow(((*name).empty() ? size : size/2.0), 1.0/args.size()));
                                     ^
scons: *** [build/debug/libgringo/src/term.o] Error 1
scons: building terminated because of errors.

There seems to be an additional error:

libgringo/src/term.cc:1849:37: error: 'pow' is not a member of 'std'
         double root = std::max(1.0, std::pow(((*name).empty() ? size : size/2.0), 1.0/args.size()));
                                     ^
FRidh commented 7 years ago

gringo seems to be discontinued so there doesn't seem to be a place to ask if they've encountered the same issue. Note that gringo has been superseded by clingo.

Since all other packages depending on scons build fine, I would prefer not to undo the commit. Therefore, could you copy the old expression of scons into your expression of gringo, and use that version of scons to build gringo?

sternenseemann commented 7 years ago

Can we replace gringo with clingo trivially?

sternenseemann commented 7 years ago

This derivation, as suggested by @FRidh, works, but I can't work out why this is any different from the usual scons which really bothers me. It doesn't seem like a good fix for the problem.

{ stdenv, fetchurl,
  bison, re2c,
  python2, makeWrapper
}:

let
  scons = stdenv.mkDerivation rec {
    version = "2.5.0";
    name = "scons-${version}";

    src = fetchurl {
      url = "mirror://sourceforge/scons/${name}.tar.gz";
      sha256 = "1sdcj8iapfzmlq7098yas40qwl6khsiwydbxv33sw81wy93nnagb";
    };

    buildInputs = [python2 makeWrapper];

    preConfigure = ''
    for i in "script/"*; do
    substituteInPlace $i --replace "/usr/bin/env python" "${python2}/bin/python"
    done
    '';
    buildPhase = "python setup.py install --prefix=$out --install-data=$out/share --install-lib=$(toPythonPath $out) --symlink-scons -O1";
    installPhase = "for n in $out/bin/*-${version}; do wrapProgram $n --suffix PYTHONPATH ':' \"$(toPythonPath $out)\"; done";

    pythonPath = [];
  };

in

stdenv.mkDerivation rec {
  name = "gringo-${version}";
  version = "4.5.4";

  src = fetchurl {
    url = "mirror://sourceforge/project/potassco/gringo/${version}/gringo-${version}-source.tar.gz";
    sha256 = "16k4pkwyr2mh5w8j91vhxh9aff7f4y31npwf09w6f8q63fxvpy41";
  };

  buildInputs = [ bison re2c scons ];

  patches = [
    ./gringo-4.5.4-cmath.patch
  ];

  buildPhase = ''
    scons --build-dir=release
  '';

  installPhase = ''
    mkdir -p $out/bin
    cp build/release/gringo $out/bin/gringo
  '';

  meta = with stdenv.lib; {
    description = "Converts input programs with first-order variables to equivalent ground programs";
    homepage = http://potassco.sourceforge.net/;
    platforms = platforms.linux;
    maintainers = [ maintainers.hakuch ];
    license = licenses.gpl3Plus;
  };
}
Zimmi48 commented 7 years ago

Personally, I'm not specifically interested in gringo. I would like to build OCaml packages which depend on opam. opam's derivation depends on aspcud which in turns depends on gringo. Here is an explanation from the OPAM team of the dependency on aspcud: http://opam.ocaml.org/doc/Install.html#ExternalSolvers. It could apparently be dropped completely or replaced with another solver such as packup.

aspcud is from the same team as gringo and clingo. From this page http://www.cs.uni-potsdam.de/wv/aspcud/ it seems that aspcud depends on gringo but gringo itself is now part of clingo, as shown on https://github.com/potassco/clingo:

Clingo combines both gringo and clasp into a monolithic system.

Additionally, it looks like aspcud is the only package depending on gringo in nixpkgs: https://github.com/NixOS/nixpkgs/search?q=gringo and opam is the only package depending on aspcud: https://github.com/NixOS/nixpkgs/search?q=aspcud

To me any solution would be fine (replacing gringo with clingo or replacing aspcud with something else or merely dropping this dependency). Maybe the OCaml team of nixpkgs should be consulted on this matter and topic: ocaml be added to this issue.

sternenseemann commented 7 years ago

Same applies for me, I ran into it as well, when trying to package ptime.

FRidh commented 7 years ago

I leave finding a solution up to you, but, if you need a quick fix, then just open a PR as I proposed and that would be fine.

Zimmi48 commented 7 years ago

It looks easy to replace gringo by clingo so I'm going to try that and if it works, I'll open a PR.

Zimmi48 commented 7 years ago

Closed by #20086