pkgsrc-Changes archive

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

CVS commit: pkgsrc/pkgtools/cwrappers



Module Name:    pkgsrc
Committed By:   joerg
Date:           Sun Jun 11 19:34:44 UTC 2017

Modified Files:
        pkgsrc/pkgtools/cwrappers: Makefile
        pkgsrc/pkgtools/cwrappers/files/bin: base-wrapper.c common.c common.h
            normalise-cc.c normalise-ld.c
        pkgsrc/pkgtools/cwrappers/files/doc: configuration.txt normalise-ld.txt
            normalise.txt

Log Message:
cwrappers-20170611:
Add new configuration options {ap,pre}pend_{shared,executable} for
adding options when the operation mode is identified as linking.

Based loosely on patch from khorben.


To generate a diff of this commit:
cvs rdiff -u -r1.19 -r1.20 pkgsrc/pkgtools/cwrappers/Makefile
cvs rdiff -u -r1.4 -r1.5 pkgsrc/pkgtools/cwrappers/files/bin/base-wrapper.c \
    pkgsrc/pkgtools/cwrappers/files/bin/normalise-cc.c
cvs rdiff -u -r1.6 -r1.7 pkgsrc/pkgtools/cwrappers/files/bin/common.c
cvs rdiff -u -r1.5 -r1.6 pkgsrc/pkgtools/cwrappers/files/bin/common.h
cvs rdiff -u -r1.2 -r1.3 pkgsrc/pkgtools/cwrappers/files/bin/normalise-ld.c
cvs rdiff -u -r1.2 -r1.3 \
    pkgsrc/pkgtools/cwrappers/files/doc/configuration.txt
cvs rdiff -u -r1.1 -r1.2 pkgsrc/pkgtools/cwrappers/files/doc/normalise-ld.txt \
    pkgsrc/pkgtools/cwrappers/files/doc/normalise.txt

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: pkgsrc/pkgtools/cwrappers/Makefile
diff -u pkgsrc/pkgtools/cwrappers/Makefile:1.19 pkgsrc/pkgtools/cwrappers/Makefile:1.20
--- pkgsrc/pkgtools/cwrappers/Makefile:1.19     Thu Jan 12 14:56:35 2017
+++ pkgsrc/pkgtools/cwrappers/Makefile  Sun Jun 11 19:34:43 2017
@@ -1,6 +1,6 @@
-# $NetBSD: Makefile,v 1.19 2017/01/12 14:56:35 joerg Exp $
+# $NetBSD: Makefile,v 1.20 2017/06/11 19:34:43 joerg Exp $
 
-PKGNAME=               cwrappers-20170112
+PKGNAME=               cwrappers-20170611
 CATEGORIES=            pkgtools sysutils
 
 MAINTAINER=            joerg%NetBSD.org@localhost

