No crt2.o file found

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|

No crt2.o file found

SevenThunders
I managed to get the llvm tool chain compiled on my windows machine
using mingw a couple of weeks ago.
When I tried to run the simple test case provided in the documentation I
ran into a problem of missing object files.

I attempted to compile the simple hello.c hello world application.  
Unfortunately I get the following

$ llvm-gcc hello.c -o hello.exe
ld: crt2.o: No such file: No such file or directory


After copying the contents of llvm/Release/bin to llvm/bin I then tried,
$ llvm-gcc -O3 -emit-llvm hello.c -c -o hello.bc


but then after running



$ lli hello.bc

I got.


ERROR: Program used external function '_alloca' which could not be resolved!

This application has requested the Runtime to terminate it in an unusual
way.
Please contact the application's support team for more information.

Something must be wrong with my installation.  For one, I note that
there is no crt2.o anywhere in the llvm directory, although such object
files do exist in the mingw installation I used to compile the llvm
tools.  I do not know why lli does not work and why it can't find alloca.

_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
Reply | Threaded
Open this post in threaded view
|

Re: No crt2.o file found

Anton Korobeynikov
Hello, Matthew

> I managed to get the llvm tool chain compiled on my windows machine
> using mingw a couple of weeks ago.
Have you tried to build llvm-gcc by yourself?

> $ llvm-gcc hello.c -o hello.exe
> ld: crt2.o: No such file: No such file or directory
Normally crt*.o files are built during normal gcc build process
(llvm-gcc as well). However, mingw32 runtime has its own crt*.o files,
which are included with binary distribution of llvm-gcc4 (mingw32
variant).

> ERROR: Program used external function '_alloca' which could not be resolved!
Right. _alloca is inside runtime code, not bytecode. lli was not touched
to get mingw32 compatibility. I'll take a look.

--
With best regards, Anton Korobeynikov.

Faculty of Mathematics & Mechanics, Saint Petersburg State University.


_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
Reply | Threaded
Open this post in threaded view
|

Re: No crt2.o file found

SevenThunders
In reply to this post by SevenThunders
Have you tried to build llvm-gcc by yourself?

Not with the recent build.  In times past I failed miserably at this using cygwin. Maybe I should try again?

Normally crt*.o files are built during normal gcc build process
(llvm-gcc as well). However, mingw32 runtime has its own crt*.o files,
which are included with binary distribution of llvm-gcc4 (mingw32
variant).

I thought that would be the case, but I didn't see them in my llvm directory after unpacking the archive.
A search for *crt* does not reveal their location.  There is a crtend.c file however and some
other static libraries with crt in their names.  I figured that just copying the mingw crt*.o files would not 
be a good idea.  Perhaps I downloaded an incomplete llvm gcc binary?

> ERROR: Program used external function '_alloca' which could not be resolved!
  
Right. _alloca is inside runtime code, not bytecode. lli was not touched
to get mingw32 compatibility. I'll take a look.

I figured as much.  It would be great to get the mingw branch on windows working, since it avoids the cygwin dll 
and some restrictive licensing issues.  Thanks for the help in advance!


_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
Reply | Threaded
Open this post in threaded view
|

Re: No crt2.o file found

Anton Korobeynikov
In reply to this post by SevenThunders
Hello, Matthew.

> Not with the recent build.  In times past I failed miserably at this using cygwin. Maybe I should try again?
Well, actually I mean: whether llvm-gcc binary under consideration was
built by yourself or you're using pre-built binaries from downloads
section?

If you're using llvm-gcc4 binary from downloads section, mingw binary is
included into tarball, you might find crt*.o in /lib subdirectory
inside.

> I figured that just copying the mingw crt*.o files would not
> be a good idea.
Why not? Mingw32 crt does not depend on LLVM.

> Perhaps I downloaded an incomplete llvm gcc binary?
Please check:
1. File size of llvm-gcc4-1.9-patched-x86-mingw32.tar.bz2 is 15018565
bytes
2. Md5sum is 61a73059be528b19f2ce64d35d7df25b

> I figured as much.  It would be great to get the mingw branch on windows working, since it avoids the cygwin dll
> and some restrictive licensing issues.  Thanks for the help in advance!
Could you please fill in corresponding bug - I'll have look in it. We'll
use it to track progress & problems.

--
With best regards, Anton Korobeynikov.

Faculty of Mathematics & Mechanics, Saint Petersburg State University.


_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
Reply | Threaded
Open this post in threaded view
|

Re: No crt2.o file found

Anton Korobeynikov
In reply to this post by SevenThunders
Hello, Matthew.

> I figured as much.  It would be great to get the mingw branch on
> windows working, since it avoids the cygwin dll and some restrictive
>  licensing issues.
Mingw32 branch is quite ok as the time of writing this lines :) I was
able to compile Qt with llvm-gcc4 1.9 and everything was fine. So, I
suppose something went wrong during unpacking tarball or something like
this.

I've just commited patch to System library which will add some missed
JIT functionality on mingw32 target. So, "hello world" should run ok
under lli.

However JIT'ing is not complete for mingw32 due to absence of dllimport
symbols support at JIT side. I'll try to add it in the nearest future.

PS: Note, patch is in 2.0 cvs head, so, probably, you should just grab
it and apply to your source tree, if it's basing on 1.9 distribution.

--
With best regards, Anton Korobeynikov.

Faculty of Mathematics & Mechanics, Saint Petersburg State University.


_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
Reply | Threaded
Open this post in threaded view
|

Re: No crt2.o file found

SevenThunders
In reply to this post by SevenThunders
Hello, Matthew.


> I figured that just copying the mingw crt*.o files would not 
> be a good idea.
  
Why not? Mingw32 crt does not depend on LLVM.

I rashly copied all the *.o files from my mingw\lib directory to the llvm\lib directory.
This does enable the hello world binary to compile and to function correctly.

However the byte code file does not work correctly giving:
$ lli hello.bc
ERROR: Program used external function '_alloca' which could not be resolved!

This application has requested the Runtime to terminate it in an unusual way.
Please contact the application's support team for more information.


I suppose this is consistent with the comment that the Jit functionality is currently broken on mingw?

Please check:
1. File size of llvm-gcc4-1.9-patched-x86-mingw32.tar.bz2 is 15018565
bytes
2. Md5sum is 61a73059be528b19f2ce64d35d7df25b

My file size matches the patched file.  I haven't figured out how to get 7-zip to give me checksum information on windows.

Aha! I just noted that the archive does in fact have the crt*.o files, but they did not end up in my lib directory after I built the system.  I did however run a make clean prior to the build since the first time I tried to build it, it failed.  If the clean deletes the object files then it might well have deleted the crt*.o files.  That's the only reasonable explanation that I have right now.

Could you please fill in corresponding bug - I'll have look in it. We'll
use it to track progress & problems.

I'm not sure if this is really a bug, unless perhaps the make clean does end up deleting the needed object files.

My final question is just what functionality is disabled with the mingw distribution?  Is it just the use of lli?  This used to work with the msvc compiled tools.  Is it possible to recover the missing functionality of the Jit interpreter using msvc to compile these tools?


_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
Reply | Threaded
Open this post in threaded view
|

Re: No crt2.o file found

Anton Korobeynikov
In reply to this post by SevenThunders
Hello, Matthew.

> My file size matches the patched file.  I haven't figured out how to get 7-zip to give me checksum information on windows.
Use md5sum utility. It can be successfully found via google.

> I rashly copied all the *.o files from my mingw\lib directory to the llvm\lib directory.
> This does enable the hello world binary to compile and to function correctly.
Strange. Seems to be some "paths problem? inside llvm-gcc. It really should find that files automatically.

> Aha! I just noted that the archive does in fact have the crt*.o files, but they did not end up in my lib directory after
> I built the system.
They shouldn't. They actually should be in llvm-gcc/lib directory.

> My final question is just what functionality is disabled with the mingw distribution?
> Is it just the use of lli?
As of 1.9 - yes.

>  This used to work with the msvc compiled tools.
This isn't true, since there were no JIT codegen for dllimported
symbols.

>  Is it possible to recover the missing functionality of the Jit interpreter using msvc to compile these tools?
Recently I've made several fixes to libSystem & codegen (in CVS head):
http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20061218/041588.html
http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20061218/041643.html

This will enable to run lli on huge amount of applications. Probably,
you have to apply them to your current 1.9 tree (+patches from
llvm-gcc4-1.9-patched) in order to enable lli for 1.9 release.

--
With best regards, Anton Korobeynikov.

Faculty of Mathematics & Mechanics, Saint Petersburg State University.


_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
Reply | Threaded
Open this post in threaded view
|

