Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[armv6][5.0] Cannot select: intrinsic %llvm.arm.clrex #44

Open
uraimo opened this issue Apr 8, 2019 · 3 comments
Open

[armv6][5.0] Cannot select: intrinsic %llvm.arm.clrex #44

uraimo opened this issue Apr 8, 2019 · 3 comments

Comments

@uraimo
Copy link
Owner

uraimo commented Apr 8, 2019

On a Raspberry Pi Zero, while compiling libdispatch:

+ /usr/bin/cmake --build /home/pi/buildSwiftOnARM/build/buildbot_linux/swift-linux-armv6 -- -j1 all swift-test-stdlib-linux-armv6
[1/51] Performing build step for 'libdispatch'
FAILED: tools/SourceKit/libdispatch-prefix/src/libdispatch-stamp/libdispatch-build tools/SourceKit/libdispatch-prefix/lib/libdispatch.so tools/SourceKit/libdispatch-prefix
/lib/dispatch tools/SourceKit/libdispatch-prefix/lib/libBlocksRuntime.so tools/SourceKit/libdispatch-prefix/lib/BlocksRuntime
cd /home/pi/buildSwiftOnARM/build/buildbot_linux/swift-linux-armv6/tools/SourceKit/libdispatch-prefix/src/libdispatch-build && /usr/bin/cmake --build .
[1/3] Building CXX object src/CMakeFiles/dispatch.dir/block.cpp.o
[2/3] Building C object src/CMakeFiles/dispatch.dir/shims/yield.c.o
FAILED: src/CMakeFiles/dispatch.dir/shims/yield.c.o
/usr/bin/clang  -DDISPATCH_USE_DTRACE=0 -DHAVE_CONFIG_H -D_GNU_SOURCE=1 -Ddispatch_EXPORTS -isystem /home/pi/buildSwiftOnARM/swift-corelibs-libdispatch/src/BlocksRuntime -
I. -I/home/pi/buildSwiftOnARM/swift-corelibs-libdispatch -I/home/pi/buildSwiftOnARM/swift-corelibs-libdispatch/src -Isrc -I/home/pi/buildSwiftOnARM/swift-corelibs-libdispa
tch/private -Wno-unknown-warning-option -Werror=unguarded-availability-new -fno-stack-protector -fPIC -Werror=date-time -Werror=unguarded-availability-new -Wall -Wextra -W
no-unused-parameter -Wwrite-strings -Wmissing-field-initializers -Wcovered-switch-default -Wdelete-non-virtual-dtor -Wstring-conversion -fdiagnostics-color -ffunction-sect
ions -fdata-sections -O3 -DNDEBUG -fPIC -fvisibility=hidden   -Werror -Wall -Wextra -Warray-bounds-pointer-arithmetic -Wassign-enum -Watomic-properties -Wcomma -Wcondition
al-uninitialized -Wconversion -Wcovered-switch-default -Wdate-time -Wdeprecated -Wdocumentation -Wdouble-promotion -Wduplicate-enum -Wexpansion-to-defined -Wfloat-equal -Widiomatic-parentheses -Winfinite-recursion -Wmissing-prototypes -Wnewline-eof -Wnullable-to-nonnull-conversion -Wobjc-interface-ivars -Wover-aligned -Wpacked -Wpointer-ar$th -Wselector -Wshadow -Wshorten-64-to-32 -Wsign-conversion -Wstatic-in-inline -Wsuper-class-method-mismatch -Wswitch-enum -Wunguarded-availability -Wunreachable-code -Wu$used -Wno-unknown-warning-option -Wno-trigraphs -Wno-four-char-constants -Wno-disabled-macro-expansion -Wno-pedantic -Wno-bad-function-cast -Wno-c++-compat -Wno-c++98-com$at -Wno-c++98-compat-pedantic -Wno-cast-align -Wno-cast-qual -Wno-documentation-unknown-command -Wno-format-nonliteral -Wno-missing-variable-declarations -Wno-old-style-c$st -Wno-padded -Wno-reserved-id-macro -Wno-shift-sign-overflow -Wno-undef -Wno-unreachable-code-aggressive -Wno-unused-macros -Wno-used-but-marked-unused -Wno-vla -Wno-er$or=assign-enum -fno-exceptions -isystem /usr/include/bsd -DLIBBSD_OVERLAY -fblocks -momit-leaf-frame-pointer -pthread -std=gnu11 -MD -MT src/CMakeFiles/dispatch.dir/shims$yield.c.o -MF src/CMakeFiles/dispatch.dir/shims/yield.c.o.d -o src/CMakeFiles/dispatch.dir/shims/yield.c.o   -c /home/pi/buildSwiftOnARM/swift-corelibs-libdispatch/src/sh$ms/yield.c
fatal error: error in backend: Cannot select: intrinsic %llvm.arm.clrex
clang: error: clang frontend command failed with exit code 70 (use -v to see invocation)
clang version 3.8.1-24+rpi1 (tags/RELEASE_381/final)
Target: armv6--linux-gnueabihf
Thread model: posix
InstalledDir: /usr/bin
clang: note: diagnostic msg: PLEASE submit a bug report to http://llvm.org/bugs/ and include the crash backtrace, preprocessed source, and associated run script.
clang: note: diagnostic msg:
********************

PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
Preprocessed source(s) and associated run script(s) are located at:
clang: note: diagnostic msg: /tmp/yield-47a628.c
clang: note: diagnostic msg: /tmp/yield-47a628.sh
clang: note: diagnostic msg:

********************
ninja: build stopped: subcommand failed.
ninja: build stopped: subcommand failed.
./swift/utils/build-script: fatal error: command terminated with a non-zero exit status 1, aborting
@uraimo uraimo added the 5.0 label Apr 8, 2019
@uraimo
Copy link
Owner Author

uraimo commented Apr 8, 2019

clrex is available on ARMv6k/v7+ as confirmed here:

Architectures

This ARM instruction is available in ARMv6K and above.

This 32-bit Thumb-2 instruction is available in ARMv7 and above.

There is no 16-bit Thumb CLREX instruction

The Raspberry Pi Zero is identified as an armv6l (I don't know enough about the armv6 variants but it's possible that the basic armv6l does not support clrex and other related instructions like LDREX and STREX).

A quick search leads to another issue addressed by William, two years ago (armv6l variant added to the armv6 family).

This issue is the result of this:

#if defined(__arm__) || defined(__arm64__)
	int spins = DISPATCH_WAIT_SPINS_WFE;
	void *value;
	while (unlikely(spins-- > 0)) {
		if (likely(value = __builtin_arm_ldrex(ptr))) {
			__builtin_arm_clrex();
			return value;
		}
		__builtin_arm_wfe();
	}
#else

That generic #if defined(__arm__) makes no difference between the various arm32 variants.
Will look into it.

Note: Could we just use dispatch_hardware_pause defined here?

@uraimo
Copy link
Owner Author

uraimo commented Apr 10, 2019

Temporary workaround: 7903180

@uraimo
Copy link
Owner Author

uraimo commented May 16, 2019

CLREX should be a thumb2 instruction, so a proper fix would check for (defined(__arm__) && defined(_ARM_ARCH_7)) or defined(__thumb2__) if it's available.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant