This is an automated email from the ASF dual-hosted git repository.

kou pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/arrow.git


The following commit(s) were added to refs/heads/master by this push:
     new 26666df  ARROW-6237: [R] Allow compilation flags to be passed for R 
package with ARROW_R_CXXFLAGS
26666df is described below

commit 26666df5b23a25a0f839c24c78874f9ae3df2f29
Author: Wes McKinney <wesm+...@apache.org>
AuthorDate: Thu Aug 15 06:55:58 2019 +0900

    ARROW-6237: [R] Allow compilation flags to be passed for R package with 
ARROW_R_CXXFLAGS
    
    For example:
    
    ```
    export ARROW_R_CXXFLAGS="-fno-omit-frame-pointer"
    ```
    
    (this flag is needed to record performance data on Linux with `perf`)
    
    I also amended the README.Rmd to say to use `$R_LD_LIBRARY_PATH` instead of 
`$LD_LIBRARY_PATH` for custom install location
    
    Closes #5088 from wesm/r-cxxflags and squashes the following commits:
    
    e25de5e15 <Wes McKinney> Add ARROW_R_CXXFLAGS to documentation
    8718aaf0b <Wes McKinney> Change R package README to indicate to use 
R_LD_LIBRARY_PATH
    3a919df48 <Wes McKinney> Allow compilation flags to be passed for R package 
with ARROW_R_CXXFLAGS
    
    Authored-by: Wes McKinney <wesm+...@apache.org>
    Signed-off-by: Sutou Kouhei <k...@clear-code.com>
---
 r/README.Rmd | 16 ++++++++++++----
 r/README.md  | 19 ++++++++++++++-----
 r/configure  |  7 ++++++-
 3 files changed, 32 insertions(+), 10 deletions(-)

diff --git a/r/README.Rmd b/r/README.Rmd
index 2dd1eb5..f39f057 100644
--- a/r/README.Rmd
+++ b/r/README.Rmd
@@ -46,7 +46,7 @@ arrow::install_arrow()
 
 for version- and platform-specific guidance on installing the Arrow C++ 
library.
 
-When installing from source, if the R and C++ library versions do not match, 
installation may fail. If you've previously installed the libraries and want to 
upgrade the R package, you'll need to update the Arrow C++ library first.  
+When installing from source, if the R and C++ library versions do not match, 
installation may fail. If you've previously installed the libraries and want to 
upgrade the R package, you'll need to update the Arrow C++ library first.
 
 ## Example
 
@@ -112,6 +112,14 @@ R -e 'install.packages("devtools"); 
devtools::install_dev_deps()'
 R CMD INSTALL .
 ```
 
+If you need to set any compilation flags while building the Rcpp extensions,
+you can use the `ARROW_R_CXXFLAGS` environment variable. For example, if you
+are using `perf` to profile the R extensions, you may need to set
+
+```shell
+export ARROW_R_CXXFLAGS=-fno-omit-frame-pointer
+```
+
 If the package fails to install/load with an error like this:
 
 ```
@@ -121,9 +129,9 @@ unable to load shared object 
'/Users/you/R/00LOCK-r/00new/arrow/libs/arrow.so':
 dlopen(/Users/you/R/00LOCK-r/00new/arrow/libs/arrow.so, 6): Library not 
loaded: @rpath/libarrow.14.dylib
 ```
 
-try setting the environment variable `LD_LIBRARY_PATH` (or `DYLD_LIBRARY_PATH`
-on macOS) to wherever Arrow C++ was put in `make install`, e.g. `export
-LD_LIBRARY_PATH=/usr/local/lib`, and retry installing the R package.
+try setting the environment variable `R_LD_LIBRARY_PATH` to wherever Arrow C++
+was put in `make install`, e.g. `export R_LD_LIBRARY_PATH=/usr/local/lib`, and
+retry installing the R package.
 
 For any other build/configuration challenges, see the [C++ developer
 guide](https://arrow.apache.org/docs/developers/cpp.html#building).
diff --git a/r/README.md b/r/README.md
index f487fc7..6617df2 100644
--- a/r/README.md
+++ b/r/README.md
@@ -40,7 +40,8 @@ page](https://arrow.apache.org/install/) to find pre-compiled 
binary
 packages for some common Linux distributions, including Debian, Ubuntu,
 and CentOS. You’ll need to install `libparquet-dev` on Debian and
 Ubuntu, or `parquet-devel` on CentOS. This will also automatically
-install the Arrow C++ library as a dependency.
+install the Arrow C++ library as a dependency. Other Linux distributions
+must install the C++ library from source.
 
 If you install the `arrow` package from source and the C++ library is
 not found, the R package functions will notify you that Arrow is not
@@ -161,6 +162,15 @@ R -e 'install.packages("devtools"); 
devtools::install_dev_deps()'
 R CMD INSTALL .
 ```
 
+If you need to set any compilation flags while building the Rcpp
+extensions, you can use the `ARROW_R_CXXFLAGS` environment variable. For
+example, if you are using `perf` to profile the R extensions, you may
+need to set
+
+``` shell
+export ARROW_R_CXXFLAGS=-fno-omit-frame-pointer
+```
+
 If the package fails to install/load with an error like this:
 
     ** testing if installed package can be loaded from temporary location
@@ -168,10 +178,9 @@ If the package fails to install/load with an error like 
this:
     unable to load shared object 
'/Users/you/R/00LOCK-r/00new/arrow/libs/arrow.so':
     dlopen(/Users/you/R/00LOCK-r/00new/arrow/libs/arrow.so, 6): Library not 
loaded: @rpath/libarrow.14.dylib
 
-try setting the environment variable `LD_LIBRARY_PATH` (or
-`DYLD_LIBRARY_PATH` on macOS) to wherever Arrow C++ was put in `make
-install`, e.g. `export LD_LIBRARY_PATH=/usr/local/lib`, and retry
-installing the R package.
+try setting the environment variable `R_LD_LIBRARY_PATH` to wherever
+Arrow C++ was put in `make install`, e.g. `export
+R_LD_LIBRARY_PATH=/usr/local/lib`, and retry installing the R package.
 
 For any other build/configuration challenges, see the [C++ developer
 guide](https://arrow.apache.org/docs/developers/cpp.html#building).
diff --git a/r/configure b/r/configure
index f06078e..8c89fc5 100755
--- a/r/configure
+++ b/r/configure
@@ -86,7 +86,7 @@ CPPFLAGS=$("${R_HOME}"/bin/R CMD config CPPFLAGS)
 
 # If libarrow uses the old GLIBCXX ABI, so we have to use it too
 if [ "$ARROW_USE_OLD_CXXABI" ]; then
-  $PKG_CFLAGS="$PKG_CFLAGS -D_GLIBCXX_USE_CXX11_ABI=0"
+  PKG_CFLAGS="$PKG_CFLAGS -D_GLIBCXX_USE_CXX11_ABI=0"
 fi
 
 # Test configuration
@@ -112,6 +112,11 @@ else
   PKG_CFLAGS=""
 fi
 
+# Set any user-defined CXXFLAGS
+if [ "$ARROW_R_CXXFLAGS" ]; then
+  PKG_CFLAGS="$PKG_CFLAGS $ARROW_R_CXXFLAGS"
+fi
+
 # Write to Makevars
 sed -e "s|@cflags@|$PKG_CFLAGS|" -e "s|@libs@|$PKG_LIBS|" src/Makevars.in > 
src/Makevars
 

Reply via email to