rmyorston / busybox-w32

WIN32 native port of BusyBox.
https://frippery.org/busybox
Other
670 stars 124 forks source link

busybox-w32 make performs the same task repeatedly #410

Closed smalltalkman closed 4 months ago

smalltalkman commented 4 months ago

busybox-w32 make will perform the same task repeatedly when compiling, testing and installing m4-1.4.19. This phenomenon was not found when using gnu make. I recorded this phenomenon here so that I can retest it later.

root@lenovo-PC ~/m4-1.4.19          
# make                              
make  all-recursive                 
Making all in .                     
make: nothing to be done for all-am 
Making all in examples              
make: nothing to be done for all    
Making all in lib                   
  GEN      alloca.h                 
  GEN      configmake.h             
  GEN      dirent.h                 
  GEN      errno.h                  
  GEN      fcntl.h                  
  GEN      inttypes.h               
  GEN      langinfo.h               
  GEN      limits.h                 
  GEN      locale.h                 
  GEN      math.h                   
  GEN      sched.h                  
  GEN      signal.h                 
  GEN      sigsegv.h                
  GEN      spawn.h                  
  GEN      stdint.h                 
  GEN      stdio.h                  
  GEN      stdlib.h                 
  GEN      string.h                 
  GEN      sys/random.h             
  GEN      sys/stat.h               
  GEN      sys/types.h              
  GEN      sys/wait.h               
  GEN      time.h                   
  GEN      unistd.h                 
  GEN      unistr.h                 
  GEN      unitypes.h               
  GEN      uniwidth.h               
  GEN      wchar.h                  
  GEN      wctype.h                 
make  all-am                        
  CC       asyncsafe-spin.o         
  CC       openat-proc.o            
  CC       gl_avltree_oset.o        
  CC       basename-lgpl.o          
  CC       binary-io.o              
  CC       bitrotate.o              
  CC       c-ctype.o                
  CC       c-stack.o                
  CC       c-strcasecmp.o           
  CC       c-strncasecmp.o          
  CC       canonicalize.o           
...
...
  AR       libm4.a
Making all in src
  CC       m4.o
  CC       builtin.o
  CC       debug.o
  CC       eval.o
  CC       format.o
  CC       freeze.o
  CC       input.o
  CC       macro.o
  CC       output.o
  CC       path.o
  CC       symtab.o
  CCLD     m4.exe
Making all in doc
make: nothing to be done for all
Making all in checks
make: nothing to be done for all
Making all in po
make: nothing to be done for all
Making all in tests
  GEN      arpa/inet.h
  GEN      ctype.h
  GEN      netinet/in.h
  GEN      test-posix_spawn-dup2-stdout.sh
  GEN      test-posix_spawn-dup2-stdin.sh
  GEN      pthread.h
  GEN      sys/ioctl.h
  GEN      sys/select.h
  GEN      sys/socket.h
  GEN      sys/time.h
  GEN      sys/uio.h
make  all-recursive
Making all in .
  CC       locale.o
  CC       gl_array_list.o
  CC       gl_array_oset.o
  CC       findprog.o
  CC       imaxtostr.o
  CC       inttostr.o
  CC       offtostr.o
  CC       uinttostr.o
  CC       umaxtostr.o
  CC       read-file.o
  CC       sockets.o
  CC       sys_socket.o
  CC       glthread/thread.o
  CC       vma-iter.o
  CC       xconcat-filename.o
  CC       accept.o
  CC       bind.o
...
...
  CC       setenv.o
  CC       setsockopt.o
  CC       sleep.o
  CC       socket.o
  CC       strerror_r.o
  CC       symlink.o
  CC       unsetenv.o
  CC       wctob.o
  CC       windows-thread.o
  CC       write.o
  AR       libtests.a
  CCLD     current-locale.exe
  CC       test-localcharset.o
  CCLD     test-localcharset.exe
root@lenovo-PC ~/m4-1.4.19
# make install
make  install-recursive
Making install in .
make: nothing to be done for install-exec-am
make: nothing to be done for install-data-am
Making install in examples
make: nothing to be done for install-exec-am
make: nothing to be done for install-data-am
Making install in lib
make  install-am
  CC       asyncsafe-spin.o
  CC       openat-proc.o
  CC       gl_avltree_oset.o
  CC       basename-lgpl.o
  CC       binary-io.o
  CC       bitrotate.o
  CC       c-ctype.o
  CC       c-stack.o
  CC       c-strcasecmp.o
  CC       c-strncasecmp.o
  CC       canonicalize.o
...
...
  AR       libm4.a
make: nothing to be done for install-exec-am
make: nothing to be done for install-data-am
Making install in src
  CCLD     m4.exe
 .././build-aux/install-sh -c -d 'D:/gym/softwares/busybox/usr/local/bin'
  .././build-aux/install-sh -c m4.exe 'D:/gym/softwares/busybox/usr/local/bin'
