thisisnic opened a new issue, #48013:
URL: https://github.com/apache/arrow/issues/48013

   ## Problem
   
   CRAN now runs [musl checks](https://github.com/bastistician/Rcheck) on 
Alpine Linux 3.22, but the Arrow R package fails to install because bundled RE2 
2022-06-01 cannot build on musl due to a missing `#include <cstdint>` (see 
#46769).
   
   The R package needs to:
   1. Detect when building on musl (Alpine Linux)
   2. Automatically use system RE2 instead of bundled RE2
   3. Have CI coverage to prevent regressions
   
   Related issues:
   - #46769: Bundled RE2 fails on Alpine musl 
   - #43350: System RE2 on Fedora has ABI issues (why we default to bundled)
   
   ## Solution
   
   ### 1. Auto-detect musl and use system RE2 in R package build
   
   **File:** `r/tools/nixlibs.R`
   
   Add musl detection:
   ```r
   on_musl <- tolower(Sys.info()[["sysname"]]) == "linux" &&
     grepl("musl", system2("ldd", "--version", stdout = TRUE, stderr = TRUE), 
ignore.case = TRUE)
   ```
   
   Override RE2 source when on musl:
   ```r
   # On musl (Alpine Linux), bundled RE2 fails to build due to missing int32_t
   # Use system RE2 which is built for musl. Related: #43350, #46769
   if (on_musl) {
     env_var <- "re2_SOURCE"
     if (Sys.getenv(env_var) == "") {
       env_var_list <- c(env_var_list, setNames("SYSTEM", env_var))
       lg("Using system RE2 on musl (Alpine Linux)", .indent = "****")
     }
   }
   ```
   
   This preserves the Fedora workaround (bundled RE2 by default) while fixing 
musl.
   
   ### 2. Add Alpine R CI job
   
   Add `alpine-linux-r` to `compose.yaml` and `test-r-alpine-linux` to 
`dev/tasks/tasks.yml` to test R package installation on Alpine 3.22 with musl. 
The job should run in "extra" CI (with label).
   
   The CI job tests that:
   - R package builds from source on musl (like CRAN does)
   - Musl detection works correctly
   - System RE2 is used automatically
   - Installation succeeds
   
   ### 3. Future work: Contribute to rhub containers
   
   Consider contributing Alpine R container configuration to 
[r-hub](https://github.com/r-hub) so the broader R community can test musl 
compatibility.
   
   ## Checklist
   
   - [ ] Add musl detection to nixlibs.R
   - [ ] Add RE2 system override for musl in nixlibs.R  
   - [ ] Add alpine-linux-r service to compose.yaml
   - [ ] Update x-hierarchy in compose.yaml
   - [ ] Add test-r-alpine-linux to dev/tasks/tasks.yml
   - [ ] Test CI job runs successfully
   - [ ] (Future) Reach out to r-hub about Alpine container contribution


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to