Skip to content

Commit 7b0a448

Browse files
amboardas
authored andcommitted
lock: Avoid use of undefined DISPATCH_INTERNAL_CRASH
Building swift-corelibs-libdispatch on powerpc64le under Linux lead to the following build failure: /bin/bash ../libtool --tag=CXX --mode=compile /home/ubuntu/swift-dev/build/buildbot_incremental/llvm-linux-powerpc64le/bin/clang++ -DHAVE_CONFIG_H -I. -I../config -I.. -I.. -I../private -DDISPATCH_USE_DTRACE=0 -I../libpwq/include -Wall -fvisibility=hidden -momit-leaf-frame-pointer -isystem /usr/include/bsd -DLIBBSD_OVERLAY -fblocks -I../src/BlocksRuntime -std=gnu++11 -fno-exceptions -O2 -c -o libdispatch_la-block.lo `test -f 'block.cpp' || echo './'`block.cpp libtool: compile: /home/ubuntu/swift-dev/build/buildbot_incremental/llvm-linux-powerpc64le/bin/clang++ -DHAVE_CONFIG_H -I. -I../config -I.. -I.. -I../private -DDISPATCH_USE_DTRACE=0 -I../libpwq/include -Wall -fvisibility=hidden -momit-leaf-frame-pointer -isystem /usr/include/bsd -DLIBBSD_OVERLAY -fblocks -I../src/BlocksRuntime -std=gnu++11 -fno-exce ptions -O2 -c block.cpp -fPIC -DPIC -o .libs/libdispatch_la-block.o In file included from block.cpp:32: In file included from ./internal.h:628: In file included from ./shims.h:171: ./shims/lock.h:550:3: error: use of undeclared identifier 'DISPATCH_INTERNAL_CRASH' DISPATCH_INTERNAL_CRASH(errno, "sys_membarrier not supported"); ^ 1 error generated. Makefile:701: recipe for target 'libdispatch_la-block.lo' failed make[2]: *** [libdispatch_la-block.lo] Error 1 make[2]: Leaving directory '/home/ubuntu/swift-dev/swift-corelibs-libdispatch/src' Makefile:541: recipe for target 'all' failed make[1]: *** [all] Error 2 make[1]: Leaving directory '/home/ubuntu/swift-dev/swift-corelibs-libdispatch/src' Makefile:457: recipe for target 'all-recursive' failed make: *** [all-recursive] Error 1 Include ordering in internal.h is tightly constrained, so open-code the macro to avoid the dependency problem. Signed-off-by: Andrew Jeffery <andrew@aj.id.au> Signed-off-by: Daniel A. Steffen <dsteffen@apple.com>
1 parent 00e7e55 commit 7b0a448

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/shims/lock.h

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -548,7 +548,17 @@ _dispatch_once_xchg_done(dispatch_once_t *pred)
548548
return os_atomic_xchg(pred, DLOCK_ONCE_DONE, release);
549549
#elif defined(__linux__)
550550
if (unlikely(syscall(__NR_membarrier, MEMBARRIER_CMD_SHARED, 0) < 0)) {
551-
DISPATCH_INTERNAL_CRASH(errno, "sys_membarrier not supported");
551+
/*
552+
* sys_membarrier not supported
553+
*
554+
* Ideally we would call DISPATCH_INTERNAL_CRASH() here, but
555+
* due to ordering constraints in internal.h required by Darwin
556+
* the macro is undefined when this header is included.
557+
* Instead, open-code what would be a call to
558+
* _dispatch_hardware_crash() inside DISPATCH_INTERNAL_CRASH().
559+
*/
560+
__asm__("");
561+
__builtin_trap();
552562
}
553563
return os_atomic_xchg(pred, DLOCK_ONCE_DONE, relaxed);
554564
#else

0 commit comments

Comments
 (0)