Skip to content

Adds compiler warning message (closes #308) #515

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

Closed
wants to merge 7 commits into from
Closed

Adds compiler warning message (closes #308) #515

wants to merge 7 commits into from

Conversation

coatless
Copy link
Contributor

@coatless coatless commented Jul 23, 2016

Modifies /Rcpp/platform/compiler.h to trigger a pragma message
indicating if gcc <= 4.6.2 to satisfy #308

Part of #506

coatless added 2 commits July 22, 2016 18:55
Modifies /Rcpp/platform/compiler.h to trigger a pragma message
indicating if gcc <= 4.6.2
@eddelbuettel
Copy link
Member

We will get that #pragma shown for each compilation unit, correct? That may be a little noisy. Should we maybe just warn once on installation? I once went towards this route in #474.

@jjallaire What is the informal census on proportion of systems out there still running old RHEL/CentOS? How many of these are likely to be using Rcpp (maybe via tidyverse) ?

@coatless
Copy link
Contributor Author

coatless commented Jul 25, 2016

@eddelbuettel

I'm thinking that the only way to do this is going to be via configure.

Though, it may be a bit more appropriate to alert the user at the time of compilation that the compiler is problematic. What if the alert just has only one line?

#pragma message ("WARNING: GCC Compiler Version <= 4.6.2")

I say this because sometimes it is just the sysadmin or an inexperience user who might not catch the warning in the sea of compile messages if it is only on package install.

@eddelbuettel
Copy link
Member

eddelbuettel commented Jul 25, 2016

May be converging:

  • I also use configure here for RcppArmadillo
  • I was thinking earlier today that a one-liner may work better. It might still be bloody noisy though.

@coatless
Copy link
Contributor Author

coatless commented Jul 25, 2016

@eddelbuettel Bad url for the RcppArmadillo line.

I think you are referring to:

## If it is g++, we have GXX set so let's examine it
if test "${GXX}" = yes; then
    { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether g++ version is sufficient" >&5
$as_echo_n "checking whether g++ version is sufficient... " >&6; }
    gxx_version=$(${CXX} -v 2>&1 | awk '/^.*g.. version/ {print $3}')
    case ${gxx_version} in
        1.*|2.*|3.*|4.0.*|4.1.*|4.2.*|4.3.*|4.4.*|4.5.*)
             { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
         { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Only g++ version 4.6 or greater can be used with RcppArmadillo." >&5
$as_echo "$as_me: WARNING: Only g++ version 4.6 or greater can be used with RcppArmadillo." >&2;}
         as_fn_error $? "Please use a different compiler." "$LINENO" 5
        ;;
    4.6.*|4.7.*|4.8.*|4.9.*|5.*|6.*)
         gxx_newer_than_45="-fpermissive"
             { $as_echo "$as_me:${as_lineno-$LINENO}: result: (${gxx_version}) yes" >&5
$as_echo "(${gxx_version}) yes" >&6; }
    ;;
    esac
fi

https://github.com/RcppCore/RcppArmadillo/blob/master/configure#L2700-L2719

That is a heck of a lot of code that is powering the configure. I'm sure about 9/10ths of it isn't needed per https://cran.r-project.org/doc/manuals/R-exts.html#Configure-and-cleanup

@eddelbuettel
Copy link
Member

@coatless My bad. Updated the URL. Still had the region highlighted in another tab. In general we always look at configure.ac as the generated configure is mostly unreadable...

@coatless
Copy link
Contributor Author

@eddelbuettel

To confirm, the plan is to write a configure.ac file with GCC detection and include only one line of the pre-existing message:

#pragma message ("WARNING: GCC Compiler Version <= 4.6.2")

Sound about right? If so, I'll update this PR on Friday.

@eddelbuettel
Copy link
Member

Yes, let's refine. I see two things.

First: configure.ac

Which we already have, with refinements, in RQuantLib and RcppArmadillo:

## Set R_HOME, respecting an environment variable if one is set 
: ${R_HOME=$(R RHOME)}
if test -z "${R_HOME}"; then
    AC_MSG_ERROR([Could not determine R_HOME.])   
fi
## Use R to set CXX and CXXFLAGS
CXX=$(${R_HOME}/bin/R CMD config CXX)
CXXFLAGS=$("${R_HOME}/bin/R" CMD config CXXFLAGS)

## We are using C++
AC_LANG(C++)
AC_REQUIRE_CPP

## Check the C++ compiler using the CXX value set
AC_PROG_CXX
## If it is g++, we have GXX set so let's examine it
if test "${GXX}" = yes; then
    AC_MSG_CHECKING([whether g++ version is sufficient])
    gxx_version=$(${CXX} -v 2>&1 | awk '/^.*g.. version/ {print $3}')
    case ${gxx_version} in
        1.*|2.*|3.*|4.0.*|4.1.*|4.2.*|4.3.*|4.4.*|4.5.*)
             AC_MSG_RESULT([no])
         AC_MSG_WARN([Only g++ version 4.6 or greater can be used with RcppArmadillo.])
         AC_MSG_ERROR([Please use a different compiler.])   
        ;;
    4.6.*|4.7.*|4.8.*|4.9.*|5.*|6.*)
         gxx_newer_than_45="-fpermissive"
             AC_MSG_RESULT([(${gxx_version}) yes])
    ;;
    esac