make: nothing to be done for install-data-am
Making install in doc
make: nothing to be done for install-exec-am
 .././build-aux/install-sh -c -d 'D:/gym/softwares/busybox/usr/local/share/info'
 .././build-aux/install-sh -c -m 644 ./m4.info ./m4.info-1 ./m4.info-2 'D:/gym/softwares/busybox/usr/local/share/info'
 .././build-aux/install-sh -c -d 'D:/gym/softwares/busybox/usr/local/share/man/man1'
 .././build-aux/install-sh -c -m 644 ./m4.1 'D:/gym/softwares/busybox/usr/local/share/man/man1'
Making install in checks
make: nothing to be done for install-exec-am
make: nothing to be done for install-data-am
Making install in po
if test "m4" = "gettext-tools"; then \
  .././build-aux/install-sh -c -d D:/gym/softwares/busybox/usr/local/share/gettext/po; \
  for file in Makefile.in.in remove-potcdate.sin  quot.sed boldquot.sed en@quot.header en@boldquot.header insert-header.sin Rules-quot   Makevars.template; do \
    .././build-aux/install-sh -c -m 644 ./$file \
                    D:/gym/softwares/busybox/usr/local/share/gettext/po/$file; \
  done; \
  for file in Makevars; do \
    rm -f D:/gym/softwares/busybox/usr/local/share/gettext/po/$file; \
  done; \
else \
  : ; \
fi
Making install in tests
make  install-recursive
Making install in .
  CCLD     current-locale.exe
  CCLD     test-localcharset.exe
make: nothing to be done for install-exec-am
make: nothing to be done for install-data-am
# make check
make  check-recursive
Making check in .
make: nothing to be done for check-am
Making check in examples
make: nothing to be done for check
Making check in lib
make  check-am
  CC       asyncsafe-spin.o
  CC       openat-proc.o
  CC       gl_avltree_oset.o
  CC       basename-lgpl.o
  CC       binary-io.o
  CC       bitrotate.o
  CC       c-ctype.o
  CC       c-stack.o
  CC       c-strcasecmp.o
  CC       c-strncasecmp.o
  CC       canonicalize.o
...
...
  AR       libm4.a
Making check in src
  CCLD     m4.exe
Making check in doc
make: nothing to be done for check
Making check in checks
make  check-local
PATH=`pwd`/../src";"$PATH; export PATH; \
./check-them -I ./../examples ./*[0-9][0-9][0-9].* ./stackovf.test
m4 (GNU M4) 1.4.19
Copyright (C) 2021 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <https://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Written by Rene' Seindal.
Ignoring carriage returns
Checking ./001.preprocess
Checking ./002.debugging_
Checking ./003.command_li
Checking ./004.command_li
Checking ./005.command_li
 skipping: syscmd does not have unix semantics
Checking ./006.command_li
 skipping: syscmd does not have unix semantics
Checking ./007.command_li
 skipping: syscmd does not have unix semantics
Checking ./008.comments
Checking ./009.comments
Checking ./010.input_proc
Checking ./011.input_proc
Checking ./012.inhibiting
Checking ./013.inhibiting
Checking ./014.inhibiting
Checking ./015.inhibiting
...
...

It is obvious that CC asyncsafe-spin.o and similar tasks are executed repeatedly.

rmyorston commented 4 months ago

I see what the problem is, I just need to figure out how to fix it.

Pretty much everything in the m4-1.4.19 lib directory depends on config.h, and config.h depends on stamp-h1.

The first run of make sees that stamp-h1 doesn't exist so it runs the rule to create it. This rule first creates config.h then creates stamp-h1.

On subsequent runs, config.h is seen to be out-of-date relative to its prerequisite stamp-h1 so the rule to create it is run. But since config.h already exists that rule doesn't actually do anything.

At this point busybox-w32 make, thinking that config.h has been updated, records the current time as its modification time. Thus all the files that depend on config.h are considered out-of-date and are rebuilt. Other versions of make are cleverer (and probably more POSIX compliant) and don't do all the unnecessary rebuilding.

rmyorston commented 4 months ago

I've applied a quick patch which solves the immediate problem. Let's hope it doesn't break anything else.

Try the latest prerelease (PRE-5331 or above).

smalltalkman commented 4 months ago

I've applied a quick patch which solves the immediate problem. Let's hope it doesn't break anything else.

Try the latest prerelease (PRE-5331 or above).

Recompiled, tested and installed on m4-1.4.19. Judging from the results, the patch worked very well and no problems were found.

I will make additional verifications on diffutils-3.10 and make-4.4.1 tomorrow.

smalltalkman commented 4 months ago

I will make additional verifications on diffutils-3.10 and make-4.4.1 tomorrow.

No issues found so far.