bug-make
[Top][All Lists]
Advanced

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

Fixing broken djgpp support in make 3.81


From: Juan Manuel Guerrero
Subject: Fixing broken djgpp support in make 3.81
Date: Thu, 15 Nov 2007 05:39:46 +0100
User-agent: KMail/1.9.5

The djgpp specific support of make 3.81 is brocken.  There are two sources for
this:
1) failure of the compilation stage.
   It is not possible to compile the sources out-of-the-box because:
   - configh.dos defines HAVE_SYS_SIGLIST instead of HAVE_DECL_SYS_SIGLIST
     what is the macro name that is checked for in signame.c
   - in job.c the function child_execute_job is compiled when __MSDOS__ is
     defined.  This is wrong; the DJGPP port uses directly system() and
     spawnvpe() in start_job_command.  There is no MSDOS/DJGPP version of
     child_execute_job at all.
   These two issues had to been fixed before it was possible to compile the
   successfully the sources.
   There is also a mismatch of the function prototype of my_realloc in glob.c
   with realloc() of djgpp's libc, but this only causes a compiler warning and
   does not stop the show.  Neitherless it is woth to be fixed; see patch.

2) failure of the produced binary when used with an OS that does not use bash
as default shell.
After fixing configh.dos and inhibiting the use of child_execute_job() in job.c
I was able to produce a binary but this binary did not work as expected.
I tried to run the testsuite by typing the command: make check and I got the
following output on the screen:
  Befehl oder Dateiname nicht gefunden  (command or file not found.  Error 
message from command.com started by system() of libc)
  Befehl oder Dateiname nicht gefunden
  Befehl oder Dateiname nicht gefunden
  Befehl oder Dateiname nicht gefunden
  No command name seen.                 (Error message from djgpp's libc 
system() call)

  make.exe: *** [check-recursive] Error -1

The text in parenthesis have been added by me.  The string that is passed to
djgpp's libc system() that originate the above error messages is:
  failcom='exit 1'; \
  for f in x $MAKEFLAGS; do \
    case $f in \
      *=* | --[!k]*);; \
      *k*) failcom='fail=yes';; \
    esac; \
  done; \
  dot_seen=no; \
  target=`echo check-recursive | sed s/-recursive//`; \
  list='glob config po doc '; for subdir in $list; do \
    echo "Making $target in $subdir"; \
    if test "$subdir" = "."; then \
      dot_seen=yes; \
      local_target="$target-am"; \
    else \
      local_target="$target"; \
    fi; \
    (cd $subdir && e:/p2/make-3.81/make.exe  $local_target) \
    || eval $failcom; \
  done; \
  if test "$dot_seen" = "no"; then \
    e:/p2/make-3.81/make.exe  "$target-am" || exit 1; \
  fi; test -z "$fail"

The average user will _never_ figure out why the same makefile fails so
miserably when make 3.81 is used and works perfectly when make 3.80 is used.
It took me some hours to understand what had happend.  For some reason
completly unclear to me, some one has decided not to propagate the value of the
SHELL environment variable to the child process anymore.  In the case of 
MSDOS/DJGPP
this means that the value of SHELL is deleted from the environment before
system() is called.  On _all_ non-POSIX operating systems this will have
catastrophic implications because the libc system() function will have to use
the default shell or command processor.  The default shell on non-POSIX OSs
is usualy not bash so the above shell script must fail.  After some stepping
through the code with gdb I have found that the problem can be fixed in
define_automatic_variables() in variable.c.  If compiled with DJGPP then SHELL
will always be exported.  Please note that I am not objecting the change that
have been done by the make maintainers.  There may be some good reason not to
export automatically all the envorenment variables.  Neitherless if make shall
continue supporting non-PoSIX platforms, certain precaution should be taken.
In this particular case it has been shown that it is not valid to assume that
the used OS will provide a POSIX compatible shell or command processor.
If no one takes care of things like this issue, make becomes useless on certain
platforms.

I have appended a small patch that shows the things I had to change to get a
working make binary.  That patch is not intended to be used.  It shall only
show the code lines that may need to be adjusted to solve the problems.  There
may be better ways to solve the issue, but I am not familiar enough with the
make sources to provide a better patch.  There may be also much more MSDOS or
DJGPp specific things that may be fixed.  The patch only fixes things that I am
aware.  Things that may cause trouble are drive letters, checks for absolute
patch, etc, etc etc.  The usual DOS/WINDOWS things.

I have also appended the output generated by the testsuite.  It shows that
there are some more things to fix.

I have not waiste my time trying to fix the Makefile.DOS, but now that make.texi
has been moved into /doc it needs to be adjusted accordingly.  It would be nice
if rules for dvi, ps, pdf and html could be added.  It would also be usefull
not to split the MSDOS version of make.info anymore.  The extensions .info-[0-9]
are changed to .i[0-9] to acomplish with the 8.3 file name rule but it is always
forgotten to adjust the file name strings in make.info accordingly.  All this
difficulties can be avoided by no spliting the info formated docs anymore.

I have compiled make 3.81 on WinXP(home) with djdev204 and the djgpp ports of
gcc 4.2.2, binutils 2.17 and perl 5.8.8.  If more information is needed, please
contact me.

I have cc the mail to djgpp-workers.  May be that someone there has some
djgpp specific fix to contribute.


Regards,
Juan M. Guerrero



2007-11-19  Juan Manuel Guerrero  <address@hidden>

        * glob/glob.c [__GNU_LIBRARY__] [__DJGPP__]: Add a realloc declaration
        that matches the djgpp's libc one.

        * configh.dos [__DJGPP__]: Replace HAVE_SYS_SIGLIST with 
HAVE_DECL_SYS_SIGLIST.

        * job.c (child_execute_job): Remove __MSDOS__ because MSDOS/DJGPP build
        do not use child_execute_job.

        * variable.c (define_automatic_variables) [__MSDOS__]: Export always
        the SHELL environment variable to the child.





diff -aprNU5 make-3.81.orig/configh.dos make-3.81/configh.dos
--- make-3.81.orig/configh.dos  2006-04-01 06:42:38 +0000
+++ make-3.81/configh.dos       2007-11-15 05:12:02 +0000
@@ -23,11 +23,11 @@ Foundation, Inc., 51 Franklin St, Fifth 
 
 /* Define if `sys_siglist' is declared by <signal.h>.  */
 # define SYS_SIGLIST_DECLARED 1
 
 /* Define this if the C library defines the variable `_sys_siglist'.  */
-# define HAVE_SYS_SIGLIST 1
+# define HAVE_DECL_SYS_SIGLIST 1
 
 #else
 
 /* Define NSIG.  */
 # define NSIG SIGMAX
diff -aprNU5 make-3.81.orig/glob/glob.c make-3.81/glob/glob.c
--- make-3.81.orig/glob/glob.c  2006-03-10 02:20:44 +0000
+++ make-3.81/glob/glob.c       2007-11-15 01:58:30 +0000
@@ -187,16 +187,19 @@ __inline
 # endif
 # ifndef __SASC
 #  ifdef WINDOWS32
 static void *
 my_realloc (void *p, unsigned int n)
+#  elif defined(__DJGPP__)
+static void *
+my_realloc (void *p, size_t n)
 #  else
 static char *
 my_realloc (p, n)
      char *p;
      unsigned int n;
-# endif
+#  endif
 {
   /* These casts are the for sake of the broken Ultrix compiler,
      which warns of illegal pointer combinations otherwise.  */
   if (p == NULL)
     return (char *) malloc (n);
diff -aprNU5 make-3.81.orig/job.c make-3.81/job.c
--- make-3.81.orig/job.c        2006-03-20 03:03:04 +0000
+++ make-3.81/job.c     2007-11-15 01:58:30 +0000
@@ -1890,11 +1890,11 @@ start_waiting_jobs (void)
 }
  
 #ifndef WINDOWS32
 
 /* EMX: Start a child process. This function returns the new pid.  */
-# if defined __MSDOS__ || defined __EMX__
+# if defined __EMX__
 int
 child_execute_job (int stdin_fd, int stdout_fd, char **argv, char **envp)
 {
   int pid;
   /* stdin_fd == 0 means: nothing to do for stdin;
diff -aprNU5 make-3.81.orig/variable.c make-3.81/variable.c
--- make-3.81.orig/variable.c   2006-03-08 20:15:08 +0000
+++ make-3.81/variable.c        2007-11-15 01:58:30 +0000
@@ -793,10 +793,13 @@ define_automatic_variables (void)
 #endif
 
   /* This won't override any definition, but it will provide one if there
      isn't one there.  */
   v = define_variable ("SHELL", 5, default_shell, o_default, 0);
+#ifdef __MSDOS__
+  v->export = v_export;  /*  Export always SHELL.  */
+#endif
 
   /* On MSDOS we do use SHELL from environment, since it isn't a standard
      environment variable on MSDOS, so whoever sets it, does that on purpose.
      On OS/2 we do not use SHELL from environment but we have already handled
      that problem above. */


make.exe: *** No rule to make target `make.texinfo', needed by `make.info'.
Making check in glob
e:/p2/__/make-3.81/make.exe -C glob -f ../Makefile check-am
make.exe[1]: Entering directory `e:/p2/__/make-3.81/glob'
make.exe[1]: Nothing to be done for `check-am'.
make.exe[1]: Leaving directory `e:/p2/__/make-3.81/glob'
If Make says Error -1, you do not have Unix-style shell installed
cd tests && perl ./run_make_tests.pl -make ../make.exe 
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
        LC_ALL = (unset),
        LANG = "de"
    are supported and installed on your system.
perl: warning: Falling back to the standard locale ("C").
------------------------------------------------------------------------------
             Running tests for GNU make on MS-DOS MEIN_COM 5 i786
                                GNU Make 3.81
------------------------------------------------------------------------------

Finding tests...

features/comments ....................................... ok     (1 passed)
features/conditionals ................................... ok     (4 passed)
features/default_names .................................. ok     (2 passed)
features/double_colon ................................... ok     (6 passed)
features/echoing ........................................ ok     (4 passed)
features/errors ......................................... ok     (2 passed)
features/escape ......................................... ok     (6 passed)
features/export ......................................... ok     (10 passed)
features/include ........................................ ok     (7 passed)
features/mult_rules ..................................... ok     (2 passed)
features/mult_targets ................................... ok     (2 passed)
features/order_only ..................................... ok     (10 passed)
features/override ....................................... ok     (1 passed)
features/parallelism .................................... N/A
features/patspecific_vars ............................... ok     (7 passed)
features/patternrules ................................... ok     (5 passed)
features/quoting ........................................ ok     (1 passed)
features/recursion ...................................... ok     (2 passed)
features/reinvoke ....................................... ok     (4 passed)
features/se_explicit .................................... ok     (5 passed)
features/se_implicit .................................... ok     (8 passed)
features/se_statpat ..................................... ok     (4 passed)
features/statipattrules ................................. ok     (8 passed)
features/targetvars ..................................... ok     (20 passed)
features/varnesting ..................................... ok     (1 passed)
features/vpath .......................................... ok     (1 passed)
features/vpath2 ......................................... ok     (1 passed)
features/vpathgpath ..................................... ok     (1 passed)
features/vpathplus ...................................... ok     (4 passed)
functions/abspath ....................................... FAILED (0/1 passed)
functions/addprefix ..................................... ok     (1 passed)
functions/addsuffix ..................................... ok     (2 passed)
functions/andor ......................................... ok     (2 passed)
functions/basename ...................................... ok     (1 passed)
functions/call .......................................... ok     (2 passed)
functions/dir ........................................... ok     (1 passed)
functions/error ......................................... ok     (5 passed)
functions/eval .......................................... ok     (9 passed)
functions/filter-out .................................... ok     (1 passed)
functions/findstring .................................... ok     (1 passed)
functions/flavor ........................................ ok     (1 passed)
functions/foreach ....................................... ok     (4 passed)
functions/if ............................................ ok     (1 passed)
functions/join .......................................... ok     (1 passed)
functions/notdir ........................................ ok     (1 passed)
functions/origin ........................................ ok     (1 passed)
functions/realpath ...................................... ok     (2 passed)
functions/shell ......................................... ok     (2 passed)
functions/sort .......................................... ok     (1 passed)
functions/strip ......................................... ok     (2 passed)
functions/substitution .................................. ok     (3 passed)
functions/suffix ........................................ ok     (1 passed)
functions/value ......................................... ok     (1 passed)
functions/warning ....................................... ok     (4 passed)
functions/wildcard ...................................... ok     (3 passed)
functions/word .......................................... ok     (16 passed)
misc/close_stdout ....................................... ok     (0 passed)
misc/general1 ........................................... ok     (1 passed)
misc/general2 ........................................... ok     (1 passed)
misc/general3 ........................................... ok     (10 passed)
misc/general4 ........................................... ok     (6 passed)
options/dash-B .......................................... FAILED (5/7 passed)
options/dash-C .......................................... ok     (2 passed)
options/dash-I .......................................... ok     (3 passed)
options/dash-W .......................................... FAILED (9/10 passed)
options/dash-e .......................................... ok     (1 passed)
options/dash-f .......................................... ok     (4 passed)
options/dash-k .......................................... FAILED (2/3 passed)
options/dash-l .......................................... ok     (1 passed)
options/dash-n .......................................... ok     (4 passed)
options/dash-q .......................................... ok     (8 passed)
options/dash-t .......................................... ok     (2 passed)
options/general ......................................... ok     (1 passed)
options/symlinks ........................................ N/A
options/warn-undefined-variables ........................ ok     (2 passed)
targets/INTERMEDIATE .................................... ok     (8 passed)
targets/SECONDARY ....................................... ok     (8 passed)
targets/clean ........................................... ok     (2 passed)
targets/default ......................................... ok     (1 passed)
targets/force ........................................... ok     (1 passed)
targets/phony ........................................... ok     (1 passed)
targets/silent .......................................... ok     (1 passed)
variables/DEFAULT_GOAL .................................. ok     (4 passed)
variables/INCLUDE_DIRS .................................. ok     (2 passed)
variables/MAKECMDGOALS .................................. ok     (3 passed)
variables/MAKEFILES ..................................... ok     (1 passed)
variables/MAKELEVEL ..................................... ok     (1 passed)
variables/MAKE_RESTARTS ................................. FAILED (0/3 passed)
variables/MFILE_LIST .................................... ok     (1 passed)
variables/automatic ..................................... ok     (5 passed)
variables/curdir ........................................ ok     (1 passed)
variables/flavors ....................................... ok     (10 passed)
variables/make .......................................... ok     (1 passed)
variables/negative ...................................... ok     (4 passed)
variables/shell ......................................... FAILED (0/5 passed)
variables/special ....................................... ok     (1 passed)

13 Tests in 6 Categories Failed (See .diff files in work dir for details) :-(

make.exe: *** [check-regression] Error 1
make.exe: Target `check' not remade because of errors.




reply via email to

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