randombit / botan

Cryptography Toolkit
https://botan.randombit.net
BSD 2-Clause "Simplified" License
2.59k stars 570 forks source link

Current master fails to link on MacOS (Apple Silicon M2) with Xcode-16 #4348

Closed mouse07410 closed 1 month ago

mouse07410 commented 2 months ago

Something changed with the upgrade from Xcode-15.x to Xcode-16.0. As a result, I cannot link botan anymore:

build:

.  .  .
-L/opt/local/lib/libomp -lomp -L/opt/local/libexec/boost/1.81/lib  -lbotan-3 -L/opt/local/lib/libomp -lomp -L/opt/local/libexec/boost/1.81/lib   -lbz2 -ldl -llzma -lsqlite3 -lz -framework CoreFoundation -framework Security  -o botan-test3
ld: warning: ignoring duplicate libraries: '-lomp'
ld: warning: reexported library with install name '@rpath/libunwind.1.dylib' found at '/opt/local/libexec/llvm-18/lib/libunwind.1.0.dylib' couldn't be matched with any parent library and will be linked directly
dyld[2670]: Symbol not found: __ZNSt13exception_ptr31__from_native_exception_pointerEPv
  Referenced from: <7F40720F-BA53-3688-8474-1BBCE54D4A78> /Users/ur20980/src/botan/botan-test3
  Expected in:     <C4E10D69-6F13-32B1-831D-82DA32D7DB88> /usr/lib/libc++.1.dylib

and attempt to run the created executable (I install it as botan3 to avoid collision with botan from Botan-2 package):

$ botan3 help
dyld[25331]: Symbol not found: __ZNSt13exception_ptr31__from_native_exception_pointerEPv
  Referenced from: <F9E7EE19-E8BF-34BF-9E55-B26E71651C29> /opt/local/bin/botan3
  Expected in:     <C4E10D69-6F13-32B1-831D-82DA32D7DB88> /usr/lib/libc++.1.dylib
zsh: abort      botan3 help
$ 

MacOS Sonoma 14.7, Xcode-16.0.

Update

I forgot the most important part: the underlying hardware is Apple Silicon M2 Max. In other words, Apple ARM. On Intel-based Mac it compiles and works OK. It also compiles fine on M2 with Xcode-15.4. But Apple Silicon with Xcode-16.0 or Xcode-16.1-beta2 manifest this problem.

mouse07410 commented 1 month ago

Found the culprit. :-(

My build script was adding -D_LIBCPP_DISABLE_AVAILABILITY flag - I don't recall now when or why it was added.

Removing it restored the build. Sorry for the noise!

P.S. If you understand what was going on, could you please kindly enlighten me?