ContinuumIO / anaconda-issues

Anaconda issue tracking
646 stars 220 forks source link

Compiling fortran fails in a conda environment on MacOS Ventura with Xcode 14 #13087

Open jo2267 opened 1 year ago

jo2267 commented 1 year ago

Checklist

Impacted product

What happened?

After I started using MacOS Ventura with Xcode 14, compiling a Fortran code in a conda environment fails. The error seems to be due to ld of Anaconda:

ld: unsupported tapi file type '!tapi-tbd' in YAML file '/Library/Developer/CommandLineTools/SDKs/MacOSX12.sdk/usr/lib/libSystem.tbd' for architecture x86_64

The ld in Anaconda3/bin/ supports only Apple TAPI version 10.0.0

@(#)PROGRAM:ld PROJECT:ld64-530 BUILD 07:42:29 Sep 7 2022 configured to support archs: armv6 armv7 armv7s arm64 arm64e arm64_32 i386 x86_64 x86_64h armv6m armv7k armv7m armv7em (tvOS) LTO support using: LLVM version 14.0.6 (static support for 26, runtime is 29) TAPI support using: Apple TAPI version 10.0.0 (tapi-1000.10.8)

Outside Anaconda, compiling works and the ld in /usr/bin/ supports Apple TAPI version 14.0.0

@(#)PROGRAM:ld PROJECT:ld64-819.6 BUILD 21:47:27 Sep 13 2022 configured to support archs: armv6 armv7 armv7s arm64 arm64e arm64_32 i386 x86_64 x86_64h armv6m armv7k armv7m armv7em LTO support using: LLVM version 14.0.0, (clang-1400.0.29.102) (static support for 29, runtime is 29) TAPI support using: Apple TAPI version 14.0.0 (tapi-1400.0.11)

To fix the problem, first, I tried both Xcode 14.01 and 14.1 (13.4 was incompatible with Ventura), but they didn't work.

Second, I tried using old SDK following here, but this also didn't work.

I want to stay in a conda environment managing python tools combined with Fortran, instead of compiling Fortran code outside conda environments every time.

Expected behavior or outcome

ld in Anaconda3/bin supports recent tapi versions for Mac OS Ventura.

Conda info

No response

Conda config

No response

Conda list

No response

Additional information

No response

stefanomattia commented 1 year ago

I am having the same problem, did you happen to find a solution? My temporary workaround was to use gfortran installed via home-brew (brew install gcc), and temporary removing /opt/anaconda3/bin from my PATH.

jo2267 commented 1 year ago

Unfortunately, the problem is still unsolved. I need to deactivate the conda environment and compile as you said. The problem seems that 13.0 SDK, which is the only the compatible version for Xcode 14, is too new for the linker (ld in conda).

jo2267 commented 1 year ago

I found that any created environment (i.e., except the base environment) ld supports TAPI version 14.0.0. on my macOS and I can compile my fortran code.

ivanfei-1 commented 1 year ago

You cannot simply upgrade tapi beacuse (anaconda -> requires tapi==1000.10.8=ha1b3eb9_0) anaconda itself requires this spacific version.

However, after runnig conda update --all to upgrade anaconda, I tried conda upgrade tapi again and it was now upgraded to 11.0.0.

I have no idea why there aren't newer distributions, it's very likely that anaconda itself depends on the spacific version to work.

But at least this approach gets me out of 10.0.0.

jo2267 commented 1 year ago

Thanks. Somehow your method doesn't work on my Mac, but if you can upgrade tapi, maybe it solves the problem. I also found a similar discussion here.

https://stackoverflow.com/questions/74318052/cant-compile-fortran-on-macos-monterey-ld-unsupported-tapi-file-type-tapi-t

edbennett commented 5 months ago

FWIW, the same issue occurs on Sonoma with tapi 11.0.