RcppCore / RcppArmadillo

Rcpp integration for the Armadillo templated linear algebra library
192 stars 56 forks source link

compilation on fedora39 raise error: cannot run C++ compiled programs #428

Closed jangorecki closed 9 months ago

jangorecki commented 10 months ago

Tried CRAN and master, both got error, using R 4.3.2:

install.packages("RcppArmadillo_0.12.6.6.0.tar.gz", repos=NULL)
Installing package into ‘/home/jan/R/x86_64-redhat-linux-gnu-library/4.3’
(as ‘lib’ is unspecified)
* installing *source* package ‘RcppArmadillo’ ...
** using staged installation
checking whether the C++ compiler works... yes
checking for C++ compiler default output file name... a.out
checking for suffix of executables... 
checking whether we are cross compiling... configure: error: in `/tmp/RtmpH1tiIN/R.INSTALL52ce3d4c4d4a/RcppArmadillo':
configure: error: cannot run C++ compiled programs.
If you meant to cross compile, use `--host'.
See `config.log' for more details
ERROR: configuration failed for package ‘RcppArmadillo’
* removing ‘/home/jan/R/x86_64-redhat-linux-gnu-library/4.3/RcppArmadillo’
Warning message:
In install.packages("RcppArmadillo_0.12.6.6.0.tar.gz", repos = NULL) :
  installation of package ‘RcppArmadillo_0.12.6.6.0.tar.gz’ had non-zero exit status

Tried from console and from inside R. In both cases /tmp/R... is not existing anymore.

config.log file

This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.

It was created by RcppArmadillo configure 0.12.6.6.0, which was
generated by GNU Autoconf 2.71.  Invocation command line was

  $ ./configure

## --------- ##
## Platform. ##
## --------- ##

hostname = fedora
uname -m = x86_64
uname -r = 6.5.11-300.fc39.x86_64
uname -s = Linux
uname -v = #1 SMP PREEMPT_DYNAMIC Wed Nov  8 22:37:57 UTC 2023

/usr/bin/uname -p = unknown
/bin/uname -X     = unknown

/bin/arch              = x86_64
/usr/bin/arch -k       = unknown
/usr/convex/getsysinfo = unknown
/usr/bin/hostinfo      = unknown
/bin/machine           = unknown
/usr/bin/oslevel       = unknown
/bin/universe          = unknown

PATH: /home/jan/.cargo/bin/
PATH: /home/jan/.local/bin/
PATH: /home/jan/bin/
PATH: /usr/local/bin/
PATH: /usr/local/sbin/
PATH: /usr/bin/
PATH: /usr/sbin/

## ----------- ##
## Core tests. ##
## ----------- ##

configure:2191: checking for C++ compiler version
configure:2200: g++ -std=gnu++17 --version >&5
g++ (GCC) 13.2.1 20231011 (Red Hat 13.2.1-4)
Copyright (C) 2023 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

configure:2211: $? = 0
configure:2200: g++ -std=gnu++17 -v >&5
Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-redhat-linux/13/lto-wrapper
OFFLOAD_TARGET_NAMES=nvptx-none
OFFLOAD_TARGET_DEFAULT=1
Target: x86_64-redhat-linux
Configured with: ../configure --enable-bootstrap --enable-languages=c,c++,fortran,objc,obj-c++,ada,go,d,m2,lto --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-shared --enable-threads=posix --enable-checking=release --enable-multilib --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object --enable-linker-build-id --with-gcc-major-version-only --enable-libstdcxx-backtrace --with-libstdcxx-zoneinfo=/usr/share/zoneinfo --with-linker-hash-style=gnu --enable-plugin --enable-initfini-array --with-isl=/builddir/build/BUILD/gcc-13.2.1-20231011/obj-x86_64-redhat-linux/isl-install --enable-offload-targets=nvptx-none --without-cuda-driver --enable-offload-defaulted --enable-gnu-indirect-function --enable-cet --with-tune=generic --with-arch_32=i686 --build=x86_64-redhat-linux --with-build-config=bootstrap-lto --enable-link-serialization=1
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 13.2.1 20231011 (Red Hat 13.2.1-4) (GCC) 
... rest of stderr output deleted ...
configure:2211: $? = 0
configure:2200: g++ -std=gnu++17 -V >&5
g++: error: unrecognized command-line option '-V'
g++: fatal error: no input files
compilation terminated.
configure:2211: $? = 1
configure:2200: g++ -std=gnu++17 -qversion >&5
g++: error: unrecognized command-line option '-qversion'; did you mean '--version'?
g++: fatal error: no input files
compilation terminated.
configure:2211: $? = 1
configure:2231: checking whether the C++ compiler works
configure:2253: g++ -std=gnu++17 -O3 -mtune=native -I/usr/local/include -Wl,-z,relro -Wl,--as-needed -Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -Wl,--build-id=sha1 conftest.cpp  >&5
configure:2257: $? = 0
configure:2307: result: yes
configure:2310: checking for C++ compiler default output file name
configure:2312: result: a.out
configure:2318: checking for suffix of executables
configure:2325: g++ -std=gnu++17 -o conftest -O3 -mtune=native -I/usr/local/include -Wl,-z,relro -Wl,--as-needed -Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -Wl,--build-id=sha1 conftest.cpp  >&5
configure:2329: $? = 0
configure:2352: result: 
configure:2374: checking whether we are cross compiling
configure:2382: g++ -std=gnu++17 -o conftest -O3 -mtune=native -I/usr/local/include -Wl,-z,relro -Wl,--as-needed -Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -Wl,--build-id=sha1 conftest.cpp  >&5
/usr/bin/ld: /tmp/ccbkaq7a.o: relocation R_X86_64_32 against `.rodata.str1.1' can not be used when making a PIE object; recompile with -fPIE
/usr/bin/ld: failed to set dynamic section sizes: bad value
collect2: error: ld returned 1 exit status
configure:2386: $? = 1
configure:2393: ./conftest
./configure: line 2395: ./conftest: No such file or directory
configure:2397: $? = 127
configure:2404: error: in `/home/jan/git/RcppArmadillo.Rcheck/00_pkg_src/RcppArmadillo':
configure:2406: error: cannot run C++ compiled programs.
If you meant to cross compile, use `--host'.
See `config.log' for more details

## ---------------- ##
## Cache variables. ##
## ---------------- ##

ac_cv_env_CCC_set=
ac_cv_env_CCC_value=
ac_cv_env_CPPFLAGS_set=set
ac_cv_env_CPPFLAGS_value=-I/usr/local/include
ac_cv_env_CXXCPP_set=
ac_cv_env_CXXCPP_value=
ac_cv_env_CXXFLAGS_set=set
ac_cv_env_CXXFLAGS_value='-O3 -mtune=native'
ac_cv_env_CXX_set=set
ac_cv_env_CXX_value='g++ -std=gnu++17'
ac_cv_env_LDFLAGS_set=set
ac_cv_env_LDFLAGS_value='-Wl,-z,relro -Wl,--as-needed -Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -Wl,--build-id=sha1'
ac_cv_env_LIBS_set=
ac_cv_env_LIBS_value=
ac_cv_env_build_alias_set=
ac_cv_env_build_alias_value=
ac_cv_env_host_alias_set=
ac_cv_env_host_alias_value=
ac_cv_env_target_alias_set=
ac_cv_env_target_alias_value=

## ----------------- ##
## Output variables. ##
## ----------------- ##

ARMA_HAVE_OPENMP=''
ARMA_LAPACK=''
CPPFLAGS='-I/usr/local/include'
CXX='g++ -std=gnu++17'
CXXCPP=''
CXXFLAGS='-O3 -mtune=native'
DEFS=''
ECHO_C=''
ECHO_N='-n'
ECHO_T=''
EXEEXT=''
LDFLAGS='-Wl,-z,relro -Wl,--as-needed -Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -Wl,--build-id=sha1'
LIBOBJS=''
LIBS=''
LTLIBOBJS=''
OBJEXT=''
OPENMP_FLAG=''
PACKAGE_BUGREPORT='edd@debian.org'
PACKAGE_NAME='RcppArmadillo'
PACKAGE_STRING='RcppArmadillo 0.12.6.6.0'
PACKAGE_TARNAME='rcpparmadillo'
PACKAGE_URL=''
PACKAGE_VERSION='0.12.6.6.0'
PATH_SEPARATOR=':'
SHELL='/bin/sh'
ac_ct_CXX=''
bindir='${exec_prefix}/bin'
build_alias=''
datadir='${datarootdir}'
datarootdir='${prefix}/share'
docdir='${datarootdir}/doc/${PACKAGE_TARNAME}'
dvidir='${docdir}'
exec_prefix='NONE'
host_alias=''
htmldir='${docdir}'
includedir='${prefix}/include'
infodir='${datarootdir}/info'
libdir='${exec_prefix}/lib'
libexecdir='${exec_prefix}/libexec'
localedir='${datarootdir}/locale'
localstatedir='${prefix}/var'
mandir='${datarootdir}/man'
oldincludedir='/usr/include'
pdfdir='${docdir}'
prefix='NONE'
program_transform_name='s,x,x,'
psdir='${docdir}'
runstatedir='${localstatedir}/run'
sbindir='${exec_prefix}/sbin'
sharedstatedir='${prefix}/com'
sysconfdir='${prefix}/etc'
target_alias=''

## ----------- ##
## confdefs.h. ##
## ----------- ##

/* confdefs.h */
#define PACKAGE_NAME "RcppArmadillo"
#define PACKAGE_TARNAME "rcpparmadillo"
#define PACKAGE_VERSION "0.12.6.6.0"
#define PACKAGE_STRING "RcppArmadillo 0.12.6.6.0"
#define PACKAGE_BUGREPORT "edd@debian.org"
#define PACKAGE_URL ""

configure: exit 77

Double checked against cannot run C++ compiled programs that I can compile and run cpp hello world.

Not able to reproduce via docker fedora:39 (which most likely is no a "workstation" version).

eddelbuettel commented 9 months ago

I have some difficulty reading and understanding this and may need more context. The

checking whether we are cross compiling... configure: error: in `/tmp/RtmpH1tiIN/R.INSTALL52ce3d4c4d4a/RcppArmadillo':
configure: error: cannot run C++ compiled programs.
If you meant to cross compile, use `--host'.
See `config.log' for more details
ERROR: configuration failed for package ‘RcppArmadillo’
* removing ‘/home/jan/R/x86_64-redhat-linux-gnu-library/4.3/RcppArmadillo’

