source: trunk/dports/lang/llvm-3.7/Portfile @ 137330

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

llvm-3.7: Bump to r239386

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 18.0 KB
Line 
1# $Id: Portfile 137330 2015-06-09 06:33:35Z jeremyhu@macports.org $
2
3PortSystem              1.0
4PortGroup select        1.0
5PortGroup compiler_blacklist_versions 1.0
6
7set llvm_version        3.7
8set llvm_version_no_dot 37
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
65fetch.type              svn
66svn.revision            239386
67
68set compiler_rt_rev     ${svn.revision}
69set libcxx_rev          ${svn.revision}
70set clang-modernize_rev ${svn.revision}
71version                 ${llvm_version}-r${svn.revision}
72revision                0
73worksrcdir              trunk
74svn.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}
77default_variants-append +assertions
78
79#version                 ${llvm_version}.0
80#epoch                   1
81#master_sites            http://llvm.org/releases/${version}
82#use_xz                  yes
83#extract.suffix          .tar.xz
84#distfiles               llvm-${version}.src${extract.suffix}
85#worksrcdir              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
97patch.pre_args  -p1
98patchfiles \
99        0001-Set-the-Mach-O-CPU-Subtype-to-ppc7400-when-targeting.patch \
100        0002-Define-EXC_MASK_CRASH-and-MACH_EXCEPTION_CODES-if-th.patch \
101        0003-MacPorts-Only-Update-install-targets-for-clang-subpo.patch \
102        0004-MacPorts-Only-Use-full-path-for-the-dylib-id-instead.patch \
103        0005-MacPorts-Only-Don-t-embed-the-deployment-target-in-t.patch \
104        0006-MacPorts-Only-Skip-checking-for-python-in-configure.patch \
105        llvm-skip-unittests.patch
106
107if {${subport} eq "clang-${llvm_version}"} {
108    patchfiles-append \
109        1001-MacPorts-Only-Prepare-clang-format-for-replacement-w.patch \
110        1002-MacPorts-Only-Fall-back-on-xcodebuild-sdk-when-xcrun.patch \
111        1003-MacPorts-Only-Fix-name-of-scan-view-executable-insid.patch \
112        1004-MacPorts-Only-Fix-libclang_rt-dylib-ids.patch \
113        1005-MacPorts-Only-Relocate-clang-resources-using-llvm-ve.patch \
114        1006-Default-to-ppc7400-for-OSX-10.5.patch \
115        1007-Only-call-setpriority-PRIO_DARWIN_THREAD-0-PRIO_DARW.patch \
116        1008-Default-to-fragile-ObjC-runtime-when-targeting-darwi.patch \
117        2001-MacPorts-Only-Comment-out-SL-cctools-workaround.patch \
118        2002-Update-CheckArches-to-fallback-on-Intel-ppc-if-ld-v-.patch \
119        2003-Fall-back-on-xcodebuild-sdk-when-xcrun-sdk-is-not-su.patch \
120        2004-On-darwin-build-ppc-slices-of-the-compiler-runtime-i.patch \
121        3001-buildit-build-fix-for-Leopard.patch \
122        3002-buildit-Set-compatibility-version-to-RC_ProjectSourc.patch \
123        3003-Fix-local-and-iterator-when-building-with-Lion-and-n.patch \
124        3004-Fix-missing-long-long-math-prototypes-when-using-the.patch \
125        3005-implement-atomic-using-mutex-lock_guard-for-64b-ops-.patch \
126        compiler_rt-toolchain.patch
127
128    # I'm not sure if we need to delete this.  It seems to build fine with it
129    # present, but we used to explicitly only use this patch for the llvm subport.
130    patchfiles-delete \
131        0005-MacPorts-Only-Skip-checking-for-python-in-configure.patch
132
133    build.target        clang-only
134    destroot.target     install-clang
135}
136
137build.env-append        VERBOSE=1 \
138                        REQUIRES_RTTI=1
139destroot.env-append     VERBOSE=1 \
140                        REQUIRES_RTTI=1
141
142configure.dir           ${workpath}/build
143build.dir               ${configure.dir}
144
145configure.cmd           ${worksrcpath}/configure
146configure.pre_args-delete --prefix=${prefix}
147configure.args          --enable-bindings=none --enable-libffi --enable-shared --enable-jit \
148                        --enable-optimized --disable-profiling --enable-pic \
149                        --enable-debug-symbols --disable-debug-runtime \
150                        --prefix="${sub_prefix}" --disable-assertions
151
152if {${subport} eq "llvm-${llvm_version}"} {
153    select.group        llvm
154    select.file         ${filespath}/mp-${subport}
155} elseif {${subport} eq "clang-${llvm_version}"} {
156    select.group        clang
157    select.file         ${filespath}/mp-${subport}
158
159    configure.args-append --with-python=${prefix}/bin/python2.7
160}
161
162# llvm-3.5 and later requires a C++11 runtime
163# XCode 4.3's clang (318.x) fails per https://trac.macports.org/ticket/44161
164# XCode 4.5's clang (421.11.66) fails due to http://llvm.org/bugs/show_bug.cgi?id=20184
165# Xcode 4.6.3's clang (425.0.28) fails due to http://trac.macports.org/ticket/46897
166compiler.blacklist *gcc* macports-clang-2.9 macports-clang-3.0 macports-clang-3.1 {clang < 500}
167
168platform darwin {
169    # Note that we are forcing this choice.  This means that anything linking
170    # against llvm-3.5 needs to also be using libc++.  This is possibly
171    # problematic, but luckily there is just a limited set of such dependents.
172
173    configure.cxx_stdlib libc++
174    depends_lib-append port:libcxx
175    supported_archs i386 x86_64
176
177    pre-fetch {
178        if {![file exists /usr/lib/libc++.dylib]} {
179            ui_error "$name requires a C++11 runtime, which your configuration does not allow"
180            error "unsupported configuration"
181        }
182    }
183}
184
185variant universal {
186    build.env-append \
187        UNIVERSAL=1 \
188        UNIVERSAL_ARCH="[get_canonical_archs]"
189    destroot.env-append \
190        UNIVERSAL=1 \
191        UNIVERSAL_ARCH="[get_canonical_archs]"
192
193    post-extract {
194        # workaround a bug in Apple's shipped gcc driver-driver, patched in
195        # ours with driverdriver-num_infiles.patch
196        if {${configure.compiler} eq "gcc-4.0" ||
197            ${configure.compiler} eq "gcc-4.2" ||
198            ${configure.compiler} eq "llvm-gcc-4.2"} {
199            system "echo \"static int ___ignoreme;\" > ${worksrcpath}/tools/llvm-shlib/ignore.c"
200        }
201    }
202}
203
204variant assertions description "Enable assertions for error detection (has performance impacts, especially on JIT)" {
205    configure.args-delete --disable-assertions
206    configure.args-append --enable-assertions
207}
208
209platform darwin {
210    if {${build_arch} eq "i386"} {
211        configure.pre_args-append --build=i686-apple-darwin${os.major}
212    } elseif {${build_arch} eq "ppc"} {
213        configure.pre_args-append --build=powerpc-apple-darwin${os.major}
214    } elseif {${build_arch} eq "ppc64"} {
215        configure.pre_args-append --build=powerpc64-apple-darwin${os.major}
216    } else {
217        configure.pre_args-append --build=${build_arch}-apple-darwin${os.major}
218    }
219
220    if {[string match "*ppc*" [get_canonical_archs]]} {
221        # http://trac.macports.org/ticket/33987
222        configure.args-append --with-optimize-option=-Os
223        configure.optflags    -Os
224    }
225
226    if {${subport} eq "clang-${llvm_version}" && ${os.major} <= 10} {
227        patchfiles-append leopard-no-asan.patch
228    }
229
230    if {${subport} eq "clang-${llvm_version}" && ${os.major} <= 9} {
231        patchfiles-append leopard-no-blocks.patch
232    }
233
234    if {${os.major} < 11} {
235        # Proxy for eliminating the dependency on native TLS
236        # http://trac.macports.org/ticket/46887
237        configure.args-append --disable-backtraces
238    }
239}
240
241post-extract {
242    # Get HTTP proxy arguments if required, assuming we can use the same proxy for all repositories
243    set proxy_args [portfetch::svn_proxy_args http://llvm.org/svn/llvm-project/cfe/trunk]
244    if {${subport} eq "llvm-${llvm_version}"} {
245        if {[variant_isset polly]} {
246            if {${worksrcdir} eq "trunk"} {
247                system -W ${worksrcpath}/tools "svn ${proxy_args} co -r ${svn.revision} http://llvm.org/svn/llvm-project/polly/trunk polly"
248            } elseif {${worksrcdir} eq "release_${llvm_version_no_dot}" } {
249                system -W ${worksrcpath}/tools "svn ${proxy_args} co -r ${svn.revision} http://llvm.org/svn/llvm-project/polly/branches/release_${llvm_version_no_dot} polly"
250            } else {
251                file rename ${workpath}/polly-${version}.src ${worksrcpath}/tools/polly
252            }
253        }
254    } elseif {${subport} eq "clang-${llvm_version}"} {
255        if {${worksrcdir} eq "trunk"} {
256            system -W ${worksrcpath}/tools "svn ${proxy_args} co -r ${svn.revision} http://llvm.org/svn/llvm-project/cfe/trunk clang"
257            system -W ${worksrcpath}/projects "svn ${proxy_args} co -r ${compiler_rt_rev} http://llvm.org/svn/llvm-project/compiler-rt/trunk compiler-rt"
258            system -W ${worksrcpath}/projects "svn ${proxy_args} co -r ${libcxx_rev} http://llvm.org/svn/llvm-project/libcxx/trunk libcxx"
259            system -W ${worksrcpath}/tools/clang/tools "svn ${proxy_args} co -r ${clang-modernize_rev} http://llvm.org/svn/llvm-project/clang-tools-extra/trunk extra"
260        } elseif {${worksrcdir} eq "release_${llvm_version_no_dot}" } {
261            system -W ${worksrcpath}/tools "svn ${proxy_args} co -r ${svn.revision} http://llvm.org/svn/llvm-project/cfe/branches/release_${llvm_version_no_dot} clang"
262            system -W ${worksrcpath}/projects "svn ${proxy_args} co -r ${compiler_rt_rev} http://llvm.org/svn/llvm-project/compiler-rt/branches/release_${llvm_version_no_dot} compiler-rt"
263            system -W ${worksrcpath}/projects "svn ${proxy_args} co -r ${libcxx_rev} http://llvm.org/svn/llvm-project/libcxx/branches/release_${llvm_version_no_dot} libcxx"
264            system -W ${worksrcpath}/tools/clang/tools "svn ${proxy_args} co -r ${clang-modernize_rev} http://llvm.org/svn/llvm-project/clang-tools-extra/branches/release_${llvm_version_no_dot} extra"
265        } else {
266            file rename ${workpath}/cfe-${version}.src ${worksrcpath}/tools/clang
267            file rename ${workpath}/compiler-rt-${version}.src ${worksrcpath}/projects/compiler-rt
268            file rename ${workpath}/libcxx-${version}.src ${worksrcpath}/projects/libcxx
269            file rename ${workpath}/clang-tools-extra-${version}.src ${worksrcpath}/tools/clang/tools/extra
270        }
271    }
272}
273
274post-patch {
275    if {${subport} eq "clang-${llvm_version}"} {
276        reinplace "s|@@PREFIX@@|${prefix}|g" \
277            ${worksrcpath}/projects/compiler-rt/make/platform/clang_darwin.mk \
278            ${worksrcpath}/projects/compiler-rt/make/platform/clang_macho_embedded.mk
279    }
280}
281
282post-destroot {
283    file mkdir ${destroot}${prefix}/share/doc
284    file rename ${destroot}${sub_prefix}/docs/llvm ${destroot}${prefix}/share/doc/${subport}
285
286    foreach bin [glob ${destroot}${sub_prefix}/bin/*] {
287        set bin_filename [string map "${sub_prefix} ${prefix}" ${bin}]-${suffix}
288        set exec_path [string map "${destroot}${sub_prefix} ${sub_prefix}" ${bin}]
289
290        xinstall -m 755 "${filespath}/llvm-bin" "${bin_filename}"
291        reinplace "s:EXEC_PATH:${exec_path}:" "${bin_filename}"
292    }
293
294    if {${subport} eq "llvm-${llvm_version}"} {
295        # r156389 (a5d2435409858728970202226d0bbbee508fe408) temporarilary removed llvm man pages
296        #foreach man [glob ${destroot}${sub_prefix}/share/man/man1/*.1] {
297        #    set basename [string map "${destroot}${sub_prefix}/share/man/man1/ {}" ${man}]
298        #    file rename ${man} ${destroot}${prefix}/share/man/man1/[string map ".1 -${suffix}.1" ${basename}]
299        #}
300    } elseif {${subport} eq "clang-${llvm_version}"} {
301        system "ditto ${worksrcpath}/projects/libcxx/include ${destroot}${sub_prefix}/lib/c++/v1"
302
303        # http://trac.macports.org/ticket/33207
304        ln -s ${prefix}/libexec/ld64/ld ${destroot}${sub_prefix}/bin/ld
305    }
306}
307
308if {${subport} eq "llvm-${llvm_version}"} {
309    variant polly description {Provide the polly polyhedral optimizer} {}
310
311    # Unless upstream reverts to their old OCaml detection mechanism,
312    # this variant will be broken until #46161 is resolved.
313    variant ocaml description {Enable generation of OCaml binding} {
314        depends_lib-append   port:ocaml
315
316        configure.args-delete --enable-bindings=none
317        configure.args-append --enable-bindings=ocaml
318
319        destroot.args-append  OVERRIDE_libdir=${sub_prefix}/lib
320    }
321} elseif {${subport} eq "clang-${llvm_version}"} {
322    variant analyzer description {Install clang static analyzer} {
323        depends_run-append port:perl5
324
325        post-patch {
326            reinplace "s|/usr/bin/env perl|${prefix}/bin/perl5|g" \
327                ${worksrcpath}/tools/clang/tools/scan-build/ccc-analyzer \
328                ${worksrcpath}/tools/clang/tools/scan-build/c++-analyzer \
329                ${worksrcpath}/tools/clang/tools/scan-build/scan-build
330            reinplace "s|/usr/bin/env python|${prefix}/bin/python2.7|g" \
331                ${worksrcpath}/tools/clang/tools/scan-build/set-xcode-analyzer \
332                ${worksrcpath}/tools/clang/tools/scan-view/scan-view
333        }
334
335        post-destroot {
336            file mkdir ${destroot}${sub_prefix}/libexec
337            file copy ${worksrcpath}/tools/clang/tools/scan-build ${destroot}${sub_prefix}/libexec/scan-build
338            file copy ${worksrcpath}/tools/clang/tools/scan-view ${destroot}${sub_prefix}/libexec/scan-view
339
340            file delete -force ${destroot}${sub_prefix}/libexec/scan-build/.svn
341            file delete -force ${destroot}${sub_prefix}/libexec/scan-view/.svn
342            file delete -force ${destroot}${sub_prefix}/libexec/scan-view/Resources/.svn
343
344            ln -s ${sub_prefix}/libexec/scan-build/scan-build ${destroot}${sub_prefix}/bin/scan-build
345            ln -s ${sub_prefix}/libexec/scan-view/scan-view ${destroot}${sub_prefix}/bin/scan-view
346            ln -s ${sub_prefix}/bin ${destroot}${sub_prefix}/libexec/scan-build/bin
347
348            xinstall -m 755 "${filespath}/llvm-bin" "${destroot}${prefix}/bin/scan-build-${suffix}"
349            reinplace "s:EXEC_PATH:${sub_prefix}/bin/scan-build:" "${destroot}${prefix}/bin/scan-build-${suffix}"
350
351            xinstall -m 755 "${filespath}/llvm-bin" "${destroot}${prefix}/bin/scan-view-${suffix}"
352            reinplace "s:EXEC_PATH:${sub_prefix}/bin/scan-view:" "${destroot}${prefix}/bin/scan-view-${suffix}"
353        }
354    }
355
356
357    post-patch {
358        reinplace "s|@CLANG_FORMAT_PATH@|${prefix}/bin/clang-format-${suffix}|g" \
359            ${worksrcpath}/tools/clang/tools/clang-format/clang-format-bbedit.applescript \
360            ${worksrcpath}/tools/clang/tools/clang-format/clang-format-diff.py            \
361            ${worksrcpath}/tools/clang/tools/clang-format/clang-format-sublime.py         \
362            ${worksrcpath}/tools/clang/tools/clang-format/clang-format.el                 \
363            ${worksrcpath}/tools/clang/tools/clang-format/clang-format.py
364    }
365
366    post-destroot {
367        file mkdir ${destroot}${sub_prefix}/libexec
368        file copy ${worksrcpath}/tools/clang/tools/clang-format ${destroot}${sub_prefix}/libexec/clang-format
369
370        file delete -force ${destroot}${sub_prefix}/libexec/clang-format/.svn
371        file delete -force ${destroot}${sub_prefix}/libexec/clang-format/Makefile
372        file delete -force ${destroot}${sub_prefix}/libexec/clang-format/Release+Debug+Asserts
373        file delete -force ${destroot}${sub_prefix}/libexec/clang-format/CMakeLists.txt
374        file delete -force ${destroot}${sub_prefix}/libexec/clang-format/ClangFormat.cpp
375    }
376}
377
378livecheck.type          none
Note: See TracBrowser for help on using the repository browser.