using llvm-ld with existing libraries

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

using llvm-ld with existing libraries

Jack Howarth
   I am running into some problems when trying to use
llvm-ld to link object files, created by llvm-gcc-4.2
at -O4, with the stock libraries available on
powerpc-apple-darwin9. In particular, I am finding that
the link command...

llvm-ld -O4 -native -o molscript molscript.tab.o global.o lex.o col.o select.o state.o graphics.o segment.o coord.o xform.o postscript.o raster3d.o vrml.o regex.o opengl.o image.o eps_img.o sgi_img.o jpeg_img.o png_img.o clib/clib.a /sw/lib/libfreeglut.3.8.0.dylib /usr/X11R6/lib/libGLU.1.3.dylib /usr/X11R6/lib/libGL.1.2.dylib /System/Library/Frameworks/OpenGL.framework/Libraries/libGL.dylib /usr/X11R6/lib/libX11.6.2.0.dylib /usr/X11R6/lib/libXi.6.0.0.dylib /usr/X11R6/lib/libXmu.6.2.0.dylib /sw/lib/libjpeg.62.0.0.dylib /sw/lib/libpng.3.18.0.dylib /usr/lib/libz.1.2.3.dylib /usr/lib/libSystem.B.dylib

...produces the warnings...

llvm-ld: warning: Ignoring file '/sw/lib/libfreeglut.3.8.0.dylib' because does not contain bitcode.
llvm-ld: warning: Ignoring file '/sw/lib/libjpeg.62.0.0.dylib' because does not contain bitcode.
llvm-ld: warning: Ignoring file '/sw/lib/libpng.3.18.0.dylib' because does not contain bitcode.

...followed by errors of the form...

Undefined symbols:
  "_jpeg_stdio_dest", referenced from:
      _jpgi_first_plot in ccDTZ2L8.o
  "_jpeg_write_scanlines", referenced from:
      _jpgi_finish_output in ccDTZ2L8.o
  "_glutGet", referenced from:
      _ogl_start_plot in ccDTZ2L8.o
      _ogl_start_plot in ccDTZ2L8.o
      _menu_action in ccDTZ2L8.o
      _menu_action in ccDTZ2L8.o
      _menu_action in ccDTZ2L8.o
      _menu_action in ccDTZ2L8.o
      _ogl_first_plot in ccDTZ2L8.o
      _ogl_first_plot in ccDTZ2L8.o
      _ogl_display_mode_not_available in clib.a(ogl_utils.o)
      _ogl_display_mode_not_available_fatal in clib.a(ogl_utils.o)

...etc. Does this work on any other platform (eg linux)? Also, I find that
when I invoke the llvm-ld linker with '-L' and '-l' to link in shared libraries
that the libraries don't seem to be found. I have to explicitly add the libraries
with their full path in order for them to be found. Thanks in advance for any
advice on whether these are known issues or if I should fill bug reports on
them.
            Jack
_______________________________________________
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: using llvm-ld with existing libraries

Jack Howarth
   I am seeing the same problems using 'llvm-ld' with llvm-gcc
at -O4 on x86_64 Fedora 8 linux as on Darwin. Another example
of this is building the scimark2_1c benchmark...

http://math.nist.gov/scimark2/download_c.html

as follows on x86_64 Fedora 8...

/home/howarth/llvm-gcc42-work/bin/gcc -O4 -m64  -c FFT.c
/home/howarth/llvm-gcc42-work/bin/gcc -O4 -m64  -c kernel.c
/home/howarth/llvm-gcc42-work/bin/gcc -O4 -m64  -c Stopwatch.c
/home/howarth/llvm-gcc42-work/bin/gcc -O4 -m64  -c Random.c
/home/howarth/llvm-gcc42-work/bin/gcc -O4 -m64  -c SOR.c
/home/howarth/llvm-gcc42-work/bin/gcc -O4 -m64  -c SparseCompRow.c
/home/howarth/llvm-gcc42-work/bin/gcc -O4 -m64  -c array.c
/home/howarth/llvm-gcc42-work/bin/gcc -O4 -m64  -c MonteCarlo.c
/home/howarth/llvm-gcc42-work/bin/gcc -O4 -m64  -c LU.c
/home/howarth/llvm-gcc42-work/bin/llvm-ld -O4 -native  -o scimark2 scimark2.o FFT.o kernel.o Stopwatch.o Random.o SOR.o SparseCompRow.o array.o MonteCarlo.o LU.o   /usr/lib64/libm.so
/usr/lib/../lib64/crt1.o: In function `_start':
(.text+0x20): undefined reference to `main'
collect2: ld returned 1 exit status
llvm-ld:
make: *** [scimark2] Error 1

