Compiling Error after Upgrading to macOS Big Sur 11.2.3

After accidentally upgrading to Big Sur 11.2.3, the stan program I have been running via pystan no long compiles. The error message is

Traceback (most recent call last):
File “/Users/codywan/opt/anaconda3/lib/python3.8/distutils/unixccompiler.py”, line 205, in link
self.spawn(linker + ld_args)
File “/Users/codywan/opt/anaconda3/lib/python3.8/distutils/ccompiler.py”, line 910, in spawn
spawn(cmd, dry_run=self.dry_run)
File “/Users/codywan/opt/anaconda3/lib/python3.8/distutils/spawn.py”, line 36, in spawn
_spawn_posix(cmd, search_path, dry_run=dry_run)
File “/Users/codywan/opt/anaconda3/lib/python3.8/distutils/spawn.py”, line 157, in _spawn_posix
raise DistutilsExecError(
distutils.errors.DistutilsExecError: command ‘x86_64-apple-darwin13.4.0-clang++’ failed with exit status 1

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File “utils/run_stan.py”, line 34, in
sm = pystan.StanModel(model_code=model)
File “/Users/codywan/opt/anaconda3/lib/python3.8/site-packages/pystan/model.py”, line 378, in init
build_extension.run()
File “/Users/codywan/opt/anaconda3/lib/python3.8/distutils/command/build_ext.py”, line 340, in run
self.build_extensions()
File “/Users/codywan/opt/anaconda3/lib/python3.8/distutils/command/build_ext.py”, line 449, in build_extensions
self._build_extensions_serial()
File “/Users/codywan/opt/anaconda3/lib/python3.8/distutils/command/build_ext.py”, line 474, in _build_extensions_serial
self.build_extension(ext)
File “/Users/codywan/opt/anaconda3/lib/python3.8/distutils/command/build_ext.py”, line 550, in build_extension
self.compiler.link_shared_object(
File “/Users/codywan/opt/anaconda3/lib/python3.8/distutils/ccompiler.py”, line 713, in link_shared_object
self.link(CCompiler.SHARED_OBJECT, objects,
File “/Users/codywan/opt/anaconda3/lib/python3.8/distutils/unixccompiler.py”, line 207, in link
raise LinkError(msg)
distutils.errors.LinkError: command ‘x86_64-apple-darwin13.4.0-clang++’ failed with exit status 1

I’ve checked out this post (Compiling error after upgrading to MacOS Big Sur - #3 by Mustafa_Burak_Dogruel) and tried their fix but it didn’t work. It was prob a different issue. I know very little about compiling and linking, so any help is much appreciated!

P.S. I’m using pystan2, and my gcc version is

Configured with: --prefix=/Library/Developer/CommandLineTools/usr --with-gxx-include-dir=/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/4.2.1
Apple clang version 12.0.0 (clang-1200.0.32.29)
Target: x86_64-apple-darwin20.3.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin

Can you try compiling with verbose=True

Sure thing. After running with verbose=True, there’s a lot of console output, so I copied and pasted them to a text file here.
error.txt (1.4 MB)

Ok, this line is the important

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

So, there have been similar errors before

Can you try solution mentioned here