[LLVMdev] Darwin option processing

Chris Lattner clattner at apple.com
Fri May 8 13:02:53 PDT 2009


On May 8, 2009, at 12:58 PM, Mike Stump wrote:
>> I think the best thing to do
>> is to compile LLVM PIC (the default) and then build the clang front-
>> end pieces with -mdynamic-no-pic.  Does this work for you?
>
> The proposed patch is more general that that.  It avoids the flag,
> when it is known it can't work, and leaves it in otherwise.  This
> allows the configurer of llvm to make the choice.  Longer term, I'd
> like to have the build system default to this, as appropriate.  This
> patch is merely a bridge until that patch is in.  If you'd prefer that
> patch instead, I could just do that one up.  My only reservation is
> that a change like that precedes the testing I'd rather have on it
> before I did the flip.

This goes against our general direction for llvm libraries: they  
should generally all be built pic.  This is because we don't know how  
they will be linked in.  For example, anything that links into liblto  
or llvm-gcc (on the mac) get stuck into dylibs.

> The other patch would look something like this:
>
> Index: Makefile.rules
> ===================================================================
> --- Makefile.rules	(revision 71041)
> +++ Makefile.rules	(working copy)
> @@ -245,6 +245,13 @@
>      OmitFramePointer := -fomit-frame-pointer
>    endif
>    endif
> +  ifndef LOADABLE_MODULE
> +    ifndef SHARED_LIBRARY
> +      ifeq ($(OS),Darwin)
> +        DynamicNoPic := -mdynamic-no-pic
> +      endif
> +    endif
> +  endif

How about factoring the logic so that there is one PIC_SETTING.  This  
setting can be either -fpic, -mdynamic-no-pic, or empty.

-Chris

>
>
>    # Darwin requires -fstrict-aliasing to be explicitly enabled.
>    # Avoid -fstrict-aliasing on Darwin for now, there are unresolved
> issues
> @@ -252,8 +259,8 @@
>    #ifeq ($(OS),Darwin)
>    #  EXTRA_OPTIONS += -fstrict-aliasing -Wstrict-aliasing
>    #endif
> -  CXX.Flags += $(OPTIMIZE_OPTION) $(OmitFramePointer)
> -  C.Flags   += $(OPTIMIZE_OPTION) $(OmitFramePointer)
> +  CXX.Flags += $(OPTIMIZE_OPTION) $(OmitFramePointer) $(DynamicNoPic)
> +  C.Flags   += $(OPTIMIZE_OPTION) $(OmitFramePointer) $(DynamicNoPic)
>    LD.Flags  += $(OPTIMIZE_OPTION)
>  else
>    BuildMode := Debug
>
> Thoughts?
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev




More information about the llvm-dev mailing list