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

CPPFLAGS vs CXXFLAGS #1

Closed
jeroen opened this issue Dec 12, 2016 · 4 comments
Closed

CPPFLAGS vs CXXFLAGS #1

jeroen opened this issue Dec 12, 2016 · 4 comments
Assignees

Comments

@jeroen
Copy link
Contributor

jeroen commented Dec 12, 2016

From your Makevars files it seems you are confusing CPPFLAGS with CXXFLAGS / CXX1XFLAGS.

  • CPPFLAGS: C/C++ preprocessor flags. These are applied both to c and c++ preprocessor. Usually this only includes flags that start with -D and -I.
  • CFLAGS / CXXFLAGS / CXX1XFLAGS: Compiler flags for the c/c++/c++11 compiler that are not in the preprocessor. Things like -g -o -pthread. You should rarely set these as R automatically uses the appropriate defaults.

As a package author you do not have to manually pass any CXXFLAGS or CXX1X flags in your Makevars. R does that automatically: c++ code is always compiled with CXXFLAGS (or CXX1XFLAGS when CXX_STD = CXX11)

Hence the configure script should only set the CPPFLAGS which are system dependent based on how libssl was compiled and where it resides on the user system.

@rubak
Copy link
Contributor

rubak commented Dec 13, 2016

Thanks for pointing this out. I will try to clean up CPPFLAGS so it doesn't include stuff like -pthread etc.

@rubak rubak self-assigned this Dec 13, 2016
@rubak
Copy link
Contributor

rubak commented Dec 13, 2016

I have looked a bit more into this and I think I can clean things a bit. However, the pthreads section of Writing R Extensions states that one should use

PKG_CPPFLAGS = -pthread
PKG_LIBS = -pthread

Reading on the web it seems your comment about this belonging to CFLAGS/CXXFLAGS is more appropriate. Do you think I should notify somebody on r-devel so they can update that section?

@jeroen
Copy link
Contributor Author

jeroen commented Dec 13, 2016

Hmm if it written in WRE than I stand corrected. But the other flags -g -o definitely don't belong in the preprocessor.

@rubak
Copy link
Contributor

rubak commented Dec 16, 2016

OK. You are definitely right about the -g -o flags. However, as I tried to say before, I also think you in principle are right about the -pthread flag belonging to the compiler and not in the preprocessor as WRE states, but I don't know if it is worth the trouble to point this out to R core if things work fine the way they do it now (if it ain't broke -- don't fix it)?

In the gcc man page it sounds like -pthread is a compiler flag that automatically set flags for both the preprocessor and the linker:

-pthread
Adds support for multithreading with the pthreads library. This option sets flags for both the preprocessor and linker.

And according to this SO answer clang will only accept the flag when compiling and not when linking.

@rubak rubak closed this as completed Dec 21, 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

No branches or pull requests

2 participants