source: trunk/dports/lang/llvm-3.6/Portfile @ 137992

Last change on this file since 137992 was 137992, checked in by mww@…, 4 years ago

inc. revision to rebuild library dependents of ocaml (ocaml update to version 4.02.2)

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 18.9 KB
Line 
1# $Id: Portfile 137992 2015-06-24 16:17:51Z mww@macports.org $
2
3PortSystem              1.0
4PortGroup select        1.0
5PortGroup compiler_blacklist_versions 1.0
6
7set llvm_version        3.6
8set llvm_version_no_dot 36
9name                    llvm-${llvm_version}
10revision                1
11subport                 clang-${llvm_version} {}
12set suffix              mp-${llvm_version}
13set sub_prefix          ${prefix}/libexec/llvm-${llvm_version}
14dist_subdir             llvm
15categories              lang
16platforms               darwin
17license                 NCSA
18maintainers             jeremyhu larryv
19
20if {${subport} eq "llvm-${llvm_version}"} {
21    homepage            http://llvm.org/
22    description         llvm is a next generation compiler infrastructure
23    long_description    The LLVM Core libraries provide a modern source- and \
24                        target-independent optimizer, along with code \
25                        generation support for many popular CPUs (as well as \
26                        some less common ones!) These libraries are built \
27                        around a well specified code representation known as \
28                        the LLVM intermediate representation ("LLVM IR").
29
30    depends_lib         port:libedit port:libffi port:ncurses port:zlib
31    depends_run         bin:perl:perl5 port:llvm_select
32
33    # 3.2.6's install_name_tool doesn't support load commands we might see with newer clang+ld64
34    # 4.3 is just a guess here and should be updated if there are additional reports with other Xcode versions
35    if {[vercmp $xcodeversion 4.3] < 0 && [string match "*macports*" ${configure.compiler}]} {
36        depends_build-append port:cctools
37    }
38} elseif {${subport} eq "clang-${llvm_version}"} {
39    homepage            http://clang.llvm.org/
40    description         C, C++, Objective C and Objective C++ compiler
41    long_description    Clang is an "LLVM native" C/C++/Objective-C compiler, \
42                        which aims to deliver amazingly fast compiles (e.g. \
43                        about 3x faster than GCC when compiling Objective-C \
44                        code in a debug configuration), extremely useful error \
45                        and warning messages and to provide a platform for \
46                        building great source level tools. The included Clang \
47                        Static Analyzer is a tool that automatically finds bugs in \
48                        your code, and is a great example of the sort of tool \
49                        that can be built using the Clang frontend as a \
50                        library to parse C/C++ code.
51
52    depends_lib         port:libxml2 port:llvm-${llvm_version} port:python27
53    depends_run         port:clang_select port:ld64
54    depends_extract     bin:svn:subversion
55    depends_build       port:cctools
56    depends_skip_archcheck-append cctools ld64 subversion
57
58    # Clang doesn't actually use any of these, but the LLVM makefile
59    # system overlinks its binaries. Remove (or convert to build deps?)
60    # after #46040 is resolved.
61    depends_lib-append  port:libedit port:libffi port:ncurses port:zlib
62
63    default_variants    +analyzer
64}
65
66#fetch.type              svn
67#svn.revision            229298
68
69#set compiler_rt_rev     ${svn.revision}
70#set libcxx_rev          ${svn.revision}
71#set clang-modernize_rev ${svn.revision}
72#version                 ${llvm_version}-r${svn.revision}
73#worksrcdir              trunk
74#svn.url                 https://llvm.org/svn/llvm-project/llvm/trunk
75#worksrcdir              release_${llvm_version_no_dot}
76#svn.url                 https://llvm.org/svn/llvm-project/llvm/branches/release_${llvm_version_no_dot}
77#default_variants-append +assertions
78
79version                 ${llvm_version}.1
80epoch                   1
81master_sites            http://llvm.org/releases/${version}
82use_xz                  yes
83extract.suffix          .tar.xz
84distfiles               llvm-${version}.src${extract.suffix}
85worksrcdir              llvm-${version}.src
86
87if {${distfiles} ne ""} {
88    if {${subport} eq "llvm-${llvm_version}"} {
89        if {[variant_isset polly]} {
90            distfiles-append     polly-${version}.src${extract.suffix}
91        }
92    } elseif {${subport} eq "clang-${llvm_version}"} {
93        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}
94    }
95}
96
97checksums           llvm-3.6.1.src.tar.xz \
98                    rmd160  9a66dc3f06078ffede1a190dcca95e071e63feb4 \
99                    sha256  2f00c615913aa0b56607ee1548936e60ad2aa89e6d56f23fb032a4463366fc7a \
100                    cfe-3.6.1.src.tar.xz \
101                    rmd160  2199271489c7a1c63aa41e80ff78089aeebdcd3e \
102                    sha256  74f92d0c93b86678b015e87655f59474b2f657769680efdeb3c0524ffbd2dad7 \
103                    compiler-rt-3.6.1.src.tar.xz \
104                    rmd160  171af614b4656c121a6b8e58ce3e137b0495cd64 \
105                    sha256  fcbf610c77be6047f11ca10c4725610417beba832565115a9e2fcfe2897b649f \
106                    libcxx-3.6.1.src.tar.xz \
107                    rmd160  3da38b89322c0ea4abf42df3823831d8033b764a \
108                    sha256  5a5c653becf3978d4c4f6095708660855bed691210a9426bb839eecd88b6c0f9 \
109                    clang-tools-extra-3.6.1.src.tar.xz \
110                    rmd160  411dda52ca2a7b7aa9cbb7b54dfa5ac5edcf4f98 \
111                    sha256  f4ee70d870d550a9147ac6a548ce7daf7d9e6897348bf411f43c572966fb92b6 \
112                    polly-3.6.1.src.tar.xz \
113                    rmd160  b673db8980ba925b5d98c54303341f804238d0e8 \
114                    sha256  d085f97bcbb4e47b51ed60ba9a55b3fee394193e7e48ab5c5b0035e6fc80a7eb
115
116patch.pre_args  -p1
117patchfiles \
118        0001-Set-the-Mach-O-CPU-Subtype-to-ppc7400-when-targeting.patch \
119        0002-MacPorts-Only-Update-install-targets-for-clang-subpo.patch \
120        0003-MacPorts-Only-Use-full-path-for-the-dylib-id-instead.patch \
121        0004-MacPorts-Only-Don-t-embed-the-deployment-target-in-t.patch \
122        0005-MacPorts-Only-Skip-checking-for-python-in-configure.patch \
123        llvm-skip-unittests.patch
124
125if {${subport} eq "clang-${llvm_version}"} {
126    patchfiles-append \
127        1001-MacPorts-Only-Prepare-clang-format-for-replacement-w.patch \
128        1002-MacPorts-Only-Fall-back-on-xcodebuild-sdk-when-xcrun.patch \
129        1003-MacPorts-Only-Fix-name-of-scan-view-executable-insid.patch \
130        1004-MacPorts-Only-Fix-libclang_rt-dylib-ids.patch \
131        1005-MacPorts-Only-Relocate-clang-resources-using-llvm-ve.patch \
132        1006-Default-to-ppc7400-for-OSX-10.5.patch \
133        1007-Only-call-setpriority-PRIO_DARWIN_THREAD-0-PRIO_DARW.patch \
134        1008-Default-to-fragile-ObjC-runtime-when-targeting-darwi.patch \
135        2001-MacPorts-Only-Comment-out-SL-cctools-workaround.patch \
136        2002-Update-CheckArches-to-fallback-on-Intel-ppc-if-ld-v-.patch \
137        2003-Fall-back-on-xcodebuild-sdk-when-xcrun-sdk-is-not-su.patch \
138        2004-On-darwin-build-ppc-slices-of-the-compiler-runtime-i.patch \
139        3001-buildit-build-fix-for-Leopard.patch \
140        3002-buildit-Set-compatibility-version-to-RC_ProjectSourc.patch \
141        3003-Fix-local-and-iterator-when-building-with-Lion-and-n.patch \
142        3004-Fix-missing-long-long-math-prototypes-when-using-the.patch \
143        3005-implement-atomic-using-mutex-lock_guard-for-64b-ops-.patch \
144        compiler_rt-toolchain.patch
145
146    # I'm not sure if we need to delete this.  It seems to build fine with it
147    # present, but we used to explicitly only use this patch for the llvm subport.
148    patchfiles-delete \
149        0005-MacPorts-Only-Skip-checking-for-python-in-configure.patch
150
151    build.target        clang-only
152    destroot.target     install-clang
153}
154
155build.env-append        VERBOSE=1 \
156                        REQUIRES_RTTI=1
157destroot.env-append     VERBOSE=1 \
158                        REQUIRES_RTTI=1
159
160configure.dir           ${workpath}/build
161build.dir               ${configure.dir}
162
163configure.cmd           ${worksrcpath}/configure
164configure.pre_args-delete --prefix=${prefix}
165configure.args          --enable-bindings=none --enable-libffi --enable-shared --enable-jit \
166                        --enable-optimized --disable-profiling --enable-pic \
167                        --enable-debug-symbols --disable-debug-runtime \
168                        --prefix="${sub_prefix}" --disable-assertions
169
170if {${subport} eq "llvm-${llvm_version}"} {
171    select.group        llvm
172    select.file         ${filespath}/mp-${subport}
173} elseif {${subport} eq "clang-${llvm_version}"} {
174    select.group        clang
175    select.file         ${filespath}/mp-${subport}
176
177    configure.args-append --with-python=${prefix}/bin/python2.7
178}
179
180# llvm-3.5 and later requires a C++11 runtime
181# XCode 4.3's clang (318.x) fails per https://trac.macports.org/ticket/44161
182# XCode 4.5's clang (421.11.66) fails due to http://llvm.org/bugs/show_bug.cgi?id=20184
183# Xcode 4.6.x's clang (425.0.28) works, assuming 425.0.24 from 4.6.0 works too
184compiler.blacklist *gcc* macports-clang-2.9 macports-clang-3.0 macports-clang-3.1 {clang < 425.0.24}
185
186platform darwin {
187    # Note that we are forcing this choice.  This means that anything linking
188    # against llvm-3.5 needs to also be using libc++.  This is possibly
189    # problematic, but luckily there is just a limited set of such dependents.
190
191    configure.cxx_stdlib libc++
192    depends_lib-append port:libcxx
193    supported_archs i386 x86_64
194
195    pre-fetch {
196        if {![file exists /usr/lib/libc++.dylib]} {
197            ui_error "$name requires a C++11 runtime, which your configuration does not allow"
198            error "unsupported configuration"
199        }
200    }
201}
202
203variant universal {
204    build.env-append \
205        UNIVERSAL=1 \
206        UNIVERSAL_ARCH="[get_canonical_archs]"
207    destroot.env-append \
208        UNIVERSAL=1 \
209        UNIVERSAL_ARCH="[get_canonical_archs]"
210
211    post-extract {
212        # workaround a bug in Apple's shipped gcc driver-driver, patched in
213        # ours with driverdriver-num_infiles.patch
214        if {${configure.compiler} eq "gcc-4.0" ||
215            ${configure.compiler} eq "gcc-4.2" ||
216            ${configure.compiler} eq "llvm-gcc-4.2"} {
217            system "echo \"static int ___ignoreme;\" > ${worksrcpath}/tools/llvm-shlib/ignore.c"
218        }
219    }
220}
221
222variant assertions description "Enable assertions for error detection (has performance impacts, especially on JIT)" {
223    configure.args-delete --disable-assertions
224    configure.args-append --enable-assertions
225}
226
227platform darwin {
228    if {${build_arch} eq "i386"} {
229        configure.pre_args-append --build=i686-apple-darwin${os.major}
230    } elseif {${build_arch} eq "ppc"} {
231        configure.pre_args-append --build=powerpc-apple-darwin${os.major}
232    } elseif {${build_arch} eq "ppc64"} {
233        configure.pre_args-append --build=powerpc64-apple-darwin${os.major}
234    } else {
235        configure.pre_args-append --build=${build_arch}-apple-darwin${os.major}
236    }
237
238    if {[string match "*ppc*" [get_canonical_archs]]} {
239        # http://trac.macports.org/ticket/33987
240        configure.args-append --with-optimize-option=-Os
241        configure.optflags    -Os
242    }
243
244    if {${subport} eq "clang-${llvm_version}" && ${os.major} <= 9} {
245        patchfiles-append leopard-no-asan.patch leopard-no-blocks.patch
246    }
247}
248
249post-extract {
250    if {${subport} eq "llvm-${llvm_version}"} {
251        if {[variant_isset polly]} {
252            if {${worksrcdir} eq "trunk"} {
253                system "cd ${worksrcpath}/tools && svn co -r ${svn.revision} http://llvm.org/svn/llvm-project/polly/trunk polly"
254            } elseif {${worksrcdir} eq "release_${llvm_version_no_dot}" } {
255                system "cd ${worksrcpath}/tools && svn co -r ${svn.revision} http://llvm.org/svn/llvm-project/polly/branches/release_${llvm_version_no_dot} polly"
256            } else {
257                file rename ${workpath}/polly-${version}.src ${worksrcpath}/tools/polly
258            }
259        }
260    } elseif {${subport} eq "clang-${llvm_version}"} {
261        if {${worksrcdir} eq "trunk"} {
262            system "cd ${worksrcpath}/tools && svn co -r ${svn.revision} http://llvm.org/svn/llvm-project/cfe/trunk clang"
263            system "cd ${worksrcpath}/projects && svn co -r ${compiler_rt_rev} http://llvm.org/svn/llvm-project/compiler-rt/trunk compiler-rt"
264            system "cd ${worksrcpath}/projects && svn co -r ${libcxx_rev} http://llvm.org/svn/llvm-project/libcxx/trunk libcxx"
265            system "cd ${worksrcpath}/tools/clang/tools && svn co -r ${clang-modernize_rev} http://llvm.org/svn/llvm-project/clang-tools-extra/trunk extra"
266        } elseif {${worksrcdir} eq "release_${llvm_version_no_dot}" } {
267            system "cd ${worksrcpath}/tools && svn co -r ${svn.revision} http://llvm.org/svn/llvm-project/cfe/branches/release_${llvm_version_no_dot} clang"
268            system "cd ${worksrcpath}/projects && svn co -r ${compiler_rt_rev} http://llvm.org/svn/llvm-project/compiler-rt/branches/release_${llvm_version_no_dot} compiler-rt"
269            system "cd ${worksrcpath}/projects && svn co -r ${libcxx_rev} http://llvm.org/svn/llvm-project/libcxx/branches/release_${llvm_version_no_dot} libcxx"
270            system "cd ${worksrcpath}/tools/clang/tools && svn co -r ${clang-modernize_rev} http://llvm.org/svn/llvm-project/clang-tools-extra/branches/release_${llvm_version_no_dot} extra"
271        } else {
272            file rename ${workpath}/cfe-${version}.src ${worksrcpath}/tools/clang
273            file rename ${workpath}/compiler-rt-${version}.src ${worksrcpath}/projects/compiler-rt
274            file rename ${workpath}/libcxx-${version}.src ${worksrcpath}/projects/libcxx
275            file rename ${workpath}/clang-tools-extra-${version}.src ${worksrcpath}/tools/clang/tools/extra
276        }
277    }
278}
279
280post-patch {
281    if {${subport} eq "clang-${llvm_version}"} {
282        reinplace "s|@@PREFIX@@|${prefix}|g" \
283            ${worksrcpath}/projects/compiler-rt/make/platform/clang_darwin.mk \
284            ${worksrcpath}/projects/compiler-rt/make/platform/clang_macho_embedded.mk
285    }
286}
287
288post-destroot {
289    file mkdir ${destroot}${prefix}/share/doc
290    file rename ${destroot}${sub_prefix}/docs/llvm ${destroot}${prefix}/share/doc/${subport}
291
292    foreach bin [glob ${destroot}${sub_prefix}/bin/*] {
293        set bin_filename [string map "${sub_prefix} ${prefix}" ${bin}]-${suffix}
294        set exec_path [string map "${destroot}${sub_prefix} ${sub_prefix}" ${bin}]
295
296        xinstall -m 755 "${filespath}/llvm-bin" "${bin_filename}"
297        reinplace "s:EXEC_PATH:${exec_path}:" "${bin_filename}"
298    }
299
300    if {${subport} eq "llvm-${llvm_version}"} {
301        # r156389 (a5d2435409858728970202226d0bbbee508fe408) temporarilary removed llvm man pages
302        #foreach man [glob ${destroot}${sub_prefix}/share/man/man1/*.1] {
303        #    set basename [string map "${destroot}${sub_prefix}/share/man/man1/ {}" ${man}]
304        #    file rename ${man} ${destroot}${prefix}/share/man/man1/[string map ".1 -${suffix}.1" ${basename}]
305        #}
306    } elseif {${subport} eq "clang-${llvm_version}"} {
307        system "ditto ${worksrcpath}/projects/libcxx/include ${destroot}${sub_prefix}/lib/c++/v1"
308
309        # http://trac.macports.org/ticket/33207
310        ln -s ${prefix}/libexec/ld64/ld ${destroot}${sub_prefix}/bin/ld
311    }
312}
313
314if {${subport} eq "llvm-${llvm_version}"} {
315    variant polly description {Provide the polly polyhedral optimizer} {
316        depends_lib-append      port:gmp
317        if {${worksrcdir} eq "trunk"} {
318            # Polly likes using bleeding-edge isl.
319            depends_lib-append  port:isl-devel
320        } else {
321            depends_lib-append  path:lib/pkgconfig/isl.pc:isl
322        }
323    }
324
325    # Unless upstream reverts to their old OCaml detection mechanism,
326    # this variant will be broken until #46161 is resolved.
327    variant ocaml description {Enable generation of OCaml binding} {
328        depends_lib-append   port:ocaml
329
330        configure.args-delete --enable-bindings=none
331        configure.args-append --enable-bindings=ocaml
332
333        destroot.args-append  OVERRIDE_libdir=${sub_prefix}/lib
334    }
335} elseif {${subport} eq "clang-${llvm_version}"} {
336    variant analyzer description {Install clang static analyzer} {
337        depends_run-append port:perl5
338
339        post-patch {
340            reinplace "s|/usr/bin/env perl|${prefix}/bin/perl5|g" \
341                ${worksrcpath}/tools/clang/tools/scan-build/ccc-analyzer \
342                ${worksrcpath}/tools/clang/tools/scan-build/c++-analyzer \
343                ${worksrcpath}/tools/clang/tools/scan-build/scan-build
344            reinplace "s|/usr/bin/env python|${prefix}/bin/python2.7|g" \
345                ${worksrcpath}/tools/clang/tools/scan-build/set-xcode-analyzer \
346                ${worksrcpath}/tools/clang/tools/scan-view/scan-view
347        }
348
349        post-destroot {
350            file mkdir ${destroot}${sub_prefix}/libexec
351            file copy ${worksrcpath}/tools/clang/tools/scan-build ${destroot}${sub_prefix}/libexec/scan-build
352            file copy ${worksrcpath}/tools/clang/tools/scan-view ${destroot}${sub_prefix}/libexec/scan-view
353
354            file delete -force ${destroot}${sub_prefix}/libexec/scan-build/.svn
355            file delete -force ${destroot}${sub_prefix}/libexec/scan-view/.svn
356            file delete -force ${destroot}${sub_prefix}/libexec/scan-view/Resources/.svn
357
358            ln -s ${sub_prefix}/libexec/scan-build/scan-build ${destroot}${sub_prefix}/bin/scan-build
359            ln -s ${sub_prefix}/libexec/scan-view/scan-view ${destroot}${sub_prefix}/bin/scan-view
360            ln -s ${sub_prefix}/bin ${destroot}${sub_prefix}/libexec/scan-build/bin
361
362            xinstall -m 755 "${filespath}/llvm-bin" "${destroot}${prefix}/bin/scan-build-${suffix}"
363            reinplace "s:EXEC_PATH:${sub_prefix}/bin/scan-build:" "${destroot}${prefix}/bin/scan-build-${suffix}"
364
365            xinstall -m 755 "${filespath}/llvm-bin" "${destroot}${prefix}/bin/scan-view-${suffix}"
366            reinplace "s:EXEC_PATH:${sub_prefix}/bin/scan-view:" "${destroot}${prefix}/bin/scan-view-${suffix}"
367        }
368    }
369
370
371    post-patch {
372        reinplace "s|@CLANG_FORMAT_PATH@|${prefix}/bin/clang-format-${suffix}|g" \
373            ${worksrcpath}/tools/clang/tools/clang-format/clang-format-bbedit.applescript \
374            ${worksrcpath}/tools/clang/tools/clang-format/clang-format-diff.py            \
375            ${worksrcpath}/tools/clang/tools/clang-format/clang-format-sublime.py         \
376            ${worksrcpath}/tools/clang/tools/clang-format/clang-format.el                 \
377            ${worksrcpath}/tools/clang/tools/clang-format/clang-format.py
378    }
379
380    post-destroot {
381        file mkdir ${destroot}${sub_prefix}/libexec
382        file copy ${worksrcpath}/tools/clang/tools/clang-format ${destroot}${sub_prefix}/libexec/clang-format
383
384        file delete -force ${destroot}${sub_prefix}/libexec/clang-format/.svn
385        file delete -force ${destroot}${sub_prefix}/libexec/clang-format/Makefile
386        file delete -force ${destroot}${sub_prefix}/libexec/clang-format/Release+Debug+Asserts
387        file delete -force ${destroot}${sub_prefix}/libexec/clang-format/CMakeLists.txt
388        file delete -force ${destroot}${sub_prefix}/libexec/clang-format/ClangFormat.cpp
389    }
390}
391
392livecheck.type          none
Note: See TracBrowser for help on using the repository browser.