bug-make
[Top][All Lists]
Advanced

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

make-4.2.93 patch fix compilation in -ansi/-std=c99 mode


From: Dmitry Goncharov
Subject: make-4.2.93 patch fix compilation in -ansi/-std=c99 mode
Date: Fri, 3 Jan 2020 22:18:38 -0500

Good morning.

job.c fails to compile on glibc when -ansi or -std=c99 is specified.
../src/job.c: In function 'reap_children':
../src/job.c:753: error: incompatible type for argument 1 of 'wait'
/usr/include/sys/wait.h:116: note: expected '__WAIT_STATUS' but argument is of
type 'int *'

This happens because makeint.h has the following
# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 5) || __STRICT_ANSI__
#  define __attribute__(x)

Both -ansi and -std=c99 define __STRICT_ANSI__.

In sys/wait.h wait is declared  as
extern __pid_t wait (__WAIT_STATUS __stat_loc);
and __WAIT_STATUS is defined as

typedef union
  {
    union wait *__uptr;
    int *__iptr;
  } __WAIT_STATUS __attribute__ ((__transparent_union__));

The above piece of preprocessor code from makeint.h messes up the definition of
__WAIT_STATUS by removing the attribute. Without the attribute wait does not
take int*.

This patch replaces __attribute__ with gmake_attribute to retain the
current behavior of getting __attribute__ removed from gmake's internal
function declartions and keep glibc declarations intact and allow
-std=c99/-ansi.

regards, Dmitry


diff --git a/src/getopt.c b/src/getopt.c
index 35e71ef..5e0f7c2 100644
--- a/src/getopt.c
+++ b/src/getopt.c
@@ -256,7 +256,7 @@ static char *const *original_argv;
 /* Make sure the environment variable bash 2.0 puts in the environment
    is valid for the getopt call we must make sure that the ARGV passed
    to getopt is that one passed to the process.  */
-static void __attribute__ ((unused))
+static void gmake_attribute ((unused))
 store_args_and_env (int argc, char *const *argv)
 {
   /* XXX This is no good solution.  We should rather copy the args so
diff --git a/src/job.h b/src/job.h
index 812df0d..f052ace 100644
--- a/src/job.h
+++ b/src/job.h
@@ -80,11 +80,11 @@ char **construct_command_argv (char *line, char
**restp, struct file *file,
 pid_t child_execute_job (struct childbase *child, int good_stdin, char **argv);

 #ifdef _AMIGA
-void exec_command (char **argv) __attribute__ ((noreturn));
+void exec_command (char **argv) gmake_attribute ((noreturn));
 #elif defined(__EMX__)
 int exec_command (char **argv, char **envp);
 #else
-void exec_command (char **argv, char **envp) __attribute__ ((noreturn));
+void exec_command (char **argv, char **envp) gmake_attribute ((noreturn));
 #endif

 void unblock_all_sigs (void);
diff --git a/src/main.c b/src/main.c
index 8d18d14..98915ae 100644
--- a/src/main.c
+++ b/src/main.c
@@ -96,7 +96,7 @@ int chdir ();
 #endif
 #ifndef STDC_HEADERS
 # ifndef sun                    /* Sun has an incorrect decl in a header.  */
-void exit (int) __attribute__ ((noreturn));
+void exit (int) gmake_attribute ((noreturn));
 # endif
 double atof ();
 #endif
diff --git a/src/makeint.h b/src/makeint.h
index 09bfd8c..efc9112 100644
--- a/src/makeint.h
+++ b/src/makeint.h
@@ -220,10 +220,12 @@ extern int vms_legacy_behavior;
 extern int vms_unix_simulation;
 #endif

-#ifndef __attribute__
+#ifndef gmake_attribute
 /* This feature is available in gcc versions 2.5 and later.  */
 # if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 5) || __STRICT_ANSI__
-#  define __attribute__(x)
+#  define gmake_attribute(x)
+#else
+#  define gmake_attribute(x) __attribute__(x)
 # endif
 /* The __-protected variants of 'format' and 'printf' attributes
    are accepted by gcc versions 2.6.4 (effectively 2.7) and later.  */
@@ -232,7 +234,7 @@ extern int vms_unix_simulation;
 #  define __printf__ printf
 # endif
 #endif
-#define UNUSED  __attribute__ ((unused))
+#define UNUSED  gmake_attribute ((unused))

 #if defined (STDC_HEADERS) || defined (__GNU_LIBRARY__)
 # include <stdlib.h>
@@ -255,8 +257,8 @@ void *malloc (int);
 void *realloc (void *, int);
 void free (void *);

-void abort (void) __attribute__ ((noreturn));
-void exit (int) __attribute__ ((noreturn));
+void abort (void) gmake_attribute ((noreturn));
+void exit (int) gmake_attribute ((noreturn));
 # endif /* HAVE_STDLIB_H.  */

 #endif /* Standard headers.  */
@@ -486,12 +488,12 @@ typedef struct

 const char *concat (unsigned int, ...);
 void message (int prefix, size_t length, const char *fmt, ...)
-              __attribute__ ((__format__ (__printf__, 3, 4)));
+              gmake_attribute ((__format__ (__printf__, 3, 4)));
 void error (const floc *flocp, size_t length, const char *fmt, ...)
-            __attribute__ ((__format__ (__printf__, 3, 4)));
+            gmake_attribute ((__format__ (__printf__, 3, 4)));
 void fatal (const floc *flocp, size_t length, const char *fmt, ...)
-            __attribute__ ((noreturn, __format__ (__printf__, 3, 4)));
-void out_of_memory () __attribute__((noreturn));
+            gmake_attribute ((noreturn, __format__ (__printf__, 3, 4)));
+void out_of_memory () gmake_attribute((noreturn));

 /* When adding macros to this list be sure to update the value of
    XGETTEXT_OPTIONS in the po/Makevars file.  */
@@ -509,8 +511,8 @@ void out_of_memory () __attribute__((noreturn));
 #define ONS(_t,_a,_f,_n,_s)   _t((_a), INTSTR_LENGTH + strlen (_s), \
                                  (_f), (_n), (_s))

-void die (int) __attribute__ ((noreturn));
-void pfatal_with_name (const char *) __attribute__ ((noreturn));
+void die (int) gmake_attribute ((noreturn));
+void pfatal_with_name (const char *) gmake_attribute ((noreturn));
 void perror_with_name (const char *, const char *);
 #define xstrlen(_s) ((_s)==NULL ? 0 : strlen (_s))
 void *xmalloc (size_t);



reply via email to

[Prev in Thread] Current Thread [Next in Thread]