You are not logged in.

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

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
cc  -o -Wl,--as-needed -Wl,--no-undefined -Wl,-O1 -shared -fPIC -Wl,-soname, -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/ -pthread -lncursesw -lasound -lportaudio /usr/lib/ -lpulse-simple -lsndio /usr/lib/ /usr/lib/ /usr/lib/ /usr/lib/ -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/ /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/

  1. invoked from cli

     LINK_ARGS = -Wl,--as-needed -Wl,--no-undefined -Wl,-O1 -shared -fPIC -Wl,-soname, -Wl,--start-group -liniparser -lm /usr/lib/ -pthread -lncursesw -lasound -lportaudio /usr/lib/ -lpulse-simple -lsndio /usr/lib/ /usr/lib/ /usr/lib/ /usr/lib/ -Wl,--end-group
  2. invoked via makepkg

    LINK_ARGS = -Wl,--as-needed -Wl,--no-undefined -Wl,-O1 -shared -fPIC -Wl,-soname, -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/ -pthread -lncursesw -lasound -lportaudio /usr/lib/ -lpulse-simple -lsndio /usr/lib/ /usr/lib/ /usr/lib/ /usr/lib/ -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)


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

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

Re: [SOLVED] Linker error when building via makepkg

Mod note: Moving to AUR Issues.

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.


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

Registered: 2014-03-06
Posts: 17,558

Re: [SOLVED] Linker error when building via makepkg

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


or on the command line adding the option b_lto=true


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

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.


Board footer

Powered by FluxBB