dart-lang / sdk

The Dart SDK, including the VM, JS and Wasm compilers, analysis, core libraries, and more.
https://dart.dev
BSD 3-Clause "New" or "Revised" License
10.19k stars 1.57k forks source link

Compilation failure: Inline asm clobber list contains reserved registers #46873

Closed ardera closed 3 years ago

ardera commented 3 years ago

I'm currently cross-compiling the flutter engine for arm (armv7a-linux-gnueabihf), and that worked more or less fine for the last 2 years, but now suddenly compiling the engine throws an error in a file of the dart SDK (actually a warning, but it's an error because of -Werror):

hannes@pop-os:~/devel/flutter_engine/engine_out/out/linux_debug_arm$ ninja
[2236/6719] CXX obj/third_party/dart/runtime/vm/libdart_vm_jit.thread_interrupter_linux.o
FAILED: obj/third_party/dart/runtime/vm/libdart_vm_jit.thread_interrupter_linux.o 
../../../engine/src/buildtools/linux-x64/clang/bin/clang++ -MD -MF obj/third_party/dart/runtime/vm/libdart_vm_jit.thread_interrupter_linux.o.d -DUSE_OPENSSL=1 -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D_LIBCPP_DISABLE_AVAILABILITY=1 -D_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS -D_LIBCPP_ENABLE_THREAD_SAFETY_ANNOTATIONS -DNDEBUG -DNVALGRIND -DDYNAMIC_ANNOTATIONS_ENABLED=0 -DTARGET_ARCH_ARM -DDART_TARGET_OS_LINUX -DU_USING_ICU_NAMESPACE=0 -DU_ENABLE_DYLOAD=0 -DUSE_CHROMIUM_ICU=1 -DU_ENABLE_TRACING=1 -DU_ENABLE_RESOURCE_TRACING=0 -DU_STATIC_IMPLEMENTATION -DICU_UTIL_DATA_IMPL=ICU_UTIL_DATA_FILE -I../../../engine/src/third_party/dart/runtime -I../../../engine/src -Igen -I../../../engine/src/third_party/libcxx/include -I../../../engine/src/third_party/libcxxabi/include -I../../../engine/src/third_party/dart/runtime/include -I../../../engine/src/third_party/icu/source/common -I../../../engine/src/third_party/icu/source/i18n -fno-strict-aliasing -fstack-protector --param=ssp-buffer-size=4 --target=armv7a-linux-gnueabihf -fPIC -pipe -pthread -fcolor-diagnostics -mfpu=neon -Wall -Wextra -Wendif-labels -Werror -Wno-missing-field-initializers -Wno-unused-parameter -Wno-unused-but-set-parameter -Wno-unused-but-set-variable -Wno-implicit-int-float-conversion -Wno-c99-designator -Wno-deprecated-copy -Wno-psabi -Wno-non-c-typedef-for-linkage -Wno-range-loop-construct -fvisibility=hidden --sysroot=/home/hannes/devel/flutter_engine/engine/src/build/linux/debian_sid_arm-sysroot -Wstring-conversion -Wnewline-eof -O2 -fno-ident -fdata-sections -ffunction-sections -g0 -Werror -Wall -Wextra -Wno-unused-parameter -Wno-unused-private-field -Wnon-virtual-dtor -Wvla -Woverloaded-virtual -Wno-comments -g3 -ggdb3 -fno-rtti -fno-exceptions -Wimplicit-fallthrough -O3 -fvisibility-inlines-hidden -std=c++17 -fno-rtti -nostdinc++ -nostdinc++ -fno-exceptions   -c ../../../engine/src/third_party/dart/runtime/vm/thread_interrupter_linux.cc -o obj/third_party/dart/runtime/vm/libdart_vm_jit.thread_interrupter_linux.o
In file included from ../../../engine/src/third_party/dart/runtime/vm/thread_interrupter_linux.cc:12:
In file included from ../../../engine/src/third_party/dart/runtime/vm/profiler.h:19:
In file included from ../../../engine/src/third_party/dart/runtime/vm/thread_interrupter.h:10:
../../../engine/src/third_party/dart/runtime/vm/signal_handler.h:99:18: error: inline asm clobber list contains reserved registers: SP [-Werror,-Winline-asm]
    asm volatile("nop; nop; nop; nop;"
                 ^
../../../engine/src/third_party/dart/runtime/vm/signal_handler.h:99:18: note: Reserved registers on the clobber list may not be preserved across the asm statement, and clobbering them may lead to undefined behaviour.
1 error generated.
[2253/6719] CXX obj/third_party/dart/runtime/vm/libdart_vm_jit.object.o
ninja: build stopped: subcommand failed.

The part of the file with the asm volatile("nop; nop; nop; nop;") didn't change for the last few years, and -Winline-asm also exists since 2018 or so. Maybe the upgrade to clang 13 changed something and SP is now a reserved register?

Anyway, it's only a workaround for linux kernels < 3.18, so maybe it can be removed now that that kernel version is no longer supported by any maintained android version or linux distro?

a-siva commented 3 years ago

/cc @mraleph can the work around introduced in https://github.com/dart-lang/sdk/commit/b089d4f0040c be removed.

mraleph commented 3 years ago

@a-siva https://flutter.dev/docs/development/tools/sdk/release-notes/supported-platforms says Flutter supports API level >=19 which corresponds to Kit Kat or later Android versions which in turn corresponds to Kernel version 3.10. This probably means we have to keep this code around (even though it is unlikely that anybody is actually developing on a Kit Kat device). 3.18 kernel arrived in Marshmallow (API level 23).

mraleph commented 3 years ago

I have made a CL that should fix the compilation error: https://dart-review.googlesource.com/c/sdk/+/209917