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