Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Will not compile on Solaris 11 with gcc #28

Closed
jimhall opened this issue Apr 2, 2014 · 18 comments
Closed

Will not compile on Solaris 11 with gcc #28

jimhall opened this issue Apr 2, 2014 · 18 comments

Comments

@jimhall
Copy link

jimhall commented Apr 2, 2014

Hit the following issue compiling on Solaris 11:

cpan[5]> test Compiler::Lexer
Running test for module 'Compiler::Lexer'
Running Build for G/GO/GOCCY/Compiler-Lexer-0.17.tar.gz
Has already been unwrapped into directory /home/jhall/.cpan/build/Compiler-Lexer-0.17-1z7dih

CPAN.pm: Going to build G/GO/GOCCY/Compiler-Lexer-0.17.tar.gz

Created MYMETA.yml and MYMETA.json
Creating new 'Build' script for 'Compiler-Lexer' version '0.17'
Merging cpanfile prereqs to MYMETA.yml
Merging cpanfile prereqs to MYMETA.json
Building Compiler-Lexer
gcc -Isrc -I/usr/perl5/5.12/lib/i86pc-solaris-64int/CORE -fPIC -Iinclude -Wno-missing-field-initializers -g3 -c -DPTR_IS_LONG -I/usr/gnu/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -DPERL_USE_SAFE_PUTENV -O2 -o src/compiler/util/Compiler_token.o src/compiler/util/Compiler_token.cpp
In file included from src/compiler/util/Compiler_token.cpp:1:0:
include/lexer.hpp: In member function ‘TokenInfo TokenManager::getTokenInfo(const char*)’:
include/lexer.hpp:55:67: error: ‘strlen’ was not declared in this scope
error building src/compiler/util/Compiler_token.o from 'src/compiler/util/Compiler_token.cpp' at /export/code/perl5/lib/site_perl/ExtUtils/CBuilder/Base.pm line 175, line 1.
GOCCY/Compiler-Lexer-0.17.tar.gz
./Build --extra_linker_flags -L/export/code/perl5/lib --extra_linker_flags -L/export/code/perl5/lib -- NOT OK
Running Build test
Can't test without successful make
Failed during this command:
GOCCY/Compiler-Lexer-0.17.tar.gz : make NO

This is my environment:

perlgcc2 -V
Summary of my perl5 (revision 5 version 12 subversion 5) configuration:

Platform:
osname=solaris, osvers=2.11, archname=i86pc-solaris-64int
uname='sunos localhost 5.11 i86pc i386 i86pc'
config_args='-Dprefix=/usr/perl5/5.12 -Dprivlib=/usr/perl5/5.12/lib -Dsitelib=/usr/perl5/site_perl/5.12 -Dvendorprefix=/usr/perl5/5.12 -Dvendorlib=/usr/perl5/vendor_perl/5.12 -Dlibperl=libperl.so -Duseshrplib -Dusedtrace -Duse64bitint -Dcc=cc -Doptimize=-xO4 -Dcf_email=userland-discuss@opensolaris.org -Dcf_by=perl-bugs -Dmyhostname=localhost -Dmksymlinks -O -de'
hint=recommended, useposix=true, d_sigaction=define
useithreads=undef, usemultiplicity=undef
useperlio=define, d_sfio=undef, uselargefiles=define, usesocks=undef
use64bitint=define, use64bitall=undef, uselongdouble=undef
usemymalloc=n, bincompat5005=undef
Compiler:
cc='gcc', ccflags ='-DPTR_IS_LONG -I/usr/gnu/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -DPERL_USE_SAFE_PUTENV',
optimize='-O2 ',
cppflags='-DPTR_IS_LONG -I/usr/gnu/include'
ccversion='Sun C 5.10 SunOS_i386 Patch 142363-07 2010/12/09', gccversion='', gccosandvers=''
intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=12345678
d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=12
ivtype='long long', ivsize=8, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=8
alignbytes=4, prototype=define
Linker and Libraries:
ld='gcc', ldflags =' -L/usr/lib -L/usr/ccs/lib -L/lib -L/usr/gnu/lib '
libpth=/usr/lib /usr/ccs/lib /lib /usr/gnu/lib
libs=-lsocket -lnsl -lgdbm -ldb -ldl -lm -lc
perllibs=-lsocket -lnsl -ldl -lm -lc
libc=/lib/libc.so, so=so, useshrplib=true, libperl=libperl.so
gnulibc_version=''
Dynamic Linking:
dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags=' -R /usr/perl5/5.12/lib/i86pc-solaris-64int/CORE'
cccdlflags='-fPIC', lddlflags='-G -L/usr/lib -L/usr/ccs/lib -L/lib -L/usr/gnu/lib'

Characteristics of this binary (from libperl):
Compile-time options: PERL_DONT_CREATE_GVSV PERL_MALLOC_WRAP
PERL_USE_SAFE_PUTENV USE_64_BIT_INT USE_LARGE_FILES
USE_PERLIO USE_PERL_ATOF
Locally applied patches:
7111771 Problem with utility/perl
7125218 Problem with utility/perl
7030196 Problem with utility/perl
15820486 Problem with utility/perl
15880426 Problem with utility/perl
16417744 Problem with utility/perl
16427786 Problem with utility/perl
Built under solaris
Compiled at Dec 3 2013 00:45:56
%ENV:
PERL5LIB="/export/code/perl5/lib/PerlGcc2:/export/code/perl5/lib:/export/code/perl5/lib/site_perl:/export/code/perl5/lib/perl5"
PERL5_OVERRIDE_CONFIG="1"
@inc:
/export/code/perl5/lib/PerlGcc2
/export/code/perl5/lib/i86pc-solaris-64int
/export/code/perl5/lib
/export/code/perl5/lib/site_perl/5.12.5/i86pc-solaris-64int
/export/code/perl5/lib/site_perl/5.12.5
/export/code/perl5/lib/site_perl
/export/code/perl5/lib/perl5/i86pc-solaris-64int
/export/code/perl5/lib/perl5
/usr/perl5/site_perl/5.12/i86pc-solaris-64int
/usr/perl5/site_perl/5.12
/usr/perl5/vendor_perl/5.12/i86pc-solaris-64int
/usr/perl5/vendor_perl/5.12
/usr/perl5/5.12/lib/i86pc-solaris-64int
/usr/perl5/5.12/lib
.

Any suggestions?

@syohex
Copy link
Contributor

syohex commented Apr 3, 2014

Your environment misses strlen function.
Could you compile after including string.h(or applying following patch) ?

diff --git a/include/common.hpp b/include/common.hpp
index f674d8a..ab7398a 100644
--- a/include/common.hpp
+++ b/include/common.hpp
@@ -1,5 +1,6 @@
 #include <stdio.h>
 #include <stdlib.h>
+#include <string.h>
 #include <stdint.h>
 #include <memory.h>
 #include <iostream>

@jimhall
Copy link
Author

jimhall commented Apr 12, 2014

Thanks so much for the pointer! Things got a little farther, but still no luck. It looks like it does not realize that it should be compiling C++. Maybe I need to explicitly define the include for iostream? Here is the output:

cpan[9]> test Compiler::Lexer
Running test for module 'Compiler::Lexer'
Running Build for G/GO/GOCCY/Compiler-Lexer-0.18.tar.gz
Has already been unwrapped into directory /home/jhall/.cpan/build/Compiler-Lexer-0.18-2QYcAh

CPAN.pm: Going to build G/GO/GOCCY/Compiler-Lexer-0.18.tar.gz

Created MYMETA.yml and MYMETA.json
Creating new 'Build' script for 'Compiler-Lexer' version '0.18'
Merging cpanfile prereqs to MYMETA.yml
Merging cpanfile prereqs to MYMETA.json
Building Compiler-Lexer
gcc -Isrc -I/usr/perl5/5.12/lib/i86pc-solaris-64int/CORE -fPIC -Iinclude -Wno-missing-field-initializers -g3 -c -DPTR_IS_LONG -I/usr/gnu/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -DPERL_USE_SAFE_PUTENV -O2 -o src/compiler/util/Compiler_token.o src/compiler/util/Compiler_token.cpp
gcc -Isrc -I/usr/perl5/5.12/lib/i86pc-solaris-64int/CORE -fPIC -Iinclude -Wno-missing-field-initializers -g3 -c -DPTR_IS_LONG -I/usr/gnu/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -DPERL_USE_SAFE_PUTENV -O2 -o src/compiler/util/Compiler_triple_charactor_operator.o src/compiler/util/Compiler_triple_charactor_operator.cpp
gcc -Isrc -I/usr/perl5/5.12/lib/i86pc-solaris-64int/CORE -fPIC -Iinclude -Wno-missing-field-initializers -g3 -c -DPTR_IS_LONG -I/usr/gnu/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -DPERL_USE_SAFE_PUTENV -O2 -o src/compiler/util/Compiler_double_charactor_operator.o src/compiler/util/Compiler_double_charactor_operator.cpp
gcc -Isrc -I/usr/perl5/5.12/lib/i86pc-solaris-64int/CORE -fPIC -Iinclude -Wno-missing-field-initializers -g3 -c -DPTR_IS_LONG -I/usr/gnu/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -DPERL_USE_SAFE_PUTENV -O2 -o src/compiler/util/Compiler_reserved_keyword.o src/compiler/util/Compiler_reserved_keyword.cpp
gcc -Isrc -I/usr/perl5/5.12/lib/i86pc-solaris-64int/CORE -fPIC -Iinclude -Wno-missing-field-initializers -g3 -c -DPTR_IS_LONG -I/usr/gnu/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -DPERL_USE_SAFE_PUTENV -O2 -o src/compiler/util/Compiler_gen_token_decl.o src/compiler/util/Compiler_gen_token_decl.cpp
gcc -Isrc -I/usr/perl5/5.12/lib/i86pc-solaris-64int/CORE -fPIC -Iinclude -Wno-missing-field-initializers -g3 -c -DPTR_IS_LONG -I/usr/gnu/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -DPERL_USE_SAFE_PUTENV -O2 -o src/compiler/util/Compiler_util.o src/compiler/util/Compiler_util.cpp
gcc -Isrc -I/usr/perl5/5.12/lib/i86pc-solaris-64int/CORE -fPIC -Iinclude -Wno-missing-field-initializers -g3 -c -DPTR_IS_LONG -I/usr/gnu/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -DPERL_USE_SAFE_PUTENV -O2 -o src/compiler/lexer/Compiler_annotator.o src/compiler/lexer/Compiler_annotator.cpp
gcc -Isrc -I/usr/perl5/5.12/lib/i86pc-solaris-64int/CORE -fPIC -Iinclude -Wno-missing-field-initializers -g3 -c -DPTR_IS_LONG -I/usr/gnu/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -DPERL_USE_SAFE_PUTENV -O2 -o src/compiler/lexer/Compiler_lexer.o src/compiler/lexer/Compiler_lexer.cpp
src/compiler/lexer/Compiler_lexer.cpp: In member function ‘void Lexer::parseSpecificStmt(Token*)’:
src/compiler/lexer/Compiler_lexer.cpp:484:40: warning: comparison between ‘enum Enum::Token::Type::Type’ and ‘enum Enum::Parser::Syntax::Type’ [-Wenum-compare]
gcc -Isrc -I/usr/perl5/5.12/lib/i86pc-solaris-64int/CORE -fPIC -Iinclude -Wno-missing-field-initializers -g3 -c -DPTR_IS_LONG -I/usr/gnu/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -DPERL_USE_SAFE_PUTENV -O2 -o src/compiler/lexer/Compiler_manager.o src/compiler/lexer/Compiler_manager.cpp
gcc -Isrc -I/usr/perl5/5.12/lib/i86pc-solaris-64int/CORE -fPIC -Iinclude -Wno-missing-field-initializers -g3 -c -DPTR_IS_LONG -I/usr/gnu/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -DPERL_USE_SAFE_PUTENV -O2 -o src/compiler/lexer/Compiler_scanner.o src/compiler/lexer/Compiler_scanner.cpp
gcc -Isrc -I/usr/perl5/5.12/lib/i86pc-solaris-64int/CORE -DXS_VERSION="0.18" -DVERSION="0.18" -fPIC -Iinclude -Wno-missing-field-initializers -g3 -c -DPTR_IS_LONG -I/usr/gnu/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -DPERL_USE_SAFE_PUTENV -O2 -o lib/Compiler/Lexer.o lib/Compiler/Lexer.c
In file included from include/lexer.hpp:1:0,
from lib/Compiler/Lexer.xs:1:
include/common.hpp:6:20: fatal error: iostream: No such file or directory
compilation terminated.
error building lib/Compiler/Lexer.o from 'lib/Compiler/Lexer.c' at /export/code/perl5/lib/site_perl/ExtUtils/CBuilder/Base.pm line 175.
GOCCY/Compiler-Lexer-0.18.tar.gz
./Build --extra_linker_flags -L/export/code/perl5/lib --extra_linker_flags -L/export/code/perl5/lib -- NOT OK
Running Build test
Can't test without successful make
Failed during this command:
GOCCY/Compiler-Lexer-0.18.tar.gz : make NO

@syohex
Copy link
Contributor

syohex commented Apr 12, 2014

@jimhall Could you try to apply following patch for compiling sources as C++ ?

