I’ve run into this problem before as well (not finding emutls_w), and have done 
a fair amount of research on it. Some key points of what I’ve learned:

R/CRAN, including the default R Makeconf assumes that you have a specific 
version/build of gfortran installed from https://mac.r-project.org/tools/:

- gfortran 4.2.3 for R 3.6 (https://cran.r-project.org/bin/macosx/tools/)
- gfortran 8.2 for intel R 4.0 through 4.2 
(https://github.com/fxcoudert/gfortran-for-macOS)
- gfortran 11.0.0 for arm64 R 4.1 
(https://mac.r-project.org/libs-arm64/gfortran-f51f1da0-darwin20.0-arm64.tar.gz)
- gfortran 12.0.1 for arm64 R 4.2 (https://github.com/R-macos/gcc-darwin-arm64)
- gfortran-12.2-universal.pkg for R 4.3 and 4.4 
(https://github.com/R-macos/gcc-12-branch)
- gfortran-14.2-universal.pkg (r-gfortran) for R 4.5 and newer 
(https://github.com/R-macos/gcc-14-branch)

If you’re using a different gfortran (for example, from Homebrew’s gcc 
formula), you’ll need a custom .R/Makevars (which you may need for other 
reasons, such as using libomp). (A copy of my Makevars is available here: 
https://github.com/jabenninghoff/macos-env/blob/master/R/Makevars). This is 
also discussed in an issue for rig: https://github.com/r-lib/rig/issues/207.

What I don’t know and don’t understand is why emutls_w (or heapt_w) are needed, 
does anyone here know? In the past, I’ve been able to build R packages from 
source with a custom FLIBS that doesn’t include either library, although I’ve 
now switched to using the official R gfortran.

Also, FWIW, I built a Homebrew cask to automate installation of R’s gfortran: 
https://github.com/jabenninghoff/homebrew-edge/blob/master/Casks/r-gfortran.rb.

Thanks,
John

> On Jan 26, 2026, at 10:25 AM, Adelchi Azzalini <[email protected]> wrote:
> 
> Updating to gfortran 14.2 led to successful checking of the package.
> Thanks, Ivan, for the effective suggestion. 
> The R version was already up to date.
> 
> best wishes 
> Adelchi
> 
> 
> 
> 
>> On 26 Jan 2026, at 16:01, Ivan Krylov <[email protected]> wrote:
>> 
>> В Mon, 26 Jan 2026 15:31:59 +0100
>> Adelchi Azzalini <[email protected]> пишет:
>> 
>>> It shows a long list of Fortran warning messages, many of them of the
>>> following form:
>>> 
>>> Warning: Possible change of value in conversion from REAL(8) to
>>> INTEGER(4) at (1) [-Wconversion]
>> 
>> These are also present in the compilation log for macOS on CRAN:
>> https://www.r-project.org/nosvn/R.check/r-release-macos-x86_64/mnormt-00install.html
>> 
>>> and finally
>>> ld: library 'emutls_w' not found
>>> clang: error: linker command failed with exit code 1 (use -v to see
>>> invocation)
>> 
>>> Since my macOS has recently been updated to version 26.2 (Tahoe) with
>>> a corresponding update of Xcode, I wonder whether this update has
>>> anything to do with these problems.
>> 
>> It's probably due to the toolchain version mismatch. What's your R
>> version? Maybe you need a newer gfortran, 14.2 instead of 12.2?
>> See https://mac.r-project.org/tools/ for download links.
>> 
>> -- 
>> Best regards,
>> Ivan
> 
> ______________________________________________
> [email protected] mailing list
> https://stat.ethz.ch/mailman/listinfo/r-package-devel


        [[alternative HTML version deleted]]

______________________________________________
[email protected] mailing list
https://stat.ethz.ch/mailman/listinfo/r-package-devel

Reply via email to