This is identical to what I see on Darwin...

llvm-ld -native -O4  -o scimark2 scimark2.o FFT.o kernel.o Stopwatch.o Random.o SOR.o SparseCompRow.o array.o MonteCarlo.o LU.o   -lm
llvm-ld: warning: Ignoring file 'scimark2.o' because does not contain bitcode.
Undefined symbols:
  "_main", referenced from:
      start in crt1.10.5.o
ld: symbol(s) not found
collect2: ld returned 1 exit status
llvm-ld:
make: *** [scimark2] Error 1

How are people testing code at -O4 if the existing linkers can't use any
pre-existing system libraries? Thanks in advance for any clarifications.
            Jack
_______________________________________________
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: using llvm-ld with existing libraries

Devang Patel
In reply to this post by Jack Howarth

On Dec 30, 2007, at 12:21 PM, Jack Howarth wrote:

>   I am running into some problems when trying to use
> llvm-ld to link object files, created by llvm-gcc-4.2
> at -O4, with the stock libraries available on
> powerpc-apple-darwin9. In particular, I am finding that
> the link command...
>
> llvm-ld -O4 -native -o molscript molscript.tab.o global.o lex.o  
> col.o select.o state.o graphics.o segment.o coord.o xform.o  
> postscript.o raster3d.o vrml.o regex.o opengl.o image.o eps_img.o  
> sgi_img.o jpeg_img.o png_img.o clib/clib.a /sw/lib/libfreeglut.
> 3.8.0.dylib /usr/X11R6/lib/libGLU.1.3.dylib /usr/X11R6/lib/libGL.
> 1.2.dylib /System/Library/Frameworks/OpenGL.framework/Libraries/
> libGL.dylib /usr/X11R6/lib/libX11.6.2.0.dylib /usr/X11R6/lib/libXi.
> 6.0.0.dylib /usr/X11R6/lib/libXmu.6.2.0.dylib /sw/lib/libjpeg.
> 62.0.0.dylib /sw/lib/libpng.3.18.0.dylib /usr/lib/libz.1.2.3.dylib /
> usr/lib/libSystem.B.dylib
>
> ...produces the warnings...
>
> llvm-ld: warning: Ignoring file '/sw/lib/libfreeglut.3.8.0.dylib'  
> because does not contain bitcode.
> llvm-ld: warning: Ignoring file '/sw/lib/libjpeg.62.0.0.dylib'  
> because does not contain bitcode.
> llvm-ld: warning: Ignoring file '/sw/lib/libpng.3.18.0.dylib'  
> because does not contain bitcode.

As expected, /sw/lib/libjpeg.62.0.0.dylib is not llvm bitcode and llvm-
ld only accepts bitcode files as input. What you want to do is


> $ llvm-ld -O4 -native molscript.tab.o global.o lex.o col.o select.o  
> state.o graphics.o segment.o coord.o xform.o postscript.o raster3d.o  
> vrml.o regex.o opengl.o image.o eps_img.o sgi_img.o jpeg_img.o  
> png_img.o -o my_big.o

> $ <my_compiler_or_linker_driver> my_big.o -o molscript clib/clib.a /
> sw/lib/libfreeglut.3.8.0.dylib /usr/X11R6/lib/libGLU.1.3.dylib /usr/
> X11R6/lib/libGL.1.2.dylib /System/Library/Frameworks/
> OpenGL.framework/Libraries/libGL.dylib /usr/X11R6/lib/
> libX11.6.2.0.dylib /usr/X11R6/lib/libXi.6.0.0.dylib /usr/X11R6/lib/
> libXmu.6.2.0.dylib /sw/lib/libjpeg.62.0.0.dylib /sw/lib/libpng.
> 3.18.0.dylib /usr/lib/libz.1.2.3.dylib /usr/lib/libSystem.B.dylib

> ...etc. Does this work on any other platform (eg linux)? Also, I  
> find that
> when I invoke the llvm-ld linker with '-L' and '-l' to link in  
> shared libraries
> that the libraries don't seem to be found. I have to explicitly add  
> the libraries
> with their full path in order for them to be found.

Are you using -L=<blah> and -l=<blah> syntax ? See llvm-ld --help.


-
Devang



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