Trying to bootstrap Ada with a 4.2-suffixed host compiler install yields + CC=gcc-4.2 + GNATBIND=gnatbind-4.2 + GNATMAKE=gnatmake-4.2 + ../configure --enable-threads=posix --prefix=/usr --with-local-prefix=/usr/local --infodir=/usr/share/info --mandir=/usr/share/man --libdir=/usr/lib --libexecdir=/usr/lib --enable-languages=c,c++,objc,fortran,obj-c++,java,ada --enable-checking=release --with-gxx-include-dir=/usr/include/c++/4.3.0 --enable-ssp --disable-libssp --with-bugurl=http://bugs.opensuse.org/ '--with-pkgversion=SUSE Linux' --disable-libgcj --with-slibdir=/lib --with-system-zlib --enable-shared --enable-__cxa_atexit --enable-libstdcxx-allocator=new --disable-libstdcxx-pch --program-suffix=-4.3 --enable-version-specific-runtime-libs --without-system-libunwind --with-cpu=generic --build=i586-suse-linux ... checking for gnatbind... gnatbind-4.2 checking for gnatmake... gnatmake-4.2 checking whether compiler driver understands Ada... yes ... (cd ada/bldtools/nmake_b; gnatmake-4.2 -q xnmake ; ./xnmake -b ../../nmake.adb ) gnatmake-4: error, unable to locate gnatmake-gcc /bin/sh: ./xnmake: No such file or directory make[3]: *** [ada/nmake.adb] Error 127 apperantly gnatmake is totally confused about its own name.
I'm seeing essentially the same thing on i686-apple-darwin9: # gnattools2 make -C ../gcc/ada/tools -f ../Makefile \ "CC=../../xgcc -B../../" "CFLAGS=-O2 -g -g -O2 " "ADAFLAGS=-gnatpg -g nata" "INCLUDES=-I. -I.. -I../.. -I/Users/dave/gnu/gcc/gcc/gcc/ada -I/Users/dave /gnu/gcc/gcc/gcc/ada/../config -I/Users/dave/gnu/gcc/gcc/gcc/ada/../../include - I/Users/dave/gnu/gcc/gcc/gcc/ada/.." "ADA_INCLUDES=-I../rts -I. -I/Users/dave/gn u/gcc/gcc/gcc/ada" "exeext=" "fsrcdir=/Users/dave/gnu/gcc/gcc/gcc/ada" "srcdir=/ Users/dave/gnu/gcc/gcc/gcc/ada" "GNATMAKE=../../gnatmake" "GNATLINK=../../gnatli nk" "GNATBIND=../../gnatbind" "TOOLSCASE=native" \ ../../gnatchop ../../gnat ../../gnatkr ../../gnatls ../../gnatprep ../ ../gnatxref ../../gnatfind ../../gnatname ../../gnatclean ../../gnatmake -c -I../rts -I. -I/Users/dave/gnu/gcc/gcc/gcc/ada gnatchop --GCC= "../../xgcc -B../../ -O2 -g -g -O2 -gnatpg -gnata" ../../xgcc -c -I./ -I../rts -I. -I/Users/dave/gnu/gcc/gcc/gcc/ada -B../../ -O2 - g -g -O2 -gnatpg -gnata -I- /Users/dave/gnu/gcc/gcc-4.3/gcc/ada/gnatchop.adb gnatmake: error, unable to locate ../../xgcc make[3]: *** [../../gnatchop] Error 4 make[2]: *** [gnattools-native] Error 2 make[1]: *** [all-gnattools] Error 2 make: *** [bootstrap] Error 2 Sun 24 Feb 2008 22:42:12 EST In this case, the bootstrap compiler was gcc version 4.3.0 20070903.
I can confirm this bug against gcc 4.2.3 and gcc 4.3.0 on os x (10.5.2). Apparently apple has changed the way that putenv is handled. From the `man 3 getenv` page i quote: "COMPATIBILITY putenv() no longer copies its input buffer. This often appears in crash logs as a crash in getenv(). Avoid passing local buffers or freeing the memory that is passed to putenv(). Use setenv(), which still makes an internal copy of its buffers." I have examined the source code and found the error to be in the file <base_path>/gcc/ada/env.c near line 179 in __gnat_setenv() with the following code: 179: putenv (expression); 180: #if (defined (__FreeBSD__) && (__FreeBSD__ < 7)) \ 181: || defined (__APPLE__) || defined (__MINGW32__) \ 182: ||(defined (__vxworks) && ! defined (__RTP__)) 183: /* On some systems like FreeBSD 6.x and earlier, MacOS X and Windows, 184: putenv is making a copy of the expression string so we can free 185: it after the call to putenv */ 186: free (expression); 187:#endif On current versions of OS X (10.5 on my system). This call to free on line 186 is causing all calls to getenv() after calling __gnat_setenv() to return NULL This happens when calling gnatmake during the Initialize procedure in make.adb near line 6645 with the following code: 6645: declare 6646: PATH : constant String := 6647: Prefix & Directory_Separator & "bin" & 6648: Path_Separator & 6649: Getenv ("PATH").all; 6650: begin 6651: Setenv ("PATH", PATH); 6652: end; Setenv here is located in <base_path>/gcc/ada/s-os_lib.adb near line 2285 Setenv imports __gnat_setenv I can confirm that removing the call to free fixes the problem in this bug report. However i do not know what proper preprocessor flags to use.
Subject: Re: Cannot bootstrap Ada with host gnatmake-4.2 > ------- Comment #2 from charles dot w dot lambert at gmail dot com 2008-02-27 16:32 ------- > I can confirm this bug against gcc 4.2.3 and gcc 4.3.0 on os x (10.5.2). > Apparently apple has changed the way that putenv is handled. From the `man 3 > getenv` page i quote: > "COMPATIBILITY > putenv() no longer copies its input buffer. This often appears in crash > logs as a > crash in getenv(). Avoid passing local buffers or freeing the memory that > is passed > to putenv(). Use setenv(), which still makes an internal copy of its > buffers." > > I have examined the source code and found the error to be in the file > <base_path>/gcc/ada/env.c near line 179 in __gnat_setenv() with the following > code: > 179: putenv (expression); > 180: #if (defined (__FreeBSD__) && (__FreeBSD__ < 7)) \ > 181: || defined (__APPLE__) || defined (__MINGW32__) \ > 182: ||(defined (__vxworks) && ! defined (__RTP__)) > 183: /* On some systems like FreeBSD 6.x and earlier, MacOS X and Windows, > 184: putenv is making a copy of the expression string so we can free > 185: it after the call to putenv */ > 186: free (expression); > 187:#endif It looks like setenv should be used, as in previous hunk for vxworks: #elif defined (__vxworks) && defined (__RTP__) setenv (name, value, 1); Dave
I agree, what flags can be used to determine when to use it? I used ... #elif (defined (__vxworks) && defined (__RTP__)) \ || (defined (__i386__) && (__APPLE__)) setenv (name, value, 1); #else ... but i know that is most likely not the correct fix. If someone could verify that setenv copies the input buffer on all versions of OS X then it could simply be changed to ... #elif (defined (__vxworks) && defined (__RTP__)) \ || defined (__APPLE__) setenv (name, value, 1); #else ...
I also forgot to add that changing to ... #elif (defined (__vxworks) && defined (__RTP__)) \ || defined (__APPLE__) setenv (name, value, 1); #else ... would involve changing ... putenv (expression); #if (defined (__FreeBSD__) && (__FreeBSD__ < 7)) \ || defined (__APPLE__) || defined (__MINGW32__) \ ||(defined (__vxworks) && ! defined (__RTP__)) /* On some systems like FreeBSD 6.x and earlier, MacOS X and Windows, putenv is making a copy of the expression string so we can free it after the call to putenv */ free (expression); #endif ... to ... putenv (expression); #if (defined (__FreeBSD__) && (__FreeBSD__ < 7)) \ defined (__MINGW32__) \ ||(defined (__vxworks) && ! defined (__RTP__)) /* On some systems like FreeBSD 6.x and earlier, and Windows, putenv is making a copy of the expression string so we can free it after the call to putenv */ free (expression); #endif ...
Subject: Re: Cannot bootstrap Ada with host gnatmake-4.2 > but i know that is most likely not the correct fix. If someone could verify > that setenv copies the input buffer on all versions of OS X then it could > simply be changed to It does on 10.3.9. Doubt that we need to be overly concerned about earlier OS X versions. I tried the setenv change with 4.2.3. Had to apply the "-larg -lgcc_eh" hack to Make-lang.in to do an initial bootstrap. After installing this build, the hack isn't needed. I'll post testresults for 4.2.3 on 10.5.2 soon. Dave
Subject: Re: Cannot bootstrap Ada with host gnatmake-4.2 > I tried the setenv change with 4.2.3. Had to apply the "-larg -lgcc_eh" > hack to Make-lang.in to do an initial bootstrap. After installing this > build, the hack isn't needed. I'll post testresults for 4.2.3 on 10.5.2 > soon. Couldn't post 4.2.3 results. Gcc and acats are ok, but g++ and libstdc++ are a disaster. ld segfaults in many tests. Some 4.3.0 results are here: http://gcc.gnu.org/ml/gcc-testresults/2008-02/msg01915.html As can be seen, ada is in excellent shape on this target. Dave
*** Bug 35572 has been marked as a duplicate of this bug. ***
Subject: Bug 33857 Author: danglin Date: Tue Apr 1 22:23:04 2008 New Revision: 133806 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=133806 Log: PR ada/33857 * env.c: Always include crt_externs.h if __APPLE__ is defined. (__gnat_setenv): Use setenv instead of putenv if __APPLE__ is defined. Modified: trunk/gcc/ada/ChangeLog trunk/gcc/ada/env.c
Subject: Bug 33857 Author: danglin Date: Tue Apr 1 22:25:02 2008 New Revision: 133807 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=133807 Log: PR ada/33857 * env.c: Always include crt_externs.h if __APPLE__ is defined. (__gnat_setenv): Use setenv instead of putenv if __APPLE__ is defined. Modified: branches/gcc-4_3-branch/gcc/ada/ChangeLog branches/gcc-4_3-branch/gcc/ada/env.c
This bug is fixed on darwin.
Also a duplicate of PR864, which is now fixed. *** This bug has been marked as a duplicate of 864 ***