Skip to content

Sdl2-compat breaks compilation of dhewm3,mgba-git-qt, and other programs. Using -ffat-lto-objects and compiling sdl2-compat-git fixes the issue.

Description:

Hello, I hope that you are doing fine. So, I was compiling a program named dhewm3 when I got an error as follows: (Which is slightly trimmed)

[276/452] Linking C executable sdl/mgba
FAILED: sdl/mgba 
: && /usr/lib/ccache/bin/cc -march=native -O3 -pipe -fno-plt -fexceptions         -Wp,-D_FORTIFY_SOURCE=3 -Wformat -Werror=format-security         -fstack-clash-protection -fcf-protection         -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -flto=auto -Wall -Wextra -Wno-missing-field-initializers -Werror=implicit-function-declaration -Werror=implicit-int -fwrapv -Werror=incompatible-pointer-types -pthread -O3 -DNDEBUG -flto -Wl,-O1 -Wl,--sort-common -Wl,--as-needed -Wl,-z,relro -Wl,-z,now          -Wl,-z,pack-relative-relocs -fuse-ld=mold -flto=auto sdl/CMakeFiles/mgba-sdl.dir/sdl-audio.c.o sdl/CMakeFiles/mgba-sdl.dir/sdl-events.c.o sdl/CMakeFiles/mgba-sdl.dir/gl-common.c.o sdl/CMakeFiles/mgba-sdl.dir/main.c.o sdl/CMakeFiles/mgba-sdl.dir/gl-sdl.c.o sdl/CMakeFiles/mgba-sdl.dir/gles2-sdl.c.o sdl/CMakeFiles/mgba-sdl.dir/sw-sdl2.c.o -o sdl/mgba  libmgba.so.0.11.0  /usr/lib/libSDL2.so  /usr/lib/libSDL2main.a  /usr/lib/libSDL2.so  /usr/lib/libGL.so  /usr/lib/libEGL.so  /usr/lib/libepoxy.so  -ledit  -lavcodec  -lavfilter  -lavformat  -lavutil  -lswscale  -lswresample  /usr/lib/libzip.so.5.5  /usr/lib/libfreetype.so  /usr/lib/libjson-c.so.5.4.0  /usr/lib/libz.so  /usr/lib/libpng.so  /usr/lib/libsqlite3.so  -lelf  /usr/lib/liblua5.4.so  /usr/lib/libz.so  /usr/lib/libpng.so  /usr/lib/libsqlite3.so  -lelf  /usr/lib/liblua5.4.so  -lm  /usr/lib/libSDL2main.a  /usr/lib/libEGL.so  /usr/lib/libepoxy.so && :
mold: fatal: SDL_dummy_main.c.o: not claimed by the LTO plugin; please make sure you are using the same compiler of the same version for all object files <<<<< This is the error.
collect2: error: ld returned 1 exit status
[277/452] Automatic MOC for target mgba-qt
ninja: build stopped: subcommand failed.
==> ERROR: A failure occurred in build().
    Aborting...

Changing to another linker, (By changing it in makepkg.conf in CFLAGS) like the default, workarounds the issue. OR, you can compile sdl2-compat-git yourself with the flag -fflag-lto-objects. And then compile the program, succeeds in my case. loqs and Lone_Wolf from the arch forums says "It's a packaging issue." So I was sent here.

Additional info:

Exact dialogue of loqs:

More specifically, Rebuilding sdl2-compat with CFLAGS+=' -ffat-lto-objects' then building mgba-git with that with succeeds. Could the default linker be silently falling back to libSDL2.so when it can not find the required symbols in libSDL2main.a? To me this looks like an issue in sdl2-compat shipping a static library without using '-ffat-lto-objects'.

This is my post, which has even more detail. https://bbs.archlinux.org/viewtopic.php?id=306103

  • package version(s): Normal = 2.32.56-1, Git = 2.32.56.r4.g82b9d2e-1
  • config and/or log files:
  • link to upstream bug report, if any:

Steps to reproduce:

Step 1 : Have sdl2-compat installed from the pacman repo using "sudo pacman -S sdl2-compat" Step 2 : Use an aur helper like trizen, and install mgba-git-qt with "trizen -S mgba-git-qt" Step 3 : The issue occurs mid compilation/linking?

Edited by Abhinav Singh
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information