|
| 1 | +# Licensed to the Apache Software Foundation (ASF) under one |
| 2 | +# or more contributor license agreements. See the NOTICE file |
| 3 | +# distributed with this work for additional information |
| 4 | +# regarding copyright ownership. The ASF licenses this file |
| 5 | +# to you under the Apache License, Version 2.0 (the |
| 6 | +# "License"); you may not use this file except in compliance |
| 7 | +# with the License. You may obtain a copy of the License at |
| 8 | +# |
| 9 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | +# |
| 11 | +# Unless required by applicable law or agreed to in writing, |
| 12 | +# software distributed under the License is distributed on an |
| 13 | +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 14 | +# KIND, either express or implied. See the License for the |
| 15 | +# specific language governing permissions and limitations |
| 16 | +# under the License. |
| 17 | + |
| 18 | +# Fedora 42 container with Clang and R-devel for testing Arrow R package |
| 19 | +# Replicates CRAN's r-devel-linux-x86_64-fedora-clang environment |
| 20 | +# See: https://www.stats.ox.ac.uk/pub/bdr/Rconfig/r-devel-linux-x86_64-fedora-clang |
| 21 | + |
| 22 | +ARG arch=amd64 |
| 23 | +FROM ${arch}/fedora:42 |
| 24 | + |
| 25 | +# Install build dependencies |
| 26 | +RUN dnf update -y && \ |
| 27 | + dnf install -y \ |
| 28 | + # Build tools |
| 29 | + autoconf \ |
| 30 | + automake \ |
| 31 | + bzip2 \ |
| 32 | + bzip2-devel \ |
| 33 | + cmake \ |
| 34 | + curl \ |
| 35 | + curl-devel \ |
| 36 | + diffutils \ |
| 37 | + gcc \ |
| 38 | + gcc-c++ \ |
| 39 | + gcc-gfortran \ |
| 40 | + git \ |
| 41 | + java-latest-openjdk-devel \ |
| 42 | + libicu-devel \ |
| 43 | + libtool \ |
| 44 | + libuuid-devel \ |
| 45 | + libxcrypt-devel \ |
| 46 | + lld \ |
| 47 | + make \ |
| 48 | + ninja-build \ |
| 49 | + openssl-devel \ |
| 50 | + patch \ |
| 51 | + pcre2-devel \ |
| 52 | + perl \ |
| 53 | + pkgconfig \ |
| 54 | + python3 \ |
| 55 | + python3-pip \ |
| 56 | + readline-devel \ |
| 57 | + rsync \ |
| 58 | + subversion \ |
| 59 | + tar \ |
| 60 | + texinfo \ |
| 61 | + texlive-collection-basic \ |
| 62 | + texlive-collection-latex \ |
| 63 | + texlive-collection-latexrecommended \ |
| 64 | + texlive-collection-fontsrecommended \ |
| 65 | + texlive-inconsolata \ |
| 66 | + texlive-parskip \ |
| 67 | + texlive-natbib \ |
| 68 | + texlive-fancyvrb \ |
| 69 | + texlive-framed \ |
| 70 | + unzip \ |
| 71 | + wget \ |
| 72 | + which \ |
| 73 | + xz \ |
| 74 | + xz-devel \ |
| 75 | + zlib-devel \ |
| 76 | + # X11 libraries for R |
| 77 | + cairo-devel \ |
| 78 | + libX11-devel \ |
| 79 | + libXmu-devel \ |
| 80 | + libXt-devel \ |
| 81 | + libcurl-devel \ |
| 82 | + libjpeg-turbo-devel \ |
| 83 | + libpng-devel \ |
| 84 | + libtiff-devel \ |
| 85 | + pango-devel \ |
| 86 | + tk-devel \ |
| 87 | + # Additional R dependencies |
| 88 | + libxml2-devel \ |
| 89 | + fontconfig-devel \ |
| 90 | + freetype-devel \ |
| 91 | + fribidi-devel \ |
| 92 | + harfbuzz-devel && \ |
| 93 | + dnf clean all |
| 94 | + |
| 95 | +# Install LLVM/Clang from Fedora repos (will be the latest available in Fedora 42) |
| 96 | +# Note: CRAN uses Clang 21, but we use whatever is available in Fedora repos |
| 97 | +# This should be close enough for testing purposes |
| 98 | +RUN dnf install -y \ |
| 99 | + clang \ |
| 100 | + clang-devel \ |
| 101 | + clang-tools-extra \ |
| 102 | + compiler-rt \ |
| 103 | + flang \ |
| 104 | + lld \ |
| 105 | + llvm \ |
| 106 | + llvm-devel \ |
| 107 | + libcxx \ |
| 108 | + libcxx-devel \ |
| 109 | + libcxxabi \ |
| 110 | + libcxxabi-devel \ |
| 111 | + libomp \ |
| 112 | + libomp-devel && \ |
| 113 | + dnf clean all |
| 114 | + |
| 115 | +# Install locale support |
| 116 | +RUN dnf install -y glibc-langpack-en && dnf clean all |
| 117 | + |
| 118 | +# Set up compiler environment to match CRAN's Fedora Clang configuration |
| 119 | +# CRAN uses: -O3 -Wall -pedantic -Wp,-D_FORTIFY_SOURCE=3 |
| 120 | +# CRAN's clang is built to use libc++ by default; Fedora's defaults to libstdc++, |
| 121 | +# so we must add -stdlib=libc++ explicitly |
| 122 | +ENV CC=clang \ |
| 123 | + CXX="clang++ -stdlib=libc++" \ |
| 124 | + FC=flang-new \ |
| 125 | + CFLAGS="-O3 -Wall -pedantic -Wp,-D_FORTIFY_SOURCE=3" \ |
| 126 | + CXXFLAGS="-O3 -Wall -pedantic -frtti -stdlib=libc++ -Wp,-D_FORTIFY_SOURCE=3" \ |
| 127 | + FFLAGS="-O2 -pedantic" \ |
| 128 | + LDFLAGS="-fuse-ld=lld" |
| 129 | + |
| 130 | +# Set locale (glibc-langpack-en must be installed first) |
| 131 | +ENV LANG=en_US.UTF-8 \ |
| 132 | + LC_ALL=en_US.UTF-8 \ |
| 133 | + LC_COLLATE=C \ |
| 134 | + TZ=UTC |
| 135 | + |
| 136 | +# Build R-devel from source to match CRAN's R-devel |
| 137 | +ARG r_version=devel |
| 138 | +RUN cd /tmp && \ |
| 139 | + if [ "$r_version" = "devel" ]; then \ |
| 140 | + svn checkout https://svn.r-project.org/R/trunk R-devel && \ |
| 141 | + cd R-devel/tools && \ |
| 142 | + ./rsync-recommended; \ |
| 143 | + else \ |
| 144 | + wget -q https://cran.r-project.org/src/base/R-4/R-${r_version}.tar.gz && \ |
| 145 | + tar xf R-${r_version}.tar.gz && \ |
| 146 | + mv R-${r_version} R-devel; \ |
| 147 | + fi && \ |
| 148 | + cd /tmp/R-devel && \ |
| 149 | + ./configure \ |
| 150 | + --prefix=/usr/local \ |
| 151 | + --enable-R-shlib \ |
| 152 | + --enable-memory-profiling \ |
| 153 | + --with-blas \ |
| 154 | + --with-lapack \ |
| 155 | + --with-x \ |
| 156 | + --with-tcltk \ |
| 157 | + CC="clang" \ |
| 158 | + CXX="clang++ -stdlib=libc++" \ |
| 159 | + FC="flang-new" \ |
| 160 | + CFLAGS="-O3 -Wall -pedantic -Wp,-D_FORTIFY_SOURCE=3" \ |
| 161 | + CXXFLAGS="-O3 -Wall -pedantic -frtti -stdlib=libc++ -Wp,-D_FORTIFY_SOURCE=3" \ |
| 162 | + FFLAGS="-O2 -pedantic" \ |
| 163 | + LDFLAGS="-fuse-ld=lld" && \ |
| 164 | + make -j$(nproc) && \ |
| 165 | + make install && \ |
| 166 | + cd / && \ |
| 167 | + rm -rf /tmp/R-devel |
| 168 | + |
| 169 | +# Verify R installation and clang |
| 170 | +RUN R --version && clang --version |
| 171 | + |
| 172 | +# Set CRAN repo |
| 173 | +RUN echo 'options(repos = c(CRAN = "https://cran.rstudio.com"))' >> $(R RHOME)/etc/Rprofile.site |
| 174 | + |
| 175 | +# Install pak for package management |
| 176 | +RUN R -q -e 'install.packages("pak", repos = sprintf("https://r-lib.github.io/p/pak/%s/%s/%s/%s", "devel", .Platform$pkgType, R.Version()$os, R.Version()$arch))' |
| 177 | + |
| 178 | +# Enable automatic system requirements installation |
| 179 | +ENV PKG_SYSREQS=true \ |
| 180 | + R_PKG_SYSREQS2=true |
| 181 | + |
| 182 | +# Set up parallel compilation |
| 183 | +RUN echo "MAKEFLAGS=-j$(R -s -e 'cat(parallel::detectCores())')" >> $(R RHOME)/etc/Renviron.site |
| 184 | + |
| 185 | +# Configure R to use clang for package compilation (matching CRAN's Makevars) |
| 186 | +# Fedora's clang defaults to libstdc++, so we must specify -stdlib=libc++ |
| 187 | +RUN mkdir -p /root/.R && \ |
| 188 | + echo "CC = clang" >> /root/.R/Makevars && \ |
| 189 | + echo "CXX = clang++ -stdlib=libc++" >> /root/.R/Makevars && \ |
| 190 | + echo "CXX11 = clang++ -stdlib=libc++" >> /root/.R/Makevars && \ |
| 191 | + echo "CXX14 = clang++ -stdlib=libc++" >> /root/.R/Makevars && \ |
| 192 | + echo "CXX17 = clang++ -stdlib=libc++" >> /root/.R/Makevars && \ |
| 193 | + echo "CXX20 = clang++ -stdlib=libc++" >> /root/.R/Makevars && \ |
| 194 | + echo "FC = flang-new" >> /root/.R/Makevars && \ |
| 195 | + echo "CFLAGS = -O3 -Wall -pedantic -Wp,-D_FORTIFY_SOURCE=3" >> /root/.R/Makevars && \ |
| 196 | + echo "CXXFLAGS = -O3 -Wall -pedantic -frtti -stdlib=libc++ -Wp,-D_FORTIFY_SOURCE=3" >> /root/.R/Makevars && \ |
| 197 | + echo "CXX11FLAGS = -O3 -Wall -pedantic -frtti -stdlib=libc++ -Wp,-D_FORTIFY_SOURCE=3" >> /root/.R/Makevars && \ |
| 198 | + echo "CXX14FLAGS = -O3 -Wall -pedantic -frtti -stdlib=libc++ -Wp,-D_FORTIFY_SOURCE=3" >> /root/.R/Makevars && \ |
| 199 | + echo "CXX17FLAGS = -O3 -Wall -pedantic -frtti -stdlib=libc++ -Wp,-D_FORTIFY_SOURCE=3" >> /root/.R/Makevars && \ |
| 200 | + echo "CXX20FLAGS = -O3 -Wall -pedantic -frtti -stdlib=libc++ -Wp,-D_FORTIFY_SOURCE=3" >> /root/.R/Makevars && \ |
| 201 | + echo "FFLAGS = -O2 -pedantic" >> /root/.R/Makevars && \ |
| 202 | + echo "LDFLAGS = -fuse-ld=lld" >> /root/.R/Makevars |
| 203 | + |
| 204 | +# Configure image and install Arrow-specific tooling |
| 205 | +COPY ci/scripts/r_docker_configure.sh /arrow/ci/scripts/ |
| 206 | +COPY ci/etc/rprofile /arrow/ci/etc/ |
| 207 | +COPY ci/scripts/r_install_system_dependencies.sh /arrow/ci/scripts/ |
| 208 | +COPY ci/scripts/install_minio.sh /arrow/ci/scripts/ |
| 209 | +COPY ci/scripts/install_gcs_testbench.sh /arrow/ci/scripts/ |
| 210 | +RUN /arrow/ci/scripts/r_docker_configure.sh |
| 211 | + |
| 212 | +# Install sccache |
| 213 | +COPY ci/scripts/install_sccache.sh /arrow/ci/scripts/ |
| 214 | +RUN /arrow/ci/scripts/install_sccache.sh unknown-linux-musl /usr/local/bin |
| 215 | + |
| 216 | +# Install R package dependencies |
| 217 | +COPY ci/scripts/r_deps.sh /arrow/ci/scripts/ |
| 218 | +COPY r/DESCRIPTION /arrow/r/ |
| 219 | +RUN /arrow/ci/scripts/r_deps.sh /arrow |
| 220 | + |
| 221 | +# Verify setup |
| 222 | +RUN R --version && \ |
| 223 | + clang --version && \ |
| 224 | + R -e "sessionInfo()" |
0 commit comments