Skip to content

Commit

Permalink
apacheGH-33807: [R] Add a message if we detect running under emulation (
Browse files Browse the repository at this point in the history
apache#37777)

Resolves apache#33807 and apache#37034

If someone is running R under emulation, arrow segfaults without error. We can detect this when we load so can also warn people that this is not recommended. Though the version of R being run is not directly an arrow issue, arrow fails very quickly in this configuration.

Detect when running under rosetta (on macOS only) and warn when the library is attached

No, given the paucity of ARM-based mac CI, testing this organically would be difficult. But the logic is straightforward.

Yes, a warning when someone loads arrow under emulation.
* Closes: apache#33807

Authored-by: Jonathan Keane <jkeane@gmail.com>
Signed-off-by: Jonathan Keane <jkeane@gmail.com>
  • Loading branch information
jonkeane authored and dgreiss committed Feb 17, 2024
1 parent 7ba5694 commit 2b07ebb
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 4 deletions.
21 changes: 21 additions & 0 deletions r/R/arrow-package.R
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,22 @@ configure_tzdb <- function() {
# Just to be extra safe, let's wrap this in a try();
# we don't want a failed startup message to prevent the package from loading
try({
# On MacOS only, Check if we are running in under emulation, and warn this will not work
if (on_rosetta()) {
packageStartupMessage(
paste(
"Warning:",
" It appears that you are running R and Arrow in emulation (i.e. you're",
" running an Intel version of R on a non-Intel mac). This configuration is",
" not supported by arrow, you should install a native (arm64) build of R",
" and use arrow with that. See https://cran.r-project.org/bin/macosx/",
"",
sep = "\n"
)
)
}


features <- arrow_info()$capabilities
# That has all of the #ifdef features, plus the compression libs and the
# string libraries (but not the memory allocators, they're added elsewhere)
Expand Down Expand Up @@ -225,6 +241,11 @@ on_macos_10_13_or_lower <- function() {
package_version(unname(Sys.info()["release"])) < "18.0.0"
}

on_rosetta <- function() {
identical(tolower(Sys.info()[["sysname"]]), "darwin") &&
identical(system("sysctl -n sysctl.proc_translated", intern = TRUE), "1")
}

option_use_threads <- function() {
!is_false(getOption("arrow.use_threads"))
}
Expand Down
4 changes: 1 addition & 3 deletions r/R/install-arrow.R
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ install_arrow <- function(nightly = FALSE,
verbose = Sys.getenv("ARROW_R_DEV", FALSE),
repos = getOption("repos"),
...) {
sysname <- tolower(Sys.info()[["sysname"]])
conda <- isTRUE(grepl("conda", R.Version()$platform))

if (conda) {
Expand All @@ -80,8 +79,7 @@ install_arrow <- function(nightly = FALSE,
# On the M1, we can't use the usual autobrew, which pulls Intel dependencies
apple_m1 <- grepl("arm-apple|aarch64.*darwin", R.Version()$platform)
# On Rosetta, we have to build without JEMALLOC, so we also can't autobrew
rosetta <- identical(sysname, "darwin") && identical(system("sysctl -n sysctl.proc_translated", intern = TRUE), "1")
if (rosetta) {
if (on_rosetta()) {
Sys.setenv(ARROW_JEMALLOC = "OFF")
}
if (apple_m1 || rosetta) {
Expand Down
5 changes: 4 additions & 1 deletion r/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,10 @@ conda install -c conda-forge --strict-channel-priority r-arrow

There are some special cases to note:

- On Linux the installation process can sometimes be more involved because CRAN does not host binaries for Linux. For more information please see the [installation guide](articles/install.html).
- On macOS, the R you use with Arrow should match the architecture of the machine you are using. If you're using an ARM (aka M1, M2, etc.) processor use R compiled for arm64. If you're using an Intel based mac, use R compiled for x86. Using R and Arrow compiled for Intel based macs on an ARM based mac will result in segfaults and crashes.

- On Linux the installation process can sometimes be more involved because
CRAN does not host binaries for Linux. For more information please see the [installation guide](https://arrow.apache.org/docs/r/articles/install.html).

- If you are compiling arrow from source, please note that as of version 10.0.0, arrow requires C++17 to build. This has implications on Windows and CentOS 7. For Windows users it means you need to be running an R version of 4.0 or later. On CentOS 7, it means you need to install a newer compiler than the default system compiler gcc. See the [installation details article](https://arrow.apache.org/docs/r/articles/developers/install_details.html) for guidance.

Expand Down

0 comments on commit 2b07ebb

Please sign in to comment.