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

Fix building with custom CXXFLAGS and LDFLAGS #15

Merged
merged 5 commits into from Jul 19, 2016

Conversation

@chradcliffe
Copy link
Contributor

@chradcliffe chradcliffe commented Jul 19, 2016

I tried to build rprotobuf with a protobuf library install that was in a custom location (so that I had to set CXXFLAGS and LDFLAGS), but I ran into an issue where the environment variables were picked up by the configure script, but at build time the paths were not set properly. I noticed two issues:

  • The CXXFLAGS variable is clobbered in the configure script late in the build process so that the value written to src/Makevars does not preserve the CXXFLAGS as set in the environment at configure time.
  • The LDFLAGS variable is omitted when setting PKG_LIB in configure.in, which means that LDFLAGS similarly doesn't propagate to src/Makevars

After fixing these issues, I was able to successfully build with a custom libprotobuf location.

Craig Radcliffe added 4 commits Jul 19, 2016
* The CXXFLAGS variable was previously clobbered by a call to `R CMD
  config CXXFLAGS`. This commit fixes the issue by assigning the output
  of the call to a temporary variable and appending this temporary
  variable to the original CXXFLAGS

* The LDFLAGS variable is now used when setting PKG_LIBS
Craig Radcliffe
@@ -4202,7 +4202,8 @@ fi
if test -z "${R_HOME}"; then
as_fn_error $? "Could not determine R_HOME." "$LINENO" 5
fi
CXXFLAGS=`"${R_HOME}/bin/R" CMD config CXXFLAGS`
R_CXXFLAGS=`"${R_HOME}/bin/R" CMD config CXXFLAGS`
CXXFLAGS="${CXXFLAGS} ${R_CXXFLAGS}"

This comment has been minimized.

@eddelbuettel

eddelbuettel Jul 19, 2016
Owner

That's a good catch.

(Comment belongs to configure.in, of course.)

configure Outdated
@@ -4263,7 +4264,7 @@ fi
## now use all these
PKG_CPPFLAGS="${PKG_CPPFLAGS} ${CXXFLAGS} $protobuf_cxxflags"

PKG_LIBS="${PKG_LIBS} $rcpp_ldflags $protobuf_libs"
PKG_LIBS="${PKG_LIBS} ${LDFLAGS} $rcpp_ldflags $protobuf_libs"

This comment has been minimized.

@eddelbuettel

eddelbuettel Jul 19, 2016
Owner

Doesn't that come in from R? May not do harm here, but might get added twice?

(Comment belongs to configure.in, of course.)

This comment has been minimized.

@chradcliffe

chradcliffe Jul 19, 2016
Author Contributor

You're right. I removed the LDFLAGS inclusion from my working copy and it looks as if src/Makevars is populated with the LDFLAGS variable correctly. I've pushed an update that removes the LDFLAGS so that there's no duplication.

@eddelbuettel
Copy link
Owner

@eddelbuettel eddelbuettel commented Jul 19, 2016

Thanks. Looks like a nicely minimal patch. All this is of course fallback mode because under normal circumstances pkg-config tells us all this ...

rcpp_ldflags already contains the environment's LDFLAGS so adding it
again to PKG_LIB isn't necessary.
@eddelbuettel eddelbuettel merged commit 77dd9d7 into eddelbuettel:master Jul 19, 2016
1 check passed
1 check passed
continuous-integration/travis-ci/pr The Travis CI build passed
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

2 participants
You can’t perform that action at this time.