Hi Michael,
On Tue, 2007-01-16 at 13:13 +0800, Michael T. Richter
wrote:> On Tue, 2007-16-01 at 02:50 +0000, Reid Spencer wrote:
> > > The build instructions provided tell me to build llvm-gcc first
from
> > > the source.
> > > The source for that tells me to build llvm first from the source.
I'm
> > > not sure where to go from this point.
>
> > You should build llvm first, then llvm-gcc.
>
> When I build LLVM first, however, I get told that it can't find
> llvm-gcc and that it therefore won't build properly. And, true to
> form, when I ignore the warning from ./configure and proceed anyway it
> chokes.
>
> Configure output (elided):
> config.status: creating Makefile.common
> config.status: executing setup commands
> config.status: executing Makefile commands
> config.status: executing lib/Makefile commands
> config.status: executing lib/sample/Makefile commands
> config.status: executing tools/Makefile commands
> config.status: executing tools/sample/Makefile commands
> configure: WARNING: ***** llvm-gcc/llvm-g++ was not found, or
> does not appear to be
> configure: WARNING: ***** working. Please make sure you have
> llvm-gcc and llvm-g++ in
> configure: WARNING: ***** your path before configuring LLVM.
> The runtime libraries
> configure: WARNING: ***** (llvm/runtime) will not be built but
> you should be able to
> configure: WARNING: ***** build the llvm tools.
This is correct. The first configure will do this because llvm-gcc isn't
built yet. This message can safely be ignored before you've built
llvm-gcc.
>
> Despite the warning a make seems to work and a make install seems to
> put things into sane places.
Right. The build of llvm is fine, that configure warning should not show
up the second time you configure (after building llvm-gcc).
> So I run a configure, then a make in the gcc4 source directory. It
> builds fine until I get this:
>
> /home/michael/Development/obj/gcc/xgcc
> -B/home/michael/Development/obj/gcc/
> -B/usr/local/i686-pc-linux-gnu/bin/
> -B/usr/local/i686-pc-linux-gnu/lib/
> -isystem /usr/local/i686-pc-linux-gnu/include
> -isystem /usr/local/i686-pc-linux-gnu/sys-include -O2
> -DIN_GCC -W -Wall -Wwrite-strings -Wstrict-prototypes
> -Wmissing-prototypes -Wold-style-definition
> -isystem ./include -fPIC -g -DHAVE_GTHR_DEFAULT -DIN_LIBGCC2
> -D__GCC_FLOAT_NOT_NEEDED -shared -nodefaultlibs
> -Wl,--soname=libgcc_s.so.1
> -Wl,--version-script=libgcc/./libgcc.map
> -o ./libgcc_s.so.1.tmp libgcc/./_muldi3_s.o
> libgcc/./_negdi2_s.o libgcc/./_lshrdi3_s.o
> libgcc/./_ashldi3_s.o libgcc/./_ashrdi3_s.o
> libgcc/./_cmpdi2_s.o libgcc/./_ucmpdi2_s.o
> libgcc/./_floatdidf_s.o libgcc/./_floatdisf_s.o
> libgcc/./_fixunsdfsi_s.o libgcc/./_fixunssfsi_s.o
> libgcc/./_fixunsdfdi_s.o libgcc/./_fixdfdi_s.o
> libgcc/./_fixunssfdi_s.o libgcc/./_fixsfdi_s.o
> libgcc/./_fixxfdi_s.o libgcc/./_fixunsxfdi_s.o
> libgcc/./_floatdixf_s.o libgcc/./_fixunsxfsi_s.o
> libgcc/./_fixtfdi_s.o libgcc/./_fixunstfdi_s.o
> libgcc/./_floatditf_s.o libgcc/./_clear_cache_s.o
> libgcc/./_enable_execute_stack_s.o libgcc/./_trampoline_s.o
> libgcc/./__main_s.o libgcc/./_absvsi2_s.o
> libgcc/./_absvdi2_s.o libgcc/./_addvsi3_s.o
> libgcc/./_addvdi3_s.o libgcc/./_subvsi3_s.o
> libgcc/./_subvdi3_s.o libgcc/./_mulvsi3_s.o
> libgcc/./_mulvdi3_s.o libgcc/./_negvsi2_s.o
> libgcc/./_negvdi2_s.o libgcc/./_ctors_s.o libgcc/./_ffssi2_s.o
> libgcc/./_ffsdi2_s.o libgcc/./_clz_s.o libgcc/./_clzsi2_s.o
> libgcc/./_clzdi2_s.o libgcc/./_ctzsi2_s.o libgcc/./_ctzdi2_s.o
> libgcc/./_popcount_tab_s.o libgcc/./_popcountsi2_s.o
> libgcc/./_popcountdi2_s.o libgcc/./_paritysi2_s.o
> libgcc/./_paritydi2_s.o libgcc/./_powisf2_s.o
> libgcc/./_powidf2_s.o libgcc/./_powixf2_s.o
> libgcc/./_powitf2_s.o libgcc/./_mulsc3_s.o
> libgcc/./_muldc3_s.o libgcc/./_mulxc3_s.o libgcc/./_multc3_s.o
> libgcc/./_divsc3_s.o libgcc/./_divdc3_s.o libgcc/./_divxc3_s.o
> libgcc/./_divtc3_s.o libgcc/./_divdi3_s.o libgcc/./_moddi3_s.o
> libgcc/./_udivdi3_s.o libgcc/./_umoddi3_s.o
> libgcc/./_udiv_w_sdiv_s.o libgcc/./_udivmoddi4_s.o
> libgcc/./unwind-dw2_s.o libgcc/./unwind-dw2-fde-glibc_s.o
> libgcc/./unwind-sjlj_s.o libgcc/./gthr-gnat_s.o
> libgcc/./unwind-c_s.o -lc && rm -f ./libgcc_s.so &&
if
> [ -f ./libgcc_s.so.1 ]; then mv
> -f ./libgcc_s.so.1 ./libgcc_s.so.1.backup; else true; fi &&
> mv ./libgcc_s.so.1.tmp ./libgcc_s.so.1 && ln -s
> libgcc_s.so.1 ./libgcc_s.so
> /home/michael/Development/obj/gcc/xgcc
> -B/home/michael/Development/obj/gcc/
> -B/usr/local/i686-pc-linux-gnu/bin/
> -B/usr/local/i686-pc-linux-gnu/lib/
> -isystem /usr/local/i686-pc-linux-gnu/include
> -isystem /usr/local/i686-pc-linux-gnu/sys-include -O2
> -DIN_GCC -W -Wall -Wwrite-strings -Wstrict-prototypes
> -Wmissing-prototypes -Wold-style-definition
> -isystem ./include -fPIC -g -DHAVE_GTHR_DEFAULT -DIN_LIBGCC2
> -D__GCC_FLOAT_NOT_NEEDED -I. -I.
> -I../../llvm-gcc4-1.9.source/gcc
> -I../../llvm-gcc4-1.9.source/gcc/.
> -I../../llvm-gcc4-1.9.source/gcc/../include
> -I../../llvm-gcc4-1.9.source/gcc/../libcpp/include
> -I/home/michael/Development/llvm-1.9/include
> -I/home/michael/Development/llvm-1.9//include -static -fno-pic
> -DL_muldi3 -fvisibility=hidden -DHIDE_EXPORTS
> -c ../../llvm-gcc4-1.9.source/gcc/libgcc2.c -o
> libgcc/static/_muldi3.o
> /home/michael/Development/obj/gcc/xgcc:
/home/michael/Development/obj/gcc/libgcc_s.so.1: version `GCC_4.2.0' not
found (required by /usr/lib/libstdc++.so.6)
> make[2]: *** [libgcc/static/_muldi3.o] Error 1
> make[2]: Leaving directory `/home/michael/Development/obj/gcc'
> make[1]: *** [libgcc.a] Error 2
> make[1]: Leaving directory `/home/michael/Development/obj/gcc'
> make: *** [all-gcc] Error 2
>
> This is where I'm stuck, now.
This isn't related to the llvm build or the configure warning. It has to
do with linking shared libraries. This part of the build is using xgcc
(a temporary version of llvm-gcc used to build the libraries). In this
case you are linking the libgcc_s.so shared library. The -B options tell
xgcc where to find its libraries. However, you've (probably) set an
LD_LIBRARY_PATH that is finding /usr/lib/libstdc++.so.6 which is a much
more recent version of libstdc++ than what llvm-gcc wants.
> It's looking for some kind of library made by gcc's build that
> obviously failed somewhere earlier in the millions of lines of
> messages spewed out by GCC's build system.
Probably not. Its failed because of dynamically linking the wrong
library. I suggest you try the -disable-shared option since you're on
Linux. Did you follow the configuration instructions found in this
document:
http://llvm.org/releases/1.9/docs/CFEBuildInstrs.html#llvm-gcc3-instructions
?
> Given the profusion of -I and such statements pointing into the llvm
> source code, I'm pretty sure it's something in the llvm build
that's
> failed on me.
It's not.
> (Of course after poring over these millions of lines of code I could
> be missing something really obvious, so I'm not sure here at all.)
You're just missing either -disable-shared option or unsetting your
LD_LIBRARY_PATH.
>
> > > What's the next step? How do I actually do a bootstrap?
>
> > There are two versions of llvm-gcc, v3 and v4, for the 1.9 release.
> > We're dropping support for llvm-gcc3 in 2.0 so I urge you to use
> > llvm-gcc4. However, llvm-gcc4 doesn't yet support C++ exception
handling
> > so you may need llvm-gcc3. In all other respects, llvm-gcc4 is the
> > superior product.
>
> I'll be building both, but probably using 4 most often because most of
> what I'd be using it for is C code anyway. I can wait for 2.0 to get
> C++.
In that case, please follow these directions:
http://llvm.org/releases/1.9/docs/CFEBuildInstrs.html#instructions
>
> > For llvm-gcc4, the basic flow is:
> > 1. Build llvm
> > 2. Build llvm-gcc
>
> This is the one I was trying with the results you can see above when
> building LLVM without an llvm-gcc.
We build i686-pc-linux-gnu every day without any issues. Please try the
suggestions above.
>
> > This should be covered in the GettingStarted.html document:
> > http://llvm.org/docs/GettingStarted.html
>
> This would be the source that has conflicting dependencies.
> GettingStarted tells you you need an llvm-gcc to build llvm.
That is true if you want to build the whole thing. However, it is only
needed if you want to build the runtime libraries and those are only
needed for llvm-gcc3.
I don't see the conflict, however. It says this: "Before configuring
and
compiling the LLVM suite, you need to extract the LLVM GCC front end
from the binary distribution. It is used for building the bytecode
libraries later used by the GCC front end for linking programs, and its
location must be specified when the LLVM suite is configured."
Note that it says "binary distribution". If you're building
llvm-gcc,
its a whole different ball game.
It also says this:
"The binary versions of the GCC front end may not suit all of your
needs. For example, the binary distribution may include an old version
of a system header file, not "fix" a header file that needs to be
fixed
for GCC, or it may be linked with libraries not available on your
system.
In cases like these, you may want to try building the GCC front end from
source. This is not for the faint of heart, so be forewarned."
This seems to match your situation. Your original email indicated that
you had problems with the binary version of llvm-gcc on your platform.
So, please just do this:
1. Forget about llvm-gcc3, its cyclic build nature is causing you
trouble and you don't need it.
2. You've already built llvm successfully, so that's the first step
done.
3. Get the llvm-gcc4 sources for 1.9 and follow the directions in
README.LLVM at the top level. Make sure you pay attention to the
configure options. Also make sure to read this:
http://llvm.org/releases/1.9/docs/CFEBuildInstrs.html
> But the pointer to bootstrapping llvm-gcc says you need a functioning
> llvm.
You do. Especially for llvm-gcc4.
> Man! I'm only just figuring out how large my self-assigned project of
> making a GHC that uses LLVM as a back-end really is! ;)
Compilers are generally "big". Once you get past this build stuff,
the
rest will seem easy. :)
> For my next number I will prove that P=NP and destroy the whole field
> of public key cryptography! :D
Go for it! :)
Reid.
>
> --
> Michael T. Richter
> Email: ttmrichter at gmail.com, mtr1966 at hotpop.com
> MSN: ttmrichter at hotmail.com, mtr1966 at hotmail.com; YIM:
> michael_richter_1966; AIM: YanJiahua1966; ICQ: 241960658; Jabber:
> mtr1966 at jabber.cn
>
> "I would not flinch from sacrificing a million lives for India's
> liberty!" --Mahatma Gandhi