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

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

llvm-3.6: Bump to 3.6.1

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