cdown / clipmenu

Clipboard management using dmenu
MIT License
1.1k stars 90 forks source link

compilation failure on archlinux #215

Closed RFDAJE closed 4 months ago

RFDAJE commented 4 months ago
cc -std=gnu11 -O2 -Wall -Wextra -Wshadow -Wpointer-arith -Wcast-align -Wmissing-prototypes -Wstrict-overflow -Wformat=2 -Wwrite-strings -Warray-bounds -Wstrict-prototypes -Werror -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/abc/.cache/yay/clipmenu-git/src=/usr/src/debug/clipmenu-git -flto=auto -I/usr/X11R6/include -L/usr/X11R6/lib src/clipmenu.c src/config.o src/store.o src/util.o src/x.o -Wl,-O1 -Wl,--sort-common -Wl,--as-needed -Wl,-z,relro -Wl,-z,now          -Wl,-z,pack-relative-relocs -flto=auto -lX11 -lXfixes -o src/clipmenu
In function ‘interact_with_dmenu’,
    inlined from ‘prompt_user_for_hash’ at src/clipmenu.c:171:12,
    inlined from ‘main’ at src/clipmenu.c:181:27:
src/clipmenu.c:105:42: error: ‘cur_clips’ may be used uninitialized [-Werror=maybe-uninitialized]
  105 |     _drop_(free) uint64_t *idx_to_hash = malloc(cur_clips * sizeof(uint64_t));
      |                                          ^
src/clipmenu.c: In function ‘main’:
src/clipmenu.c:103:12: note: ‘cur_clips’ was declared here
  103 |     size_t cur_clips;
      |            ^
In function ‘interact_with_dmenu’,
    inlined from ‘prompt_user_for_hash’ at src/clipmenu.c:171:12,
    inlined from ‘main’ at src/clipmenu.c:181:27:
src/clipmenu.c:137:66: error: ‘sel_idx’ may be used uninitialized [-Werror=maybe-uninitialized]
  137 |     if (str_to_uint64(sel_idx_str, &sel_idx) < 0 || sel_idx == 0 ||
      |                                                                  ^
src/clipmenu.c: In function ‘main’:
src/clipmenu.c:135:14: note: ‘sel_idx’ was declared here
  135 |     uint64_t sel_idx;
      |              ^
lto1: all warnings being treated as errors
make[1]: *** [/tmp/ccTsXFBj.mk:2: /tmp/ccsQK063.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
make: *** [Makefile:22: src/clipmenu] Error 1
==> ERROR: A failure occurred in package().
    Aborting...
 -> error making: clipmenu-git-exit status 4
 -> Failed to install the following packages. Manual intervention is required:
clipmenu-git - exit status 4

it is built with aur script. https://aur.archlinux.org/packages/clipmenu-git

cdown commented 4 months ago

This works just fine here:

clipmenu develop % cc -std=gnu11 -O2 -Wall -Wextra -Wshadow -Wpointer-arith -Wcast-align -Wmissing-prototypes -Wstrict-overflow -Wformat=2 -Wwrite-strings -Warray-bounds -Wstrict-prototypes -Werror -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/xxx/.cache/yay/clipmenu-git/src=/usr/src/debug/clipmenu-git -flto=auto -I/usr/X11R6/include -L/usr/X11R6/lib src/clipmenu.c src/config.o src/store.o src/util.o src/x.o -Wl,-O1 -Wl,--sort-common -Wl,--as-needed -Wl,-z,relro -Wl,-z,now -Wl,-z,pack-relative-relocs -flto=auto -lX11 -lXfixes -o src/clipmenu clipmenu develop % echo $? 0


Please give your full CFLAGS/CPPFLAGS/LDFLAGS/LDLIBS for the entire build process and compiler.

RFDAJE commented 4 months ago

{{{ CFLAGS: -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/abc/.cache/yay/clipmenu-git/src=/usr/src/debug/clipmenu-git -flto=auto CPPFLAGS: LDFLAGS: -Wl,-O1 -Wl,--sort-common -Wl,--as-needed -Wl,-z,relro -Wl,-z,now -Wl,-z,pack-relative-relocs -flto=auto LDLIBS:

gcc version 13.2.1 20230801 (GCC) }}}

N-R-K commented 2 months ago

IMO a better fix would've been to move -Werror to debug flags and leave it out of "release" builds. See: https://flameeyes.blog/2009/02/25/future-proof-your-code-dont-use-werror/