[LLVMdev] darwin dragon-egg build issues

Jack Howarth howarth at bromo.med.uc.edu
Mon Apr 12 20:23:27 PDT 2010


On Sat, Apr 10, 2010 at 08:29:07PM -0500, Peter O'Gorman wrote:
> On 04/10/2010 08:01 PM, Jack Howarth wrote:
> 
> > 
> > bash-3.2$ GCC=/sw/bin/gcc-4 CC=gcc-4 CXX=g++-4 CFLAGS=-I/sw/include CXXFLAGS=-I/sw/include LLVM_CONFIG=/sw/lib/llvm/bin/llvm-config make
> > g++-4 -c  -I/sw/lib/llvm/include  -D_DEBUG -D_GNU_SOURCE -D__STDC_LIMIT_MACROS -D__STDC_CONSTANT_MACROS -MD -MP -DIN_GCC -DREVISION=\"100954M\" -DTARGET_NAME=\"x86_64-apple-darwin10.3.0\" -I/Users/howarth/llvm_svn/dragonegg -I/sw/lib/gcc4.5/lib/gcc/x86_64-apple-darwin10.3.0/4.5.0/plugin/include -I/Users/howarth/llvm_svn/dragonegg/x86 -I/Users/howarth/llvm_svn/dragonegg/darwin -I/sw/include -Wall -Werror -I/sw/lib/llvm/include  -D_DEBUG -D_GNU_SOURCE -D__STDC_LIMIT_MACROS -D__STDC_CONSTANT_MACROS -O2  -fno-exceptions -fno-rtti -fno-common -Woverloaded-virtual /Users/howarth/llvm_svn/dragonegg/llvm-convert.cpp
> > In file included from /Users/howarth/llvm_svn/dragonegg/llvm-convert.cpp:88:0:
> > /Users/howarth/llvm_svn/dragonegg/llvm-debug.h:150:3: error: ‘DIFile’ does not name a type
> 
> 
> After editing the dragonegg Makefile to remove -Werror, installing
> r100954 of llvm/clang (to /opt/llv, being too lazy to type the 'm'),
> copying the missing  darwin-sections.def to the installed gcc-4.5.0
> release-candidate, as you noticed, I could add /opt/llv/bin to my path
> and the path to my gcc-4.5 install, and do:
> 
> GCC=/sw/lib/gcc4.5/bin/gcc make CPPFLAGS="-DENABLE_LTO -I/sw/include"
> 
> And it worked until the final link, which failed (-shared works in
> recent gcc, but is just an alias for -dynamiclib, and doesn't allow
> undefined symbols). I copy & pasted the link line, added -undefined
> dynamic_lookup, and it linked and apparently works:
> 
> mini:dragonegg pogma$ gcc hello.c -S -O1 -o - -fplugin=./dragonegg.so
> -fplugin-arg-dragonegg-emit-ir
> ; ModuleID = 'hello.c'
> target datalayout =
> "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64"
> target triple = "x86_64-apple-darwin10.3.0"
> 
> %"char[]" = type [6 x i8]
> 
> @.str = private constant %"char[]" c"Hello\00", align 1 ; <%"char[]"*>
> [#uses=2]
> 
> define i32 @main() nounwind {
> entry:
>   %0 = tail call i32 @puts(i8* getelementptr inbounds (%"char[]"* @.str,
> i64 0, i64 0)) nounwind ; <i32> [#uses=0]
>   ret i32 undef
> }
> 
> declare i32 @puts(i8* nocapture) nounwind
> 
> Pretty awesome!
> 
> Peter

Peter,
   Does this still work for you with current llvm svn? I created a new llvm
fink package from current svn and used that to build the current dragon-egg
against my gcc45 package with plugin support enabled. The build of the plugin
worked but when I try to use it I get..

bash-3.2$ gcc-4 hello.c -S -O1 -o - -fplugin=./dragonegg.so
cc1: error: Cannot load plugin ./dragonegg.so
dlopen(./dragonegg.so, 10): Symbol not found: _classify_argument
  Referenced from: /Users/howarth/llvm_svn/dragonegg/dragonegg.so
  Expected in: flat namespace
 in /Users/howarth/llvm_svn/dragonegg/dragonegg.so

I noticed that I have...

bash-3.2$ otool -L ./dragonegg.so
./dragonegg.so:
	/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 125.0.1)
	/usr/lib/libstdc++.6.dylib (compatibility version 7.0.0, current version 7.9.0)

in both builds I tried...

GCC=/sw/lib/gcc4.5/bin/gcc LLVM_CONFIG=/sw/lib/llvm/bin/llvm-config make CPPFLAGS="-DENABLE_LTO -I/sw/include"

and

GCC=/sw/lib/gcc4.5/bin/gcc LLVM_CONFIG=/sw/lib/llvm/bin/llvm-config CC=gcc-4 CCX=g++-4 LDFLAGS=-L/sw/lib make CPPFLAGS="-DENABLE_LTO -I/sw/include"

How do you build llvm? I am using...

Info2: <<
Package: llvm
Version: 2.799
Revision: 101114
#Source: http://llvm.org/releases/%v/llvm-%v.tar.gz
Source: http://llvm.org/releases/%v/llvm-2.8.tar.gz
Source-MD5: d317d277e97c3852994bb4dcaadf1591
SourceDirectory: llvm-2.8
Type: -64bit .
Architecture: x86_64
BuildDepends: fink (>= 0.28)
ConfigureParams: <<
 --prefix=%p/lib/llvm --mandir=%p/share/man --infodir=%p/share/info --with-gmp=%p --with-libiconv-prefix=/usr --with-system-zlib --with-as=`xcode-select  -print-path`/usr/bin/as --with-ld=`xcode-select  -print-path`/usr/bin/ld --with-nm=`xcode-select  -print-path`/usr/bin/nm
<<
CompileScript: <<
 #!/bin/bash -ev
 export LD=`xcode-select  -print-path`/usr/bin/ld
 ulimit -s `ulimit -s`
 mkdir ../llvm_objdir
 cd ../llvm_objdir
# ../llvm-%v/configure %c --enable-optimized --enable-assertions --enable-pic --enable-targets=host-only
../llvm-2.8/configure %c --enable-optimized --enable-assertions --enable-pic --enable-targets=host-only
 num_cpu=$(echo `sysctl -n hw.ncpu`)
 make -j $num_cpu
<<
InstallScript: <<
 #!/bin/sh -ev
 export LD=`xcode-select  -print-path`/usr/bin/ld
 cd ../llvm_objdir
 make install DESTDIR=%d 
 mkdir -p %i/bin
 ln -s %p/lib/llvm/bin/bugpoint %i/bin/bugpoint
 ln -s %p/lib/llvm/bin/gccas %i/bin/gccas
 ln -s %p/lib/llvm/bin/gccld %i/bin/gccld
 ln -s %p/lib/llvm/bin/llc %i/bin/llc
 ln -s %p/lib/llvm/bin/lli %i/bin/lli
 ln -s %p/lib/llvm/bin/llvm-ar %i/bin/llvm-ar
 ln -s %p/lib/llvm/bin/llvm-as %i/bin/llvm-as
 ln -s %p/lib/llvm/bin/llvm-bcanalyzer %i/bin/llvm-bcanalyzer
 ln -s %p/lib/llvm/bin/llvm-config %i/bin/llvm-config
 ln -s %p/lib/llvm/bin/llvm-db %i/bin/llvm-db
 ln -s %p/lib/llvm/bin/llvm-dis %i/bin/llvm-dis
 ln -s %p/lib/llvm/bin/llvm-extract %i/bin/llvm-extract
 ln -s %p/lib/llvm/bin/llvm-ld %i/bin/llvm-ld
 ln -s %p/lib/llvm/bin/llvm-link %i/bin/llvm-link
 ln -s %p/lib/llvm/bin/llvm-nm %i/bin/llvm-nm
 ln -s %p/lib/llvm/bin/llvm-prof  %i/bin/llvm-prof
 ln -s %p/lib/llvm/bin/llvm-ranlib %i/bin/llvm-ranlib
 ln -s %p/lib/llvm/bin/llvm-stub %i/bin/llvm-stub
 ln -s %p/lib/llvm/bin/llvmc %i/bin/llvmc
 ln -s %p/lib/llvm/bin/opt %i/bin/opt
 <<
SplitOff: <<
  Package: %N-shlibs
  Files: <<
     lib/llvm/lib/libEnhancedDisassembly.dylib
     lib/llvm/lib/libLLVMHello.dylib
     lib/llvm/lib/libprofile_rt.dylib
     lib/llvm/lib/libLTO.dylib
  << 
  Shlibs: <<
     !%p/lib/llvm/lib/libEnhancedDisassembly.dylib
     !%p/lib/llvm/lib/libLLVMHello.dylib
     !%p/lib/llvm/lib/libprofile_rt.dylib
     %p/lib/llvm/lib/libLTO.dylib 0.0.0 %n (>= 2.7-1) 64 
  <<
<<
License: GPL
Description: Low Level Virtual Machine Compiler
DescDetail: <<
A compilation strategy designed to enable effective program optimization across
the entire lifetime of a program. LLVM supports effective optimization at
compile time, link-time (particularly interprocedural), run-time and offline 
(i.e., after software is installed), while remaining transparent to developers
and maintaining compatibility with existing build scripts.
<<
DescPackaging: <<
The file libLTO.dylib in %p/lib/llvm/lib can be used to replace the libLTO.dylib
in /Developer/usr/lib from Xcode 3.1.2 to enable full LTO support at -O4 in
the compilers of the llvm-gcc42 package. Note that the fink maintainer mode
doesn't understand the @executable_path/../lib/libLTO.dylib syntax in libLTO.dylib's
otool -L output.
<<
Homepage: http://llvm.org/
Maintainer: None <fink-devel at lists.sourceforge.net>
<<




More information about the llvm-dev mailing list