[LLVMbugs] [Bug 16738] New: cmake ENABLE_PIC forced off on Darwin/Xcodde

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Mon Jul 29 12:59:53 PDT 2013


http://llvm.org/bugs/show_bug.cgi?id=16738

            Bug ID: 16738
           Summary: cmake ENABLE_PIC forced off on Darwin/Xcodde
           Product: Build scripts
           Version: trunk
          Hardware: All
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: cmake
          Assignee: unassignedbugs at nondot.org
          Reporter: rfoos at codeaurora.org
                CC: fang at csl.cornell.edu, llvmbugs at cs.uiuc.edu,
                    rafael.espindola at gmail.com
        Depends on: 14903
    Classification: Unclassified

+++ This bug was initially created as a clone of Bug #14903 +++
Cmake for Xcode disables PIC.
    # Xcode has -mdynamic-no-pic on by default, which overrides -fPIC. I don't
    # know how to disable this, so just force ENABLE_PIC off for now.

--- autoconf ENABLE_PIC logic for DARWIN
Makefile.rules
ifeq ($(ENABLE_PIC),1)
  ifeq ($(HOST_OS), $(filter $(HOST_OS), Cygwin MingW))
    # Nothing. Win32 defaults to PIC and warns when given -fPIC
  else
    ifeq ($(HOST_OS),Darwin)
      # Common symbols not allowed in dylib files
      CXX.Flags += -fno-common
      C.Flags   += -fno-common
    else
      # Linux and others; pass -fPIC
      CXX.Flags += -fPIC
      C.Flags   += -fPIC
    endif
  endif
else
  ifeq ($(HOST_OS),Darwin)
      CXX.Flags += -mdynamic-no-pic
      C.Flags   += -mdynamic-no-pic
  endif
endif

--- cmake ENABLE_PIC logic for darwin/xcode.
cmake/modules/HandleLLVMOptions.cmake

if( ENABLE_PIC )
  if( XCODE )
    # Xcode has -mdynamic-no-pic on by default, which overrides -fPIC. I don't
    # know how to disable this, so just force ENABLE_PIC off for now.
    message(WARNING "-fPIC not supported with Xcode.")
  elseif( WIN32 OR CYGWIN)
    # On Windows all code is PIC. MinGW warns if -fPIC is used.
  else()
    add_flag_or_print_warning("-fPIC")

    if( WIN32 OR CYGWIN)
      # MinGW warns if -fvisibility-inlines-hidden is used.
    else()
      check_cxx_compiler_flag("-fvisibility-inlines-hidden"
SUPPORTS_FVISIBILITY_INLINES_HIDDEN_FLAG)
      append_if(SUPPORTS_FVISIBILITY_INLINES_HIDDEN_FLAG
"-fvisibility-inlines-hidden" CMAKE_CXX_FLAGS)
    endif()
  endif()
endif()

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20130729/7dfe8e62/attachment.html>


More information about the llvm-bugs mailing list