is very suspicious. Why would it a) test for cross compilation and b) fail? You are on a standard Linux system?

If so, please try the git repo, re-run autoconf and see if a newer configure is better. This is solid 30+ year old technology that is used all over the place so I think something else may be going on. Note that BDR is also very forwaard looking in his use of GNU tools and Fedora itself and would have said something but I am still looking at sunnt skies at CRAN:

image

jangorecki commented 9 months ago

Thanks, will try. Yes it is standard Linux. Comparing to CRAN machines, I am on 39, CRAN is on 36. And most likely CRAN runs fedora server (or some other non-workstation flavor). And docker fedora:39 was working fine, so either related to my environment or fedora:39 workstation strictly.

I found same error for another pkg: https://github.com/astamm/nloptr/issues/45

eddelbuettel commented 9 months ago

Jan, don't get me wrong but I really think there is a 99.9% chance this is you. We are doing nothing special here.

Unless the gcc people lost their mind and --host is now required but then R would be borked, not RcppArmadillo. We really just call R CMD ... and friends.

(I had one very recent case of needing --host ... but that was in an actual cross-compiling situation where @jeroen was doing his webr/wasm magic. For you with Linux-on-Linux this has a strong smell of 'your binary tools are hosed or confused'. But by all means let us try to sort this out. I am also the author of the nloptr configure snippet so maybe I am behind the eightball and newer autoconf needs a new variable I need to set?)

jangorecki commented 9 months ago

OK, I have found the root cause. Makevars

CFLAGS=-O3 -mtune=native
CXXFLAGS=-O3 -mtune=native

Commenting that out makes compilation succeed.

Closing issue then. At least if someone will get same error they will be able to find solution here.

eddelbuettel commented 9 months ago

Yeppers. Been there done that myself and now try to keep Makevars simpler (though still use and love ccache). So no worries. Glad it is all good now!

(Any idea though why R and gcc/g++ no longer like -mtune=native ?)

jangorecki commented 9 months ago

Nope