diff --git a/builder/MyBuilder.pm b/builder/MyBuilder.pm
index d8b5dd4..fb532f1 100644
--- a/builder/MyBuilder.pm
+++ b/builder/MyBuilder.pm
@@ -15,7 +15,7 @@ sub new {
         c_source => [qw/src/],
         xs_files => { 'src/Compiler-Lexer.xs' => 'lib/Compiler/Lexer.xs' },
         cc_warnings => 0, # TODO
-        extra_compiler_flags => ['-Iinclude', @ignore_warnings_options, '-g3'],
+        extra_compiler_flags => ['-Iinclude', @ignore_warnings_options, '-g3', '-x', 'c++'],
         add_to_cleanup => [
             'lib/Compiler/Lexer/*.o', 'lib/Compiler/Lexer/*.c',
             'lib/Compiler/Lexer/*.xs',

@jimhall
Copy link
Author

jimhall commented Apr 12, 2014

Got much further! But now I wonder if I am hitting something due to the system perl being made with solaris cc and I am trying to build the module with gcc? I wonder if I need a newer DynaLoader?

cpan[11]> test Compiler::Lexer                                                                  
Running test for module 'Compiler::Lexer'
Running Build for G/GO/GOCCY/Compiler-Lexer-0.18.tar.gz
  Has already been unwrapped into directory /home/jhall/.cpan/build/Compiler-Lexer-0.18-2QYcAh

  CPAN.pm: Going to build G/GO/GOCCY/Compiler-Lexer-0.18.tar.gz

Created MYMETA.yml and MYMETA.json
Creating new 'Build' script for 'Compiler-Lexer' version '0.18'
Merging cpanfile prereqs to MYMETA.yml
Merging cpanfile prereqs to MYMETA.json
Building Compiler-Lexer
gcc -Isrc -I/usr/perl5/5.12/lib/i86pc-solaris-64int/CORE -fPIC -Iinclude -Wno-missing-field-initializers -g3 -x c++ -c -DPTR_IS_LONG -I/usr/gnu/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -DPERL_USE_SAFE_PUTENV -O2 -o src/compiler/util/Compiler_token.o src/compiler/util/Compiler_token.cpp
gcc -Isrc -I/usr/perl5/5.12/lib/i86pc-solaris-64int/CORE -fPIC -Iinclude -Wno-missing-field-initializers -g3 -x c++ -c -DPTR_IS_LONG -I/usr/gnu/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -DPERL_USE_SAFE_PUTENV -O2 -o src/compiler/util/Compiler_triple_charactor_operator.o src/compiler/util/Compiler_triple_charactor_operator.cpp
gcc -Isrc -I/usr/perl5/5.12/lib/i86pc-solaris-64int/CORE -fPIC -Iinclude -Wno-missing-field-initializers -g3 -x c++ -c -DPTR_IS_LONG -I/usr/gnu/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -DPERL_USE_SAFE_PUTENV -O2 -o src/compiler/util/Compiler_double_charactor_operator.o src/compiler/util/Compiler_double_charactor_operator.cpp
gcc -Isrc -I/usr/perl5/5.12/lib/i86pc-solaris-64int/CORE -fPIC -Iinclude -Wno-missing-field-initializers -g3 -x c++ -c -DPTR_IS_LONG -I/usr/gnu/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -DPERL_USE_SAFE_PUTENV -O2 -o src/compiler/util/Compiler_reserved_keyword.o src/compiler/util/Compiler_reserved_keyword.cpp
gcc -Isrc -I/usr/perl5/5.12/lib/i86pc-solaris-64int/CORE -fPIC -Iinclude -Wno-missing-field-initializers -g3 -x c++ -c -DPTR_IS_LONG -I/usr/gnu/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -DPERL_USE_SAFE_PUTENV -O2 -o src/compiler/util/Compiler_gen_token_decl.o src/compiler/util/Compiler_gen_token_decl.cpp
gcc -Isrc -I/usr/perl5/5.12/lib/i86pc-solaris-64int/CORE -fPIC -Iinclude -Wno-missing-field-initializers -g3 -x c++ -c -DPTR_IS_LONG -I/usr/gnu/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -DPERL_USE_SAFE_PUTENV -O2 -o src/compiler/util/Compiler_util.o src/compiler/util/Compiler_util.cpp
gcc -Isrc -I/usr/perl5/5.12/lib/i86pc-solaris-64int/CORE -fPIC -Iinclude -Wno-missing-field-initializers -g3 -x c++ -c -DPTR_IS_LONG -I/usr/gnu/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -DPERL_USE_SAFE_PUTENV -O2 -o src/compiler/lexer/Compiler_annotator.o src/compiler/lexer/Compiler_annotator.cpp
gcc -Isrc -I/usr/perl5/5.12/lib/i86pc-solaris-64int/CORE -fPIC -Iinclude -Wno-missing-field-initializers -g3 -x c++ -c -DPTR_IS_LONG -I/usr/gnu/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -DPERL_USE_SAFE_PUTENV -O2 -o src/compiler/lexer/Compiler_lexer.o src/compiler/lexer/Compiler_lexer.cpp
src/compiler/lexer/Compiler_lexer.cpp: In member function ‘void Lexer::parseSpecificStmt(Token*)’:
src/compiler/lexer/Compiler_lexer.cpp:484:40: warning: comparison between ‘enum Enum::Token::Type::Type’ and ‘enum Enum::Parser::Syntax::Type’ [-Wenum-compare]
gcc -Isrc -I/usr/perl5/5.12/lib/i86pc-solaris-64int/CORE -fPIC -Iinclude -Wno-missing-field-initializers -g3 -x c++ -c -DPTR_IS_LONG -I/usr/gnu/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -DPERL_USE_SAFE_PUTENV -O2 -o src/compiler/lexer/Compiler_manager.o src/compiler/lexer/Compiler_manager.cpp
gcc -Isrc -I/usr/perl5/5.12/lib/i86pc-solaris-64int/CORE -fPIC -Iinclude -Wno-missing-field-initializers -g3 -x c++ -c -DPTR_IS_LONG -I/usr/gnu/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -DPERL_USE_SAFE_PUTENV -O2 -o src/compiler/lexer/Compiler_scanner.o src/compiler/lexer/Compiler_scanner.cpp
gcc -Isrc -I/usr/perl5/5.12/lib/i86pc-solaris-64int/CORE -DXS_VERSION="0.18" -DVERSION="0.18" -fPIC -Iinclude -Wno-missing-field-initializers -g3 -x c++ -c -DPTR_IS_LONG -I/usr/gnu/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -DPERL_USE_SAFE_PUTENV -O2 -o lib/Compiler/Lexer.o lib/Compiler/Lexer.c
ExtUtils::Mkbootstrap::Mkbootstrap('blib/arch/auto/Compiler/Lexer/Lexer.bs')
gcc -G -L/usr/lib -L/usr/ccs/lib -L/lib -L/usr/gnu/lib -o blib/arch/auto/Compiler/Lexer/Lexer.so lib/Compiler/Lexer.o src/compiler/util/Compiler_token.o src/compiler/util/Compiler_triple_charactor_operator.o src/compiler/util/Compiler_double_charactor_operator.o src/compiler/util/Compiler_reserved_keyword.o src/compiler/util/Compiler_gen_token_decl.o src/compiler/util/Compiler_util.o src/compiler/lexer/Compiler_annotator.o src/compiler/lexer/Compiler_lexer.o src/compiler/lexer/Compiler_manager.o src/compiler/lexer/Compiler_scanner.o -L/export/code/perl5/lib -L/export/code/perl5/lib
  GOCCY/Compiler-Lexer-0.18.tar.gz
  ./Build --extra_linker_flags -L/export/code/perl5/lib --extra_linker_flags -L/export/code/perl5/lib -- OK
Running Build test
t/Lexer.t ............... 1/1 
#   Failed test 'use Compiler::Lexer;'
#   at t/Lexer.t line 5.
#     Tried to use 'Compiler::Lexer'.
#     Error:  Can't load '/home/jhall/.cpan/build/Compiler-Lexer-0.18-2QYcAh/blib/arch/auto/Compiler/Lexer/Lexer.so' for module Compiler::Lexer: ld.so.1: perl: fatal: relocation error: file /home/jhall/.cpan/build/Compiler-Lexer-0.18-2QYcAh/blib/arch/auto/Compiler/Lexer/Lexer.so: symbol __gxx_personality_v0: referenced symbol not found at /usr/perl5/5.12/lib/i86pc-solaris-64int/DynaLoader.pm line 200.
#  at t/Lexer.t line 5.
# Compilation failed in require at t/Lexer.t line 5.
# BEGIN failed--compilation aborted at t/Lexer.t line 5.
Can't locate object method "_new" via package "Compiler::Lexer" at /home/jhall/.cpan/build/Compiler-Lexer-0.18-2QYcAh/blib/lib/Compiler/Lexer.pm line 30.
# Looks like you failed 1 test of 1.
# Looks like your test exited with 255 just after 1.
t/Lexer.t ............... Dubious, test returned 255 (wstat 65280, 0xff00)
Failed 1/1 subtests 
t/format.t .............. 1/? 
#   Failed test 'use Compiler::Lexer;'
#   at t/format.t line 5.
#     Tried to use 'Compiler::Lexer'.
#     Error:  Can't load '/home/jhall/.cpan/build/Compiler-Lexer-0.18-2QYcAh/blib/arch/auto/Compiler/Lexer/Lexer.so' for module Compiler::Lexer: ld.so.1: perl: fatal: relocation error: file /home/jhall/.cpan/build/Compiler-Lexer-0.18-2QYcAh/blib/arch/auto/Compiler/Lexer/Lexer.so: symbol __gxx_personality_v0: referenced symbol not found at /usr/perl5/5.12/lib/i86pc-solaris-64int/DynaLoader.pm line 200.
#  at t/format.t line 5.
# Compilation failed in require at t/format.t line 5.
# BEGIN failed--compilation aborted at t/format.t line 5.
Can't locate object method "_new" via package "Compiler::Lexer" at /home/jhall/.cpan/build/Compiler-Lexer-0.18-2QYcAh/blib/lib/Compiler/Lexer.pm line 30.
# Tests were run but no plan was declared and done_testing() was not seen.
# Looks like your test exited with 255 just after 1.
t/format.t .............. Dubious, test returned 255 (wstat 65280, 0xff00)
Failed 1/1 subtests 
t/issue_reports.t ....... 1/? 
#   Failed test 'use Compiler::Lexer;'
#   at t/issue_reports.t line 5.
#     Tried to use 'Compiler::Lexer'.
#     Error:  Can't load '/home/jhall/.cpan/build/Compiler-Lexer-0.18-2QYcAh/blib/arch/auto/Compiler/Lexer/Lexer.so' for module Compiler::Lexer: ld.so.1: perl: fatal: relocation error: file /home/jhall/.cpan/build/Compiler-Lexer-0.18-2QYcAh/blib/arch/auto/Compiler/Lexer/Lexer.so: symbol __gxx_personality_v0: referenced symbol not found at /usr/perl5/5.12/lib/i86pc-solaris-64int/DynaLoader.pm line 200.
#  at t/issue_reports.t line 5.
# Compilation failed in require at t/issue_reports.t line 5.
# BEGIN failed--compilation aborted at t/issue_reports.t line 5.
Can't locate object method "_new" via package "Compiler::Lexer" at /home/jhall/.cpan/build/Compiler-Lexer-0.18-2QYcAh/blib/lib/Compiler/Lexer.pm line 30.
# Tests were run but no plan was declared and done_testing() was not seen.
# Looks like your test exited with 255 just after 1.
t/issue_reports.t ....... Dubious, test returned 255 (wstat 65280, 0xff00)
Failed 1/1 subtests 
t/package.t ............. Can't load '/home/jhall/.cpan/build/Compiler-Lexer-0.18-2QYcAh/blib/arch/auto/Compiler/Lexer/Lexer.so' for module Compiler::Lexer: ld.so.1: perl: fatal: relocation error: file /home/jhall/.cpan/build/Compiler-Lexer-0.18-2QYcAh/blib/arch/auto/Compiler/Lexer/Lexer.so: symbol __gxx_personality_v0: referenced symbol not found at /usr/perl5/5.12/lib/i86pc-solaris-64int/DynaLoader.pm line 200.
 at t/package.t line 3.
Compilation failed in require at t/package.t line 3.
BEGIN failed--compilation aborted at t/package.t line 3.
t/package.t ............. Dubious, test returned 255 (wstat 65280, 0xff00)
No subtests run 
t/recursive_tokenize.t .. Can't load '/home/jhall/.cpan/build/Compiler-Lexer-0.18-2QYcAh/blib/arch/auto/Compiler/Lexer/Lexer.so' for module Compiler::Lexer: ld.so.1: perl: fatal: relocation error: file /home/jhall/.cpan/build/Compiler-Lexer-0.18-2QYcAh/blib/arch/auto/Compiler/Lexer/Lexer.so: symbol __gxx_personality_v0: referenced symbol not found at /usr/perl5/5.12/lib/i86pc-solaris-64int/DynaLoader.pm line 200.
 at t/recursive_tokenize.t line 3.
Compilation failed in require at t/recursive_tokenize.t line 3.
BEGIN failed--compilation aborted at t/recursive_tokenize.t line 3.
t/recursive_tokenize.t .. Dubious, test returned 255 (wstat 65280, 0xff00)
No subtests run 
t/verbose.t ............. Can't load '/home/jhall/.cpan/build/Compiler-Lexer-0.18-2QYcAh/blib/arch/auto/Compiler/Lexer/Lexer.so' for module Compiler::Lexer: ld.so.1: perl: fatal: relocation error: file /home/jhall/.cpan/build/Compiler-Lexer-0.18-2QYcAh/blib/arch/auto/Compiler/Lexer/Lexer.so: symbol __gxx_personality_v0: referenced symbol not found at /usr/perl5/5.12/lib/i86pc-solaris-64int/DynaLoader.pm line 200.
 at t/verbose.t line 3.
Compilation failed in require at t/verbose.t line 3.
BEGIN failed--compilation aborted at t/verbose.t line 3.
t/verbose.t ............. Dubious, test returned 255 (wstat 65280, 0xff00)
No subtests run 

Test Summary Report
-------------------
t/Lexer.t             (Wstat: 65280 Tests: 1 Failed: 1)
  Failed test:  1
  Non-zero exit status: 255
t/format.t            (Wstat: 65280 Tests: 1 Failed: 1)
  Failed test:  1
  Non-zero exit status: 255
  Parse errors: No plan found in TAP output
t/issue_reports.t     (Wstat: 65280 Tests: 1 Failed: 1)
  Failed test:  1
  Non-zero exit status: 255
  Parse errors: No plan found in TAP output
t/package.t           (Wstat: 65280 Tests: 0 Failed: 0)
  Non-zero exit status: 255
  Parse errors: No plan found in TAP output
t/recursive_tokenize.t (Wstat: 65280 Tests: 0 Failed: 0)
  Non-zero exit status: 255
  Parse errors: No plan found in TAP output
t/verbose.t           (Wstat: 65280 Tests: 0 Failed: 0)
  Non-zero exit status: 255
  Parse errors: No plan found in TAP output
Files=6, Tests=3,  1 wallclock secs ( 0.05 usr  0.04 sys +  0.28 cusr  0.11 csys =  0.48 CPU)
Result: FAIL
Failed 6/6 test programs. 3/3 subtests failed.
  GOCCY/Compiler-Lexer-0.18.tar.gz
  ./Build test -- NOT OK
//hint// to see the cpan-testers results for installing this module, try:
  reports GOCCY/Compiler-Lexer-0.18.tar.gz
Failed during this command:
 GOCCY/Compiler-Lexer-0.18.tar.gz             : make_test NO

cpan[12]> 

@jimhall
Copy link
Author

jimhall commented Apr 12, 2014

Ah may not be that bad. On my Linux env:

[oracle@localhost Lexer]$ ldd Lexer.so
linux-vdso.so.1 => (0x00007fff41dc9000)
libstdc++.so.6 => /usr/lib64/libstdc++.so.6 (0x00007fc4c20ed000)
libgcc_s.so.1 => /lib64/libgcc_s.so.1 (0x00007fc4c1ed7000)
libc.so.6 => /lib64/libc.so.6 (0x00007fc4c1b42000)
libm.so.6 => /lib64/libm.so.6 (0x00007fc4c18be000)
/lib64/ld-linux-x86-64.so.2 (0x0000003d33e00000)

On my Solaris box:

ldd /home/jhall/.cpan/build/Compiler-Lexer-0.18-2QYcAh/blib/arch/auto/Compiler/Lexer/Lexer.so
libc.so.1 => /lib/libc.so.1
libm.so.2 => /lib/libm.so.2

So maybe one of the switches I need is for the C++ std library?

@syohex
Copy link
Contributor

syohex commented Apr 12, 2014

Could you specified linker option -lstdc++ explicitly as below ?

diff --git a/builder/MyBuilder.pm b/builder/MyBuilder.pm
index d8b5dd4..065f96a 100644
--- a/builder/MyBuilder.pm
+++ b/builder/MyBuilder.pm
@@ -15,7 +15,8 @@ sub new {
         c_source => [qw/src/],
         xs_files => { 'src/Compiler-Lexer.xs' => 'lib/Compiler/Lexer.xs' },
         cc_warnings => 0, # TODO
-        extra_compiler_flags => ['-Iinclude', @ignore_warnings_options, '-g3'],
+        extra_compiler_flags => ['-Iinclude', @ignore_warnings_options, '-g3', '-x', 'c++'],
+        extra_linker_flags => ['-lstdc++'],
         add_to_cleanup => [
             'lib/Compiler/Lexer/*.o', 'lib/Compiler/Lexer/*.c',
             'lib/Compiler/Lexer/*.xs',

@jimhall
Copy link
Author

jimhall commented Apr 13, 2014

Ok - that did it! But, I noticed that I had in entry in my MyConfig.pm in my CPAN shell:

mbuild_arg [--extra_linker_flags -L/export/code/perl5/lib]

This seemed to overwrite your extra_linker_flags entry. Once I zero'd this option out, your option took precedence. And everything compiled!

I do get the following warning:

src/compiler/lexer/Compiler_lexer.cpp: In member function ‘void Lexer::parseSpecificStmt(Token*)’:
src/compiler/lexer/Compiler_lexer.cpp:484:40: warning: comparison between ‘enum Enum::Token::Type::Type’ and ‘enum Enum::Parser::Syntax::Type’ [-Wenum-compare]

Otherwise - clean:

ExtUtils::Mkbootstrap::Mkbootstrap('blib/arch/auto/Compiler/Lexer/Lexer.bs')
gcc -G -L/usr/lib -L/usr/ccs/lib -L/lib -L/usr/gnu/lib -o blib/arch/auto/Compiler/Lexer/Lexer.so lib/Compiler/Lexer.o src/compiler/util/Compiler_token.o src/compiler/util/Compiler_triple_charactor_operator.o src/compiler/util/Compiler_double_charactor_operator.o src/compiler/util/Compiler_reserved_keyword.o src/compiler/util/Compiler_gen_token_decl.o src/compiler/util/Compiler_util.o src/compiler/lexer/Compiler_annotator.o src/compiler/lexer/Compiler_lexer.o src/compiler/lexer/Compiler_manager.o src/compiler/lexer/Compiler_scanner.o -lstdc++
GOCCY/Compiler-Lexer-0.18.tar.gz
./Build -- OK
Running Build test
t/Lexer.t ............... ok
t/format.t .............. ok
t/issue_reports.t ....... ok
t/package.t ............. ok
t/recursive_tokenize.t .. ok
t/verbose.t ............. ok
All tests successful.
Files=6, Tests=8, 11 wallclock secs ( 0.06 usr 0.04 sys + 3.14 cusr 1.77 csys = 5.01 CPU)
Result: PASS
GOCCY/Compiler-Lexer-0.18.tar.gz
./Build test -- OK

Is there something wrong with my environment that I needed these extra flags or are you making some assumptions that are common to these environments? I can't find these options in Config_heavy.pl for example. Also - what packaging framework are you using? Is it CPAN::Meta?

Thank you so much for taking the time to help me with this!

JIM

@syohex
Copy link
Contributor

syohex commented Apr 13, 2014

Module::Build::XSUtil can set C++ compile flags and linker flags, if perl is built
by GCC or Clang or Visual Studio. But your perl may be built by Sun Studio
(Default perl of Solaris is build by Sun Stduio), so Module::Build::XSUtil does not
set those flags.

@jimhall
Copy link
Author

jimhall commented Apr 13, 2014

Do you happen to know how Module::Build::XSUtil finds the proper flags to set? For example, is it from entries from Config_heavy.pl? Or something from perl -V? This way I could develop a proper work around.

@syohex
Copy link
Contributor

syohex commented Apr 13, 2014

Module::Build::XSUtil checks $Config{gccversion} or $Config{compiler}.

See Also.
https://github.com/hideo55/Module-Build-XSUtil/blob/master/lib/Module/Build/XSUtil.pm#L47

@jimhall
Copy link
Author

jimhall commented Apr 13, 2014

excellent - thanks!

@goccy
Copy link
Owner

goccy commented Apr 14, 2014

Thank you for reporting. Also, thanks for the appropriate advice for it!!!

@jimhall
Copy link
Author

jimhall commented Apr 14, 2014

oops... seems the github editing interface made some changes. Will preview next time. Wondering if anyone understands the fix the first issue hit with strlen function call. The line that was offered to change in common.hpp in is:

#include <string>

This modification in common.hpp allowed for good compile:

#include <string.h>

Why won't gcc take the

#include <string> 

as correct? Could this be another side effect of using Sun Studio with the original perl compile?

@syohex
Copy link
Contributor

syohex commented Apr 15, 2014

<string> is different from <string.h> in C++. <string> is for std::string, std::basic_string,
while <string.h> is for C's string functions such as strlen, strcat.

I suppose it is better to include cstring rather than including string.h as below.

diff --git a/include/common.hpp b/include/common.hpp
index f674d8a..de76ad1 100644
--- a/include/common.hpp
+++ b/include/common.hpp
@@ -1,5 +1,6 @@
-#include <stdio.h>
-#include <stdlib.h>
+#include <cstdio>
+#include <cstdlib>
+#include <cstring>
 #include <stdint.h>
 #include <memory.h>
 #include <iostream>

FYI. I think you should not use default perl of solaris you should build perl with gcc or clang
if you want to install XS module like this module.

@jimhall
Copy link
Author

jimhall commented Apr 15, 2014

Yes - I hear you. I just wish I knew why I can pick up <iostream> and not <string>. They both are in the same include path (/usr/gcc/4.7/include/c++/4.7.3/).

I do appreciate your help on this matter. I have actually learned a lot here.

@jimhall
Copy link
Author

jimhall commented Apr 18, 2014

Ok - I am back. I have installed perlbrew and created a gcc build of perl 5.12.5 and I still broke down here:

gcc -Isrc -I/home/plbrew/perl5/perlbrew/perls/perl-5.12.5/lib/5.12.5/i86pc-solaris-64int/CORE -fPIC -I/usr/gcc/4.7/include/c++/4.7.3 -Iinclude -Wno-missing-field-initializers -g3 -xc++ -D_FILE_OFFSET_BITS=64 -c -DPTR_IS_LONG -fno-strict-aliasing -pipe -fstack-protector -I/usr/gnu/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -DPERL_USE_SAFE_PUTENV -O2 -o src/compiler/lexer/Compiler_lexer.o src/compiler/lexer/Compiler_lexer.cpp
In file included from src/compiler/lexer/Compiler_lexer.cpp:1:0:
include/lexer.hpp: In member function ‘TokenInfo TokenManager::getTokenInfo(const char*)’:
include/lexer.hpp:55:67: error: ‘strlen’ was not declared in this scope
src/compiler/lexer/Compiler_lexer.cpp: In constructor ‘LexContext::LexContext(const char*, char*)’:
src/compiler/lexer/Compiler_lexer.cpp:16:29: error: ‘strlen’ was not declared in this scope
src/compiler/lexer/Compiler_lexer.cpp: In member function ‘void Lexer::insertStmt(Token*, int, uint_t)’:
src/compiler/lexer/Compiler_lexer.cpp:410:50: error: ‘memmove’ was not declared in this scope
src/compiler/lexer/Compiler_lexer.cpp: In member function ‘void Lexer::parseSpecificStmt(Token*)’:
src/compiler/lexer/Compiler_lexer.cpp:484:40: warning: comparison between ‘enum Enum::Token::Type::Type’ and ‘enum Enum::Parser::Syntax::Type’ [-Wenum-compare]
error building src/compiler/lexer/Compiler_lexer.o from 'src/compiler/lexer/Compiler_lexer.cpp' at /home/plbrew/perl5/perlbrew/perls/perl-5.12.5/lib/5.12.5/ExtUtils/CBuilder/Base.pm line 112, <DATA> line 1.

All I needed to do to fix it was add #include <cstring> in include/common.hpp in Compiler::Lexer to make the compile clean. I did not require the other two includes in the patch from @syohex. So could you add #include <cstring> to your source in common.hpp or do you believe my environment should be picking up this include automatically? I am hoping you could add this line and it won't be too much of a bother.

Thanks for your help on this -- learned a lot!

@syohex
Copy link
Contributor

syohex commented Apr 19, 2014

Include headers issue was fixed at #29.

@jimhall
Copy link
Author

jimhall commented Apr 19, 2014

ok - i guess this issue can be closed also...

thanks!

@goccy goccy closed this as completed May 5, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants