<div dir="ltr"><div><div><div><div><div>I'm having trouble compiling gcc in Chapter 6. Constructing a Temporary System. <br>----------------------------------------<br></div>BOOK£º GIT-20130602-x86_64-Multilib</div>host: debian 7, x86_64<br>
</div>target: x86_64<br>$CLFS_HOST=x86_64-cross-linux-gnu $CLFS_TARGET=x86_64-unknown-linux-gnu $BUILD32=-m32 $BUILD64=-m64<br><br></div><div>Thanks in advance.<br></div>I have to apologize that I didn't follow the version of gcc in the book(4.6.3), but jumped to 4.8.1. I know things got greatly changed with 4.8, and that's why I want to try it out:). Everything went (relatively) smooth when building /cross-tools, but got totally stuck at gcc for /tools.<br>
</div>Here's what I did:<br>------------------<br>for file in \<br> $(find gcc/config -name linux64.h -o -name linux.h -o -name sysv4.h)<br>do<br> cp -uv $file{,.orig}<br> sed -e 's@/lib\(64\)\?\(32\)\?/ld@/tools&@g' \<br>
     -e 's@/usr@/tools@g' $file.orig > $file<br> cat >> $file << EOF<br>#undef STANDARD_STARTFILE_PREFIX_1<br>#undef STANDARD_STARTFILE_PREFIX_2<br>#define STANDARD_STARTFILE_PREFIX_1 "/tools/lib/"<br>
#define STANDARD_STARTFILE_PREFIX_2 ""<br>EOF<br> touch $file.orig<br>done &&<br>cp -uv gcc/Makefile.in{,.orig} &&  # ****************Borrowed from LFS-7.3. I think it's cleaner than the patch********************************<br>
sed -e "s@\(^NATIVE_SYSTEM_HEADER_DIR =\).*@\1 /tools/include@g" gcc/Makefile.in.orig > gcc/Makefile.in &&<br>mkdir -v ../gcc-build &&<br>cd ../gcc-build &&<br>CC="${CC} ${BUILD64}" CXX="${CXX} ${BUILD64}" \<br>
  ../gcc-4.8.1/configure --prefix=/tools \<br>  --libdir=/tools/lib64 --with-native-system-header-dir=/tools/include \           # Just in case<br>  --build=${CLFS_HOST} --host=${CLFS_TARGET} --target=${CLFS_TARGET} \<br>
  --with-local-prefix=/tools  --enable-long-long \<br>  --enable-c99 --enable-shared --enable-threads=posix \<br>  --enable-__cxa_atexit --disable-nls --enable-languages=c,c++ \<br>  --disable-libstdcxx-pch --enable-cloog-backend=isl &&<br>
cp -uv Makefile{,.orig} &&<br>sed "/^HOST_\(GMP\|PPL\|CLOOG\)\(LIBS\|INC\)/s:-[IL]/\(lib\|include\)::" \<br>    Makefile.orig > Makefile &&<br>make -j4 AS_FOR_TARGET="${AS}" LD_FOR_TARGET="${LD}" &&   <b>#</b> *********** The same with the clfs book **********<br>
make install<br><div><div>------------------------------<br></div><div>And make failed:<br>In file included from ../../gcc-4.8.1/gcc/errors.c:29:0:<br>../../gcc-4.8.1/gcc/system.h:444:23: error: declaration of C function 'void* sbrk(int)' conflicts with<br>
 extern void *sbrk (int);<br>                       ^<br>In file included from ../../gcc-4.8.1/gcc/genmddeps.c:19:0:<br>../../gcc-4.8.1/gcc/system.h:444:23: error: declaration of C function 'void* sbrk(int)' conflicts with<br>
 extern void *sbrk (int);<br>                       ^<br>In file included from ../../gcc-4.8.1/gcc/system.h:254:0,<br>                 from ../../gcc-4.8.1/gcc/errors.c:29:<br>/usr/include/unistd.h:1065:14: error: previous declaration 'void* sbrk(intptr_t)' here<br>
 extern void *sbrk (intptr_t __delta) __THROW;<br>              ^<br>In file included from ../../gcc-4.8.1/gcc/system.h:254:0,<br>                 from ../../gcc-4.8.1/gcc/genmddeps.c:19:<br>/usr/include/unistd.h:1065:14: error: previous declaration 'void* sbrk(intptr_t)' here<br>
 extern void *sbrk (intptr_t __delta) __THROW;<br>              ^<br><b>.............................<br></b></div><div>//Generally a lot of conflicts between the host system headers and /tools/include/*.h<br>#####################################<br>
</div><div>make[2]: *** [build/errors.o] Error 1<br><br></div><div>That's very interesting. Actually, x86_64-unknown-linux-gnu-g++ -v -c dummy.c gives this:<br></div><div>#include "..." search starts here:<br>
#include <...> search starts here:<br> /mnt/clfs/cross-tools/bin/../lib/gcc/x86_64-unknown-linux-gnu/4.8.1/../../../../x86_64-unknown-linux-gnu/include/c++/4.8.1<br> /mnt/clfs/cross-tools/bin/../lib/gcc/x86_64-unknown-linux-gnu/4.8.1/../../../../x86_64-unknown-linux-gnu/include/c++/4.8.1/x86_64-unknown-linux-gnu<br>
 /mnt/clfs/cross-tools/bin/../lib/gcc/x86_64-unknown-linux-gnu/4.8.1/../../../../x86_64-unknown-linux-gnu/include/c++/4.8.1/backward<br> /mnt/clfs/cross-tools/bin/../lib/gcc/x86_64-unknown-linux-gnu/4.8.1/include<br> /mnt/clfs/cross-tools/bin/../lib/gcc/x86_64-unknown-linux-gnu/4.8.1/include-fixed<br>
 /mnt/clfs/cross-tools/bin/../lib/gcc/x86_64-unknown-linux-gnu/4.8.1/../../../../x86_64-unknown-linux-gnu/include<br> /mnt/clfs/tools/include<br></div><div>I think that means my cross-compiler works fine.<br><br></div><div>
And I found this line among other make output, right before the error:<br>g++ -c   -g -O2 -DIN_GCC ...... // And stuff<br></div><div>The script is actually calling the host systems g++!<br></div><div>I also found make calls:<br>
gcc -c -DHAVE_CONFIG_H ........<br>which works well.<br></div><div>I'm really frustrated. Can some one help me?  Thanks!<br></div><div><br><div><div><div><div><div><div><div dir="ltr">Sincerely,<br></div><div>Charlie<br>
</div></div>
</div></div></div></div></div></div></div></div>