Bug#956146: lintian: check for rules enabling --as-needed

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Bug#956146: lintian: check for rules enabling --as-needed

Andreas Beckmann-4
Package: lintian
Version: 2.63.0
Severity: wishlist

Hi,

if I understood correctly, the bullseye toolchain defaults to linking
with --as-needed. Therefore it should no longer be neccessary to inject
-Wl,--as-needed into the build process, allowing d/rules to be further
minimized.

Some common ways of adding --as-needed that I found in the (possibly
ancient) rules files on my local hard disk:

        export DEB_LDFLAGS_MAINT_APPEND = -Wl,--as-needed
                (may include further flags)
                (may be quoted, spaced, wrapped)
                (may use :=)

        dh_autoreconf --as-needed

        LDFLAGS += -Wl,--as-needed
                (may include further flags)
                (may be quoted, spaced, wrapped)
                (may use =, :=, export)
       
        dh_auto_configure -- -DCMAKE_EXE_LINKER_FLAGS="-Wl,--as-needed"

        $(MAKE) -C ... ... CC='$(CC) $(CPPFLAGS) $(CFLAGS) -Wall -Wl,--as-needed $(LDFLAGS)' ...


Andreas

Reply | Threaded
Open this post in threaded view
|

Bug#956146: lintian: check for rules enabling --as-needed

Chris Lamb -2
tags 956146 + moreinfo
thanks

Andreas,

> if I understood correctly, the bullseye toolchain defaults to linking
> with --as-needed. Therefore it should no longer be neccessary to inject
> -Wl,--as-needed into the build process, allowing d/rules to be further
> minimized.
>
> Some common ways of adding --as-needed that I found in the (possibly
> ancient) rules files on my local hard disk:

Thanks for this example. We can actually use codesearch to get a crude
idea of the prevalence of this:

  https://codesearch.debian.net/search?q=path%3Adebian%2Frules+%5C-Wl%2C%5C-%5C-as-needed&literal=0

Any input on whether a brute grep for "-Wl,--as-needed" in debian/
rules would be sufficient to catch most instances of these? (Feel free
to drop moreinfo tag upon replying.)


Regards,

--
      ,''`.
     : :'  :     Chris Lamb
     `. `'`      [hidden email] 🍥 chris-lamb.co.uk
       `-

Reply | Threaded
Open this post in threaded view
|

Bug#956146: lintian: check for rules enabling --as-needed

Andreas Beckmann-4
Control: tag -1 - moreinfo

On 09/04/2020 01.01, Chris Lamb wrote:
> Any input on whether a brute grep for "-Wl,--as-needed" in debian/
> rules would be sufficient to catch most instances of these? (Feel free

I think you can just grep for '--as-needed', that will catch
  -Wl,--as-needed (2579 matches)
  dh_autoreconf.* --as-needed (238 matches)
  -Wl,.*,--as-needed (9 matches)

The only 'legitimate' use of --as-needed seems to be in combination
with --no-as-needed. Therefore you should exclude matches that also
have --no-as-needed on the same (logical) line (but include them if
the matches are on different lines), e.g.
nethack:
LIB_x11 = -lncurses -lXaw -Wl,--as-needed -lXmu -lXext -Wl,--no-as-needed -lXt -lXpm -lX11 -Wl,--as-needed -lm -Wl,--no-as-needed
haproxy:
MAKEARGS+= ADDLIB="-Wl,--no-as-needed -lgcc_s -Wl,--as-needed"
grep:
LIBS=-Wl,--no-as-needed -ldl -Wl,--as-needed
graphviz:
CONFIGURE_LIBS    = LIBS="-Wl,--no-as-needed -Wl,-lpthread -Wl,--as-needed"
pnetcdf:
LDFLAGS:=$(shell dpkg-buildflags --get LDFLAGS) -Wl,--no-as-needed -lgfortran -Wl,--as-needed
clazy:
export DEB_LDFLAGS_MAINT_APPEND = -Wl,--no-as-needed -latomic -Wl,--as-needed

(there are ~26 matches for --no-as-needed, ~2865 for --as-needed
and ~6 for both on one line)


Andreas