ctfmerge: fix segfault when building on macOS
The barrier code was using semaphores which have been deprecated in
macOS and not working at all, causing a race condition. Since macOS
does not have pthread_barrier_*(), this change uses a condition
variable instead.
PR: 290958
Reported by: wosch
Reviewed by: imp, markj
Differential Revision: https://reviews.freebsd.org/D54018
(cherry picked from commit 732b4aa05d78ca6831d02e67a43f34ad104f4f01)