Using f2py on macOS Monterey 12.5 (Xcode 13.4.1) with python 3.9.13 gives error

I use f2py to compile the file barotropic.f90 from the module 'model2roms' (https://github.com/trondkr/model2roms).

My installations are: macOS Monterey 12.5 Xcode 13.4.1 Python 3.9.13

When I run: f2py -c -m barotropic barotropic.f90      

Then the log shows:

The problem seems to be in this line: ld: unsupported tapi file type '!tapi-tbd' in YAML file '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/lib/libSystem.tbd' for architecture x86_64

I think it is weird that I run macOS 12.5, but f2py refers to 'src.macosx-10.9-x86_64-3.9'

Does anyone know why I get this error and how I can solve it?

I already tried:

$ brew upgrade llvm

$ brew upgrade gcc

$ sudo rm -rf /Library/Developer/CommandLineTools

$ xcode-select --install

And I tried to downgrade Xcode to an older version

ld: unsupported tapi file type '!tapi-tbd' in YAML file

I think it is weird that I run macOS 12.5, but f2py refers to src.macosx-10.9-x86_64-3.9

Right. I’m not able to help with your specific problem — there’s way too much third-party tooling in play here and my focus is on Apple’s platforms and tools — but I can at least explain the error.

To start, let’s talk about .tbd files. Actually, let me just point you at this post, which explains the backstory. In short, a .tbd file is a YAML file that acts as a stub library.

These .tbd files debuted with the macOS 10.11 SDK. Since then they’ve gone through a number of different versions:

  • The macOS 10.11 SDK has no version information. For example, libSystem.tbd [1] starts like this:

    ---
    … lots of content …
    
  • The macOS 10.12 and 10.13 SDKs use version 2:

    --- !tapi-tbd-v2
    … lots of content …
    
  • The macOS 10.14 and 10.15 SDKs use version 3:

    --- !tapi-tbd-v3
    … lots of content …
    
  • The macOS 11, 12, and 13 beta SDKs use version 4:

    --- !tapi-tbd
    tbd-version:     4
    … lots of content …
    

This error indicates that you’re passing a .tbd file of version N to a linker that only understands version M, where M < N. This typically comes about because of a mismatch between the tools and the SDK. On Apple’s platforms the tools and SDK are effectively revlocked: You must use the SDK that came with the tools you’re using. For example, Xcode 13.4.1 includes the macOS 12.3 SDK and so its command-line tools are only guaranteed to work with that SDK.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

[1] libSystem.tbd is actually a symlink that points to libSystem.B.tbd.

This is what I did to solve the issue.

My environment is the following:

Xcode 14.0.1

macOS Monterrey 12.6

Python 3.8.5

I downloaded an old SDK version that works as expected (MacOSX10.9.sdk). I downloaded from phracker's github: git clone https://github.com/phracker/MacOSX-SDKs.git

I downloaded it into the SDKs folder created when installing xcode tools, and I set the CONDA_BUILD_SYSROOT to that path:

export CONDA_BUILD_SYSROOT="/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/manual/MacOSX-SDKs/MacOSX10.9.sdk"

After that the compilation worked successfully:

x86_64-apple-darwin13.4.0-clang /tmp/main.c -o /tmp/main.out

Hi there,

Thanks for sharing the solution! There are not many Mac Monterey F2py users out there haha. I am having the exact same problem, but your fix is not working for me. I think I just don't understand your last step. What command do you type to compile your code? Is that sill the  "f2py -c -m barotropic barotropic.f90 "??

I will deeply appreciate any help!

Thanks again

Gero

Using f2py on macOS Monterey 12.5 (Xcode 13.4.1) with python 3.9.13 gives error
 
 
Q