Bug 2172941

Summary: internal compiler error: in aarch64_layout_arg, at config/aarch64/aarch64.cc:7688
Product: [Fedora] Fedora Reporter: Germano Massullo <germano.massullo>
Component: gccAssignee: Jakub Jelinek <jakub>
Status: NEW --- QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 39CC: aoliva, dan, dmalcolm, fweimer, jakub, jlaw, jwakely, klember, mcermak, mpolacek, msebor, nickc, sipoyare
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 245418    
Attachments:
Description Flags
build.log
none
preprocessed source
none
preprocessed source none

Description Germano Massullo 2023-02-23 15:02:20 UTC
Created attachment 1945920 [details]
build.log

GCC 13.0.1-0.5.fc39

Good day, while building darktable 4.2.1 in rawhide I got following error

*** WARNING *** there are active plugins, do not report this as a bug unless you can reproduce it without enabling any plugins.
Event                            | Plugins
PLUGIN_FINISH_UNIT               | annobin: Generate final annotations
PLUGIN_START_UNIT                | annobin: Generate global annotations
PLUGIN_ALL_PASSES_START          | annobin: Generate per-function annotations
PLUGIN_ALL_PASSES_END            | annobin: Register per-function end symbols
during RTL pass: expand
/builddir/build/BUILD/darktable-4.2.1/src/common/color_vocabulary.c: In function 'Lch_to_color_name.part.0':
/builddir/build/BUILD/darktable-4.2.1/src/common/color_vocabulary.c:31:13: internal compiler error: in aarch64_layout_arg, at config/aarch64/aarch64.cc:7688
   31 | const char *Lch_to_color_name(dt_aligned_pixel_t color)
      |             ^


I am submitting this bugreport without trying to disable plugins since I have been told in fedora-devel that it is not necessary.
I attach build.log

Koji aarch64 build URL is https://koji.fedoraproject.org/koji/taskinfo?taskID=97894306

Parent Koji task https://koji.fedoraproject.org/koji/taskinfo?taskID=97894223

Comment 1 Dan Horák 2023-02-23 15:09:58 UTC
hmm, can't find the preprocessed sources on the builder, will try to reproduce it locally ...

Comment 2 Dan Horák 2023-02-23 15:48:19 UTC
ah, there is no preprocessed source, it in the LTO pass :-) Disabling LTO works the problem around.

Comment 3 Dan Horák 2023-02-23 16:38:34 UTC
The output when running the link command manually