Index: pkgsrc/pkgtools/cwrappers/files/bin/base-wrapper.c
diff -u pkgsrc/pkgtools/cwrappers/files/bin/base-wrapper.c:1.4 pkgsrc/pkgtools/cwrappers/files/bin/base-wrapper.c:1.5
--- pkgsrc/pkgtools/cwrappers/files/bin/base-wrapper.c:1.4      Thu Jan 12 14:56:35 2017
+++ pkgsrc/pkgtools/cwrappers/files/bin/base-wrapper.c  Sun Jun 11 19:34:43 2017
@@ -1,7 +1,7 @@
-/* $NetBSD: base-wrapper.c,v 1.4 2017/01/12 14:56:35 joerg Exp $ */
+/* $NetBSD: base-wrapper.c,v 1.5 2017/06/11 19:34:43 joerg Exp $ */
 
 /*-
- * Copyright (c) 2007 Joerg Sonnenberger <joerg%NetBSD.org@localhost>.
+ * Copyright (c) 2007, 2017 Joerg Sonnenberger <joerg%NetBSD.org@localhost>.
  * All rights reserved.
  *
  * This code was developed as part of Google's Summer of Code 2007 program.
@@ -128,6 +128,11 @@ main(int argc, char **argv)
                goto skip_transforms;
 #endif
 
+#if defined(WRAPPER_LD)
+       operation_mode_ld(&args);
+#else
+       operation_mode_cc(&args);
+#endif
        arglist_apply_config(&args);
 #if defined(WRAPPER_LD)
        normalise_ld(&args);
Index: pkgsrc/pkgtools/cwrappers/files/bin/normalise-cc.c
diff -u pkgsrc/pkgtools/cwrappers/files/bin/normalise-cc.c:1.4 pkgsrc/pkgtools/cwrappers/files/bin/normalise-cc.c:1.5
--- pkgsrc/pkgtools/cwrappers/files/bin/normalise-cc.c:1.4      Thu Sep 15 17:08:14 2016
+++ pkgsrc/pkgtools/cwrappers/files/bin/normalise-cc.c  Sun Jun 11 19:34:43 2017
@@ -1,7 +1,7 @@
-/* $NetBSD: normalise-cc.c,v 1.4 2016/09/15 17:08:14 joerg Exp $ */
+/* $NetBSD: normalise-cc.c,v 1.5 2017/06/11 19:34:43 joerg Exp $ */
 
 /*-
- * Copyright (c) 2009 Joerg Sonnenberger <joerg%NetBSD.org@localhost>.
+ * Copyright (c) 2009, 2017 Joerg Sonnenberger <joerg%NetBSD.org@localhost>.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -61,6 +61,34 @@ normalise_path_list(struct arglist *args
 }
 
 void
+operation_mode_cc(struct arglist *args)
+{
+       struct argument *arg;
+
+       current_operation_mode = mode_link_executable;
+       TAILQ_FOREACH(arg, args, link) {
+               if (arg->val[0] != '-')
+                       continue;
+               if (strcmp(arg->val, "-E") == 0) {
+                       current_operation_mode = mode_preprocess;
+                       continue;
+               }
+               if (strcmp(arg->val, "-S") == 0) {
+                       current_operation_mode = mode_assemble;
+                       continue;
+               }
+               if (strcmp(arg->val, "-c") == 0) {
+                       current_operation_mode = mode_compile;
+                       continue;
+               }
+               if (strcmp(arg->val, "-shared") == 0) {
+                       current_operation_mode = mode_link_shared;
+                       continue;
+               }
+       }
+}
+
+void
 normalise_cc(struct arglist *args)
 {
        struct argument *arg, *arg2, *arg3;

Index: pkgsrc/pkgtools/cwrappers/files/bin/common.c
diff -u pkgsrc/pkgtools/cwrappers/files/bin/common.c:1.6 pkgsrc/pkgtools/cwrappers/files/bin/common.c:1.7
--- pkgsrc/pkgtools/cwrappers/files/bin/common.c:1.6    Fri Dec  9 22:25:28 2016
+++ pkgsrc/pkgtools/cwrappers/files/bin/common.c        Sun Jun 11 19:34:43 2017
@@ -1,7 +1,7 @@
-/* $NetBSD: common.c,v 1.6 2016/12/09 22:25:28 joerg Exp $ */
+/* $NetBSD: common.c,v 1.7 2017/06/11 19:34:43 joerg Exp $ */
 
 /*-
- * Copyright (c) 2009 Joerg Sonnenberger <joerg%NetBSD.org@localhost>.
+ * Copyright (c) 2009, 2017 Joerg Sonnenberger <joerg%NetBSD.org@localhost>.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -49,9 +49,18 @@ char *exec_path;
 char *exec_name;
 char *wrksrc;
 int debug;
+enum operation_mode current_operation_mode = mode_unknown;
 
 static struct arglist prepend_args = TAILQ_HEAD_INITIALIZER(prepend_args);
 static struct arglist append_args = TAILQ_HEAD_INITIALIZER(append_args);
+static struct arglist prepend_executable_args =
+   TAILQ_HEAD_INITIALIZER(prepend_executable_args);
+static struct arglist append_executable_args =
+   TAILQ_HEAD_INITIALIZER(append_executable_args);
+static struct arglist prepend_shared_args =
+   TAILQ_HEAD_INITIALIZER(prepend_shared_args);
+static struct arglist append_shared_args =
+   TAILQ_HEAD_INITIALIZER(append_shared_args);
 struct argument *prepend_after;
 
 const char library_name_chars[] =
@@ -135,29 +144,56 @@ arglist_from_argc(struct arglist *args, 
        }
 }
 
-void
-arglist_apply_config(struct arglist *args)
+static void
+arglist_prepend_list(struct arglist *args, struct arglist *prepends)
 {
        struct argument *arg, *arg2;
 
        if (prepend_after) {
-               TAILQ_FOREACH(arg, &prepend_args, link) {
+               TAILQ_FOREACH(arg, prepends, link) {
                        arg2 = argument_copy(arg->val);
                        TAILQ_INSERT_AFTER(args, prepend_after, arg2, link);
                }
        } else {
-               TAILQ_FOREACH_REVERSE(arg, &prepend_args, arglist, link) {
+               TAILQ_FOREACH_REVERSE(arg, prepends, arglist, link) {
                        arg2 = argument_copy(arg->val);
                        TAILQ_INSERT_HEAD(args, arg2, link);
                }
        }
-       TAILQ_FOREACH(arg, &append_args, link) {
+}
+
+static void
+arglist_append_list(struct arglist *args, struct arglist *appends)
+{
+       struct argument *arg, *arg2;
+
+       TAILQ_FOREACH(arg, appends, link) {
                arg2 = argument_copy(arg->val);
                TAILQ_INSERT_TAIL(args, arg2, link);
        }
 }
 
 void
+arglist_apply_config(struct arglist *args)
+{
+       arglist_prepend_list(args, &prepend_args);
+       arglist_append_list(args, &append_args);
+
+       switch (current_operation_mode) {
+       default:
+               break;
+       case mode_link_executable:
+               arglist_prepend_list(args, &prepend_executable_args);
+               arglist_append_list(args, &append_executable_args);
+               break;
+       case mode_link_shared:
+               arglist_prepend_list(args, &prepend_shared_args);
+               arglist_append_list(args, &prepend_shared_args);
+               break;
+       }
+}
+
+void
 argument_unlink(struct arglist *args, struct argument **argp)
 {
        struct argument *arg;
@@ -233,6 +269,26 @@ parse_config(const char *wrapper)
                        arg = argument_copy(line + 7);
                        TAILQ_INSERT_TAIL(&append_args, arg, link);
                }
+               if (strncmp(line, "prepend_executable=", 19) == 0) {
+                       struct argument *arg;
+                       arg = argument_copy(line + 19);
+                       TAILQ_INSERT_TAIL(&prepend_executable_args, arg, link);
+               }
+               if (strncmp(line, "append_executable=", 18) == 0) {
+                       struct argument *arg;
+                       arg = argument_copy(line + 18);
+                       TAILQ_INSERT_TAIL(&append_executable_args, arg, link);
+               }
+               if (strncmp(line, "prepend_shared=", 15) == 0) {
+                       struct argument *arg;
+                       arg = argument_copy(line + 15);
+                       TAILQ_INSERT_TAIL(&prepend_shared_args, arg, link);
+               }
+               if (strncmp(line, "append_shared=", 14) == 0) {
+                       struct argument *arg;
+                       arg = argument_copy(line + 14);
+                       TAILQ_INSERT_TAIL(&append_shared_args, arg, link);
+               }
                if (strncmp(line, "wrksrc=", 7) == 0) {
                        free(wrksrc);
                        wrksrc = xstrdup(line + 7);

Index: pkgsrc/pkgtools/cwrappers/files/bin/common.h
diff -u pkgsrc/pkgtools/cwrappers/files/bin/common.h:1.5 pkgsrc/pkgtools/cwrappers/files/bin/common.h:1.6
--- pkgsrc/pkgtools/cwrappers/files/bin/common.h:1.5    Sun Nov 27 11:46:45 2016
+++ pkgsrc/pkgtools/cwrappers/files/bin/common.h        Sun Jun 11 19:34:43 2017
@@ -1,7 +1,7 @@
-/* $NetBSD: common.h,v 1.5 2016/11/27 11:46:45 joerg Exp $ */
+/* $NetBSD: common.h,v 1.6 2017/06/11 19:34:43 joerg Exp $ */
 
 /*-
- * Copyright (c) 2009 Joerg Sonnenberger <joerg%NetBSD.org@localhost>.
+ * Copyright (c) 2009, 2017 Joerg Sonnenberger <joerg%NetBSD.org@localhost>.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -44,6 +44,16 @@ extern char *exec_name;
 extern char *wrksrc;
 extern int debug;
 
+enum operation_mode {
+       mode_unknown,
+       mode_preprocess,
+       mode_assemble,
+       mode_compile,
+       mode_link_executable,
+       mode_link_shared
+};
+extern enum operation_mode current_operation_mode;
+
 TAILQ_HEAD(arglist, argument);
 
 struct argument {
@@ -84,6 +94,7 @@ void  *xrealloc(void *, size_t);
 char   *xstrdup(const char *);
 char   *xstrndup(const char *, size_t);
 
+void   operation_mode_cc(struct arglist *);
 void   normalise_cc(struct arglist *);
 void   cleanup_cc(struct arglist *args);
 void   transform_cc(struct arglist *args);
@@ -95,6 +106,7 @@ void init_generic_transform(void);
 void   register_generic_transform(const char *);
 void   generic_transform_cc(struct arglist *);
 
+void   operation_mode_ld(struct arglist *);
 void   normalise_ld(struct arglist *);
 void   generic_transform_ld(struct arglist *);
 

Index: pkgsrc/pkgtools/cwrappers/files/bin/normalise-ld.c
diff -u pkgsrc/pkgtools/cwrappers/files/bin/normalise-ld.c:1.2 pkgsrc/pkgtools/cwrappers/files/bin/normalise-ld.c:1.3
--- pkgsrc/pkgtools/cwrappers/files/bin/normalise-ld.c:1.2      Sun Apr 19 14:30:07 2015
+++ pkgsrc/pkgtools/cwrappers/files/bin/normalise-ld.c  Sun Jun 11 19:34:43 2017
@@ -1,7 +1,7 @@
-/* $NetBSD: normalise-ld.c,v 1.2 2015/04/19 14:30:07 jperkin Exp $ */
+/* $NetBSD: normalise-ld.c,v 1.3 2017/06/11 19:34:43 joerg Exp $ */
 
 /*-
- * Copyright (c) 2009 Joerg Sonnenberger <joerg%NetBSD.org@localhost>.
+ * Copyright (c) 2009, 2017 Joerg Sonnenberger <joerg%NetBSD.org@localhost>.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -36,6 +36,23 @@
 #include "common.h"
 
 void
+operation_mode_ld(struct arglist *args)
+{
+       struct argument *arg;
+
+       current_operation_mode = mode_link_executable;
+       TAILQ_FOREACH(arg, args, link) {
+               if (arg->val[0] != '-')
+                       continue;
+               if (strcmp(arg->val, "-shared") == 0 ||
+                   strcmp(arg->val, "-Bshareable") == 0) {
+                       current_operation_mode = mode_link_shared;
+                       continue;
+               }
+       }
+}
+
+void
 normalise_ld(struct arglist *args)
 {
        struct argument *arg, *arg2, *arg3;

Index: pkgsrc/pkgtools/cwrappers/files/doc/configuration.txt
diff -u pkgsrc/pkgtools/cwrappers/files/doc/configuration.txt:1.2 pkgsrc/pkgtools/cwrappers/files/doc/configuration.txt:1.3
--- pkgsrc/pkgtools/cwrappers/files/doc/configuration.txt:1.2   Thu Nov 27 20:36:43 2014
+++ pkgsrc/pkgtools/cwrappers/files/doc/configuration.txt       Sun Jun 11 19:34:44 2017
@@ -1,4 +1,4 @@
-$NetBSD: configuration.txt,v 1.2 2014/11/27 20:36:43 joerg Exp $
+$NetBSD: configuration.txt,v 1.3 2017/06/11 19:34:44 joerg Exp $
 
 The configuration of the wrapper framework depends on two variables.
 The environment variable CWRAPPERS_CONFIG_DIR points to a directory
@@ -22,7 +22,21 @@ transform: Specify a transformation rule
 the details.
 
 prepend: Prepend an option directly after logging the original command.
-The options are inserted in the order of the config file.
+The options are inserted in the order of the config file. In libtool mode,
+the options are inserted after the first argument, if that argument itself is
+not an option.
 
 append: Append an option directly after logging the original command.
 The options are inserted in the order of the config file.
+
+prepend_executable: Like prepend, but applied only if the operation mode is
+link-executable.
+
+append_executable: Like append, but applied only if the operation mode is
+link-executable.
+
+prepend_shared: Like prepend, but applied only if the operation mode is
+link-shared.
+
+append_shared: Like append, but applied only if the operation mode is
+link-shared.

Index: pkgsrc/pkgtools/cwrappers/files/doc/normalise-ld.txt
diff -u pkgsrc/pkgtools/cwrappers/files/doc/normalise-ld.txt:1.1 pkgsrc/pkgtools/cwrappers/files/doc/normalise-ld.txt:1.2
--- pkgsrc/pkgtools/cwrappers/files/doc/normalise-ld.txt:1.1    Wed Sep 17 12:40:56 2014
+++ pkgsrc/pkgtools/cwrappers/files/doc/normalise-ld.txt        Sun Jun 11 19:34:44 2017
@@ -1,4 +1,4 @@
-$NetBSD: normalise-ld.txt,v 1.1 2014/09/17 12:40:56 joerg Exp $
+$NetBSD: normalise-ld.txt,v 1.2 2017/06/11 19:34:44 joerg Exp $
 
 The first phase of wrapper processing for ld-ish wrappers is argument
 normalisation.  This simplifies processing in latter steps.
@@ -19,3 +19,6 @@ to the form "-rpath foo".
 "/lib([a-zA-Z0-9_-])*\.s[ol](\.[0-9][^/]*)$ are replaced by "-Ldir -l\1"
 with "dir" being the base name of the argument.  This is not done for
 arguments to -o, --dynamic-linker or -Wl,--dynamic-linker.
+
+If "-shared" or "-Bshareable" is present, the operation mode is considered
+to be link-shared, otherwise the output mode is link-executable.
Index: pkgsrc/pkgtools/cwrappers/files/doc/normalise.txt
diff -u pkgsrc/pkgtools/cwrappers/files/doc/normalise.txt:1.1 pkgsrc/pkgtools/cwrappers/files/doc/normalise.txt:1.2
--- pkgsrc/pkgtools/cwrappers/files/doc/normalise.txt:1.1       Wed Sep 17 12:40:56 2014
+++ pkgsrc/pkgtools/cwrappers/files/doc/normalise.txt   Sun Jun 11 19:34:44 2017
@@ -1,4 +1,4 @@
-$NetBSD: normalise.txt,v 1.1 2014/09/17 12:40:56 joerg Exp $
+$NetBSD: normalise.txt,v 1.2 2017/06/11 19:34:44 joerg Exp $
 
 The first phase of wrapper processing for cc-ish wrappers is argument
 normalisation.  This simplifies processing in latter steps.
@@ -30,3 +30,11 @@ path (e.g. not starting with /) are drop
 "/lib([a-zA-Z0-9_-])*\.s[ol](\.[0-9][^/]*)$ are replaced by "-Ldir -l\1"
 with "dir" being the base name of the argument.  This is not done for
 arguments to -o, --dynamic-linker or -Wl,--dynamic-linker.
+
+The last option in the following set is used to set the operation mode:
+- "-E" -> preprocess
+- "-S" -> assemble
+- "-c" -> compile
+- "-shared" -> link-shared
+and the default operation mode is link-executable. Note that the operation mode
+is not necessarily determined correctly for the libtool wrapper.



Home | Main Index | Thread Index | Old Index