diff --git a/compiler-rt/test/ubsan/TestCases/Misc/monitor.cpp b/compiler-rt/test/ubsan/TestCases/Misc/monitor.cpp --- a/compiler-rt/test/ubsan/TestCases/Misc/monitor.cpp +++ b/compiler-rt/test/ubsan/TestCases/Misc/monitor.cpp @@ -8,6 +8,21 @@ // Linkage issue // XFAIL: openbsd +// Apple's dynamic linker won't weak-def_coalesce in this file unless there is +// at least one weak symbol and so this local __ubsan_on_report never has the +// chance to be linked in even though it may be seen first. The behavior of weak +// defined symbols in the context of dynamic linking is undefined and so this +// behavior does not violate any "rules" per-se. Obviously there are other +// platforms (above) that are having issues with the "strong-wins-over-weak" +// expectation but while it works that way when static linked, not so in all +// cases when dynamically linked. The weak symbol that gets the dynamic linker +// to consider this compilation unit doesn't even have to be __ubsan_on_report +// so the workaround until we move to a better pattern for registering what +// amounts to a callback, is just to add *any* weak symbol to the comp unit. +#if defined(__APPLE__) +int __attribute((weak)) foo; +#endif + #include extern "C" {