Skip to content

first crack at checking compiler versions from R #474

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

Merged
merged 1 commit into from
May 14, 2016

Conversation

eddelbuettel
Copy link
Member

currently limited to g++

works reasonably well -- log from my Ubuntu 15.10 box below

edd@max:~$ g++ --version | head -1                                  # default
g++ (Ubuntu 5.2.1-22ubuntu2) 5.2.1 20151010
edd@max:~$ Rscript -e 'Rcpp:::compilerCheck("5.2.1")' 
[1] TRUE
edd@max:~$ Rscript -e 'Rcpp:::compilerCheck("4.6.0")' 
[1] TRUE
edd@max:~$ Rscript -e 'Rcpp:::compilerCheck("5.3.1")'               # what 16.04 has
[1] FALSE
edd@max:~$ CXX=g++-4.5 Rscript -e 'Rcpp:::compilerCheck("4.6.0")'   # old version
[1] FALSE
edd@max:~$ 

@JanMarvin
Copy link

int gccver(){
  return(  __GNUC__ * 10000 +  \
    __GNUC_MINOR__ * 100     +  \
    __GNUC_PATCHLEVEL__);
}

Isn't this what you want?

@eddelbuettel
Copy link
Member Author

@JanMarvin: Thanks. In fact, @dcdillon made a similar point ("just compile g++ -std=c+11 hello.cpp"). But I wanted something a little simpler and quicker.

We do actually have some tests in Rcpp already:

  • inst/include/Rcpp/platform/compiler.h tests for a variety of features needed around/before TR1
  • inst/discovery/cxx0x.R is an old (and outdated) check for minimal standards version

so I don't think the last word has been said. Right now it is more about helping users right at the start of a build process, ie in configure. We had a number of unfortunate error reports when folks on older RHEL/CentOS attempted to build RcppArmadillo, and of course flamed out fabulously as g++-4.4 doesn't even buy you half a cup of joe anymore.

@eddelbuettel
Copy link
Member Author

I'm going to merge this in, it is unlikely to cause harm as it isn't even exported yet.

@eddelbuettel eddelbuettel merged commit 7a1dfa3 into master May 14, 2016
@eddelbuettel eddelbuettel deleted the feature/minimal-compiler branch May 14, 2016 13:44
@jjallaire
Copy link
Member

It would be cool to have a variation of this which could be called from Makevars and which throws an error when the minimum compiler version isn't met. The error would have a nice clear message indicating that the issue is the compiler version.

@eddelbuettel
Copy link
Member Author

eddelbuettel commented May 14, 2016

Certainly. The bigger question really is whether we want

  • full-blown compiler-based tests which actually test particular compiler features (a la platform/compiler.h in the sources)
  • something lightweight to throw decent error messages either via Makevars (but then everybody has to modify Makevars again)
  • or just build on this and call via Rscript from a shell script configure which people copy as is into their projects (if they currently do not use configure).

Making the error message nicer/more informative is easy. I was just happy when I realized that I could test g++ as well as the common environment variables from R and use R to compare versions strings correctly. What we have here is a start, and possibly 'good enough' to replace what I just did in RcppArmadillo.

@jjallaire
Copy link
Member

I think that #2 (have folks add a line to Makevars) strikes the best
balance, especially since everyone already has a Makevars and this is
pretty much a boilderplate one-liner.

On Sat, May 14, 2016 at 12:27 PM, Dirk Eddelbuettel <
notifications@github.com> wrote:

Certainly. The bigger question really is whether we want

  • full-blown compiler-based tests which actually test particular
    compiler features (a la platform/compiler.h in the sources)
  • something lightweight to throw decent error messages either via
    Makevars (but then everybody has to modify Makevars again)
  • or just build on this and call via Rscript from a shell script
    configure which people call?

Making the error message nicer/more informative is easy. I was just happy
when I realized that I could test g++ as well as the common environment
variables from R and use R to compare versions strings correctly. What
we have here is a start, and possibly 'good enough' to replace what I just
did in RcppArmadillo.


You are receiving this because you commented.
Reply to this email directly or view it on GitHub
#474 (comment)

@eddelbuettel
Copy link
Member Author

How do you suggest to hook it in? It is not just an expansion as PKG_CXXFLAGS ?

Or expand to something which gets called and remains silent on success but emits loud and clear error messages on failure?

@jjallaire
Copy link
Member

Yeah, I'd say silent on success and loud and clear error messages on
failure.

On Sat, May 14, 2016 at 12:33 PM, Dirk Eddelbuettel <
notifications@github.com> wrote:

How do you suggest to hook it in? It is not just an expansion as
PKG_CXXFLAGS ?

Or expand to something which gets called and remains silent on success but
emits loud and clear error messages on failure?


You are receiving this because you commented.
Reply to this email directly or view it on GitHub
#474 (comment)

@eddelbuettel
Copy link
Member Author

I thought about that while going for a run and I am not so sure we can 'break' cleanly there. It is R calling make calling our (Rscript-based ?) snippet. I still think configure is cleaner. To be seen...

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.

3 participants