Bug 18810 - [4.0 Regression] Darwin's as unlinks /dev/null
Summary: [4.0 Regression] Darwin's as unlinks /dev/null
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: bootstrap (show other bugs)
Version: 4.0.0
: P2 normal
Target Milestone: 4.0.0
Assignee: Not yet assigned to anyone
URL:
Keywords: build, patch
Depends on:
Blocks:
 
Reported: 2004-12-03 14:24 UTC by Ed Smith-Rowland
Modified: 2005-02-16 04:49 UTC (History)
5 users (show)

See Also:
Host: powerpc-apple-darwin7.6.0
Target: powerpc-apple-darwin7.6.0
Build: powerpc-apple-darwin7.6.0
Known to work:
Known to fail:
Last reconfirmed: 2005-02-10 03:58:07


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Ed Smith-Rowland 2004-12-03 14:24:09 UTC
I did a make bootstrap with the latest CVS and everything went fine.
This was right after I did a cvs update.  The configure was rerun.  Everything
built just fine.

Here are the setup particulars:

MacOSX:~/obj-4.0.0 ed$ ../gcc-4.0.0/bin/gfortran -v
Reading specs from /Users/ed/gcc-4.0.0/lib/gcc/powerpc-apple-darwin7.6.0/4.0.0/specs
Configured with: ../gcc/configure --prefix=/Users/ed/gcc-4.0.0 : (reconfigured)
../gcc/configure --prefix=/Users/ed/gcc-4.0.0
--with-gcc-version-trigger=/Users/ed/gcc/gcc/version.c
--enable-languages=c,c++,f95,java,objc --no-create --no-recursion
Thread model: posix
gcc version 4.0.0 20041202 (experimental)


Then I did a make install and most of the executables seem to be installed
correctly but then it seems to endlessly loop these lines:

./config.status: line 24: /dev/null: Operation not supported
./config.status: line 32: /dev/null: Operation not supported
./config.status: line 55: /dev/null: Operation not supported
./config.status: line 65: /dev/null: Operation not supported
./config.status: line 2: /dev/null: Operation not supported
./config.status: line 1: /dev/null: Operation not supported

The libs have not been updated and
It seems like Apple doesn't have a /dev/null file! WTF!

There is a /dev/zero but I don't know if this is the equivalent.
Comment 1 Andrew Pinski 2004-12-03 14:27:25 UTC
Something must be wrong with OS or machine because I have a /dev/null:


crw-rw-rw-  1 root  wheel    3,   2  3 Dec 09:26 /dev/null

