LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Linux From Scratch
User Name
Password
Linux From Scratch This Forum is for the discussion of LFS.
LFS is a project that provides you with the steps necessary to build your own custom Linux system.

Notices


Reply
  Search this Thread
Old 05-20-2013, 04:05 PM   #1
richard620
LQ Newbie
 
Registered: May 2013
Posts: 12

Rep: Reputation: Disabled
GCC Pass1 - undefined reference to `GNU_USER_TARGET_OS_CPP_BUILTINS'


Ok, I'm officially stuck. I've tried this multiple times on multiple computers and always get to the same point and fail. It could be due to the fact that I'm booting from a 32bit arch usb stick onto a 64bit machine, but this also failed on a 32bit machine as well, so that's probably not the problem.

What's happening is that I'm getting the old "undefined reference to `GNU_USER_TARGET_OS_CPP_BUILTINS'" error.
Code:
gcc   -g -O2 -DIN_GCC -DCROSS_DIRECTORY_STRUCTURE  -W -Wall -Wno-narrowing -Wwrite-strings -Wcast-qual -Wstrict-prototypes -Wmissing-prototypes -Wmissing-format-attribute -pedantic -Wno-long-long -Wno-variadic-macros -Wno-overlength-strings -Wold-style-definition -Wc++-compat   -DHAVE_CONFIG_H  -o cc1 c-lang.o c-family/stub-objc.o attribs.o c-errors.o c-decl.o c-typeck.o c-convert.o c-aux-info.o c-objc-common.o c-parser.o tree-mudflap.o c-family/c-common.o c-family/c-cppbuiltin.o c-family/c-dump.o c-family/c-format.o c-family/c-gimplify.o c-family/c-lex.o c-family/c-omp.o c-family/c-opts.o c-family/c-pch.o c-family/c-ppoutput.o c-family/c-pragma.o c-family/c-pretty-print.o c-family/c-semantics.o c-family/c-ada-spec.o i386-c.o default-c.o \
  cc1-checksum.o main.o  libbackend.a libcommon-target.a libcommon.a ../libcpp/libcpp.a ../libdecnumber/libdecnumber.a libcommon.a ../libcpp/libcpp.a   ../libiberty/libiberty.a ../libdecnumber/libdecnumber.a    -L/mnt/lfs/sources/gcc-build/./gmp/.libs -L/mnt/lfs/sources/gcc-build/mpfr/src/.libs -L/mnt/lfs/sources/gcc-build/./mpc/src/.libs -lmpc -lmpfr -lgmp -rdynamic -ldl  -L../zlib -lz
c-family/c-cppbuiltin.o: In function `c_cpp_builtins':
/mnt/lfs/sources/gcc-build/gcc/../../gcc-4.7.2/gcc/c-family/c-cppbuiltin.c:918: undefined reference to `GNU_USER_TARGET_OS_CPP_BUILTINS'
collect2: error: ld returned 1 exit status
make[2]: *** [cc1] Error 1
make[2]: Leaving directory `/mnt/lfs/sources/gcc-build/gcc'
make[1]: *** [all-gcc] Error 2
make[1]: Leaving directory `/mnt/lfs/sources/gcc-build'
make: *** [all] Error 2
I've looked all over and it seems that this usually happens when you're missing an application, but I've got all of them
Code:
bash, version 4.2.45(2)-release
/bin/sh -> /usr/bin/bash
Binutils: (GNU Binutils) 2.22.0.20120323
bison (GNU Bison) 2.6.2
/usr/bin/yacc -> /usr/bin/yacc
bzip2,  Version 1.0.6, 6-Sept-2010.
Coreutils:  8.19
diff (GNU diffutils) 3.2
find (GNU findutils) 4.4.2
GNU Awk 4.0.1
/usr/bin/awk -> /usr/bin/gawk
gcc (GCC) 4.7.1 20120721 (prerelease)
(GNU libc) 2.17
grep (GNU grep) 2.14
gzip 1.5
Linux version 3.5.4-1-ARCH (tobias@T-POWA-LX) (gcc version 4.7.1 20120721 (prerelease) (GCC) ) #1 SMP PREEMPT Sat Sep 15 13:04:04 UTC 2012
m4 (GNU M4) 1.4.16
GNU Make 3.82
patch 2.6.1
Perl version='5.16.1';
GNU sed version 4.2.1
tar (GNU tar) 1.26
Texinfo: makeinfo (GNU texinfo) 4.13
xz (XZ Utils) 5.0.4
gcc compilation OK
My layout is as follows:
Code:
 /mnt/lfs/sources/gcc-4.7.2
 /mnt/lfs/sources/gcc-4.7.2/mpfr
 /mnt/lfs/sources/gcc-4.7.2/gmp
 /mnt/lfs/sources/gcc-4.7.2/mpc
 /mnt/lfs/sources/gcc-build
I don't know if it will help, but my binutilies was configed like this:
Code:
../binutils-2.23.1/configure --prefix=/tools --with-sysroot=$LFS --with-lib-path=/tools/lib --target=$LFS_TGT --disable-nls --disable-werror
and I used this for gcc:
Code:
for file in \
$(find gcc/config -name linux64.h -o -name linux.h  -o -name sysv4.h) 
do cp -uv $file{,.org} 
sed -e 's@/lib\(64\)\?\(32\)\?/ld@/tools&@g' \
-e 's@/usr@/tools@g' $file.orig > $file
 echo ' 
#undef STANDARD_STARTFILE_PREFIX_1
#undef STANDARD_STARTFILE_PREFIX_2
#define STANDARD_STARTFILE_PREFIX_1 "/tools/lib/"
#define STANDARD_STARTFILE_PREFIX_2 ""' >> $file
 touch $file.orig
done

sed -i '/k prot/agcc_cv_libc_provides_ssp=yes' gcc/configure
sed -i 's/BUILD_INFO=info/BUILD_INFO=/' gcc/configure
I configed gcc like this:
Code:
../gcc-4.7.2/configure \
 --target=$LFS_TGT \
 --prefix=/tools \
 --with-sysroot=$LFS \
 --with-newlib \
 --without-headers \
 --with-local-prefix=/tools \
 --with-native-system-header-dir=/tools/include \
 --disable-nls \
 --disable-shared \
 --disable-multilib \
 --disable-decimal-float \
 --disable-threads \
 --disable-libmudflap \
 --disable-libssp \
 --disable-libgomp \
 --disable-libquadmath \
 --enable-language=c \
 --with-mpfr-include=$(pwd)/../gcc-4.7.2/mpfr/src \
 --with-mpfr-lib=$(pwd)/mpfr/src/.libs
I know this is not mush info... but I really can't think of what else would be causing it.
 
Old 05-21-2013, 01:53 AM   #2
spiky0011
Senior Member
 
Registered: Jan 2011
Location: PLANET-SPIKE
Distribution: /LFS/Debian
Posts: 2,511
Blog Entries: 1

Rep: Reputation: 412Reputation: 412Reputation: 412Reputation: 412Reputation: 412
Hi

What dose echo $LFS produce
 
Old 05-21-2013, 05:45 AM   #3
Keith Hedger
Senior Member
 
Registered: Jun 2010
Location: Wiltshire, UK
Distribution: Void, Linux From Scratch, Slackware64
Posts: 3,150

Rep: Reputation: 856Reputation: 856Reputation: 856Reputation: 856Reputation: 856Reputation: 856Reputation: 856
Can't see anything wrong with the commands compared to mine but what is LFS_TGT set to? it should be this:
Code:
LFS_TGT=$(uname -m)-lfs-linux-gnu
And as Spiky said what is LFS set to?

If you still have trouble you MAY have a corrupted archive, as you are only on the start of building the tools I would suggest a fresh start re-download the archives and check the hash numbers before you start and check what you are doing carefully before going on to the next step.
 
Old 05-21-2013, 05:58 AM   #4
richard620
LQ Newbie
 
Registered: May 2013
Posts: 12

Original Poster
Rep: Reputation: Disabled
$LFS = /mnt/lfs
$LFS_TGT = i686-lfs-linux-gnu

I checked the checksums when I downloaded the sources and they all looked fine.
 
Old 05-21-2013, 06:17 AM   #5
Keith Hedger
Senior Member
 
Registered: Jun 2010
Location: Wiltshire, UK
Distribution: Void, Linux From Scratch, Slackware64
Posts: 3,150

Rep: Reputation: 856Reputation: 856Reputation: 856Reputation: 856Reputation: 856Reputation: 856Reputation: 856
You've got some minor version number differences which probably isn't the problem but some combinations of gcc/binutils just don't play nice together, this is my version check
Code:
bash, version 4.2.42(1)-release
/bin/sh -> /bin/bash
Binutils: (GNU Binutils) 2.23.1
bison (GNU Bison) 2.7
/usr/bin/yacc -> /usr/bin/yacc
bzip2,  Version 1.0.6, 6-Sept-2010.
Coreutils:  8.21
diff (GNU diffutils) 3.2
find (GNU findutils) 4.4.2
GNU Awk 4.0.2
/usr/bin/awk -> /usr/bin/gawk
gcc (GCC) 4.7.2
(GNU libc) 2.17
grep (GNU grep) 2.14
gzip 1.5
Linux version 3.8.0 (root@LFSHolly) (gcc version 4.7.2 (GCC) ) #1 SMP PREEMPT Mon Mar 25 10:34:37 UTC 2013
m4 (GNU M4) 1.4.16
GNU Make 3.82
GNU patch 2.7.1
Perl version='5.16.2';
GNU sed version 4.2.1
tar (GNU tar) 1.26
Texinfo: makeinfo (GNU texinfo) 5.0
xz (XZ Utils) 5.0.4
gcc compilation OK
Try adjusting the versions of first gcc and binutils then the others otherwise I can't see anything blatantly wrong.
 
Old 05-21-2013, 11:56 AM   #6
richard620
LQ Newbie
 
Registered: May 2013
Posts: 12

Original Poster
Rep: Reputation: Disabled
I updated my arch stick today but still have the exact same error as before.

Here's the output of version_check:
Code:
bash, version 4.2.45(2)-release
/bin/sh -> /usr/bin/bash
Binutils: (GNU Binutils) 2.23.2
bison (GNU Bison) 2.7.12-4996
/usr/bin/yacc -> /usr/bin/yacc
bzip2,  Version 1.0.6, 6-Sept-2010.
Coreutils:  8.21
diff (GNU diffutils) 3.3
find (GNU findutils) 4.4.2
GNU Awk 4.0.2
/usr/bin/awk -> /usr/bin/gawk
gcc (GCC) 4.8.0 20130502 (prerelease)
(GNU libc) 2.17
grep (GNU grep) 2.14
gzip 1.5
Linux version 3.9.3-1-ARCH (tobias@testing) (gcc version 4.8.0 20130502 (prerelease) (GCC) ) #1 SMP PREEMPT Mon May 20 08:00:01 CEST 2013
m4 (GNU M4) 1.4.16
GNU Make 3.82
GNU patch 2.7.1
Perl version='5.16.3';
sed (GNU sed) 4.2.2
tar (GNU tar) 1.26
Texinfo: makeinfo (GNU texinfo) 5.1
xz (XZ Utils) 5.0.4
gcc compilation OK
 
Old 05-21-2013, 02:29 PM   #7
Keith Hedger
Senior Member
 
Registered: Jun 2010
Location: Wiltshire, UK
Distribution: Void, Linux From Scratch, Slackware64
Posts: 3,150

Rep: Reputation: 856Reputation: 856Reputation: 856Reputation: 856Reputation: 856Reputation: 856Reputation: 856
Well I just had a quick go at building gcc 4.8.0 and I also get build errors ( but not the same as yours ), I gather you are using the development branch of the book, is there any particular reason you are not using the stable version as this builds O.K.?
 
Old 05-21-2013, 02:45 PM   #8
richard620
LQ Newbie
 
Registered: May 2013
Posts: 12

Original Poster
Rep: Reputation: Disabled
The 4.8 was just for my host arch machine, but I'm still trying to build gcc 4.7.2 from the stable branch - never tried the development version.
 
Old 05-21-2013, 02:54 PM   #9
spiky0011
Senior Member
 
Registered: Jan 2011
Location: PLANET-SPIKE
Distribution: /LFS/Debian
Posts: 2,511
Blog Entries: 1

Rep: Reputation: 412Reputation: 412Reputation: 412Reputation: 412Reputation: 412
Hi richard

I know you are using a usb stick, Is it possible to install arch onto hard drive I know it should be able to work from usb but there seems nothing amiss with everything you are doing, it just a thought might be worth a try.

Maybe post you bashrc although I would expect it to be correct
 
Old 05-21-2013, 03:19 PM   #10
richard620
LQ Newbie
 
Registered: May 2013
Posts: 12

Original Poster
Rep: Reputation: Disabled
This is my .bashrc for the lfs user
Code:
set +h
umask 022
LFS=/mnt/lfs
LC_ALL=POSIX
LFS_TGT=$(uname -m)-lfs-linux-gnu
PATH=/tools/bin:/bin:/usr/bin
export LFS LC_ALL LFS_TGT PATH
I have another arch machine that I could try this on, but I'll need to update it, install missing apps, and do some other work to get it up to the point where I could us it. Currently, I'm also thinking that it must be something to do with the fact that I'm doing this on a stick and not the hd... but, as you said, there should be no reason that it shouldn't work from a stick. Or it could be the fact that my target is also on a stick and doing stick-to-stick causes the issue.
 
Old 05-21-2013, 03:23 PM   #11
spiky0011
Senior Member
 
Registered: Jan 2011
Location: PLANET-SPIKE
Distribution: /LFS/Debian
Posts: 2,511
Blog Entries: 1

Rep: Reputation: 412Reputation: 412Reputation: 412Reputation: 412Reputation: 412
Hi

I would give it a try from an installed host to a partiton on drive then try to usb stick see how it works out, keep us posted plz
 
Old 05-22-2013, 06:22 AM   #12
Keith Hedger
Senior Member
 
Registered: Jun 2010
Location: Wiltshire, UK
Distribution: Void, Linux From Scratch, Slackware64
Posts: 3,150

Rep: Reputation: 856Reputation: 856Reputation: 856Reputation: 856Reputation: 856Reputation: 856Reputation: 856
Quote:
Originally Posted by richard620 View Post
The 4.8 was just for my host arch machine, but I'm still trying to build gcc 4.7.2 from the stable branch - never tried the development version.
If you look here:http://www.linuxfromscratch.org/lfs/.../hostreqs.html
This may be the problem as gcc > 4.7.2 and binutils > 2.23.1 are not recommended, seems daft but your host system may be to high a spec, if possible try installing slackware and build lfs on that, ( slackware >=13.37 ) is compliant 'out of the box'

Booting from a usb stick should not be a problem when building the tool chain though you may have problems later when it comes to making the system bootable, I don't know for sure as I have never built from a stick, one little thing to watch is when you have to chroot into the lfs partition if you are running from a 64bit kernel you can chroot into 32bit/64bit environment but if you are running from a 32bit kernel you can't chroot into a 63bit environment.
 
Old 05-22-2013, 06:35 AM   #13
richard620
LQ Newbie
 
Registered: May 2013
Posts: 12

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by Keith Hedger
This may be the problem as gcc > 4.7.2 and binutils > 2.23.1 are not recommended
The first attempt, before upgrading the stick, was gcc 4.7.1 and binutils 2.22.0 and it still had the same problem.
I might give slackware idea a try since it would take a little work to get my other arch box up anyway.
 
Old 05-23-2013, 09:36 AM   #14
richard620
LQ Newbie
 
Registered: May 2013
Posts: 12

Original Poster
Rep: Reputation: Disabled
I installed slackware 14.0 (64bit) onto the hd and used the same target usb stick that I was using the last time for the lfs build. The exact same error occurred again. Except for one thing, when I tried to make gcc the first time, I got a 'error couldn't find /usr/lib64/libgmp.la' or something like that. So I tried it again and it seemed to make it past that and gave me my original error.
 
Old 05-23-2013, 09:45 AM   #15
Keith Hedger
Senior Member
 
Registered: Jun 2010
Location: Wiltshire, UK
Distribution: Void, Linux From Scratch, Slackware64
Posts: 3,150

Rep: Reputation: 856Reputation: 856Reputation: 856Reputation: 856Reputation: 856Reputation: 856Reputation: 856
Why don't you try just building the tools to a folder and not the usb stick, you may have duff stick, by the way what is the usb stick formated/mounted as? some times the mount options can do odd things.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] LFS 7.2 GCC First pass: undefined reference to `GNU_USER_TARGET_OS_CPP_BUILTINS' anjohn Linux From Scratch 11 01-08-2013 06:09 AM
LFS 7.2 GCC First pass: undefined reference to `GNU_USER_TARGET_OS_CPP_BUILTINS' SuMZ Linux From Scratch 3 12-30-2012 07:33 AM
gcc linking: undefined reference to just about everything shabbychef Programming 7 09-09-2005 08:42 PM
gcc ld error. Undefined reference redness Linux - Software 4 02-08-2005 02:01 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Linux From Scratch

All times are GMT -5. The time now is 02:55 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration