-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
GH-35140: [R] Rewrite configure script and ensure we don't use mismat…
…ched libarrow (#35147) I've significantly rewritten `r/configure` to make it easier to reason about and harder for issues like #34229 and #35140 to happen. I've also added a version check to make sure that we don't obviously try to use a system C++ library that doesn't match the R package version. Making sure this was applied in all of the right places and handling what to do if the versions didn't match was the impetus for the whole refactor. `configure` has been broken up into some functions, and the flow of the script is, as is documented at the top of the file: ``` # * Find libarrow on the system. If it is present, make sure # that its version is compatible with the R package. # * If no suitable libarrow is found, download it (where allowed) # or build it from source. # * Determine what features this libarrow has and what other # flags it requires, and set them in src/Makevars for use when # compiling the bindings. # * Run a test program to confirm that arrow headers are found ``` All of the detection of CFLAGS and `-L` dirs etc. happen in one place now, and they all prefer using `pkg-config` to read from the libarrow build what libraries and flags it requires, rather than hard-coding. (autobrew is the only remaining exception, but I didn't feel like messing with that today.) This should make the builds more future proof, should make it so more build configurations work (e.g. I suspect that a static build in ARROW_HOME wouldn't have gotten picked up correctly because it didn't add `-larrow_bundled_dependencies` to the libs, but now it will), and it may eliminate the redundant `-l` and `-D` setting I've observed in some builds (not harmful but definitely sloppy). Version checking has been added in an R script for ease of testing (and for easier handling of arithmetic), and there is an accompanying `test-check-versions.R` added. These are run on all the builds that use `ci/scripts/r_test.sh`. ### Behavior changes * If libarrow is found on the system (via ARROW_HOME, pkg-config, or brew), but the version does not match, it will not be used, and we will try a bundled build. This should mean that users installing a released version will never have libarrow version problems. * If both the found C++ library and R package are on matching dev versions (i.e. not identical given the x.y.z.9000 vs x+1.y.z-SNAPSHOT difference), it will proceed with a warning that you may need to rebuild if there are issues. This means that regular developers will see an extra message in the build output. * autobrew is only used on a release version unless you set FORCE_AUTOBREW=true. This eliminates another source of version mismatches (C++ release version, R dev version). * The path where you could set `LIB_DIR` and `INCLUDE_DIR` env vars has been removed. Use `ARROW_HOME` instead. * Closes: #35140 * Closes: #31989 Lead-authored-by: Neal Richardson <neal.p.richardson@gmail.com> Co-authored-by: Sutou Kouhei <kou@cozmixng.org> Signed-off-by: Neal Richardson <neal.p.richardson@gmail.com>
- Loading branch information
1 parent
f794b20
commit ec89360
Showing
13 changed files
with
502 additions
and
275 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
# Licensed to the Apache Software Foundation (ASF) under one | ||
# or more contributor license agreements. See the NOTICE file | ||
# distributed with this work for additional information | ||
# regarding copyright ownership. The ASF licenses this file | ||
# to you under the Apache License, Version 2.0 (the | ||
# "License"); you may not use this file except in compliance | ||
# with the License. You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, | ||
# software distributed under the License is distributed on an | ||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
# KIND, either express or implied. See the License for the | ||
# specific language governing permissions and limitations | ||
# under the License. | ||
|
||
args <- commandArgs(TRUE) | ||
|
||
# TESTING is set in test-check-version.R; it won't be set when called from configure | ||
test_mode <- exists("TESTING") | ||
|
||
check_versions <- function(r_version, cpp_version) { | ||
r_parsed <- package_version(r_version) | ||
r_dev_version <- r_parsed[1, 4] | ||
r_is_dev <- !is.na(r_dev_version) && r_dev_version > 100 | ||
cpp_is_dev <- grepl("SNAPSHOT$", cpp_version) | ||
cpp_parsed <- package_version(sub("-SNAPSHOT$", "", cpp_version)) | ||
|
||
major <- function(x) as.numeric(x[1, 1]) | ||
# R and C++ denote dev versions differently | ||
# R is current.release.9000, C++ is next.release-SNAPSHOT | ||
# So a "match" is if the R major version + 1 = C++ major version | ||
if (r_is_dev && cpp_is_dev && major(r_parsed) + 1 == major(cpp_parsed)) { | ||
msg <- c( | ||
sprintf("*** > Packages are both on development versions (%s, %s)", cpp_version, r_version), | ||
"*** > If installation fails, rebuild the C++ library to match the R version", | ||
"*** > or retry with FORCE_BUNDLED_BUILD=true" | ||
) | ||
cat(paste0(msg, "\n", collapse = "")) | ||
} else if (r_version != cpp_version) { | ||
cat( | ||
sprintf( | ||
"**** Not using: C++ library version (%s) does not match R package (%s)\n", | ||
cpp_version, | ||
r_version | ||
) | ||
) | ||
stop("version mismatch") | ||
# Add ALLOW_VERSION_MISMATCH env var to override stop()? (Could be useful for debugging) | ||
} else { | ||
# OK | ||
cat(sprintf("**** C++ and R library versions match: %s\n", cpp_version)) | ||
} | ||
} | ||
|
||
if (!test_mode) { | ||
check_versions(args[1], args[2]) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
# Licensed to the Apache Software Foundation (ASF) under one | ||
# or more contributor license agreements. See the NOTICE file | ||
# distributed with this work for additional information | ||
# regarding copyright ownership. The ASF licenses this file | ||
# to you under the Apache License, Version 2.0 (the | ||
# "License"); you may not use this file except in compliance | ||
# with the License. You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, | ||
# software distributed under the License is distributed on an | ||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
# KIND, either express or implied. See the License for the | ||
# specific language governing permissions and limitations | ||
# under the License. | ||
|
||
|
||
# Usage: run testthat::test_dir(".") inside of this directory | ||
|
||
# Flag so that we just load the functions and don't evaluate them like we do | ||
# when called from configure.R | ||
TESTING <- TRUE | ||
|
||
source("check-versions.R", local = TRUE) | ||
|
||
test_that("check_versions", { | ||
expect_output( | ||
check_versions("10.0.0", "10.0.0"), | ||
"**** C++ and R library versions match: 10.0.0", | ||
fixed = TRUE | ||
) | ||
expect_output( | ||
expect_error( | ||
check_versions("10.0.0", "10.0.0-SNAPSHOT"), | ||
"version mismatch" | ||
), | ||
"**** Not using: C++ library version (10.0.0-SNAPSHOT) does not match R package (10.0.0)", | ||
fixed = TRUE | ||
) | ||
expect_output( | ||
expect_error( | ||
check_versions("10.0.0.9000", "10.0.0-SNAPSHOT"), | ||
"version mismatch" | ||
), | ||
"**** Not using: C++ library version (10.0.0-SNAPSHOT) does not match R package (10.0.0.9000)", | ||
fixed = TRUE | ||
) | ||
expect_output( | ||
expect_error( | ||
check_versions("10.0.0.9000", "10.0.0"), | ||
"version mismatch" | ||
), | ||
"**** Not using: C++ library version (10.0.0) does not match R package (10.0.0.9000)", | ||
fixed = TRUE | ||
) | ||
expect_output( | ||
check_versions("10.0.0.9000", "11.0.0-SNAPSHOT"), | ||
"*** > Packages are both on development versions (11.0.0-SNAPSHOT, 10.0.0.9000)\n", | ||
fixed = TRUE | ||
) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters