Ticket #45251: llvm-3.9.diff

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

    old new  
    1 # $Id: Portfile 152329 2016-09-04 01:22:27Z jeremyhu@macports.org $
     1# $Id: Portfile 146341 2016-03-05 17:53:16Z jeremyhu@macports.org $
     2# $Id: Portfile 151991 2016-08-25 22:42:32Z jeremyhu@macports.org $
    23
    34# TODO:
    45#  * Update clang subport to build against installed llvm
     
    1415name                    llvm-${llvm_version}
    1516revision                0
    1617subport                 clang-${llvm_version} {}
     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
     
    97115        }
    98116    } elseif {${subport} eq "clang-${llvm_version}"} {
    99117        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}
     118    } elseif {${subport} eq "lldb-${llvm_version}"} {
     119        distfiles-append     cfe-${version}.src${extract.suffix} lldb-${version}.src${extract.suffix}
    100120    }
    101121}
    102122
     
    117137                    sha256  5b7aec46ec8e999ec683c87ad744082e1133781ee4b01905b4bdae5d20785f14 \
    118138                    polly-3.9.0.src.tar.xz \
    119139                    rmd160  76b4fba05ffbfa1ce1486e80b55824fdcbfcbfe2 \
    120                     sha256  ef0dd25010099baad84597cf150b543c84feac2574d055d6780463d5de8cd97e
     140                    sha256  ef0dd25010099baad84597cf150b543c84feac2574d055d6780463d5de8cd97e \
     141                    lldb-3.9.0.src.tar.xz \
     142                    rmd160  dbcbe796ea46fc0081e6d5519b4a96c6c32e0fc5 \
     143                    sha256  61280e07411e3f2b4cca0067412b39c16b0a9edd19d304d3fc90249899d12384
    121144
    122145patch.pre_args  -p1
    123146patchfiles \
     
    160183        }
    161184    }
    162185}
     186if {${subport} eq "lldb-${llvm_version}"} {
     187    # lldb needs the clang sources present, so we apply the applicable patches.
     188    patchfiles-append \
     189        1001-MacPorts-Only-Prepare-clang-format-for-replacement-w.patch \
     190        1002-MacPorts-Only-Fix-name-of-scan-view-executable-insid.patch \
     191        1003-Default-to-ppc7400-for-OSX-10.5.patch \
     192        1004-Only-call-setpriority-PRIO_DARWIN_THREAD-0-PRIO_DARW.patch \
     193        1005-Default-to-fragile-ObjC-runtime-when-targeting-darwi.patch \
     194        openmp-locations.patch
     195
     196    # https://llvm.org/bugs/show_bug.cgi?id=25681
     197    if {${worksrcdir} eq "trunk" || ${worksrcdir} eq "release_${llvm_version_no_dot}"} {
     198        # Cannot set cppflags due to https://cmake.org/Bug/view.php?id=12928
     199        # Cannot set cxxflags due to https://llvm.org/bugs/show_bug.cgi?id=25904
     200        #configure.cxxflags-append -DSVN_REVISION='"${svn.revision}"'
     201
     202        post-patch {
     203            reinplace "1 i \\                             
     204                #define SVN_REVISION \"${svn.revision}\"
     205            " ${worksrcpath}/tools/clang/lib/Basic/Version.cpp
     206        }
     207    }
     208
     209    # we'll need to codesign the debugserver executable, but we'll do that
     210    # in the post-activate step.
     211    patchfiles-append       patch-no-codesign-3.9.diff
     212}
     213patchfiles-append           patch-accept-build_types.diff
    163214
    164215configure.post_args         ../${worksrcdir}
    165216default configure.dir       {${workpath}/build}
     
    206257        configure.args-append \
    207258            -DCOMPILER_RT_BUILD_SANITIZERS=OFF
    208259    }
     260} elseif {${subport} eq "lldb-${llvm_version}"} {
     261    select.group        lldb
     262    select.file         ${filespath}/mp-${subport}
     263
     264    configure.args-append \
     265        -DCLANG_ENABLE_ARCMT=OFF \
     266        -DCLANG_INCLUDE_TESTS=OFF \
     267        -DCLANG_ENABLE_STATIC_ANALYZER=OFF \
     268        -DLLVM_BUILD_RUNTIME=ON \
     269        -DLIBCXX_ENABLE_SHARED=OFF \
     270        -DLIBCXX_INSTALL_LIBRARY=OFF \
     271        -DPYTHON_EXECUTABLE=${prefix}/bin/python2.7 \
     272        -DPYTHON_INCLUDE_DIR=${prefix}/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7
     273    if {${os.major} <= 12} {
     274        # We unfortunately don't have an option to just turn off tsan
     275        # https://llvm.org/bugs/show_bug.cgi?id=27715
     276        configure.args-append \
     277            -DCOMPILER_RT_BUILD_SANITIZERS=OFF
     278    }
    209279}
    210280
    211281# llvm-3.5 and later requires a C++11 runtime
     
    269339    configure.args-append -DLLVM_ENABLE_ASSERTIONS=ON
    270340}
    271341
     342if {${subport} ne "lldb-${llvm_version}"} {
     343    variant static_libllvm description "Don't build the shared libLLVM.dylib, for instance to get a standalone redistributable libclang" {
     344        configure.args-delete -DLLVM_LINK_LLVM_DYLIB=ON
     345        configure.args-append -DLLVM_LINK_LLVM_DYLIB=OFF -DLLVM_BUILD_LLVM_DYLIB=OFF
     346    }
     347
     348    variant nortti description "Don't build with internal RTTI support (increases compilation performance somewhat)" {
     349        configure.args-delete -DLLVM_ENABLE_RTTI=ON
     350        configure.args-append -DLLVM_ENABLE_RTTI=OFF
     351    }
     352}
     353
    272354platform darwin {
    273355    if {[string match "*ppc*" [get_canonical_archs]]} {
    274356        # http://trac.macports.org/ticket/33987
     
    328410            file rename ${workpath}/libcxx-${version}.src ${worksrcpath}/projects/libcxx
    329411            file rename ${workpath}/clang-tools-extra-${version}.src ${worksrcpath}/tools/clang/tools/extra
    330412        }
     413    } elseif {${subport} eq "lldb-${llvm_version}"} {
     414        file rename ${workpath}/cfe-${version}.src ${worksrcpath}/tools/clang
     415        file rename ${workpath}/lldb-${version}.src ${worksrcpath}/tools/lldb
    331416    }
    332417}
    333418
    334419if {${subport} eq "clang-${llvm_version}"} {
     420#     build {
     421#         system -W ${build.dir}/tools/clang "${build.cmd} ${build.pre_args} ${build.target} ${build.post_args}"
     422#         system -W ${build.dir}/projects/compiler-rt "${build.cmd} ${build.pre_args} ${build.target} ${build.post_args}"
     423#         system -W ${build.dir}/projects/libcxx "${build.cmd} ${build.pre_args} ${build.target} ${build.post_args}"
     424#     }
    335425    destroot {
    336426        system "cd ${destroot.dir}/tools/clang && ${destroot.cmd} ${destroot.pre_args} ${destroot.target} ${destroot.post_args}"
    337427        system "cd ${destroot.dir}/projects/compiler-rt && ${destroot.cmd} ${destroot.pre_args} ${destroot.target} ${destroot.post_args}"
     
    339429
    340430        delete ${destroot}${sub_prefix}/bin/clang
    341431        file rename ${destroot}${sub_prefix}/bin/clang-${llvm_version} ${destroot}${sub_prefix}/bin/clang
     432        if {![variant_isset static_libllvm]} {
     433            # this is not a build that aims to be (more easily) relocatable
     434            system "install_name_tool -id ${sub_prefix}/lib/libclang.dylib ${destroot}${sub_prefix}/lib/libclang.dylib"
     435            system "install_name_tool -change @rpath/libLLVM.dylib ${sub_prefix}/lib/libLLVM.dylib ${destroot}${sub_prefix}/lib/libclang.dylib"
     436        }
     437    }
     438}
     439
     440if {${subport} eq "lldb-${llvm_version}"} {
     441    post-patch {
     442        reinplace "s|@@PREFIX@@|${prefix}|" \
     443            ${worksrcpath}/tools/clang/lib/Driver/Tools.cpp
     444
     445        reinplace "s|@CLANG_FORMAT_PATH@|${prefix}/bin/clang-format-${suffix}|g" \
     446            ${worksrcpath}/tools/clang/tools/clang-format/clang-format-bbedit.applescript \
     447            ${worksrcpath}/tools/clang/tools/clang-format/clang-format-diff.py            \
     448            ${worksrcpath}/tools/clang/tools/clang-format/clang-format-sublime.py         \
     449            ${worksrcpath}/tools/clang/tools/clang-format/clang-format.el                 \
     450            ${worksrcpath}/tools/clang/tools/clang-format/clang-format.py
     451    }
     452
     453    build.dir   ${build.dir}/tools/lldb
     454
     455    destroot {
     456        destroot.target     install/fast
     457        system "cd ${destroot.dir} && ${destroot.cmd} ${destroot.pre_args} ${destroot.target} ${destroot.post_args}"
     458
     459        foreach bin {lldb lldb-mi lldb-server} {
     460            delete ${destroot}${sub_prefix}/bin/${bin}
     461            file rename ${destroot}${sub_prefix}/bin/${bin}-${version} ${destroot}${sub_prefix}/bin/${bin}
     462        }
     463        # this is not a build that aims to be (more easily) relocatable
     464        system "install_name_tool -id ${sub_prefix}/lib/liblldb.dylib ${destroot}${sub_prefix}/lib/liblldb.dylib"
     465        system "install_name_tool -change @rpath/libLLVM.dylib ${sub_prefix}/lib/libLLVM.dylib ${destroot}${sub_prefix}/lib/liblldb.dylib"
     466        xinstall -m 755 -d ${destroot}${prefix}/share/doc/lldb-${llvm_version}
     467        xinstall -m 644 ${worksrcpath}/tools/lldb/docs/code-signing.txt ${destroot}${prefix}/share/doc/lldb-${llvm_version}/
     468    }
     469    post-activate {
     470        if {[codesign ${sub_prefix}/bin/debugserver lldb_codesign] ne 0} {
     471            ui_msg "Please follow the instructions in ${prefix}/lldb-${llvm_version}/code-signing.txt and then reinstall this port"
     472        }
    342473    }
    343474}
    344475
     
    362493        if {[variant_isset polly]} {
    363494            ln -s LLVMPolly.so ${destroot}${sub_prefix}/lib/LLVMPolly.dylib
    364495        }
     496        if {[file exists ${destroot}${sub_prefix}/lib/libLLVM.dylib]} {
     497            # this is not a build that aims to be (more easily) relocatable
     498            system "install_name_tool -id ${sub_prefix}/lib/libLTO.dylib ${destroot}${sub_prefix}/lib/libLTO.dylib"
     499            system "install_name_tool -id ${sub_prefix}/lib/libLLVM.dylib ${destroot}${sub_prefix}/lib/libLLVM.dylib"
     500            system "install_name_tool -change @rpath/libLLVM.dylib ${sub_prefix}/lib/libLLVM.dylib ${destroot}${sub_prefix}/lib/libLTO.dylib"
     501        }
    365502    } elseif {${subport} eq "clang-${llvm_version}"} {
    366503        system "ditto ${worksrcpath}/projects/libcxx/include ${destroot}${sub_prefix}/lib/c++/v1"
    367504
    368505        # http://trac.macports.org/ticket/33207
    369506        ln -s ${prefix}/libexec/ld64/ld ${destroot}${sub_prefix}/bin/ld
     507    } elseif {${subport} eq "lldb-${llvm_version}"} {
     508        delete ${destroot}${prefix}/bin/debugserver-${suffix}
    370509    }
    371510}
    372511