Ticket #45251: llvm-3.8.diff

File llvm-3.8.diff, 10.3 KB (added by RJVB (René Bertin), 8 years ago)
  • lang/llvm-3.8/Portfile

    old new  
     1# $Id: Portfile 146341 2016-03-05 17:53:16Z jeremyhu@macports.org $
    12# $Id: Portfile 151991 2016-08-25 22:42:32Z jeremyhu@macports.org $
    23
    34# TODO:
     
    1415name                    llvm-${llvm_version}
    1516revision                0
    1617subport                 clang-${llvm_version} { revision 3 }
     18subport                 lldb-${llvm_version} {
     19    PortGroup           code-sign 1.0
     20}
    1721set suffix              mp-${llvm_version}
    1822set sub_prefix          ${prefix}/libexec/llvm-${llvm_version}
    1923dist_subdir             llvm
     
    6670    depends_lib-append  port:libedit port:libffi port:ncurses port:zlib
    6771
    6872    default_variants    +analyzer
     73} elseif {${subport} eq "lldb-${llvm_version}"} {
     74    homepage            http://lldb.llvm.org/
     75    description         the LLVM debugger
     76    long_description    Lldb is the "LLVM native" debugger.
     77
     78    depends_lib         port:libxml2 port:libomp port:llvm-${llvm_version} port:python27 \
     79                        port:ncurses
     80    depends_build-append port:cctools port:swig-python port:doxygen
     81    depends_skip_archcheck-append cctools
     82
     83    # Clang doesn't actually use any of these, but the LLVM makefile
     84    # system overlinks its binaries. Remove (or convert to build deps?)
     85    # after #46040 is resolved.
     86    depends_lib-append  port:libedit port:libffi port:ncurses port:zlib
    6987}
    7088
    7189#fetch.type              svn
     
    98116        }
    99117    } elseif {${subport} eq "clang-${llvm_version}"} {
    100118        distfiles-append     cfe-${version}.src${extract.suffix} compiler-rt-${version}.src${extract.suffix} libcxx-${version}.src${extract.suffix} clang-tools-extra-${version}.src${extract.suffix}
     119    } elseif {${subport} eq "lldb-${llvm_version}"} {
     120        distfiles-append     cfe-${version}.src${extract.suffix} lldb-${version}.src${extract.suffix}
    101121    }
    102122}
    103123
     
    118138                    sha256  664a5c60220de9c290bf2a5b03d902ab731a4f95fe73a00856175ead494ec396 \
    119139                    polly-3.8.1.src.tar.xz \
    120140                    rmd160  766873d4b88e0e9c5670aeb45313d47cca7bd79a \
    121                     sha256  453c27e1581614bb3b6351bf5a2da2939563ea9d1de99c420f85ca8d87b928a2
     141                    sha256  453c27e1581614bb3b6351bf5a2da2939563ea9d1de99c420f85ca8d87b928a2 \
     142                    lldb-3.8.1.src.tar.xz \
     143                    rmd160  e080bb734bcba419472acc0619fc7affb6209104 \
     144                    sha256  349148116a47e39dcb5d5042f10d8a6357d2c865034563283ca512f81cdce8a3
    122145
    123146patch.pre_args  -p1
    124147patchfiles \
     
    174197        }
    175198    }
    176199}
     200if {${subport} eq "lldb-${llvm_version}"} {
     201    # lldb needs the clang sources present, so we apply the applicable patches.
     202    patchfiles-append \
     203        1001-MacPorts-Only-Prepare-clang-format-for-replacement-w.patch \
     204        1002-MacPorts-Only-Fall-back-on-xcodebuild-sdk-when-xcrun.patch \
     205        1003-MacPorts-Only-Fix-name-of-scan-view-executable-insid.patch \
     206        1004-MacPorts-Only-Relocate-clang-resources-using-llvm-ve.patch \
     207        1005-Default-to-ppc7400-for-OSX-10.5.patch \
     208        1006-Only-call-setpriority-PRIO_DARWIN_THREAD-0-PRIO_DARW.patch \
     209        1007-Default-to-fragile-ObjC-runtime-when-targeting-darwi.patch \
     210        openmp-locations.patch
     211
     212    # I'm not sure if we need to delete this.  It seems to build fine with it
     213    # present, but we used to explicitly only use this patch for the llvm subport.
     214    patchfiles-delete \
     215        0005-MacPorts-Only-Skip-checking-for-python-in-configure.patch
     216
     217    # https://llvm.org/bugs/show_bug.cgi?id=25681
     218    if {${worksrcdir} eq "trunk" || ${worksrcdir} eq "release_${llvm_version_no_dot}"} {
     219        # Cannot set cppflags due to https://cmake.org/Bug/view.php?id=12928
     220        # Cannot set cxxflags due to https://llvm.org/bugs/show_bug.cgi?id=25904
     221        #configure.cxxflags-append -DSVN_REVISION='"${svn.revision}"'
     222
     223        post-patch {
     224            reinplace "1 i \\
     225                #define SVN_REVISION \"${svn.revision}\"
     226            " ${worksrcpath}/tools/clang/lib/Basic/Version.cpp
     227        }
     228    }
     229
     230    # we'll need to codesign the debugserver executable, but we'll do that
     231    # in the post-activate step.
     232    patchfiles-append       patch-no-codesign.diff
     233}
     234patchfiles-append           patch-accept-build_types.diff
    177235
    178236configure.post_args         ../${worksrcdir}
    179237default configure.dir       {${workpath}/build}
     
    209267        -DCLANG_ENABLE_STATIC_ANALYZER=OFF \
    210268        -DLLVM_BUILD_RUNTIME=ON \
    211269        -DLIBCXX_INSTALL_LIBRARY=OFF
     270} elseif {${subport} eq "lldb-${llvm_version}"} {
     271    select.group        lldb
     272    select.file         ${filespath}/mp-${subport}
     273
     274    configure.args-append \
     275        -DCLANG_ENABLE_ARCMT=OFF \
     276        -DCLANG_INCLUDE_TESTS=OFF \
     277        -DCLANG_ENABLE_STATIC_ANALYZER=OFF \
     278        -DLLVM_BUILD_RUNTIME=ON \
     279        -DLIBCXX_INSTALL_LIBRARY=OFF \
     280        -DPYTHON_EXECUTABLE=${prefix}/bin/python2.7 \
     281        -DPYTHON_INCLUDE_DIR=${prefix}/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7
    212282}
    213283
    214284# llvm-3.5 and later requires a C++11 runtime
     
    272342    configure.args-append -DLLVM_ENABLE_ASSERTIONS=ON
    273343}
    274344
     345if {${subport} ne "lldb-${llvm_version}"} {
     346    variant static_libllvm description "Don't build the shared libLLVM.dylib, for instance to get a standalone redistributable libclang" {
     347        configure.args-delete -DLLVM_LINK_LLVM_DYLIB=ON
     348        configure.args-append -DLLVM_LINK_LLVM_DYLIB=OFF -DLLVM_BUILD_LLVM_DYLIB=OFF
     349    }
     350
     351    variant nortti description "Don't build with internal RTTI support (increases compilation performance somewhat)" {
     352        configure.args-delete -DLLVM_ENABLE_RTTI=ON
     353        configure.args-append -DLLVM_ENABLE_RTTI=OFF
     354    }
     355}
     356
    275357platform darwin {
    276358    if {[string match "*ppc*" [get_canonical_archs]]} {
    277359        # http://trac.macports.org/ticket/33987
     
    281363    if {${subport} eq "clang-${llvm_version}" && [vercmp $xcodeversion 5.0] < 0} {
    282364        # https://llvm.org/bugs/show_bug.cgi?id=13671
    283365        patchfiles-append leopard-no-asan.patch
     366#         configure.args-append -DCOMPILER_RT_HAS_SANITIZER_COMMON=NO
    284367        configure.args-append -DCOMPILER_RT_BUILD_SANITIZERS=OFF
    285368    }
    286369
     
    331414            file rename ${workpath}/libcxx-${version}.src ${worksrcpath}/projects/libcxx
    332415            file rename ${workpath}/clang-tools-extra-${version}.src ${worksrcpath}/tools/clang/tools/extra
    333416        }
     417    } elseif {${subport} eq "lldb-${llvm_version}"} {
     418        file rename ${workpath}/cfe-${version}.src ${worksrcpath}/tools/clang
     419        file rename ${workpath}/lldb-${version}.src ${worksrcpath}/tools/lldb
    334420    }
    335421}
    336422
     
    342428
    343429        delete ${destroot}${sub_prefix}/bin/clang
    344430        file rename ${destroot}${sub_prefix}/bin/clang-${llvm_version} ${destroot}${sub_prefix}/bin/clang
     431        if {![variant_isset static_libllvm]} {
     432            # this is not a build that aims to be (more easily) relocatable
     433            system "install_name_tool -id ${sub_prefix}/lib/libclang.dylib ${destroot}${sub_prefix}/lib/libclang.dylib"
     434            system "install_name_tool -change @rpath/libLLVM.dylib ${sub_prefix}/lib/libLLVM.dylib ${destroot}${sub_prefix}/lib/libclang.dylib"
     435        }
     436    }
     437}
     438
     439if {${subport} eq "lldb-${llvm_version}"} {
     440    post-patch {
     441        reinplace "s|@@PREFIX@@|${prefix}|" \
     442            ${worksrcpath}/tools/clang/lib/Driver/Tools.cpp
     443
     444        reinplace "s|@CLANG_FORMAT_PATH@|${prefix}/bin/clang-format-${suffix}|g" \
     445            ${worksrcpath}/tools/clang/tools/clang-format/clang-format-bbedit.applescript \
     446            ${worksrcpath}/tools/clang/tools/clang-format/clang-format-diff.py            \
     447            ${worksrcpath}/tools/clang/tools/clang-format/clang-format-sublime.py         \
     448            ${worksrcpath}/tools/clang/tools/clang-format/clang-format.el                 \
     449            ${worksrcpath}/tools/clang/tools/clang-format/clang-format.py
     450    }
     451
     452    build.dir   ${build.dir}/tools/lldb
     453
     454    destroot {
     455        destroot.target     install/fast
     456        system "cd ${destroot.dir} && ${destroot.cmd} ${destroot.pre_args} ${destroot.target} ${destroot.post_args}"
     457
     458        foreach bin {lldb lldb-mi lldb-server} {
     459            delete ${destroot}${sub_prefix}/bin/${bin}
     460            file rename ${destroot}${sub_prefix}/bin/${bin}-${version} ${destroot}${sub_prefix}/bin/${bin}
     461        }
     462        # this is not a build that aims to be (more easily) relocatable
     463        system "install_name_tool -id ${sub_prefix}/lib/liblldb.dylib ${destroot}${sub_prefix}/lib/liblldb.dylib"
     464        system "install_name_tool -change @rpath/libLLVM.dylib ${sub_prefix}/lib/libLLVM.dylib ${destroot}${sub_prefix}/lib/liblldb.dylib"
     465        xinstall -m 755 -d ${destroot}${prefix}/share/doc/lldb-${llvm_version}
     466        xinstall -m 644 ${worksrcpath}/tools/lldb/docs/code-signing.txt ${destroot}${prefix}/share/doc/lldb-${llvm_version}/
     467    }
     468    post-activate {
     469        if {[codesign ${sub_prefix}/bin/debugserver lldb_codesign] ne 0} {
     470            ui_msg "Please follow the instructions in ${prefix}/lldb-${llvm_version}/code-signing.txt and then reinstall this port"
     471        }
    345472    }
    346473}
    347474
     
    365492        if {[variant_isset polly]} {
    366493            ln -s LLVMPolly.so ${destroot}${sub_prefix}/lib/LLVMPolly.dylib
    367494        }
     495        if {[file exists ${destroot}${sub_prefix}/lib/libLLVM.dylib]} {
     496            # this is not a build that aims to be (more easily) relocatable
     497            system "install_name_tool -id ${sub_prefix}/lib/libLTO.dylib ${destroot}${sub_prefix}/lib/libLTO.dylib"
     498            system "install_name_tool -id ${sub_prefix}/lib/libLLVM.dylib ${destroot}${sub_prefix}/lib/libLLVM.dylib"
     499            system "install_name_tool -change @rpath/libLLVM.dylib ${sub_prefix}/lib/libLLVM.dylib ${destroot}${sub_prefix}/lib/libLTO.dylib"
     500        }
    368501    } elseif {${subport} eq "clang-${llvm_version}"} {
    369502        system "ditto ${worksrcpath}/projects/libcxx/include ${destroot}${sub_prefix}/lib/c++/v1"
    370503
    371504        # http://trac.macports.org/ticket/33207
    372505        ln -s ${prefix}/libexec/ld64/ld ${destroot}${sub_prefix}/bin/ld
     506    } elseif {${subport} eq "lldb-${llvm_version}"} {
     507        delete ${destroot}${prefix}/bin/debugserver-${suffix}
    373508    }
    374509}
    375510