chansen / p5-time-moment

Time::Moment represents an exact moment in time.
32 stars 8 forks source link

Time::Moment 0.25 on Solaris 10 builds with errors: stdbool.h issue #15

Closed gh0stwizard closed 8 years ago

gh0stwizard commented 9 years ago

Hello,

I have an error when building Time::Moment 0.25 on Solaris 5.10 x86:

"/export/home/tvv/.stablestaticperl-5.22.0-1.001/perl/bin/perl" "-Iinc" "/export/home/tvv/.stablestaticperl-5.22.0-1.001/perl/lib/ExtUtils/xsubpp"  -typemap "/export/home/tvv/.stablestaticperl-5.22.0-1.001/perl/lib/ExtUtils/typemap" -typemap "typemap"  Moment.xs > Moment.xsc && mv Moment.xsc Moment.c
/usr/sfw/bin/gcc -B/usr/sfw/i386-sun-solaris2.10/bin/ -c  "-Isrc" "-I." -DPTR_IS_LONG -g -DPERL_DISABLE_PMC -DPERL_ARENA_SIZE=16376 -DNO_PERL_MALLOC_ENV -D_GNU_SOURCE -DNDEBUG -fno-strict-aliasing -pipe -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -DPERL_USE_SAFE_PUTENV -Wall -W -Wno-comment -Os   -DVERSION=\"0.25\" -DXS_VERSION=\"0.25\" -o Moment.o  "-I/export/home/tvv/.stablestaticperl-5.22.0-1.001/perl/lib/CORE"   Moment.c
In file included from src/dt_config.h:30,
                 from src/dt_core.h:28,
                 from src/moment.h:6,
                 from Moment.xs:6:
/usr/include/stdbool.h:42:2: #error "Use of <stdbool.h> is valid only in a c99 compilation environment."
In file included from src/dt_core.h:28,
                 from src/moment.h:6,
                 from Moment.xs:6:
src/dt_config.h:34: warning: useless keyword or type name in empty declaration
src/dt_config.h:34: warning: empty declaration
In file included from src/dt_core.h:28,
                 from src/moment.h:6,
                 from Moment.xs:6:
src/dt_config.h:35:1: warning: "bool" redefined
In file included from /export/home/tvv/.stablestaticperl-5.22.0-1.001/perl/lib/CORE/perl.h:2696,
                 from Moment.xs:3:
/export/home/tvv/.stablestaticperl-5.22.0-1.001/perl/lib/CORE/handy.h:103:1: warning: this is the location of the previous definition
Moment.xs:236: warning: 'THX_sv_2moment' defined but not used
Makefile:368: recipe for target 'Moment.o' failed
make: *** [Moment.o] Error 1

If apply the next patch the module compiles successfully and all tests will been passed:

--- src/dt_config.h.orig        Mon Aug 17 14:23:41 2015
+++ src/dt_config.h     Mon Aug 17 14:24:57 2015
@@ -26,9 +26,11 @@
 #ifndef __DT_CONFIG_H__
 #define __DT_CONFIG_H__

+#ifndef __sun__
 #if !defined(_MSC_VER) || _MSC_VER >= 1800
 #  include <stdbool.h>
 #endif
+#endif

 #if !defined(__cplusplus) && !defined(__bool_true_false_are_defined)
    typedef char  _Bool;

Environment:

OS: Solaris 5.10
Architecture: x86
Perl: 5.22.0
GCC:
Reading specs from /usr/sfw/lib/gcc/i386-pc-solaris2.10/3.4.3/specs
Configured with: /builds/sfw10-gate/usr/src/cmd/gcc/gcc-3.4.3/configure --prefix=/usr/sfw --with-as=/usr/sfw/bin/gas --with-gnu-as --with-ld=/usr/ccs/bin/ld --without-gnu-ld --enable-languages=c,c++ --enable-shared
Thread model: posix
gcc version 3.4.3 (csl-sol210-3_4-branch+sol_rpath)

Thanks!

chansen commented 9 years ago

Thanks for the report, I'll add a fix for this as soon as http://www.cpantesters.org/ is up again. I know there is some success and failure reports for Solaris that I'll need to review before adding the suggested fix.

chansen commented 9 years ago

http://www.cpantesters.org/ is still down, I have released 0.26 with your patch.

chansen commented 8 years ago

Solaris 2.10 fails to build Time::Moment, http://www.cpantesters.org/cpan/report/f53ae7e2-6f81-11e5-ad6c-50eae0bfc7aa.

gh0stwizard commented 8 years ago

As I see there was used Sun Compiler. And it does not export the definition __sun__ (in my case the compiler was GCC).

From http://nadeausoftware.com/articles/2012/01/c_c_tip_how_use_compiler_predefined_macros_detect_operating_system#Solaris

Instead of __sun__ there should be used __sun && __SVR4. My apologies, I didn't knew about this until now.

Thanks!

chansen commented 8 years ago

No worries! Thank you for the correct patch!