Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.bin/xlint/xlint lint: skip duplicate -llib and -Llibdir ...



details:   https://anonhg.NetBSD.org/src/rev/6d780bbd9212
branches:  trunk
changeset: 365238:6d780bbd9212
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sat Apr 16 00:15:47 2022 +0000

description:
lint: skip duplicate -llib and -Llibdir options

This removes many of the currently 26.000 'multiply defined' lines from
a typical NetBSD build.  Duplicate libraries happen a lot due to
overlapping transitive dependencies.  An example is usr.bin/telnet,
which links to -lcrypto and several other libraries twice.

diffstat:

 usr.bin/xlint/xlint/xlint.c |  22 ++++++++++++++++------
 1 files changed, 16 insertions(+), 6 deletions(-)

diffs (66 lines):

diff -r 9f3cea1b2f61 -r 6d780bbd9212 usr.bin/xlint/xlint/xlint.c
--- a/usr.bin/xlint/xlint/xlint.c       Fri Apr 15 23:25:04 2022 +0000
+++ b/usr.bin/xlint/xlint/xlint.c       Sat Apr 16 00:15:47 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: xlint.c,v 1.90 2022/04/15 16:08:39 rillig Exp $ */
+/* $NetBSD: xlint.c,v 1.91 2022/04/16 00:15:47 rillig Exp $ */
 
 /*
  * Copyright (c) 1996 Christopher G. Demetriou.  All Rights Reserved.
@@ -38,7 +38,7 @@
 
 #include <sys/cdefs.h>
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: xlint.c,v 1.90 2022/04/15 16:08:39 rillig Exp $");
+__RCSID("$NetBSD: xlint.c,v 1.91 2022/04/16 00:15:47 rillig Exp $");
 #endif
 
 #include <sys/param.h>
@@ -160,6 +160,16 @@
 }
 
 static void
+list_add_unique(char ***lstp, const char *s)
+{
+
+       for (char **p = *lstp; *p != NULL; p++)
+               if (strcmp(*p, s) == 0)
+                       return;
+       list_add(lstp, s);
+}
+
+static void
 list_add_all(char ***destp, char *const *src)
 {
        int     i, k;
@@ -516,7 +526,7 @@
                        break;
 
                case 'l':
-                       list_add(&libs, optarg);
+                       list_add_unique(&libs, optarg);
                        break;
 
                case 'o':
@@ -530,7 +540,7 @@
                        break;
 
                case 'L':
-                       list_add(&libsrchpath, optarg);
+                       list_add_unique(&libsrchpath, optarg);
                        break;
 
                case 'B':
@@ -577,10 +587,10 @@
                        }
 
                        if (arg[2] != '\0')
-                               list_add(list, arg + 2);
+                               list_add_unique(list, arg + 2);
                        else if (argc > 1) {
                                argc--;
-                               list_add(list, *++argv);
+                               list_add_unique(list, *++argv);
                        } else
                                usage("Missing argument for l or L");
                } else {



Home | Main Index | Thread Index | Old Index