Skip to content

Commit 3f6dfb3

Browse files
GH-35710: [R] Followup improvements to new configure script (#36435)
### Rationale for this change See #35710 ### What changes are included in this PR? * [Get `LIB_DIR` from `pkg-config` where possible](c8d09eb), to handle the possibility that it is `lib64` and not just `lib` on some platforms. * [Allow x.y.z.1 to use x.y.z C++ library](a77f909), so that apt/yum official release packages can be used with patched versions submitted to CRAN. ### Are these changes tested? The version check change has a unit test. The LIB_DIR change hopefully is well enough covered by our existing CI. * Closes: #35710 Authored-by: Neal Richardson <[email protected]> Signed-off-by: Sutou Kouhei <[email protected]>
1 parent 4a424a8 commit 3f6dfb3

File tree

3 files changed

+18
-1
lines changed

3 files changed

+18
-1
lines changed

r/configure

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,6 @@ do_autobrew () {
263263
# Once libarrow is obtained, this function sets `PKG_LIBS`, `PKG_DIRS`, and `PKG_CFLAGS`
264264
# either from pkg-config or by inferring things about the directory in $1
265265
set_pkg_vars () {
266-
LIB_DIR="$1/lib"
267266
if [ "$PKG_CONFIG_AVAILABLE" = "true" ]; then
268267
set_pkg_vars_with_pc
269268
else
@@ -281,13 +280,15 @@ set_pkg_vars () {
281280

282281
# If we have pkg-config, it will tell us what libarrow needs
283282
set_pkg_vars_with_pc () {
283+
LIB_DIR="`${PKG_CONFIG} --variable=libdir --silence-errors ${PKG_CONFIG_NAME}`"
284284
PKG_CFLAGS="`${PKG_CONFIG} --cflags --silence-errors ${PKG_CONFIG_NAME}` $PKG_CFLAGS"
285285
PKG_LIBS=`${PKG_CONFIG} --libs-only-l --libs-only-other --silence-errors ${PKG_CONFIG_NAME}`
286286
PKG_DIRS=`${PKG_CONFIG} --libs-only-L --silence-errors ${PKG_CONFIG_NAME}`
287287
}
288288

289289
# If we don't have pkg-config, we can make some inferences
290290
set_pkg_vars_without_pc () {
291+
LIB_DIR="$1/lib"
291292
PKG_CFLAGS="-I$1/include $PKG_CFLAGS"
292293
if grep -q "_GLIBCXX_USE_CXX11_ABI=0" "${LIB_DIR}/pkgconfig/arrow.pc"; then
293294
PKG_CFLAGS="${PKG_CFLAGS} -D_GLIBCXX_USE_CXX11_ABI=0"

r/tools/check-versions.R

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ check_versions <- function(r_version, cpp_version) {
2424
r_parsed <- package_version(r_version)
2525
r_dev_version <- r_parsed[1, 4]
2626
r_is_dev <- !is.na(r_dev_version) && r_dev_version > 100
27+
r_is_patch <- !is.na(r_dev_version) && r_dev_version <= 100
2728
cpp_is_dev <- grepl("SNAPSHOT$", cpp_version)
2829
cpp_parsed <- package_version(sub("-SNAPSHOT$", "", cpp_version))
2930

@@ -38,6 +39,16 @@ check_versions <- function(r_version, cpp_version) {
3839
"*** > or retry with FORCE_BUNDLED_BUILD=true"
3940
)
4041
cat(paste0(msg, "\n", collapse = ""))
42+
} else if (r_is_patch && as.character(r_parsed[1, 1:3]) == cpp_version) {
43+
# Patch releases we do for CRAN feedback get an extra x.y.z.1 version.
44+
# These should work with the x.y.z C++ library (which never has .1 added)
45+
cat(
46+
sprintf(
47+
"*** > Using C++ library version %s with R package %s\n",
48+
cpp_version,
49+
r_version
50+
)
51+
)
4152
} else if (r_version != cpp_version) {
4253
cat(
4354
sprintf(

r/tools/test-check-versions.R

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,11 @@ test_that("check_versions", {
5454
"**** Not using: C++ library version (10.0.0) does not match R package (10.0.0.9000)",
5555
fixed = TRUE
5656
)
57+
expect_output(
58+
check_versions("10.0.0.3", "10.0.0"),
59+
"*** > Using C++ library version 10.0.0 with R package 10.0.0.3",
60+
fixed = TRUE
61+
)
5762
expect_output(
5863
check_versions("10.0.0.9000", "11.0.0-SNAPSHOT"),
5964
"*** > Packages are both on development versions (11.0.0-SNAPSHOT, 10.0.0.9000)\n",

0 commit comments

Comments
 (0)