resurrecting-open-source-projects / scrot

SCReenshOT - command line screen capture utility
Other
511 stars 51 forks source link

improve the robustness of default CFLAGS #328

Closed guijan closed 1 year ago

guijan commented 1 year ago

When using default CFLAGS, we want only the CFLAGS that the compiler doesn't support to be excluded, not all of them.

N-R-K commented 1 year ago

If I remove the lto append, I see that it passes the warning flags and -O3 at linking stage anyways.

[scrot]~> git diff
diff --git a/configure.ac b/configure.ac
index 1ceb087..0178adf 100644
--- a/configure.ac
+++ b/configure.ac
@@ -22,7 +22,6 @@ AM_MAINTAINER_MODE
 m4_pattern_forbid([^AX_],[=> GNU autoconf-archive not present. <=])
 AS_IF([test "x$orig_CFLAGS" = "x"], [
     CFLAGS=""
-    AX_APPEND_COMPILE_FLAGS(["-flto"])
     AS_IF([test "x$CFLAGS" = "x-flto"], [
         LTO_ENABLED=yes
         AX_APPEND_LINK_FLAGS(["-flto"])
[scrot]~> { ./autogen.sh && ./configure; } >/dev/null
[scrot]~> { make clean; make } | tail -n5
gcc  -O3 -Wall -Wextra -Wpedantic   -o scrot scrot-scrot.o scrot-note.o scrot-options.o scrot-scrot_selection.o scrot-selection_classic.o scrot-selection_edge.o scrot-util.o -lX11 -lImlib2 -lXcomposite -lXfixes -lXext -lXinerama   -lX11 -lImlib2 -lXcomposite -lXfixes -lXext -lXinerama

Every single -l is also duplicated. Harmless, I guess, but weird.

N-R-K commented 1 year ago

This fixes the duplicated -l flag issues:

diff --git a/src/Makefile.am b/src/Makefile.am
index dc9ed48..04e374d 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -35,7 +35,6 @@ MAINTAINERCLEANFILES = Makefile.in
 bin_PROGRAMS  = scrot

 scrot_CPPFLAGS = @CPPFLAGS@
-scrot_LDADD    = @LIBS@
 scrot_SOURCES  = scrot.c scrot.h        \
 note.c note.h                           \
 options.c options.h                     \

No clue whether it's the right thing to do or not. And honestly, I don't have much motivation to look into this either since it's harmless. @guijan feel free to pursue this if you want to.

N-R-K commented 1 year ago

Also noticed this:

-D_XOPEN_SOURCE=700L   -D_XOPEN_SOURCE=700L

Looks like CPPFLAGS is getting duplicated too. I suspect removing the scrot_CPPFLAGS line will fix that as well.