Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/r.yml
Original file line number Diff line number Diff line change
Expand Up @@ -234,9 +234,9 @@ jobs:
r-${{ matrix.config.rtools }}-ccache-mingw-${{ matrix.config.arch }}-
- uses: r-lib/actions/setup-r@v2
with:
# R is not used, but setup-r picks Rtools from r-version: 4.5 gets
# R is not used, but setup-r picks Rtools from r-version: 4.6 gets
# Rtools45, which builds the Arrow C++ static library.
r-version: "4.5"
r-version: "4.6"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is true? R version 4.6 uses Rtools45, which, as I recall from the last PR, also works for R 4.4? 😵‍💫

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep! I just wanted to bump it on CI so we can take advantage of binaries for dependencies so quicker builds. The toolchain is much easier to work with than the previous ones, seems to have a ton more compatibility once we clear the super old gcc versions in earlier ones. I'm guessing the reason there isn't an RTools46 because of Tomas Kalibera passing away, and nobody formally taking over his work.

Ncpus: 2
- name: Build Arrow C++
shell: bash
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/r_nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ jobs:
prune repo/libarrow/r-libarrow-linux-x86_64-* || :
prune repo/libarrow/r-libarrow-windows-x86_64-rtools40-* || :
prune repo/libarrow/r-libarrow-windows-x86_64-rtools45-* || :
prune repo/libarrow/r-libarrow-windows-aarch64-rtools45-* || :
- name: Update Repository Index
shell: Rscript {0}
run: |
Expand Down
44 changes: 32 additions & 12 deletions ci/scripts/r_windows_build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,27 @@ ARROW_HOME="$(cd "${ARROW_HOME}" && pwd)"
export ARROW_HOME

: "${RTOOLS_VERSION:=45}"
: "${RTOOLS_HOME:=/c/rtools${RTOOLS_VERSION}}"
TOOLCHAIN="${RTOOLS_HOME}/x86_64-w64-mingw32.static.posix"
# x86_64 or aarch64
: "${RTOOLS_ARCH:=x86_64}"
case "${RTOOLS_ARCH}" in
x86_64)
: "${RTOOLS_HOME:=/c/rtools${RTOOLS_VERSION}}"
LIB_SUBDIR="x64-ucrt"
;;
aarch64)
: "${RTOOLS_HOME:=/c/rtools${RTOOLS_VERSION}-aarch64}"
LIB_SUBDIR="aarch64-ucrt"
# The aarch64 toolchain is LLVM. Without this CMake tries gcc first and
# could find one for another architecture elsewhere on PATH.
export CC="${CC:-clang}"
export CXX="${CXX:-clang++}"
;;
*)
echo "Unknown RTOOLS_ARCH: ${RTOOLS_ARCH}" >&2
exit 1
;;
esac
TOOLCHAIN="${RTOOLS_HOME}/${RTOOLS_ARCH}-w64-mingw32.static.posix"
export PATH="${TOOLCHAIN}/bin:${RTOOLS_HOME}/usr/bin:${PATH}"

# CMake is a native Windows program, so give it Windows-style paths
Expand All @@ -44,8 +63,8 @@ INSTALL_DIR="${BUILD_DIR}/install"
INSTALL_DIR_WIN="$(cygpath -am "${INSTALL_DIR}")"

printenv
gcc --version
g++ --version
"${CC:-gcc}" --version
"${CXX:-g++}" --version
cmake --version
make --version | head -n 1
ls "${TOOLCHAIN}/lib"
Expand Down Expand Up @@ -126,18 +145,19 @@ popd
ccache --show-stats || echo "ccache not found"

VERSION="$(grep Version "${ARROW_HOME}/r/DESCRIPTION" | cut -d " " -f 2)"
DST_DIR="r-libarrow-windows-x86_64-rtools${RTOOLS_VERSION}-${VERSION}"
DST_DIR="r-libarrow-windows-${RTOOLS_ARCH}-rtools${RTOOLS_VERSION}-${VERSION}"