Re: No crt2.o file found

SevenThunders
Anton Korobeynikov wrote
Hello, Matthew.



> Aha! I just noted that the archive does in fact have the crt*.o files, but they did not end up in my lib directory after
> I built the system.
They shouldn't. They actually should be in llvm-gcc/lib directory.
Hmm there is no llvm-gcc directory in either the patch file or what made it on to my system. Furthermore there are no crt*.o files after my build until I put them in the lib directory, which where they are in the patch file. Again the clean must have removed them.

> My final question is just what functionality is disabled with the mingw distribution?
> Is it just the use of lli?
As of 1.9 - yes.

>  This used to work with the msvc compiled tools.
This isn't true, since there were no JIT codegen for dllimported
symbols.

>  Is it possible to recover the missing functionality of the Jit interpreter using msvc to compile these tools?
Recently I've made several fixes to libSystem & codegen (in CVS head):
http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20061218/041588.html
http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20061218/041643.html

This will enable to run lli on huge amount of applications. Probably,
you have to apply them to your current 1.9 tree (+patches from
llvm-gcc4-1.9-patched) in order to enable lli for 1.9 release.

--
With best regards, Anton Korobeynikov.

Faculty of Mathematics & Mechanics, Saint Petersburg State University.


_______________________________________________
LLVM Developers mailing list
LLVMdev@cs.uiuc.edu         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
I think the patch files are dated.  After running patch I got the following failures
$ patch -i X86Subtargetcpp.patch -b
patching file `X86Subtarget.cpp'
Hunk #1 FAILED at 32.
Hunk #2 succeeded at 192 (offset -15 lines).
1 out of 3 hunks FAILED -- saving rejects to X86Subtarget.cpp.rej

$ patch -i X86Subtargeth.patch -b
patching file `X86Subtarget.h'
Hunk #1 succeeded at 60 (offset -1 lines).
Hunk #2 FAILED at 114.
1 out of 2 hunks FAILED -- saving rejects to X86Subtarget.h.rej

$ patch -i X86TargetMachinecpp.patch -b
patching file `X86TargetMachine.cpp'
Hunk #1 FAILED at 166.
1 out of 1 hunk FAILED -- saving rejects to X86TargetMachine.cpp.rej


Not surprisingly after these failures make at the llvm directory level failed:
make[3]: Entering directory `/d/apps/llvm/lib/Target/X86'
llvm[3]: Compiling X86Subtarget.cpp for Release build
X86Subtarget.cpp:196: error: no `void llvm::X86Subtarget::SetJITMode()' member function declared in class `llvm::X86Subtarget'
make[3]: *** [/d/apps/llvm/lib/Target/X86/Release/X86Subtarget.o] Error 1
make[3]: Leaving directory `/d/apps/llvm/lib/Target/X86'
make[2]: *** [X86/.makeall] Error 2
make[2]: Leaving directory `/d/apps/llvm/lib/Target'
make[1]: *** [Target/.makeall] Error 2
make[1]: Leaving directory `/d/apps/llvm/lib'
make: *** [all] Error 1


I can provide more details if needed.

Reply | Threaded
Open this post in threaded view
|

Re: No crt2.o file found

Anton Korobeynikov
In reply to this post by Anton Korobeynikov
Hello, Matthew.

> Hmm there is no llvm-gcc directory in either the patch file or what made it
> on to my system. Furthermore there are no crt*.o files after my build until
> I put them in the lib directory, which where they are in the patch file.
> Again the clean must have removed them.
Well. Actually you should have 2 trees:
1. One you're building LLVM in. There is directory Release inside (after
build) with sub-directories bin & lib. Let us call this dir "llvm".
2. The tree with llvm-gcc4 unpacked from tarball. Let us call this dir
"llvm-gcc".

It's highly recommended not to mix them, otherwise you'll get funny
results (e.g. during "make clean"). Note, that crt*.o should be inside
"llvm-gcc/lib" directory, as they're in "lib" subdirectory of llvm-gcc4
tarball.

> I think the patch files are dated.  After running patch I got the following
> failures
Surely. As I've said, they are against current CVS head (2.0cvs), not
1.9. You had 3 merge problems, since files itself changed alot during
last 2 months. Probably, you should apply them by hands.

--
With best regards, Anton Korobeynikov.

Faculty of Mathematics & Mechanics, Saint Petersburg State University.


_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev