build error with address sanitizer
After this with current master
CC=gcc-10 LDFLAGS='-g -fsanitize=address' CFLAGS='-g -fsanitize=address' ./configure skx
make fails:
Compiling obj/skx/kernels/haswell/3/sup/bli_gemmsup_rd_haswell_asm_d6x8m.o ('skx' CFLAGS for kernels) In file included from kernels/haswell/3/sup/bli_gemmsup_rd_haswell_asm_d6x8m.c:39: kernels/haswell/3/sup/bli_gemmsup_rd_haswell_asm_d6x8m.c: In function ‘bli_dgemmsup_rd_haswell_asm_6x4m’: ./frame/include/bli_x86_asm_macros.h:102:21: error: ‘asm’ operand has impossible constraints 102 | #define BEGIN_ASM() asm volatile ( | ^~~~~~~ ./frame/include/bli_x86_asm_macros.h:153:21: note: in expansion of macro ‘BEGIN_ASM’ 153 | #define begin_asm() BEGIN_ASM() | ^~~~~~~~~ kernels/haswell/3/sup/bli_gemmsup_rd_haswell_asm_d6x8m.c:766:2: note: in expansion of macro ‘begin_asm’ 766 | begin_asm() | ^~~~~~~~~
https://stackoverflow.com/questions/25579759/gcc-inline-assembly-what-does-asm-operand-has-impossible-constraints-mean suggests this is related to the frame pointer stuff Devin had to deal with recently.
In any case, I am not sure that debugging huge blobs of assembly with Clang Address Sanitizer is going to be productive.
Yes, you have to make sure -fomit-frame-pointer is in there for the assembly kernels to work correctly. If you are going to modify the CFLAGS, I suggest first configuring with configure -dnoopt and then going into the .mk files to add the -fsanitize=address to the global flags manually. This way all the extra flags won't get dropped.
The FLAGS variables are documented as prepended. As far as I remember I asked for them to be more-or-less consistent with autoconf specifically to work with packaging, and I think I'd have noticed if that changed.
I suppose I should have reported with V=1. Anyway -fomit-frame-pointer is the GCC default with -O up, whether or not it has an effect on a target. (That doesn't stop it being often recommended, possibly from long ago on x86, but I forget details from the era.)
gcc-10 -O2 -O3 -fomit-frame-pointer -mavx512f -mavx512dq -mavx512bw -mavx512vl -mfpmath=sse -march=skylake-avx512 -g -fsanitize=address -Wall -Wno-unused-function -Wfatal-errors -fPIC -std=c99 -D_POSIX_C_SOURCE=200112L -Iinclude/skx -I./frame/3/ -I./frame/ind/ukernels/ -I./frame/3/ -I./frame/1m/ -I./frame/1f/ -I./frame/1/ -I./frame/include -DBLIS_VERSION_STRING="0.7.0-40" -DBLIS_IS_BUILDING_LIBRARY -fvisibility=hidden -c kernels/haswell/3/sup/bli_gemmsup_rd_haswell_asm_d6x8m.c -o obj/skx/kernels/haswell/3/sup/bli_gemmsup_rd_haswell_asm_d6x8m.o In file included from kernels/haswell/3/sup/bli_gemmsup_rd_haswell_asm_d6x8m.c:39: kernels/haswell/3/sup/bli_gemmsup_rd_haswell_asm_d6x8m.c: In function ‘bli_dgemmsup_rd_haswell_asm_6x4m’: ./frame/include/bli_x86_asm_macros.h:102:21: error: ‘asm’ operand has impossible constraints 102 | #define BEGIN_ASM() asm volatile ( | ^~~~~~~ ./frame/include/bli_x86_asm_macros.h:153:21: note: in expansion of macro ‘BEGIN_ASM’ 153 | #define begin_asm() BEGIN_ASM() | ^~~~~~~~~ kernels/haswell/3/sup/bli_gemmsup_rd_haswell_asm_d6x8m.c:766:2: note: in expansion of macro ‘begin_asm’ 766 | begin_asm() | ^~~~~~~~~
If the sanitizer is wrong, it would be useful to make a bug report -- I assume against GCC, even if it's inherited from LLVM.
@loveshack can you try adding -fomit-frame-pointer again after -g -fsanitize=address? Alternatively, if the exercise is just to determine if any addressing errors occur, you can leave out the -g which should help.
The "real" solution is to just not use bp in any x86 kernels, as this also causes problems elsewhere (e.g. #504). I'll keep this open as a linked issue to #504.