fi

The ordering is somewhat important, ie need to set the PATH so that we get CXX we want (Kurt Hornik has been after me a few times on this). We now need to basically a variable YesItIsThisBad which will then used in 2. below.

Second the pragma

I was hesitating a little earlier and waiting for a hint from @jjallaire about what the 'census proportion' of really old machines is. He knows because the woes with making RStudio work there etc pp. Hitting them with the pragma on each compilation unit is a little loud.

But I am starting to come around that it may be the right thing. We all will not see it as we use reasonable compilers. And those who see it ... really ought to upgrade or stick with older code.

So PR away (provided JJ does not convince us to be more quiet). Looking forward to it.

@thirdwing
Copy link
Member

On a CentOS 6.8 VM:

> g++ --version
g++ (GCC) 4.4.7 20120313 (Red Hat 4.4.7-17)
Copyright (C) 2010 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.
> sessionInfo()
R version 3.3.1 (2016-06-21)
Platform: x86_64-redhat-linux-gnu (64-bit)
Running under: CentOS release 6.8 (Final)

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C              
 [3] LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8    
 [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8   
 [7] LC_PAPER=en_US.UTF-8       LC_NAME=C                 
 [9] LC_ADDRESS=C               LC_TELEPHONE=C            
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     
> R CMD INSTALL Rcpp/
* installing to library ‘/usr/lib64/R/library’
* installing *source* package ‘Rcpp’ ...
** libs
g++ -m64 -I/usr/include/R -DNDEBUG -I../inst/include/ -I/usr/local/include    -fpic  -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic  -c Date.cpp -o Date.o
In file included from ../inst/include/Rcpp/r/headers.h:48,
                 from ../inst/include/RcppCommon.h:29,
                 from ../inst/include/Rcpp.h:27,
                 from Date.cpp:31:
../inst/include/Rcpp/platform/compiler.h:60: note: #pragma message: WARNING: GCC Compiler Version <= 4.6.2
../inst/include/Rcpp/platform/compiler.h:61: note: #pragma message: WARNING: The compiler being used is both OUTDATED and INCOMPLETE in terms of C++ standards;
../inst/include/Rcpp/platform/compiler.h:62: note: #pragma message: WARNING: if something does not work, you should upgrade your compiler!
g++ -m64 -I/usr/include/R -DNDEBUG -I../inst/include/ -I/usr/local/include    -fpic  -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic  -c Module.cpp -o Module.o
In file included from ../inst/include/Rcpp/r/headers.h:48,
                 from ../inst/include/RcppCommon.h:29,
                 from ../inst/include/Rcpp.h:27,
                 from Module.cpp:24:
../inst/include/Rcpp/platform/compiler.h:60: note: #pragma message: WARNING: GCC Compiler Version <= 4.6.2
../inst/include/Rcpp/platform/compiler.h:61: note: #pragma message: WARNING: The compiler being used is both OUTDATED and INCOMPLETE in terms of C++ standards;
../inst/include/Rcpp/platform/compiler.h:62: note: #pragma message: WARNING: if something does not work, you should upgrade your compiler!
g++ -m64 -I/usr/include/R -DNDEBUG -I../inst/include/ -I/usr/local/include    -fpic  -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic  -c Rcpp_init.cpp -o Rcpp_init.o
In file included from ../inst/include/Rcpp/r/headers.h:48,
                 from ../inst/include/RcppCommon.h:29,
                 from ../inst/include/Rcpp.h:27,
                 from Rcpp_init.cpp:24:
../inst/include/Rcpp/platform/compiler.h:60: note: #pragma message: WARNING: GCC Compiler Version <= 4.6.2
../inst/include/Rcpp/platform/compiler.h:61: note: #pragma message: WARNING: The compiler being used is both OUTDATED and INCOMPLETE in terms of C++ standards;
../inst/include/Rcpp/platform/compiler.h:62: note: #pragma message: WARNING: if something does not work, you should upgrade your compiler!
g++ -m64 -I/usr/include/R -DNDEBUG -I../inst/include/ -I/usr/local/include    -fpic  -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic  -c api.cpp -o api.o
In file included from ../inst/include/Rcpp/r/headers.h:48,
                 from ../inst/include/RcppCommon.h:29,
                 from ../inst/include/Rcpp.h:27,
                 from api.cpp:25:
../inst/include/Rcpp/platform/compiler.h:60: note: #pragma message: WARNING: GCC Compiler Version <= 4.6.2
../inst/include/Rcpp/platform/compiler.h:61: note: #pragma message: WARNING: The compiler being used is both OUTDATED and INCOMPLETE in terms of C++ standards;
../inst/include/Rcpp/platform/compiler.h:62: note: #pragma message: WARNING: if something does not work, you should upgrade your compiler!
g++ -m64 -I/usr/include/R -DNDEBUG -I../inst/include/ -I/usr/local/include    -fpic  -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic  -c attributes.cpp -o attributes.o
In file included from ../inst/include/Rcpp/r/headers.h:48,
                 from ../inst/include/RcppCommon.h:29,
                 from ../inst/include/Rcpp.h:27,
                 from attributes.cpp:39:
../inst/include/Rcpp/platform/compiler.h:60: note: #pragma message: WARNING: GCC Compiler Version <= 4.6.2
../inst/include/Rcpp/platform/compiler.h:61: note: #pragma message: WARNING: The compiler being used is both OUTDATED and INCOMPLETE in terms of C++ standards;
../inst/include/Rcpp/platform/compiler.h:62: note: #pragma message: WARNING: if something does not work, you should upgrade your compiler!
g++ -m64 -I/usr/include/R -DNDEBUG -I../inst/include/ -I/usr/local/include    -fpic  -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic  -c barrier.cpp -o barrier.o
g++ -m64 -shared -L/usr/lib64/R/lib -o Rcpp.so Date.o Module.o Rcpp_init.o api.o attributes.o barrier.o -L/usr/lib64/R/lib -lR
installing to /usr/lib64/R/library/Rcpp/libs

@thirdwing
Copy link
Member

Maybe we can guess what people are using according to release dates (https://access.redhat.com/articles/3078).

Default compilers on different version are list below:

RHEL7 : gcc 4.8.x
RHEL6 : gcc 4.4.x
RHEL5 : gcc 4.1.x
RHEL4 : gcc 3.4.x
RHEL3 : gcc 3.2.x

@eddelbuettel
Copy link
Member

Good list. We should essentially just tell anybody who is on RHEL 6 or older to bag it and go home. Sadly, we can't quite ...

@coatless
Copy link
Contributor Author

coatless commented Jul 30, 2016

Okay, per a little bit of discovery...

clang++ identifies itself as GCC by providing the #define __GNUC__ even though it is only GCC compatible.

Discussion of the behavior of $GXX being set for clang, intel, et cetera compilers is here: https://lists.gnu.org/archive/html/autoconf/2014-09/msg00022.html

"$GCC to say that it should not be taken literally, but just to
mean some kind of gcc compatibility."

In: https://lists.gnu.org/archive/html/autoconf/2014-09/msg00027.html

As a result, the fake define throws off the compiler specific detects in platform/compiler.h and the configure scripts.

To view this in practice, note that within the RcppArmadillo script the yes/no does not trigger on the "g++ version is sufficient" check and, therefore, the line is not ended. So, there needs to be a default case that checks if gxx_version is empty (the case when compiled against clang++ or clang-omp++.

checking whether g++ version is sufficient... checking LAPACK_LIBS... fallback LAPACK from R 3.3.0 or later used
configure: creating ./config.status
config.status: creating inst/include/RcppArmadilloLapack.h

One way to solve this is to mimic llvm's configure.ac, which uses a test against the $CXX variable via:

AC_PROG_CC(clang llvm-gcc gcc)
AC_PROG_CXX(clang++ llvm-g++ g++)
AC_PROG_CPP
dnl If CXX is Clang, check that it can find and parse C++ standard library
dnl headers.
if test "$CXX" = "clang++" ; then

To avoid this problem cropping up in the compiler.h, I'm proposing a slightly more radical solution that tries to detect a "genuine" gcc compiler. The approach being proposed is based in armadillo's configuration:

#if (defined(__GNUG__) || defined(__GNUC__)) && (defined(__clang__) || defined(__INTEL_COMPILER) || defined(__NVCC__) || defined(__CUDACC__) || defined(__PGI) || defined(__PATHSCALE__) || defined(__ARMCC_VERSION) || defined(__IBMCPP__))
  #undef  RCPP_FAKE_GCC
  #define RCPP_FAKE_GCC
#endif

Also, to ease worries about noise, I've added in aRCPP_GCC_COMPILER_WARNING_SILENT option to quiet compiles on platforms with <= GCC 4.6.2

coatless added 3 commits July 30, 2016 20:54
…t down to a single `if` statement that triggers error if improperly defined.

Added a better trigger for poor GCC version support (tries to detect a fake GCC flag and accommodate it).
…lower than a given threshold.

Note: The GCC check is misleading as it will pick up other compilers that "show" GCC defines. Thus, `clang` was picked up causing the absence of a `gcc` version.
#pragma message ("WARNING: if something does not work, you should upgrade your compiler!")
#if GCC_VERSION <= 40602 && !defined(RCPP_GCC_COMPILER_WARNING_SILENT)
// Ensure not fake GCC flag set by clang or intel.
#if !(defined(__clang__) || defined(__INTEL_COMPILER))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess these do not hurt. I would have hope the earlier #ifdef __GNUC__ would be enough. Maybe not.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The reason why I added in the detect genuine GCC is due to the warning being triggered on macOS due to GCC headers being identified as 4.2.1

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we saying that anyone running RHEL 6 is going to see this warning when
compiling Rcpp? That I think is far too aggressive as this describes the
vast majority of Linux systems deployed in larger organizations. Worse yet
is that the end users who see this message during compilation have no way
to update the compiler (that's handled by the sysadmin on a multi-user
system, and compiler upgrades are considered extremely heavyweight/risky so
are basically not done).

On Sat, Jul 30, 2016 at 10:13 PM, James J Balamuta <notifications@github.com

wrote:

In inst/include/Rcpp/platform/compiler.h
#515 (comment):

@@ -57,10 +44,11 @@
#define IS_GCC_460_OR_LATER
#endif
// Inform users of dated compiler (e.g. <= RHEL6 )

  • #if GCC_VERSION <= 40602
  •    #pragma message ("WARNING: GCC Compiler Version <= 4.6.2")
    
  •    #pragma message ("WARNING: The compiler being used is both OUTDATED and INCOMPLETE in terms of C++ standards;")
    
  •    #pragma message ("WARNING: if something does not work, you should upgrade your compiler!")
    
  • #if GCC_VERSION <= 40602 && !defined(RCPP_GCC_COMPILER_WARNING_SILENT)
  •     // Ensure not fake GCC flag set by clang or intel.
    
  •     #if !(defined(**clang**) || defined(__INTEL_COMPILER))
    

The reason why I added in the detect genuine GCC is due to the warning
being triggered on macOS due to GCC headers being identified as 4.2.1


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/RcppCore/Rcpp/pull/515/files/c5f7b40770c14f8efb12f2f5e77e7aa5d17e0d0d..6b292afd4f11c5f9f95abd830f5cb383a194c3de#r72896929,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AAGXx8hmEGS19KROXcv6n0iq4lmyLblbks5qbASvgaJpZM4JTRmr
.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes that is the current discussion but I held off on merging as I wanted to hear from you.

@eddelbuettel
Copy link
Member

This now has too. See discussion in #528. Can merge manually if you want me to.

…message

Fixes merge conflicts in:

- ChangeLog
- inst/NEWS.Rd
@eddelbuettel
Copy link
Member

Let me call out to @jjallaire one last time ... JJ: any view as to with all the RHEL systems out there we are too aggressive? A one-liner message seems fair, particularly with a #define toggle to suppress it.

@@ -56,6 +43,13 @@
#if GCC_VERSION >= 40600
#define IS_GCC_460_OR_LATER
#endif
// Inform users of dated compiler (e.g. <= RHEL6 )
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Per my other comment, I don't think we can do this. We have 700+ packages on CRAN all of whom will be subjected to this warning (and all of whom will have to field enquiries about the warning from users and sysadmins worried about it's implications). If we believe that GCC <= 4.6.2 truly warrants a warning message then we need to change our code so it doesn't.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(I should add that RcppArmadillo now actually fails when this happens, but then again Conrad left me no choice. It has 246 rev.deps and mayhem may well ensue ...)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, your hand was forced there.

I should note that I am not at all happy about the state of affairs with
RHEL 6 and we are looking at creating a new binary distribution of R for
RHEL 6 that uses clang. Until then though I don't think we can cry wolf
when being compiled on RHEL 6, it's just too mainstream a platform.

On Tue, Aug 2, 2016 at 4:50 PM, Dirk Eddelbuettel notifications@github.com
wrote:

In inst/include/Rcpp/platform/compiler.h
#515 (comment):

@@ -56,6 +43,13 @@
#if GCC_VERSION >= 40600
#define IS_GCC_460_OR_LATER
#endif

  • // Inform users of dated compiler (e.g. <= RHEL6 )

(I should add that RcppArmadillo now actually fails when this happens, but
then again Conrad left me no choice. It has 246 rev.deps and mayhem may
well ensue ...)


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/RcppCore/Rcpp/pull/515/files/4bc57824b83491162a38e18fc3ca68d5e5ec3c41#r73234667,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AAGXx3FxbIiLaRmRSUxXk1fKSR09SYkFks5qb62agaJpZM4JTRmr
.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Throw it out the window... The window... We'll throw it out the window... Err, I'm removing it.

Do we still want to proceed in throwing a warning via: configure.ac? @eddelbuettel @jjallaire

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we could, and should -- but if @jjallaire vetos it I will not object.

@jjallaire
Copy link
Member

I don't think we should throw a warning of any kind right now because we are in fact fully compatible with GCC 4.6 (and if we aren't compatible we should be). Again, I would like us to get beyond this by having a RHEL 6 compatible R distribution with a more modern compiler but we aren't there yet.

@coatless
Copy link
Contributor Author

coatless commented Aug 3, 2016

Thanks @jjallaire !

@eddelbuettel verdict decreed. Please close out issue #308.

@coatless coatless closed this Aug 3, 2016
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

Successfully merging this pull request may close these issues.

4 participants