From: Brandon S. Allbery (bsa@kf8nh.wariat.org)
Date: 05/29/93


From: bsa@kf8nh.wariat.org (Brandon S. Allbery)
Subject: Compiling rc: gcc bug and workaround
Date: Sun, 30 May 1993 03:11:52 GMT

Someone asked some time ago about a problem building rc: it would compile,
but would fail its "trip test". I had similar symptoms building it under SCO
Unix with gcc 2.3.3, and it turned out to be a problem with gcc; it looks it's
a generic gcc problem, because the same workaround fixes it under Linux.

The workaround follows:

*** exec.c.orig Sat May 29 23:03:10 1993
--- exec.c Sat May 29 23:04:00 1993
***************
*** 18,23 ****
--- 18,26 ----
        bool didfork, returning, saw_exec, saw_builtin;
        av = list2array(s, dashex);
        saw_builtin = saw_exec = FALSE;
+ #if defined(M_UNIX) || defined(linux)
+ stupid_gcc_bug_hack(vp);
+ #endif
        do {
                if (*av == NULL || isabsolute(*av))
                        b = NULL;
*** /dev/null Sat Aug 29 17:48:28 1992
--- gcc_botch.c Sat May 29 22:47:24 1993
***************
*** 0 ****
--- 1,3 ----
+ stupid_gcc_bug_hack()
+ {
+ }
*** Makefile.orig Sat May 29 23:05:17 1993
--- Makefile Sat May 29 23:05:34 1993
***************
*** 27,33 ****
  OBJS=$(ADDON) builtins.o except.o exec.o $(EXECVE) fn.o footobar.o getopt.o \
        glob.o glom.o hash.o heredoc.o input.o lex.o list.o main.o match.o \
        nalloc.o open.o print.o redir.o sigmsgs.o signal.o status.o tree.o \
! utils.o var.o version.o wait.o walk.o which.o y.tab.o
  
  # If rc is compiled with READLINE defined, you must supply the correct
  # arguments to ld on this line. Typically this would be something like:
--- 27,33 ----
  OBJS=$(ADDON) builtins.o except.o exec.o $(EXECVE) fn.o footobar.o getopt.o \
        glob.o glom.o hash.o heredoc.o input.o lex.o list.o main.o match.o \
        nalloc.o open.o print.o redir.o sigmsgs.o signal.o status.o tree.o \
! utils.o var.o version.o wait.o walk.o which.o y.tab.o gcc_botch.o
  
  # If rc is compiled with READLINE defined, you must supply the correct
  # arguments to ld on this line. Typically this would be something like:

The important part seems to be the passing of vp to a function. Why that has
an effect is completely beyind me; I didn't see any obvious differences in the
assembly output from gcc -S, and the problem occurred regardless of whether
optimization was enabled or not. (I haven't reported it because 2.4 was soon
to come out --- and now is out, and 2.4.1 is pending... when 2.4 stabilizes,
I'll try it again and submit a bug report if necessary.)

++Brandon

-- 
Brandon S. Allbery         kf8nh@kf8nh.ampr.org          bsa@kf8nh.wariat.org

It's not too late to turn back from the "Gates" of Hell... Linux: the free 32-bit operating system, available NOW. Why waaaaaait for NT?