Page 1 of 1

./toolchain.sh -g is pathological before ./toolchain.sh -n

Posted: Thu Dec 14, 2006 4:40 am
by duffy399
I had occasion to run the toolchain piecemeal, first running
./toolchain.sh -binutils
to more expeditiously check something I had changed in just that area.

Then I decided not to run ./toolchain.sh in its entirety, so I kicked off
./toolchain.sh -gcc
since BUILD_GCC is listed next within the toolchain.sh file.

Turns out: that's not healthy. It causes configure to output lots of wrong settings, as illustrated by this diff of config.cache
[I am including the diff in this post, so that maybe google will help someone else who hits this.]

diff /pathological/gcc-4.0.2/build-psp-c++/psp/libiberty/config.cache
/tmp/pspdev/gcc-4.0.2/build-psp-c++/psp/libiberty/config.cache
36a37
> ac_cv_func_getpagesize=${ac_cv_func_getpagesize=no}
39,41c40,42
< ac_cv_header_alloca_h=${ac_cv_header_alloca_h=no}
< ac_cv_header_fcntl_h=${ac_cv_header_fcntl_h=no}
< ac_cv_header_inttypes_h=${ac_cv_header_inttypes_h=no}
---
> ac_cv_header_alloca_h=${ac_cv_header_alloca_h=yes}
> ac_cv_header_fcntl_h=${ac_cv_header_fcntl_h=yes}
> ac_cv_header_inttypes_h=${ac_cv_header_inttypes_h=yes}
44c45
< ac_cv_header_malloc_h=${ac_cv_header_malloc_h=no}
---
> ac_cv_header_malloc_h=${ac_cv_header_malloc_h=yes}
46,47c47,48
< ac_cv_header_stdc=${ac_cv_header_stdc=no}
< ac_cv_header_stdint_h=${ac_cv_header_stdint_h=no}
---
> ac_cv_header_stdc=${ac_cv_header_stdc=yes}
> ac_cv_header_stdint_h=${ac_cv_header_stdint_h=yes}
49,50c50,51
< ac_cv_header_stdlib_h=${ac_cv_header_stdlib_h=no}
< ac_cv_header_string_h=${ac_cv_header_string_h=no}
---
> ac_cv_header_stdlib_h=${ac_cv_header_stdlib_h=yes}
> ac_cv_header_string_h=${ac_cv_header_string_h=yes}
52c53
< ac_cv_header_sys_file_h=${ac_cv_header_sys_file_h=no}
---
> ac_cv_header_sys_file_h=${ac_cv_header_sys_file_h=yes}
54c55
< ac_cv_header_sys_param_h=${ac_cv_header_sys_param_h=no}
---
> ac_cv_header_sys_param_h=${ac_cv_header_sys_param_h=yes}
56,57c57,58
< ac_cv_header_sys_resource_h=${ac_cv_header_sys_resource_h=no}
< ac_cv_header_sys_stat_h=${ac_cv_header_sys_stat_h=no}
---
> ac_cv_header_sys_resource_h=${ac_cv_header_sys_resource_h=yes}
> ac_cv_header_sys_stat_h=${ac_cv_header_sys_stat_h=yes}
63,68c64,69
< ac_cv_header_sys_time_h=${ac_cv_header_sys_time_h=no}
< ac_cv_header_sys_types_h=${ac_cv_header_sys_types_h=no}
< ac_cv_header_sys_wait_h=${ac_cv_header_sys_wait_h=no}
< ac_cv_header_time=${ac_cv_header_time=no}
< ac_cv_header_time_h=${ac_cv_header_time_h=no}
< ac_cv_header_unistd_h=${ac_cv_header_unistd_h=no}
---
> ac_cv_header_sys_time_h=${ac_cv_header_sys_time_h=yes}
> ac_cv_header_sys_types_h=${ac_cv_header_sys_types_h=yes}
> ac_cv_header_sys_wait_h=${ac_cv_header_sys_wait_h=yes}
> ac_cv_header_time=${ac_cv_header_time=yes}
> ac_cv_header_time_h=${ac_cv_header_time_h=yes}
> ac_cv_header_unistd_h=${ac_cv_header_unistd_h=yes}
81c82
< ac_cv_prog_cc_stdc=${ac_cv_prog_cc_stdc=no}
---
> ac_cv_prog_cc_stdc=${ac_cv_prog_cc_stdc=}
83,88c84,89
< ac_cv_sizeof_int=${ac_cv_sizeof_int=0}
< ac_cv_type_int=${ac_cv_type_int=no}
< ac_cv_type_pid_t=${ac_cv_type_pid_t=no}
< ac_cv_type_uintptr_t=${ac_cv_type_uintptr_t=no}
< liberty_cv_uint64=${liberty_cv_uint64='unsigned long long'}
< libiberty_cv_declare_errno=${libiberty_cv_declare_errno=yes}
---
> ac_cv_sizeof_int=${ac_cv_sizeof_int=4}
> ac_cv_type_int=${ac_cv_type_int=yes}
> ac_cv_type_pid_t=${ac_cv_type_pid_t=yes}
> ac_cv_type_uintptr_t=${ac_cv_type_uintptr_t=yes}
> liberty_cv_uint64=${liberty_cv_uint64=uint64_t}
> libiberty_cv_declare_errno=${libiberty_cv_declare_errno=no}

./toolchain.sh -gcc
is simply pathological if run before
./toolchain.sh -newlib

The real resolution of the problem is to rerun
./toolchain.sh
in its entirety, or perhaps we'll in future have a toolchain.sh that doesn't do the GCC (C++) section before the INSTALL PSPSDK HEADERS section. Adding a clause as follows (like the one that is already present for NEWLIB), which would say

## GCC (C++) depends on PSPSDK headers, so if it's being
## built then make sure that PSPSDK is being built.
if test "$BUILD_GCC" = "1" ; then
BUILD_PSPSDK=1
fi

But a more robust resolution is probably called for.
./toolchain.sh -newlib
itself fails at /tmp/pspdev/pspsdk/src/libc/cxx.cpp
because there is no psp-g++ in existence yet, at that point.

The resolution that I used, after this problem, is to remove the pathological build-psp-c++
rm -r /tmp/pspdev/gcc-4.0.2/build-psp-c++
and then
./toolchain.sh -newlib
until that fails at /tmp/pspdev/pspsdk/src/libc/cxx.cpp
then I carved portions of ./toolchain.sh into what I call
./startatg++.sh

by eliding the DOWNLOAD and PATCH and BINUTILS and GCC and PSPSDK HEADERS and NEWLIB sections, so that it then just has

## Create and enter the temp directory.
mkdir -p "$BUILDDIR"; cd "$BUILDDIR"

#################################
## BUILD AND INSTALL GCC (C++) ##
#################################

. . .

##############################
## BUILD AND INSTALL PSPSDK ##
##############################

. . .