Previously, with Apple LLVM 9.1.0, is_lock_free()
on 128-bit structures have returned true. To have complete std::optional
support, I then upgraded to MacPorts gcc 7.3. During my first try to compile, I encountered this notorious showstopper linker error:
Undefined symbols for architecture x86_64:
"___atomic_compare_exchange_16", referenced from:
I know that I may need to add -latomic
. With Apple LLVM 9.1.0, I don't need it, and I have a very bad feeling about this. If it's lock-free, you usually should not need to link to any additional library, the compiler alone is able to handle it. Otherwise, it may just be lock-based and require support from additional library. Just as I have feared, after adding -latomic
, build succeeded, but is_lock_free()
returned false.
I do think gcc 7.3 and its standard library implementation are fine. It may just be some configuration problem on my side. As a matter of fact, I didn't do any configuration. I simply installed the MacPorts gcc and done. Any idea what I may be missing?
Found the answer myself here.