/builddir/build/BUILD/darktable-4.2.1/src/common/bilateral.c:411:6: warning: GCC does not currently support mixed size types for ‘simd’ functions
  411 | void dt_bilateral_slice_to_output(const dt_bilateral_t *const b, const float *const in, float *out,
      |      ^
/builddir/build/BUILD/darktable-4.2.1/src/common/bilateral.c:364:6: warning: GCC does not currently support mixed size types for ‘simd’ functions
  364 | void dt_bilateral_slice(const dt_bilateral_t *const b, const float *const in, float *out, const float detail)
      |      ^
/builddir/build/BUILD/darktable-4.2.1/src/common/math.h:90:21: warning: GCC does not currently support mixed size types for ‘simd’ functions
   90 | static inline float Kahan_sum(const float m, float *const __restrict__ c, const float add)
      |                     ^
during RTL pass: expand
/builddir/build/BUILD/darktable-4.2.1/src/common/color_vocabulary.c: In function ‘Lch_to_color_name.part.0’:
/builddir/build/BUILD/darktable-4.2.1/src/common/color_vocabulary.c:31:13: internal compiler error: in aarch64_layout_arg, at config/aarch64/aarch64.cc:7688
   31 | const char *Lch_to_color_name(dt_aligned_pixel_t color)
      |             ^
Please submit a full bug report, with preprocessed source.
See <http://bugzilla.redhat.com/bugzilla> for instructions.
make: *** [/tmp/cczL0Mx7.mk:8: /tmp/cca58E4z.ltrans2.ltrans.o] Error 1
make: *** Waiting for unfinished jobs....
In function ‘alignedFree’,
    inlined from ‘__dt_base ’ at /builddir/build/BUILD/darktable-4.2.1/src/external/rawspeed/src/librawspeed/io/Buffer.h:121:26,
    inlined from ‘decodeRawInternal’ at /builddir/build/BUILD/darktable-4.2.1/src/external/rawspeed/src/librawspeed/decoders/IiqDecoder.cpp:223:1:
/builddir/build/BUILD/darktable-4.2.1/src/external/rawspeed/src/librawspeed/common/Memory.cpp:77:7: warning: ‘free’ called on pointer ‘_1->data’ with nonzero offset 8 [-Wfree-nonheap-object]
   77 |   free(ptr);                    // NOLINT
      |       ^
lto-wrapper: fatal error: make returned 2 exit status
compilation terminated.
/usr/bin/ld: error: lto-wrapper failed
collect2: error: ld returned 1 exit status

Comment 4 Jakub Jelinek 2023-02-23 16:58:36 UTC
find -type f | xargs grep Lch_to_color_name
./src/libs/colorpicker.c:  sample_parts[12] = g_strdup_printf("%6s", Lch_to_color_name(color));
./src/common/color_vocabulary.h:const char *Lch_to_color_name(dt_aligned_pixel_t color);
./src/common/color_vocabulary.c:const char *Lch_to_color_name(dt_aligned_pixel_t color)
Could you perhaps attach preprocessed source just for color_vocabulary.i and colorpicker.i + their gcc command lines?
With luck it could ICE on something like trying to link with -r the two objects together.

Otherwise the usual way to minimize such cases is try to reproduce it with -r linking of just a subset of objects, try to
bisect to minimum set of them, get preprocessed source and do a multifile delta or cvise.

Comment 5 Dan Horák 2023-02-23 17:23:53 UTC
I think it works :-)

<mock-chroot> sh-5.2# gcc -flto=auto -ffat-lto-objects -o dt.so -r CMakeFiles/lib_darktable.dir/common/color_picker.c.o CMakeFiles/lib_darktable.dir/common/color_vocabulary.c.o
during RTL pass: expand
/builddir/build/BUILD/darktable-4.2.1/src/common/color_vocabulary.c: In function ‘Lch_to_color_name.part.0’:
/builddir/build/BUILD/darktable-4.2.1/src/common/color_vocabulary.c:31:13: internal compiler error: in aarch64_layout_arg, at config/aarch64/aarch64.cc:7688
   31 | const char *Lch_to_color_name(dt_aligned_pixel_t color)
      |             ^
Please submit a full bug report, with preprocessed source.
See <http://bugzilla.redhat.com/bugzilla> for instructions.
lto-wrapper: fatal error: gcc returned 1 exit status
compilation terminated.
/usr/bin/ld: error: lto-wrapper failed
collect2: error: ld returned 1 exit status

Comment 6 Dan Horák 2023-02-23 17:38:51 UTC
Created attachment 1945968 [details]
preprocessed source