# Make the zip layout r/configure.win expects: include/ and lib/x64-ucrt/
# (lib/aarch64-ucrt/ for aarch64)
pushd "${BUILD_DIR}"
rm -rf "${DST_DIR}"
mkdir -p "${DST_DIR}/lib/x64-ucrt"
mkdir -p "${DST_DIR}/lib/${LIB_SUBDIR}"
cp -r install/include "${DST_DIR}/include"
cp install/lib/*.a "${DST_DIR}/lib/x64-ucrt/"
cp install/lib/*.a "${DST_DIR}/lib/${LIB_SUBDIR}/"

# Rtools libraries in PKG_LIBS in r/configure.win; keep in sync
for lib in z zstd lz4 bz2 crypto ssl curl; do
cp "${TOOLCHAIN}/lib/lib${lib}.a" "${DST_DIR}/lib/x64-ucrt/"
cp "${TOOLCHAIN}/lib/lib${lib}.a" "${DST_DIR}/lib/${LIB_SUBDIR}/"
done

# cURL's link dependencies vary by Rtools version, so read them from
Expand All @@ -159,7 +179,7 @@ while read -r flag; do
curl | z | zstd | ssl | crypto) ;; # already copied above
*)
if [ -f "${TOOLCHAIN}/lib/lib${lib}.a" ]; then
cp "${TOOLCHAIN}/lib/lib${lib}.a" "${DST_DIR}/lib/x64-ucrt/"
cp "${TOOLCHAIN}/lib/lib${lib}.a" "${DST_DIR}/lib/${LIB_SUBDIR}/"
fi
;;
esac
Expand All @@ -175,9 +195,9 @@ case " ${CURL_LIBS} " in
exit 1
;;
esac
echo "${CURL_LIBS}${CURL_SYS_LIBS}" >"${DST_DIR}/lib/x64-ucrt/libcurl.libs"
cat "${DST_DIR}/lib/x64-ucrt/libcurl.libs"
ls -la "${DST_DIR}/lib/x64-ucrt"
echo "${CURL_LIBS}${CURL_SYS_LIBS}" >"${DST_DIR}/lib/${LIB_SUBDIR}/libcurl.libs"
cat "${DST_DIR}/lib/${LIB_SUBDIR}/libcurl.libs"
ls -la "${DST_DIR}/lib/${LIB_SUBDIR}"

# Create build artifact
zip -r "${DST_DIR}.zip" "${DST_DIR}"
Expand Down
6 changes: 3 additions & 3 deletions dev/tasks/macros.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -229,11 +229,11 @@ env:
shell: bash
run: mkdir repo
{% if get_win %}
{% for rtools in ["40", "45"] %}
- name: Get windows Rtools{{ rtools }} binary
{% for binary in ["x86_64-rtools40", "x86_64-rtools45", "aarch64-rtools45"] %}
- name: Get windows {{ binary }} binary
uses: actions/download-artifact@v4
with:
name: r-libarrow-windows-x86_64-rtools{{ rtools }}
name: r-libarrow-windows-{{ binary }}
path: repo/libarrow
{% endfor %}
{% endif %}
Expand Down
23 changes: 14 additions & 9 deletions dev/tasks/r/github.packages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -171,20 +171,22 @@ jobs:
{{ '${{ env.PKG_FILE }}' }}.sha512
windows-cpp:
name: C++ Binary Windows RTools {{ '${{ matrix.config.rtools }}' }}
name: C++ Binary Windows {{ '${{ matrix.config.arch }}' }} RTools {{ '${{ matrix.config.rtools }}' }}
needs: source
runs-on: windows-latest
runs-on: {{ '${{ matrix.config.runs_on }}' }}
strategy:
fail-fast: false
matrix:
config:
# R is not used, but setup-r picks Rtools from r-version: R 4.1 was
# the last R to use Rtools40. The Rtools40 binary is for R < 4.4.
- { rtools: 40, r: "4.1", script: r_windows_build_rtools40.sh }
- { rtools: 45, r: "4.5", script: r_windows_build.sh }
# On windows-11-arm setup-r installs the aarch64 Rtools45.
- { rtools: 40, arch: x86_64, r: "4.1", script: r_windows_build_rtools40.sh, runs_on: windows-latest }
- { rtools: 45, arch: x86_64, r: "4.6", script: r_windows_build.sh, runs_on: windows-latest }
- { rtools: 45, arch: aarch64, r: "4.6", script: r_windows_build.sh, runs_on: windows-11-arm }
env:
PKG_ID: r-libarrow-windows-x86_64-rtools{{ '${{ matrix.config.rtools }}' }}
PKG_FILE: r-libarrow-windows-x86_64-rtools{{ '${{ matrix.config.rtools }}' }}-{{ '${{ needs.source.outputs.pkg_version }}' }}.zip
PKG_ID: r-libarrow-windows-{{ '${{ matrix.config.arch }}' }}-rtools{{ '${{ matrix.config.rtools }}' }}
PKG_FILE: r-libarrow-windows-{{ '${{ matrix.config.arch }}' }}-rtools{{ '${{ matrix.config.rtools }}' }}-{{ '${{ needs.source.outputs.pkg_version }}' }}.zip
steps:
- run: git config --global core.autocrlf false
{{ macros.github_checkout_arrow()|indent }}
Expand All @@ -202,6 +204,7 @@ jobs:
env:
ARROW_HOME: "arrow"
MINGW_ARCH: "ucrt64"
RTOOLS_ARCH: {{ '${{ matrix.config.arch }}' }}
{{ macros.github_set_sccache_envvars()|indent(8) }}
run: arrow/ci/scripts/{{ '${{ matrix.config.script }}' }}
- name: Create Checksum
Expand Down Expand Up @@ -231,9 +234,11 @@ jobs:
- { runs_on: macos-26, name: "macOS arm64" }
r_version: [oldrel, release]
include:
# Tests the Rtools40 libarrow binary, which R < 4.4 downloads. The
# R package built here is not uploaded.
# These rows test libarrow binaries the rows above don't use: Rtools40
# (which R < 4.4 downloads) and aarch64. Their R packages are not

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not?

# uploaded.
- { platform: { runs_on: 'windows-latest', name: "Windows"}, r_version: "4.3" }
- { platform: { runs_on: 'windows-11-arm', name: "Windows aarch64"}, r_version: "release" }
steps:
- uses: r-lib/actions/setup-r@v2
with:
Expand Down Expand Up @@ -314,7 +319,7 @@ jobs:
cat(cmd, file = Sys.getenv("GITHUB_OUTPUT"), append = TRUE)
- name: Upload binary artifact
if: matrix.r_version != '4.3'
if: matrix.r_version != '4.3' && matrix.platform.name != 'Windows aarch64'
uses: actions/upload-artifact@v4
with:
name: r-pkg{{ '${{ steps.build.outputs.path }}' }}
Expand Down
1 change: 1 addition & 0 deletions dev/tasks/tasks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,7 @@ tasks:
artifacts:
- r-libarrow-windows-x86_64-rtools40-{no_rc_r_version}\.zip
- r-libarrow-windows-x86_64-rtools45-{no_rc_r_version}\.zip
- r-libarrow-windows-aarch64-rtools45-{no_rc_r_version}\.zip
- r-libarrow-linux-x86_64-{no_rc_r_version}\.zip
- r-libarrow-linux-arm64-{no_rc_r_version}\.zip
- r-libarrow-darwin-arm64-{no_rc_r_version}\.zip
Expand Down
11 changes: 8 additions & 3 deletions r/configure.win
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,12 @@ function configure_binaries() {
# (GH-55165).
UTF8PROC_SNAPPY_LIBS="-lutf8proc -lsnappy"
RE2_LIBS="-lre2"
CURL_LIBS_FILE="${RWINLIB#../}/lib/x64-ucrt/libcurl.libs"
# $(R_ARCH) is empty in aarch64 R, so ask R for its architecture.
case "$("${R_HOME}/bin${R_ARCH_BIN}/Rscript.exe" -e 'cat(R.version$arch)')" in
aarch64) RWINLIB_ARCH_DIR="aarch64-ucrt" ;;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Neither here nor there but RWINLIB is a vestige of the pre-rtools4 build system Jeroen maintained (https://github.com/rwinlib/), if there's a clearer name for this concept for us here, we can def rename it.

*) RWINLIB_ARCH_DIR="x64-ucrt" ;;
esac
CURL_LIBS_FILE="${RWINLIB#../}/lib/${RWINLIB_ARCH_DIR}/libcurl.libs"
if [ -f "${CURL_LIBS_FILE}" ]; then
UTF8PROC_SNAPPY_LIBS=""
RE2_LIBS=""
Expand All @@ -100,11 +105,11 @@ function configure_binaries() {
-DARROW_R_WITH_DATASET -DARROW_R_WITH_JSON \
-DARROW_R_WITH_S3 -DARROW_R_WITH_GCS" # -DARROW_R_WITH_AZURE
PKG_LIBS="-L${RWINLIB}/lib"'$(subst gcc,,$(COMPILED_BY))$(R_ARCH) '
PKG_LIBS="$PKG_LIBS -L${RWINLIB}/lib"'$(R_ARCH)$(CRT) '
PKG_LIBS="$PKG_LIBS -L${RWINLIB}/lib/${RWINLIB_ARCH_DIR} "
PKG_LIBS="$PKG_LIBS -larrow_dataset -larrow_acero -lparquet -larrow_compute -larrow_s3 \
-larrow_gcs \$(if \$(wildcard \
${RWINLIB}/lib\$(subst gcc,,\$(COMPILED_BY))\$(R_ARCH)/libarrow_gcs_bundled_dependencies.a \
${RWINLIB}/lib\$(R_ARCH)\$(CRT)/libarrow_gcs_bundled_dependencies.a),-larrow_gcs_bundled_dependencies) -larrow \
${RWINLIB}/lib/${RWINLIB_ARCH_DIR}/libarrow_gcs_bundled_dependencies.a),-larrow_gcs_bundled_dependencies) -larrow \
-larrow_bundled_dependencies \
${UTF8PROC_SNAPPY_LIBS} -lz -lzstd -llz4 -lbz2 -lole32 \
${MIMALLOC_LIBS} ${OPENSSL_LIBS} ${RE2_LIBS} ${AWS_LIBS} ${GCS_LIBS}" # ${AZURE_LIBS}
Expand Down
10 changes: 8 additions & 2 deletions r/tools/nixlibs.R
Original file line number Diff line number Diff line change
Expand Up @@ -200,14 +200,20 @@ download_binary <- function(lib) {
# * "darwin-x86_64"
# These string values, along with `NULL`, are the potential return values of
# this function. On Windows, LIBARROW_BINARY is ignored and the binary is
# chosen by R version: "windows-x86_64-rtools40" or "windows-x86_64-rtools45".
# chosen by architecture and R version: "windows-aarch64-rtools45",
# "windows-x86_64-rtools40" or "windows-x86_64-rtools45".
identify_binary <- function(
lib = Sys.getenv("LIBARROW_BINARY"),
info = distro(),
r_version = getRversion()
r_version = getRversion(),
# The architecture R was built for, as in configure.win, not the machine's
arch = tolower(R.version$arch)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the first time we have to care about arch in here? Maybe I'm old and forgetful but don't we have to build arm and x86 for mac?

) {
if (on_windows) {
if (VERSION_22_OR_LATER) {
if (normalise_arch(arch) == "arm64") {
return("windows-aarch64-rtools45")
}
# The binary built with Rtools45 can't be linked by Rtools43 or earlier,
# which R < 4.4 uses, so those get the one built with Rtools40.
if (package_version(r_version) < "4.4") {
Expand Down
21 changes: 17 additions & 4 deletions r/tools/test-nixlibs.R
Original file line number Diff line number Diff line change
Expand Up @@ -488,11 +488,24 @@ test_that("turn_off_unvendored_features()", {
)
})

test_that("identify_binary() picks the Windows binary by R version", {
test_that("identify_binary() picks the Windows binary by R version and architecture", {
local_binding("on_windows", TRUE)
local_binding("VERSION_22_OR_LATER", TRUE)

expect_identical(identify_binary(r_version = "4.3.3"), "windows-x86_64-rtools40")
expect_identical(identify_binary(r_version = "4.4.0"), "windows-x86_64-rtools45")
expect_identical(identify_binary(r_version = "4.6.0"), "windows-x86_64-rtools45")
expect_identical(
identify_binary(r_version = "4.3.3", arch = "x86_64"),
"windows-x86_64-rtools40"
)
expect_identical(
identify_binary(r_version = "4.4.0", arch = "x86_64"),
"windows-x86_64-rtools45"
)
expect_identical(
identify_binary(r_version = "4.6.0", arch = "x86_64"),
"windows-x86_64-rtools45"
)
expect_identical(
identify_binary(r_version = "4.6.0", arch = "aarch64"),
"windows-aarch64-rtools45"
)
})
Loading