[LLVMdev] darwin dragon-egg build issues

Jack Howarth howarth at bromo.med.uc.edu
Sat Apr 10 19:26:46 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,
    I am going to post this to gcc-patches after
regression testing on gcc-4_5-branch.
               Jack

2010-04-11  Jack Howarth <howarth at bromo.med.uc.edu>

        PR 43715
        * gcc/configure.ac: Use "$gcc_cv_nm -g" to check
        for exported symbols. Use "-undefined dynamic_lookup"
        on darwin.
        * gcc/configure: Regenerate.
        * testsuite/lib/plugin-support.exp: Use "-undefined
        dynamic_lookup" on darwin.


Index: testsuite/lib/plugin-support.exp
===================================================================
--- testsuite/lib/plugin-support.exp    (revision 158199)
+++ testsuite/lib/plugin-support.exp    (working copy)
@@ -88,6 +88,10 @@
 
     set optstr "$includes $extra_flags -DIN_GCC -fPIC -shared"
 
+    if { [ istarget *-*-darwin* ] } {
+        set optstr [concat $optstr "-undefined dynamic_lookup"]
+    }
+
     # Temporarily switch to the environment for the plugin compiler.
     restore_ld_library_path_env_vars
     set status [remote_exec build "$PLUGINCC $PLUGINCFLAGS $plugin_src $optstr -o $plugin_lib"]
Index: configure.ac
===================================================================
--- configure.ac        (revision 158199)
+++ configure.ac        (working copy)
@@ -4384,12 +4384,12 @@
   AC_MSG_CHECKING([for exported symbols])
   echo "int main() {return 0;} int foobar() {return 0;}" > conftest.c
   ${CC} ${CFLAGS} ${LDFLAGS} conftest.c -o conftest > /dev/null 2>&1
-  if $gcc_cv_objdump -T conftest | grep foobar > /dev/null; then
+  if $gcc_cv_nm -g conftest | grep foobar > /dev/null; then
     : # No need to use a flag
   else
     AC_MSG_CHECKING([for -rdynamic])
     ${CC} ${CFLAGS} ${LDFLAGS} -rdynamic conftest.c -o conftest > /dev/null 2>&1
-    if $gcc_cv_objdump -T conftest | grep foobar > /dev/null; then
+    if $gcc_cv_nm -g conftest | grep foobar > /dev/null; then
       pluginlibs="-rdynamic"
     else
       enable_plugin=no
@@ -4406,7 +4406,14 @@
 
   # Check that we can build shared objects with -fPIC -shared
   saved_LDFLAGS="$LDFLAGS"
-  LDFLAGS="$LDFLAGS -fPIC -shared"
+  case "${target}" in
+    *-*-darwin*)
+      LDFLAGS="$LDFLAGS -fPIC -shared -undefined dynamic_lookup"
+    ;;
+    *)
+      LDFLAGS="$LDFLAGS -fPIC -shared"
+    ;;
+  esac
   AC_MSG_CHECKING([for -fPIC -shared])
   AC_TRY_LINK(
     [extern int X;],[return X == 0;],





More information about the llvm-dev mailing list