You are not logged in.

#1 2024-03-29 09:28:25

mutoroglin
Member
Registered: 2021-04-20
Posts: 4

[SOLVED] Linker error when building via makepkg

I experience an issue where a software builds if I invoke it via command line but I receive a linker error if build in a package.

The software that causes problems is the libcava, a module for for waybar.

Building successfully invoking it from the command line
The project builds if I invoke the process from command line

meson setup build
meson compile -C build

Building fails if run within the PKGBUILD
I updated the PKGBUILD to the latest version and build the package in a clean chroot

makechrootpkg -c -r $CHROOT

but I receive a linker error:

[20/20] Linking target libcava.so
FAILED: libcava.so
cc  -o libcava.so libcava.so.p/src_cavacore.c.o libcava.so.p/src_common.c.o libcava.so.p/src_config.c.o libcava.so.p/src_input_common.c.o libcava.so.p/src_input_fifo.c.o libcava.so.p/src_input_shmem.c.o libcava.so.p/src_output_common.c.o libcava.so.p/src_output_terminal_noncurses.c.o libcava.so.p/src_output_raw.c.o libcava.so.p/src_output_noritake.c.o libcava.so.p/src_output_terminal_ncurses.c.o libcava.so.p/src_input_alsa.c.o libcava.so.p/src_input_portaudio.c.o libcava.so.p/src_input_pulse.c.o libcava.so.p/src_input_sndio.c.o libcava.so.p/src_input_pipewire.c.o libcava.so.p/src_output_sdl_cava.c.o libcava.so.p/src_output_sdl_glsl.c.o libcava.so.p/src_input_jack.c.o -Wl,--as-needed -Wl,--no-undefined -Wl,-O1 -shared -fPIC -Wl,-soname,libcava.so -Wl,-O1 -Wl,--sort-common -Wl,--as-needed -Wl,-z,relro -Wl,-z,now -Wl,-z,pack-relative-relocs -flto=auto -march=x86-64 -mtune=generic -O2 -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 -g -ffile-prefix-map=/build/libcava/src=/usr/src/debug/libcava -flto=auto -Wl,--start-group -liniparser -lm /usr/lib/libfftw3.so -pthread -lncursesw -lasound -lportaudio /usr/lib/libpulse.so -lpulse-simple -lsndio /usr/lib/libpipewire-0.3.so /usr/lib/libSDL2.so /usr/lib/libGL.so /usr/lib/libjack.so -Wl,--end-group
{standard input}: Assembler messages:
{standard input}:11: Error: file not found: example_files/config
{standard input}:31: Error: file not found: src/output/shaders/bar_spectrum.frag
{standard input}:51: Error: file not found: src/output/shaders/northern_lights.frag
{standard input}:71: Error: file not found: src/output/shaders/pass_through.vert
make: *** [/tmp/ccJaGZDY.mk:2: /tmp/ccfLjXw7.ltrans0.ltrans.o] Error 1
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
ninja: build stopped: subcommand failed.

Differences in the build files
I tracked down the differences in the build files excerpt of build/ninja.build

  1. invoked from cli

     LINK_ARGS = -Wl,--as-needed -Wl,--no-undefined -Wl,-O1 -shared -fPIC -Wl,-soname,libcava.so -Wl,--start-group -liniparser -lm /usr/lib/libfftw3.so -pthread -lncursesw -lasound -lportaudio /usr/lib/libpulse.so -lpulse-simple -lsndio /usr/lib/libpipewire-0.3.so /usr/lib/libSDL2.so /usr/lib/libGL.so /usr/lib/libjack.so -Wl,--end-group
  2. invoked via makepkg

    LINK_ARGS = -Wl,--as-needed -Wl,--no-undefined -Wl,-O1 -shared -fPIC -Wl,-soname,libcava.so -Wl,-O1 -Wl,--sort-common -Wl,--as-needed -Wl,-z,relro -Wl,-z,now -Wl,-z,pack-relative-relocs -flto=auto -march=x86-64 -mtune=generic -O2 -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 -g -ffile-prefix-map=/home/lee/Documents/joerg@nextcloud/coding/_AUR_packages/libcava/0.10.1/libcava/src=/usr/src/debug/libcava -flto=auto -Wl,--start-group -liniparser -lm /usr/lib/libfftw3.so -pthread -lncursesw -lasound -lportaudio /usr/lib/libpulse.so -lpulse-simple -lsndio /usr/lib/libpipewire-0.3.so /usr/lib/libSDL2.so /usr/lib/libGL.so /usr/lib/libjack.so -Wl,--end-group

How to further debug this?
What else did try: I updated my arch system, I reprodcued the issue on another arch computer. I am stuck at this point.
I do not understand why I get different linker arguments depending on how I invoke the process. I am further puzzled how to modify the PKGBUILD to successfully link the project.
I appreciate your thoughts and help!

Last edited by mutoroglin (2024-03-30 09:11:54)

Offline

#2 2024-03-29 09:39:12

WorMzy
Forum Moderator
From: Scotland
Registered: 2010-06-16
Posts: 11,928
Website

Re: [SOLVED] Linker error when building via makepkg

Mod note: Moving to AUR Issues.


Sakura:-
Mobo: MSI MAG X570S TORPEDO MAX // Processor: AMD Ryzen 9 5950X @4.9GHz // GFX: AMD Radeon RX 5700 XT // RAM: 32GB (4x 8GB) Corsair DDR4 (@ 3000MHz) // Storage: 1x 3TB HDD, 6x 1TB SSD, 2x 120GB SSD, 1x 275GB M2 SSD

Making lemonade from lemons since 2015.

Offline

#3 2024-03-29 12:12:24

loqs
Member
Registered: 2014-03-06
Posts: 17,560

Re: [SOLVED] Linker error when building via makepkg

I believe the issue is LTO.  Have you tried in the PKGBUILD

options=(!lto)

or on the command line adding the option b_lto=true

Online

#4 2024-03-30 09:10:52

mutoroglin
Member
Registered: 2021-04-20
Posts: 4

Re: [SOLVED] Linker error when building via makepkg

@loqs Thanks a lot for your reply, you were spot on!

Disabling the link time optimisation solved the issue, the package now links properly.

Offline

Board footer

Powered by FluxBB