/usr/bin/gcc -DAVIF_DLL -DDT_HAVE_SIGNAL_TRACE -DGDK_DISABLE_DEPRECATED -DGDK_VERSION_MIN_REQUIRED=GDK_VERSION_3_24 -DGLIB_VERSION_MAX_ALLOWED=GLIB_VERSION_MIN_REQUIRED -DGLIB_VERSION_MIN_REQUIRED=GLIB_VERSION_2_56 -DGTK_DISABLE_DEPRECATED -DGTK_DISABLE_SINGLE_INCLUDES -DHAVE_CONFIG_H -DHAVE_GAME -DHAVE_GMIC -DHAVE_GPHOTO2 -DHAVE_GRAPHICSMAGICK -DHAVE_HTTP_SERVER -DHAVE_ICU -DHAVE_IMATH -DHAVE_ISO_CODES -DHAVE_KWALLET -DHAVE_LIBAVIF=1 -DHAVE_LIBJXL -DHAVE_LIBRAW=1 -DHAVE_LIBSECRET -DHAVE_MAP -DHAVE_OPENCL -DHAVE_OPENEXR -DHAVE_OPENJPEG -DHAVE_OSMGPSMAP_110_OR_NEWER -DHAVE_PRINT -DHAVE_SQLITE_324_OR_NEWER -DHAVE_WEBP -DSQLITE_CORE -DSQLITE_ENABLE_ICU -DUSE_COLORDGTK -DUSE_LUA -D_RELEASE -D_XOPEN_SOURCE=700 -D__GDK_KEYSYMS_COMPAT_H__ -Dlib_darktable_EXPORTS -I/builddir/build/BUILD/darktable-4.2.1/redhat-linux-build/bin -I/builddir/build/BUILD/darktable-4.2.1/src -I/builddir/build/BUILD/darktable-4.2.1/src/external/lua/src -I/builddir/build/BUILD/darktable-4.2.1/src/external/LuaAutoC -I/builddir/build/BUILD/darktable-4.2.1/src/external/whereami/src -I/builddir/build/BUILD/darktable-4.2.1/src/external/LibRaw -isystem /builddir/build/BUILD/darktable-4.2.1/src/external -isystem /builddir/build/BUILD/darktable-4.2.1/src/external/OpenCL -isystem /usr/include/glib-2.0 -isystem /usr/lib64/glib-2.0/include -isystem /usr/include/gtk-3.0 -isystem /usr/include/pango-1.0 -isystem /usr/include/sysprof-4 -isystem /usr/include/harfbuzz -isystem /usr/include/freetype2 -isystem /usr/include/libpng16 -isystem /usr/include/libmount -isystem /usr/include/blkid -isystem /usr/include/fribidi -isystem /usr/include/libxml2 -isystem /usr/include/cairo -isystem /usr/include/pixman-1 -isystem /usr/include/gdk-pixbuf-2.0 -isystem /usr/include/gio-unix-2.0 -isystem /usr/include/cloudproviders -isystem /usr/include/atk-1.0 -isystem /usr/include/at-spi2-atk/2.0 -isystem /usr/include/at-spi-2.0 -isystem /usr/include/dbus-1.0 -isystem /usr/lib64/dbus-1.0/include -isystem /usr/include/libsoup-2.4 -isystem /usr/include/lensfun -isystem /usr/include/librsvg-2.0 -isystem /usr/include/json-glib-1.0 -isystem /usr/include/openjpeg-2.5 -isystem /usr/include/libsecret-1 -isystem /usr/include/GraphicsMagick -isystem /usr/include/osmgpsmap-1.0 -isystem /usr/include/colord-1 -isystem /usr/include/Imath -isystem /usr/include/OpenEXR -O2 -flto=auto -ffat-lto-objects -fexceptions -g -grecord-gcc-switches -pipe -Wall -Werror=format-security -Wp,-U_FORTIFY_SOURCE,-D_FORTIFY_SOURCE=3 -Wp,-D_GLIBCXX_ASSERTIONS -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-strong -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1  -mbranch-protection=standard -fasynchronous-unwind-tables -fstack-clash-protection -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -Wall -Wformat -Wformat-security -Wshadow -Wtype-limits -Wvla -Wold-style-declaration -Wno-unknown-pragmas -Wno-error=varargs -Wno-format-truncation -Wno-error=address-of-packed-member -std=c99 -fopenmp -mtune=generic  -g -DNDEBUG -O3 -ffast-math -fno-finite-math-only -fexpensive-optimizations -fPIC -MD -MT bin/CMakeFiles/lib_darktable.dir/common/color_picker.c.o -MF CMakeFiles/lib_darktable.dir/common/color_picker.c.o.d -o CMakeFiles/lib_darktable.dir/common/color_picker.c.o -c /builddir/build/BUILD/darktable-4.2.1/src/common/color_picker.c

Comment 7 Dan Horák 2023-02-23 17:39:28 UTC
Created attachment 1945969 [details]
preprocessed source