Darwin zhivago.erc-wireless.uc.edu 7.6.0 Darwin Kernel Version 7.6.0: Sun Oct 10 12:05:27 PDT 2004; 
root:xnu/xnu-517.9.4.obj~1/RELEASE_PPC  Power Macintosh powerpc
[zhivago:gcc/objdir/gcc] pinskia% 
Comment 2 Andrew Pinski 2004-12-03 14:29:44 UTC
See my previous comment, this works for me on an almost clean Mac OS X 10.3.6 install.  The only 
thing I installed after that was the cctools.
Comment 3 htanabe 2004-12-03 17:37:57 UTC
(In reply to comment #1)
On Mac OSX 10.3.6

> Something must be wrong with OS or machine because I have a /dev/null:
> 
> 
> crw-rw-rw-  1 root  wheel    3,   2  3 Dec 09:26 /dev/null
> 
> Darwin zhivago.erc-wireless.uc.edu 7.6.0 Darwin Kernel Version 7.6.0: Sun Oct 10 12:05:27 PDT 
2004; 
> root:xnu/xnu-517.9.4.obj~1/RELEASE_PPC  Power Macintosh powerpc
> [zhivago:gcc/objdir/gcc] pinskia% 

I have the same problem.
/dev/null exists before doing make install.
It seems to be removed during the process of making install.
Comment 4 Ed Smith-Rowland 2004-12-05 21:44:48 UTC
(In reply to comment #3)

I found a way to recreate /dev/null (besides rebooting)

sudo mknod /dev/null c 1 3
chmod a+rw /dev/null

Anyway,
I cleaned out my object directory and the install directory and bootstrapped
from scratch and installation worked.  It seems that doing a CVS update fails
after a while and leaves something corrupted.

> (In reply to comment #1)
> On Mac OSX 10.3.6
> 
> > Something must be wrong with OS or machine because I have a /dev/null:
> > 
> > 
> > crw-rw-rw-  1 root  wheel    3,   2  3 Dec 09:26 /dev/null
> > 
> > Darwin zhivago.erc-wireless.uc.edu 7.6.0 Darwin Kernel Version 7.6.0: Sun
Oct 10 12:05:27 PDT 
> 2004; 
> > root:xnu/xnu-517.9.4.obj~1/RELEASE_PPC  Power Macintosh powerpc
> > [zhivago:gcc/objdir/gcc] pinskia% 
> 
> I have the same problem.
> /dev/null exists before doing make install.
> It seems to be removed during the process of making install.
Comment 5 Ed Smith-Rowland 2004-12-12 02:21:03 UTC
Apple PPC OSX people..

The bootstrap works but I'm getting fails on the install

This bug is caused by deletion of the /dev/null file by the install process. 
I've verified that the /dev/null is there before the install and is missing
after.  You can see the messages about /dev/null not permitted.

I'm not making this up and I'm not delusional - see comment #3.

I've cleaned out all my source build, and instal directories, rebooted the
machine (to restore the /dev/null file) and downloaded cvs trunk and rebuilt
from scratch.

The make bootstrap has been going to completion for the last two weeks at least.

Sometimes the install works.

But sometimes the install fails in the middle with these messages:
or
/bin/sh: line 1: /dev/null: Operation not supported
or
./config.status: line 24: /dev/null: Operation not supported

This is real and it is caused by the make install.

I will do my best to track this down but these issues are buried down in shell
scripts that I have trouble tracing through.  Any advice on this issue of
debugging the install tools would be greatly appreciated.

Ed Smith-Rowland
Comment 6 Andrew Pinski 2004-12-12 02:26:12 UTC
There is no way /dev/null can be deleted without running as root.  Since you are installing in your home 
directory, there is no reason why you should be installing as root.

So this might be a problem with your machine (or the version of darwin you are using) and not with gcc.  
Also I just installed gcc about three hours ago.  And I also installed it like three times yesterday so I 
know this is not a gcc bug. 
Comment 7 Andrew Pinski 2004-12-12 02:29:13 UTC
Just for the record:
[zhivago:local1/gcc/gcc] pinskia% ~/local/bin/gcc -v
Reading specs from /Users/pinskia/local/lib/gcc/powerpc-apple-darwin7.6.0/4.0.0/specs
Configured with: /Users/pinskia/src/local/gcc/configure --prefix=/Users/pinskia/local --enable-
languages=c,java,objc,f95
Thread model: posix
gcc version 4.0.0 20041210 (experimental)
[zhivago:local1/gcc/gcc] pinskia% ~/local1/bin/gcc -v
Reading specs from /Users/pinskia/local1/lib/gcc/powerpc-apple-darwin7.6.0/4.0.0/specs
Configured with: /Users/pinskia/src/local1/gcc/configure --prefix=/Users/pinskia/local1 --enable-
languages=c,c++,objc,f95
Thread model: posix
gcc version 4.0.0 20041210 (experimental)
[zhivago:local1/gcc/gcc] pinskia% ~/local2/bin/gcc -v
Reading specs from /Users/pinskia/local2/lib/gcc/powerpc-apple-darwin7.6.0/4.0.0/specs
Configured with: /Users/pinskia/src/local2/gcc/configure --prefix=/Users/pinskia/local2 --enable-
languages=ada
Thread model: posix
gcc version 4.0.0 20041208 (experimental)
[zhivago:local1/gcc/gcc] pinskia% ~/local3/bin/gcc -v
Reading specs from /Users/pinskia/local3/lib/gcc/powerpc-apple-darwin7.6.0/4.0.0/specs
Configured with: /Users/pinskia/src/local3/gcc/configure --prefix=/Users/pinskia/local3 --enable-
languages=c++,objc,f95,java --disable-checking
Thread model: posix
gcc version 4.0.0 20041211 (experimental)
[zhivago:local1/gcc/gcc] pinskia% ~/local3.memory/bin/gcc -v
Reading specs from /Users/pinskia/local3.memory/lib/gcc/powerpc-apple-darwin7.6.0/4.0.0/specs
Configured with: /Users/pinskia/src/local3/gcc/configure --prefix=/Users/pinskia/local3.memory --
enable-languages=c++,objc,f95 --enable-gather-detailed-mem-stats --disable-checking
Thread model: posix
gcc version 4.0.0 20041211 (experimental)

As you can see that installed (and built it) at least 4 times in the last two days. And most of the builds 
include f95 also.
Comment 8 Andrew Pinski 2004-12-12 02:45:13 UTC
Also do "ls -la /dev/null"

can you reboot?
Also are you sure that you don't have a hardware problem like bad memory?

If this does not work, maybe reinstalling the OS might fix it as this might be a corrupted bug.
Comment 9 Ed Smith-Rowland 2004-12-12 03:48:40 UTC
(In reply to comment #8)
> Also do "ls -la /dev/null"

crw-rw-rw-  1 root  wheel    3,   2 11 Dec 22:31 /dev/null

Block special, root/wheel, should be OK.

> can you reboot?
> Also are you sure that you don't have a hardware problem like bad memory?
Rebooted.  Not sure about memory.  I'll figure out how to check that.

> If this does not work, maybe reinstalling the OS might fix it as this might be
a corrupted bug.

One wierd thing.  Somehow the install command got associated with some other
program in my directory (maybe I called some executable install by mistake.)
I removed this executable (and another link to /usr/bin/install in another
directory) and moved these directorys to the end of my $PATH.

So now install resolves to /usr/bin/install as it should.

Anyway I'm going to redo everything with just C and see how it goes.
I'm going to start small.  That Java runtime is freekin' huge.

Anyhow, thank you for your indulgence and prompt suggestions.


P.S. where do you get your compiler to bootstrap ada?
Comment 10 Andrew Pinski 2004-12-12 03:52:10 UTC
(In reply to comment #9)
> P.S. where do you get your compiler to bootstrap ada?

macada.org

Note that what is in the CVS might not bootstrap though, I have a local patch which I submitted to fix it, 
it is still not approved yet.
Comment 11 Andrew Pinski 2005-01-04 01:19:06 UTC
*** Bug 19248 has been marked as a duplicate of this bug. ***
Comment 12 Andrew Pinski 2005-01-04 08:32:34 UTC
*** Bug 19248 has been marked as a duplicate of this bug. ***
Comment 13 Peter O'Gorman 2005-02-10 03:08:13 UTC
My /dev/null also gets unlinked during 'sudo make install', so I decided to find the problem.  I made a 
shared library that contained an unlink function:
#include <sys/syscall.h>
#include <string.h>

int unlink(const char *path)
{
  if (!strcmp("/dev/null",path)) {
        sleep(180);
        return 0;
  }
  return syscall(SYS_unlink,path);
}

and used DYLD_INSERT_LIBRARIES before doing make install as root. Doing this, I discovered that my 
gcc/libgcc.mk contains:
vis_hide := $(strip $(subst @,-,\
    $(shell if echo 'void foo(void); void foo(void) {}' | \
          $(GCC_FOR_TARGET) $(LIBGCC2_CFLAGS) $(INCLUDES) -fvisibility=hidden -Werror \
          -c -xc - -o /dev/null 2> /dev/null; \
          then echo @fvisibility=hidden @DHIDE_EXPORTS; \
          fi)))

and that darwin's as has a write_object.c which at aoround line 582 has:
	(void)unlink(out_file_name);

I suggest changing the bit of gcc/mklibgcc.in that says:
  # Test -fvisibility=hidden.  We need both a -fvisibility=hidden on
  # the command line, and a #define to prevent libgcc2.h etc from
  # overriding that with #pragmas.  The dance with @ is to prevent
  # echo from seeing anything it might take for an option.
  echo "vis_hide := \$(strip \$(subst @,-,\\"
  echo "    \$(shell if echo 'void foo(void); void foo(void) {}' | \\"
  echo "          $gcc_compile -fvisibility=hidden -Werror \\"
  echo "          -c -xc - -o /dev/null 2> /dev/null; \\"
  echo "          then echo @fvisibility=hidden @DHIDE_EXPORTS; \\"
  echo "          fi)))"
  echo

So the -o /dev/null goes away. It shouldn't be too hard to make a temporary file name and rm the temp 
file here.



Comment 14 Andrew Pinski 2005-02-10 03:45:02 UTC
Subject: Re:  Operation not supported while installing 4.0.0 on apple-darmin-7.6.0.


On Feb 9, 2005, at 10:08 PM, peter at pogma dot com wrote:

> and that darwin's as has a write_object.c which at aoround line 582 
> has:
> 	(void)unlink(out_file_name);

So is this really a darwin's as bug rather than a gcc bug.

-- Andrew

Comment 15 Peter O'Gorman 2005-02-10 03:49:59 UTC
I filed a radar that /dev/null shouldn't be unlinkable. But gcc should probably avoid '-o /dev/null', it is 
just used to check if -fvisibility=hidden is available. There must either be another way to do that check 
or use the temp file method.
Comment 16 Andrew Pinski 2005-02-10 03:56:33 UTC
Reopening as a regression.
Comment 17 Andrew Pinski 2005-02-10 03:58:07 UTC
Peter could you create a patch to deal with this?
Please post it to gcc-patches@.
Comment 18 Peter O'Gorman 2005-02-10 04:05:07 UTC
Okay, I'll try.
Comment 20 GCC Commits 2005-02-16 04:49:00 UTC
Subject: Bug 18810

CVSROOT:	/cvs/gcc
Module name:	gcc
Changes by:	pinskia@gcc.gnu.org	2005-02-16 04:48:48

Modified files:
	gcc            : ChangeLog mklibgcc.in 

Log message:
	2005-02-15  Peter O'Gorman  <peter@pogma.com>
	
	PR bootstrap/18810
	* mklibgcc.in (vis_hide): Use a temporary object file, not
	-o /dev/null.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&r1=2.7489&r2=2.7490
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/mklibgcc.in.diff?cvsroot=gcc&r1=1.82&r2=1.83

Comment 21 Andrew Pinski 2005-02-16 04:49:45 UTC
Fixed finnally in gcc.  (this has been also reported and fixed in a newer cctools too by Geoff Keating).

Thanks for convencing me there was a workaround and a place to fix this.