tsee / extutils-cppguess

Guess the C++ compiler for Perl modules
6 stars 9 forks source link

Complete failure to detect compiler, and no override mechanisms, leading to failing tests. #23

Closed kentfredric closed 2 years ago

kentfredric commented 4 years ago

I have a setup wherein, there is no g++ anywhere in $PATH, nor any of the things this module looks for.

Perl itself has all relevant CC and stuff passed to it during its configure/compile, but of course, perl itself doesn't have any CXX stuff in %Config.

Under this configuration, nothing I seem to be able to do fixes the problem, explicitly setting CXX in ENV doesn't help at all, and the number of places in the code that hardcode the CXX to be "g++" is ridiculous.


>>> Test phase: dev-perl/ExtUtils-CppGuess-0.210.0
make -j3 --load-average=4 test TEST_VERBOSE=0 
PERL_DL_NONLAZY=1 "/usr/bin/perl" "-MExtUtils::Command::MM" "-MTest::Harness" "-e" "undef *Test::Harness::Switches; test_harness(0, 'blib/lib', 'blib/arch')" t/*.t
t/00-report-prereqs.t .. # 
# Versions for all modules listed in MYMETA.json (including optional ones):
# 
# === Configure Requires ===
# 
#     Module              Want Have Where                 Howbig
#     ------------------- ---- ---- --------------------- ------
#     ExtUtils::MakeMaker  any 7.44 /usr/lib64/perl5/5.32 109673
# 
# === Build Requires ===
# 
#     Module              Want Have Where                 Howbig
#     ------------------- ---- ---- --------------------- ------
#     ExtUtils::MakeMaker  any 7.44 /usr/lib64/perl5/5.32 109673
# 
# === Test Requires ===
# 
#     Module                  Want     Have Where                              Howbig
#     ------------------- -------- -------- ---------------------------------- ------
#     Capture::Tiny            any     0.48 /usr/lib64/perl5/vendor_perl/5.32   29656
#     Cwd                      any     3.78 /usr/lib64/perl5/5.32/x86_64-linux  21942
#     Data::Dumper             any    2.174 /usr/lib64/perl5/5.32/x86_64-linux  45832
#     ExtUtils::CBuilder  0.280231 0.280234 /usr/lib64/perl5/5.32                8883
#     ExtUtils::MakeMaker      any     7.44 /usr/lib64/perl5/5.32              109673
#     ExtUtils::Manifest       any     1.72 /usr/lib64/perl5/5.32               23471
#     Fatal                    any     2.32 /usr/lib64/perl5/5.32               59021
#     Module::Build            any   0.4224 /usr/lib64/perl5/vendor_perl/5.32   35680
#     Test::More              0.88 1.302175 /usr/lib64/perl5/5.32               52697
# 
# === Runtime Requires ===
# 
#     Module            Want   Have Where                              Howbig
#     ----------------- ---- ------ ---------------------------------- ------
#     Capture::Tiny      any   0.48 /usr/lib64/perl5/vendor_perl/5.32   29656
#     ExtUtils::ParseXS 3.35   3.40 /usr/lib64/perl5/5.32               66867
#     File::Basename     any   2.85 /usr/lib64/perl5/5.32               11194
#     File::Spec         any   3.78 /usr/lib64/perl5/5.32/x86_64-linux  10571
#     File::Temp         any 0.2309 /usr/lib64/perl5/vendor_perl/5.32  118255
# 
t/00-report-prereqs.t .. ok   
t/001_load.t ........... 1/? # EUMM:{
#   'CC' => 'g++',
#   'CCFLAGS' => ' -fwrapv -fno-strict-aliasing -pipe -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -xc++',
#   'dynamic_lib' => {
#     'OTHERLDFLAGS' => ' -lstdc++'
#   }
# }
# ---
# MB:{
#   'config' => {
#     'cc' => 'g++'
#   },
#   'extra_compiler_flags' => ' -xc++',
#   'extra_linker_flags' => ' -lstdc++'
# }
# ---
# Config:{
#   'byacc' => 'byacc',
#   'cc' => 'x86_64-pc-linux-gnu-gcc',
#   'cccdlflags' => '-fPIC',
#   'ccdlflags' => '-Wl,-E',
#   'ccflags' => '-fwrapv -fno-strict-aliasing -pipe -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64',
#   'ccflags_nolargefiles' => '-fwrapv -fno-strict-aliasing -pipe ',
#   'ccflags_uselargefiles' => '-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64',
#   'ccname' => 'gcc',
#   'ccstdflags' => ' -std=c89',
#   'ccsymbols' => '',
#   'ccversion' => '',
#   'ccwarnflags' => ' -Wall -Werror=pointer-arith -Wextra -Wc++-compat -Wwrite-strings -Werror=declaration-after-statement',
#   'cppccsymbols' => '',
#   'd_PRIEUldbl' => 'define',
#   'd_PRIFUldbl' => 'define',
#   'd_PRIGUldbl' => 'define',
#   'd_PRIeldbl' => 'define',
#   'd_PRIfldbl' => 'define',
#   'd_PRIgldbl' => 'define',
#   'd_SCNfldbl' => 'define',
#   'd_accept4' => 'define',
#   'd_access' => 'define',
#   'd_accessx' => undef,
#   'd_eaccess' => 'define',
#   'd_ldbl_dig' => 'define',
#   'd_ldexpl' => 'define',
#   'd_locconv' => 'define',
#   'd_old_pthread_create_joinable' => undef,
#   'd_oldpthreads' => undef,
#   'd_oldsock' => undef,
#   'd_pthread_yield' => undef,
#   'd_sched_yield' => 'define',
#   'd_setlocale_accepts_any_locale_name' => undef,
#   'd_strtold' => 'define',
#   'd_strtold_l' => 'define',
#   'd_telldir' => 'define',
#   'd_telldirproto' => 'define',
#   'gccansipedantic' => '',
#   'gccosandvers' => '',
#   'gccversion' => '10.1.0',
#   'i_sysaccess' => undef,
#   'ld' => 'x86_64-pc-linux-gnu-gcc',
#   'ld_can_script' => 'define',
#   'lddlflags' => '-shared -O2 -pipe -mtune=native -march=native -fstack-protector-strong -fno-stack-protector -Wl,-O1 -Wl,--as-needed -fstack-protector-strong -fno-stack-protector',
#   'ldflags' => '-Wl,-O1 -Wl,--as-needed -fstack-protector-strong -fno-stack-protector',
#   'ldflags_nolargefiles' => '-Wl,-O1 -Wl,--as-needed -fstack-protector-strong -fno-stack-protector',
#   'ldflags_uselargefiles' => '',
#   'ldlibpthname' => 'LD_LIBRARY_PATH',
#   'old_pthread_create_joinable' => '',
#   'sPRIEUldbl' => '"LE"',
#   'sPRIFUldbl' => '"LF"',
#   'sPRIGUldbl' => '"LG"',
#   'sPRIeldbl' => '"Le"',
#   'sPRIfldbl' => '"Lf"',
#   'sPRIgldbl' => '"Lg"',
#   'sSCNfldbl' => '"Lf"',
#   'sched_yield' => 'sched_yield()',
#   'yacc' => 'yacc',
#   'yaccflags' => ''
# }
# Method: is_sunstudio = 0
# Method: is_msvc = undef
# Method: is_gcc = 1
# Method: is_clang = 0
# Method: compiler_command = 'g++ -fwrapv -fno-strict-aliasing -pipe -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -xc++'
# Method: linker_flags = '-lstdc++'
Can't exec "g++": No such file or directory at /var/tmp/portage/dev-perl/ExtUtils-CppGuess-0.210.0/work/ExtUtils-CppGuess-0.21/blib/lib/ExtUtils/CppGuess.pm line 500.
# Method: iostream_fname = 'iostream.h'
# Method: cpp_flavor_defs = '
# //#define __INLINE_CPP_STANDARD_HEADERS 1
# //#define __INLINE_CPP_NAMESPACE_STD 1
# 
# '
t/001_load.t ........... ok   
t/002_icpp.t ........... ok   
t/010_module_build.t ... # Module::Build version: 0.4224
# ExtUtils::CBuilder version: 0.280234
t/010_module_build.t ... 1/? 
#   Failed test 'build with Module::Build'
#   at t/010_module_build.t line 19.
# Build.PL output
# ========================================
# Can't exec "g++": No such file or directory at ../../blib/lib/ExtUtils/CppGuess.pm line 500.
# Created MYMETA.yml and MYMETA.json
# Creating new 'Build' script for 'CppGuessTest' version '0.01'
# ========================================
# Build output
# ========================================
# Building CppGuessTest
# x86_64-pc-linux-gnu-gcc -I/usr/lib64/perl5/5.32/x86_64-linux/CORE -DVERSION="0.01" -DXS_VERSION="0.01" -fPIC -xc++ -DINCLUDE_DOT=1 -c -fwrapv -fno-strict-aliasing -pipe -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -O3 -pipe -frecord-gcc-switches -march=native -mtune=native -O2 -pipe -mtune=native -march=native -fstack-protector-strong -fno-stack-protector -o lib/CppGuessTest.o lib/CppGuessTest.c
# lib/CppGuessTest.xs:15:14: error: ‘string’ in namespace ‘std’ does not name a type
#    15 | typedef std::string std__string;
#       |              ^~~~~~
# lib/CppGuessTest.xs:11:1: note: ‘std::string’ is defined in header ‘<string>’; did you forget to ‘#include <string>’?
#    10 | #include <string.h>
#   +++ |+#include <string>
#    11 | #else
# lib/CppGuessTest.xs:84:6: error: ‘string’ in namespace ‘std’ does not name a type
#    84 | std::string useless_test( const std::string& a, const std::string& b )
#       |      ^~~~~~
# lib/CppGuessTest.xs:84:1: note: ‘std::string’ is defined in header ‘<string>’; did you forget to ‘#include <string>’?
#    84 | std::string useless_test( const std::string& a, const std::string& b )
#       | ^~~
# lib/CppGuessTest.c: In function ‘void XS_CppGuessTest_useless_test(CV*)’:
# lib/CppGuessTest.c:270:2: error: ‘std__string’ was not declared in this scope; did you mean ‘scan_vstring’?
#   270 |  std__string RETVAL;
#       |  ^~~~~~~~~~~
#       |  scan_vstring
# lib/CppGuessTest.c:271:13: error: expected ‘;’ before ‘a’
#   271 |  std__string    a = std::string( SvPV_nolen( ST(0) ), SvCUR( ST(0) ) )
#       |             ^   ~
#       |             ;
# lib/CppGuessTest.c:273:13: error: expected ‘;’ before ‘b’
#   273 |  std__string    b = std::string( SvPV_nolen( ST(1) ), SvCUR( ST(1) ) )
#       |             ^   ~
#       |             ;
# lib/CppGuessTest.c:276:2: error: ‘RETVAL’ was not declared in this scope; did you mean ‘GETVAL’?
#   276 |  RETVAL = useless_test(a, b);
#       |  ^~~~~~
#       |  GETVAL
# lib/CppGuessTest.c:276:24: error: ‘a’ was not declared in this scope; did you mean ‘ax’?
#   276 |  RETVAL = useless_test(a, b);
#       |                        ^
#       |                        ax
# lib/CppGuessTest.c:276:27: error: ‘b’ was not declared in this scope
#   276 |  RETVAL = useless_test(a, b);
#       |                           ^
# lib/CppGuessTest.c:276:11: error: ‘useless_test’ was not declared in this scope
#   276 |  RETVAL = useless_test(a, b);
#       |           ^~~~~~~~~~~~
# error building lib/CppGuessTest.o from 'lib/CppGuessTest.c' at /usr/lib64/perl5/5.32/ExtUtils/CBuilder/Base.pm line 185.
# ========================================
# Looks like you failed 1 test of 1.
t/010_module_build.t ... Dubious, test returned 1 (wstat 256, 0x100)
Failed 1/1 subtests 
t/011_makemaker.t ...... 1/? 
#   Failed test 'build with ExtUtils::MakeMaker'
#   at t/011_makemaker.t line 11.
# Makefile.PL output
# ========================================
# Can't exec "g++": No such file or directory at ../../blib/lib/ExtUtils/CppGuess.pm line 500.
# Checking if your kit is complete...
# Looks good
# Generating a Unix-style Makefile
# Writing Makefile for CppGuessTest
# Writing MYMETA.yml and MYMETA.json
# ========================================
# make output
# ========================================
# make[1]: warning: jobserver unavailable: using -j1.  Add '+' to parent make rule.
# make[1]: Entering directory '/var/tmp/portage/dev-perl/ExtUtils-CppGuess-0.210.0/work/ExtUtils-CppGuess-0.21/t/makemaker'
# cp lib/CppGuessTest.pm blib/lib/CppGuessTest.pm
# Running Mkbootstrap for CppGuessTest ()
# chmod 644 "CppGuessTest.bs"
# "/usr/bin/perl" -MExtUtils::Command::MM -e 'cp_nonempty' -- CppGuessTest.bs blib/arch/auto/CppGuessTest/CppGuessTest.bs 644
# "/usr/bin/perl" "/usr/lib64/perl5/5.32/ExtUtils/xsubpp"  -typemap '/usr/lib64/perl5/5.32/ExtUtils/typemap' -typemap '/var/tmp/portage/dev-perl/ExtUtils-CppGuess-0.210.0/work/ExtUtils-CppGuess-0.21/t/makemaker/typemap'  CppGuessTest.xs > CppGuessTest.xsc
# mv CppGuessTest.xsc CppGuessTest.c
# g++ -c   -fwrapv -fno-strict-aliasing -pipe -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -xc++ -DINCLUDE_DOT=1 -O2 -pipe -mtune=native -march=native -fstack-protector-strong -fno-stack-protector   -DVERSION=\"0.01\" -DXS_VERSION=\"0.01\" -fPIC "-I/usr/lib64/perl5/5.32/x86_64-linux/CORE"   CppGuessTest.c
# /bin/sh: g++: command not found
# make[1]: *** [Makefile:334: CppGuessTest.o] Error 127
# make[1]: Leaving directory '/var/tmp/portage/dev-perl/ExtUtils-CppGuess-0.210.0/work/ExtUtils-CppGuess-0.21/t/makemaker'
# ========================================
# Looks like you failed 1 test of 1.
t/011_makemaker.t ...... Dubious, test returned 1 (wstat 256, 0x100)
Failed 1/1 subtests 

Test Summary Report
-------------------
t/010_module_build.t (Wstat: 256 Tests: 1 Failed: 1)
  Failed test:  1
  Non-zero exit status: 1
t/011_makemaker.t    (Wstat: 256 Tests: 1 Failed: 1)
  Failed test:  1
  Non-zero exit status: 1
Files=5, Tests=14,  4 wallclock secs ( 0.05 usr  0.02 sys +  2.71 cusr  1.20 csys =  3.98 CPU)
Result: FAIL
Failed 2/5 test programs. 2/14 subtests failed.
make: *** [Makefile:869: test_dynamic] Error 1

^ everything here is full of wrong.

( I'm explicitly setting CXX to x86_64-pc-linux-gnu-g++ in ENV, which should be enough, but it clearly is not )

kentfredric commented 4 years ago

/me blames @mohawk2

kentfredric commented 4 years ago

These failures started occurring in 0.15, 0.14 is the newest version tests pass for me on.

dpryan79 commented 2 years ago

We're seeing the same issues in the conda build of this package. It would be great if the compiler name were made configurable. Xref: https://github.com/bioconda/bioconda-recipes/pull/33670

mohawk2 commented 2 years ago

@dpryan79 What kind of configuration had you in mind? It feels to me like an environment variable would work but doesn't seem like a general solution.

dpryan79 commented 2 years ago

@mohawk2 An environment variable (ideally $CC) would certainly work for me. In general, anything that needs a C compiler should be looking for that (or $CXX for C++ compilers).

mohawk2 commented 2 years ago

Since this is expressly for a C++ compiler, $CXX then?

dpryan79 commented 2 years ago

Yes! Mea culpa on the mention of $CC :)

mohawk2 commented 2 years ago

Ha ha, Ok! I think it would be prudent to also allow CXXFLAGS and CXXLDFLAGS to override the other two.

mohawk2 commented 2 years ago

Released as 0.24.

hroncok commented 2 years ago

FTR this new feature might have a regression, see https://github.com/tsee/extutils-cppguess/issues/26