@@ -65,6 +65,10 @@ class R < Formula
6565 # needed to preserve executable permissions on files without shebangs
6666 skip_clean "lib/R/bin" , "lib/R/doc"
6767
68+ # Fix build with clang 17
69+ # https://github.com/wch/r-source/commit/489a6b8d330bb30da82329f1949f44a0f633f1e8
70+ patch :DATA
71+
6872 def install
6973 # `configure` doesn't like curl 8+, but convince it that everything is ok.
7074 # TODO: report this upstream.
@@ -165,3 +169,28 @@ def post_install
165169 shell_output ( "#{ bin } /Rscript -e 'library(tcltk)' -e 'tclvalue(.Tcl(\" tk windowingsystem\" ))'" ) . chomp
166170 end
167171end
172+ __END__
173+ diff -pur R-4.5.0/src/nmath/mlutils.c R-4.5.0-patched/src/nmath/mlutils.c
174+ --- R-4.5.0/src/nmath/mlutils.c 2025-03-14 00:02:15
175+ +++ R-4.5.0-patched/src/nmath/mlutils.c 2025-05-24 12:16:15
176+ @@ -105,7 +105,20 @@ double R_pow_di(double x, int n)
177+ return pow;
178+ }
179+
180+ +/* It is not clear why these are being defined in standalone nmath:
181+ + * but that they are is stated in the R-admin manual.
182+ + *
183+ + * In R NA_AREAL is a specific NaN computed during initialization.
184+ + */
185+ +#if defined(__clang__) && defined(NAN)
186+ +// C99 (optionally) has NAN, which is a float but will coerce to double.
187+ +double NA_REAL = NAN;
188+ +#else
189+ +// ML_NAN is defined as (0.0/0.0) in nmath.h
190+ +// Fails to compile in Intel ics 2025.0, Apple clang 17, LLVM clang 20
191+ double NA_REAL = ML_NAN;
192+ +#endif
193+ +
194+ double R_PosInf = ML_POSINF, R_NegInf = ML_NEGINF;
195+
196+ #include <stdio.h>
0 commit comments