/usr/bin/gcc -DAVIF_DLL -DDT_HAVE_SIGNAL_TRACE -DGDK_DISABLE_DEPRECATED -DGDK_VERSION_MIN_REQUIRED=GDK_VERSION_3_24 -DGLIB_VERSION_MAX_ALLOWED=GLIB_VERSION_MIN_REQUIRED -DGLIB_VERSION_MIN_REQUIRED=GLIB_VERSION_2_56 -DGTK_DISABLE_DEPRECATED -DGTK_DISABLE_SINGLE_INCLUDES -DHAVE_CONFIG_H -DHAVE_GAME -DHAVE_GMIC -DHAVE_GPHOTO2 -DHAVE_GRAPHICSMAGICK -DHAVE_HTTP_SERVER -DHAVE_ICU -DHAVE_IMATH -DHAVE_ISO_CODES -DHAVE_KWALLET -DHAVE_LIBAVIF=1 -DHAVE_LIBJXL -DHAVE_LIBRAW=1 -DHAVE_LIBSECRET -DHAVE_MAP -DHAVE_OPENCL -DHAVE_OPENEXR -DHAVE_OPENJPEG -DHAVE_OSMGPSMAP_110_OR_NEWER -DHAVE_PRINT -DHAVE_SQLITE_324_OR_NEWER -DHAVE_WEBP -DSQLITE_CORE -DSQLITE_ENABLE_ICU -DUSE_COLORDGTK -DUSE_LUA -D_RELEASE -D_XOPEN_SOURCE=700 -D__GDK_KEYSYMS_COMPAT_H__ -Dlib_darktable_EXPORTS -I/builddir/build/BUILD/darktable-4.2.1/redhat-linux-build/bin -I/builddir/build/BUILD/darktable-4.2.1/src -I/builddir/build/BUILD/darktable-4.2.1/src/external/lua/src -I/builddir/build/BUILD/darktable-4.2.1/src/external/LuaAutoC -I/builddir/build/BUILD/darktable-4.2.1/src/external/whereami/src -I/builddir/build/BUILD/darktable-4.2.1/src/external/LibRaw -isystem /builddir/build/BUILD/darktable-4.2.1/src/external -isystem /builddir/build/BUILD/darktable-4.2.1/src/external/OpenCL -isystem /usr/include/glib-2.0 -isystem /usr/lib64/glib-2.0/include -isystem /usr/include/gtk-3.0 -isystem /usr/include/pango-1.0 -isystem /usr/include/sysprof-4 -isystem /usr/include/harfbuzz -isystem /usr/include/freetype2 -isystem /usr/include/libpng16 -isystem /usr/include/libmount -isystem /usr/include/blkid -isystem /usr/include/fribidi -isystem /usr/include/libxml2 -isystem /usr/include/cairo -isystem /usr/include/pixman-1 -isystem /usr/include/gdk-pixbuf-2.0 -isystem /usr/include/gio-unix-2.0 -isystem /usr/include/cloudproviders -isystem /usr/include/atk-1.0 -isystem /usr/include/at-spi2-atk/2.0 -isystem /usr/include/at-spi-2.0 -isystem /usr/include/dbus-1.0 -isystem /usr/lib64/dbus-1.0/include -isystem /usr/include/libsoup-2.4 -isystem /usr/include/lensfun -isystem /usr/include/librsvg-2.0 -isystem /usr/include/json-glib-1.0 -isystem /usr/include/openjpeg-2.5 -isystem /usr/include/libsecret-1 -isystem /usr/include/GraphicsMagick -isystem /usr/include/osmgpsmap-1.0 -isystem /usr/include/colord-1 -isystem /usr/include/Imath -isystem /usr/include/OpenEXR -O2 -flto=auto -ffat-lto-objects -fexceptions -g -grecord-gcc-switches -pipe -Wall -Werror=format-security -Wp,-U_FORTIFY_SOURCE,-D_FORTIFY_SOURCE=3 -Wp,-D_GLIBCXX_ASSERTIONS -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-strong -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1  -mbranch-protection=standard -fasynchronous-unwind-tables -fstack-clash-protection -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -Wall -Wformat -Wformat-security -Wshadow -Wtype-limits -Wvla -Wold-style-declaration -Wno-unknown-pragmas -Wno-error=varargs -Wno-format-truncation -Wno-error=address-of-packed-member -std=c99 -fopenmp -mtune=generic  -g -DNDEBUG -O3 -ffast-math -fno-finite-math-only -fexpensive-optimizations -fPIC -MD -MT bin/CMakeFiles/lib_darktable.dir/common/color_vocabulary.c.o -MF CMakeFiles/lib_darktable.dir/common/color_vocabulary.c.o.d -o CMakeFiles/lib_darktable.dir/common/color_vocabulary.c.o -c /builddir/build/BUILD/darktable-4.2.1/src/common/color_vocabulary.c

Comment 8 Dan Horák 2023-02-23 17:47:29 UTC
removing -ffat-lto-objects makes the ICE go away

Comment 9 Jakub Jelinek 2023-02-23 19:49:32 UTC
Ugh, that is total mess:
inline static void decompose_2D_Bspline(const float *const __attribute__((aligned(16))) restrict in,
                                        float *const __attribute__((aligned(16))) restrict HF,
                                        float *const __attribute__((aligned(16))) restrict LF,
                                        const size_t width, const size_t height, const int mult,
                                        float *const tempbuf, size_t padded_size)
{


#pragma omp parallel for default(none) firstprivate(width, height, mult, padded_size) shared(in, HF, LF, tempbuf) schedule(static)

    
      

  for(size_t row = 0; row < height; row++)
  {

    float *restrict __attribute__((aligned(64))) const temp = __builtin_assume_aligned((tempbuf) + ((padded_size) * dt_get_thread_num()), 64);

16-byte and 64-byte aligned pointers (not what it points to)?
This then mixed with the fact that our build_pointer_type_for_mode doesn't actually check TYPE_ALIGN and LTO stream out + in where we are unlucky
enough to get the bogus overaligned pointer earlier than the normally aligned one, and finally __builtin_cexpif expansion into sincosl which will
build_pointer_type (<float>) and get this bogus overaligned pointer.  Plus over sensitive aarch64 backend.

Comment 10 Kalev Lember 2023-02-24 14:21:57 UTC
I went ahead and disabled LTO on aarch64 to work this around for now, https://src.fedoraproject.org/rpms/darktable/c/b75da7bc162794560564faded5b642e0a3e350b0?branch=rawhide

Comment 11 Jakub Jelinek 2023-02-24 14:36:42 UTC
Better would be to fix the bugs on the darktable side (sure, gcc shouldn't ICE on it and it will get fixed hopefully soon).
In particular, grep on yesterday's darktable git shows:
find -type f -print0 | xargs -0 grep '\*[^]]*DT_ALIGN'
./src/iop/highlights.c:  float *const DT_ALIGNED_ARRAY tempbuf = dt_alloc_perthread_float(4 * width, &padded_size); //TODO: alloc in caller
./src/iop/diffuse.c:  float *const DT_ALIGNED_ARRAY tempbuf = dt_alloc_perthread_float(4 * width, &padded_size); //TODO: alloc in caller
./src/iop/cacorrectrgb.c:  float *const restrict DT_ALIGNED_PIXEL in_out = dt_alloc_align_float(width * height * 4);
./src/common/color_picker.c:      float *const DT_ALIGNED_ARRAY tempbuf = dt_alloc_perthread_float(4 * roi->width, &padded_size); //TODO: alloc in caller
./src/common/bspline.h:inline static void decompose_2D_Bspline(const float *const DT_ALIGNED_PIXEL restrict in,
./src/common/bspline.h:                                        float *const DT_ALIGNED_PIXEL restrict HF,
./src/common/bspline.h:                                        float *const DT_ALIGNED_PIXEL restrict LF,
./src/common/bspline.h:    float *restrict DT_ALIGNED_ARRAY const temp = dt_get_perthread(tempbuf, padded_size);
All those DT_ALIGNED_ARRAY or DT_ALIGNED_PIXEL attributes above apply to the pointer type itself, not what it points to, so they are both useless and bogus.

Comment 13 Kalev Lember 2023-02-24 15:14:47 UTC
Nice, thank you for filing that!

Comment 14 Fedora Release Engineering 2023-08-16 07:10:12 UTC
This bug appears to have been reported against 'rawhide' during the Fedora Linux 39 development cycle.
Changing version to 39.