tomhrr / dale

Lisp-flavoured C

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Complains about wrong integer width on an x86-32

amiloradovsky opened this issue · comments

While building for i686 it fails with the following error (on calling strtol) [solved]:

Scanning dependencies of target enum
[ 86%] Generating libenum.so
/tmp/nix-build-dale-20170416.drv-0/dale-ecc5ea91efef8a263c7dddd6925983df5b5258b2-src/modules/enum.dt:81:23: error: expected expression with type int64 (got type int32 instead) (see macro at 76:13)
make[2]: *** [CMakeFiles/enum.dir/build.make:61: libenum.so] Error 1
make[1]: *** [CMakeFiles/Makefile2:1445: CMakeFiles/enum.dir/all] Error 2
make: *** [Makefile:128: all] Error 2
builder for ‘/nix/store/3j3n1vi7pm5pdnwz60i77m4hg6m3iip6-dale-20170416.drv’ failed with exit code 2

earlier there are also some warnings [solved, see below]:

[ 23%] Building CXX object CMakeFiles/dalec.dir/src/dale/TypeRegister/TypeRegister.cpp.o
/tmp/nix-build-dale-20170416.drv-0/dale-ecc5ea91efef8a263c7dddd6925983df5b5258b2-src/src/dale/TypeRegister/TypeRegister.cpp: In member function 'void dale::TypeRegister::print()':
/tmp/nix-build-dale-20170416.drv-0/dale-ecc5ea91efef8a263c7dddd6925983df5b5258b2-src/src/dale/TypeRegister/TypeRegister.cpp:309:70: warning: format '%lu' expects argument of type 'long unsigned int', but argument 3 has type 'std::map<dale::Type*, dale::Type*>::size_type {aka unsigned int}' [-Wformat=]
     fprintf(stderr, "Pointer type count: %lu\n", pointer_types.size());
                                                                      ^
/tmp/nix-build-dale-20170416.drv-0/dale-ecc5ea91efef8a263c7dddd6925983df5b5258b2-src/src/dale/TypeRegister/TypeRegister.cpp:310:68: warning: format '%lu' expects argument of type 'long unsigned int', but argument 3 has type 'std::map<dale::Type*, dale::Type*>::size_type {aka unsigned int}' [-Wformat=]
     fprintf(stderr, "Const type count:   %lu\n", const_types.size());
                                                                    ^
/tmp/nix-build-dale-20170416.drv-0/dale-ecc5ea91efef8a263c7dddd6925983df5b5258b2-src/src/dale/TypeRegister/TypeRegister.cpp:311:68: warning: format '%lu' expects argument of type 'long unsigned int', but argument 3 has type 'std::map<dale::Type*, std::map<unsigned int, dale::Type*> >::size_type {aka unsigned int}' [-Wformat=]
     fprintf(stderr, "Array type count:   %lu\n", array_types.size());
                                                                    ^
/tmp/nix-build-dale-20170416.drv-0/dale-ecc5ea91efef8a263c7dddd6925983df5b5258b2-src/src/dale/TypeRegister/TypeRegister.cpp:312:71: warning: format '%lu' expects argument of type 'long unsigned int', but argument 3 has type 'std::map<dale::Type*, std::map<unsigned int, dale::Type*> >::size_type {aka unsigned int}' [-Wformat=]
     fprintf(stderr, "BF type count:      %lu\n", bitfield_types.size());
                                                                       ^
/tmp/nix-build-dale-20170416.drv-0/dale-ecc5ea91efef8a263c7dddd6925983df5b5258b2-src/src/dale/TypeRegister/TypeRegister.cpp:313:69: warning: format '%lu' expects argument of type 'long unsigned int', but argument 3 has type 'std::map<std::__cxx11::basic_string<char>, dale::Type*>::size_type {aka unsigned int}' [-Wformat=]
     fprintf(stderr, "Struct type count:  %lu\n", struct_types.size());
                                                                     ^

while for x86_64 it's Ok.

Revision: ecc5ea9

Full log is at https://nix-cache.s3.amazonaws.com/log/3j3n1vi7pm5pdnwz60i77m4hg6m3iip6-dale-20170416.drv


Regarding the warnings: if I replace "%lu" with "%u" in the format string, I get just the same complaint but on x86-64. Because size_type from std::map is defined to be size_t which may or may not be long -- there should be "%zu".

http://www.cplusplus.com/reference/map/map/


What may be causing the error is still unclear.
It may be due to the base-defining integrals (16 and 10), improperly cast. But then why strtol expected int64 on an arch. where int should be int32; and what value has to do with integers, it's a string after all...
Or, most likely, int64 is the expected type of the array-index of @$.
Status: setting up a (local) i686 test bench to find it out... nope, neither.

I haven't confirmed the fix on a 32-bit machine yet, but will update the issue accordingly once that's been done.

Just tested it all in Qemu:

  • the warnings are (indeed) gone,
  • my guesses were (both) wrong,
  • but your last commit fixed the error.

Essentially solved, but one of the tests is still failed (on i386):

#   Failed test 'Got expected results (1)'
#   at /tmp/nix-build-dale-20170418.drv-0/dale-9df0affc7f2c5531bb991269b6392016ef8702e2-src/t/005overload/006override-core.t line 18.
#                   'Overrode setf for float: old -0.00, new 0.00'
#     doesn't match '(?^:^Overrode setf for float: old (0.00|nan), new 0.00$)'
# Looks like you failed 1 test of 4.
/tmp/nix-build-dale-20170418.drv-0/dale-9df0affc7f2c5531bb991269b6392016ef8702e2-src/t/005overload/006override-core.t .................. 
Dubious, test returned 1 (wstat 256, 0x100)
Failed 1/4 subtests 

and

Test Summary Report
-------------------
/tmp/nix-build-dale-20170418.drv-0/dale-9df0affc7f2c5531bb991269b6392016ef8702e2-src/t/005overload/006override-core.t                (Wstat: 256 Tests: 4 Failed: 1)
  Failed test:  3
  Non-zero exit status: 1
Files=344, Tests=1364, 169 wallclock secs ( 0.67 usr  0.33 sys + 286.92 cusr 11.49 csys = 299.41 CPU)
Result: FAIL
Failed 1/344 test programs. 1/1364 subtests failed.
make[3]: *** [CMakeFiles/tests.dir/build.make:57: CMakeFiles/tests] Error 255
make[3]: Leaving directory '/tmp/nix-build-dale-20170418.drv-0/dale-9df0affc7f2c5531bb991269b6392016ef8702e2-src/build'
make[2]: *** [CMakeFiles/Makefile2:1178: CMakeFiles/tests.dir/all] Error 2
make[2]: Leaving directory '/tmp/nix-build-dale-20170418.drv-0/dale-9df0affc7f2c5531bb991269b6392016ef8702e2-src/build'
make[1]: *** [CMakeFiles/Makefile2:1185: CMakeFiles/tests.dir/rule] Error 2
make[1]: Leaving directory '/tmp/nix-build-dale-20170418.drv-0/dale-9df0affc7f2c5531bb991269b6392016ef8702e2-src/build'
make: *** [Makefile:526: tests] Error 2
builder for ‘/nix/store/7wfybkgda34q2wiym4d4vfa5v0drgz52-dale-20170418.drv’ failed with exit code 2
error: build of ‘/nix/store/7wfybkgda34q2wiym4d4vfa5v0drgz52-dale-20170418.drv’ failed

Thanks, that test should be fine now.

Yep, everything is ready now. Thank you!

Opened the pull request here: NixOS/nixpkgs#25013