source: trunk/dports/lang/llvm-3.3/Portfile

Last change on this file was 153720, checked in by ryandesign@…, 14 months ago

Allow old llvm versions to build on Sierra

References #52424

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 17.2 KB
Line 
1# $Id: Portfile 153720 2016-10-09 04:13:48Z ryandesign@macports.org $
2
3# This is pretty much the only compiler that will build webkit-gtk-2.0,
4# but it really doesn't have much use other than that any more.
5
6PortSystem              1.0
7PortGroup select        1.0
8
9set llvm_version        3.3
10name                    llvm-${llvm_version}
11revision                10
12subport                 clang-${llvm_version} {}
13set suffix              mp-${llvm_version}
14set sub_prefix          ${prefix}/libexec/llvm-${llvm_version}
15dist_subdir             llvm
16categories              lang
17platforms               darwin
18license                 NCSA
19maintainers             jeremyhu larryv
20
21if {${subport} == "llvm-${llvm_version}"} {
22    homepage            http://llvm.org/
23    description         llvm is a next generation compiler infrastructure
24    long_description    The LLVM Core libraries provide a modern source- and \
25                        target-independent optimizer, along with code \
26                        generation support for many popular CPUs (as well as \
27                        some less common ones!) These libraries are built \
28                        around a well specified code representation known as \
29                        the LLVM intermediate representation ("LLVM IR").
30
31    depends_lib         port:libffi
32    depends_run         bin:perl:perl5 port:llvm_select
33} elseif {${subport} == "clang-${llvm_version}"} {
34    homepage            http://clang.llvm.org/
35    description         C, C++, Objective C and Objective C++ compiler
36    long_description    Clang is an "LLVM native" C/C++/Objective-C compiler, \
37                        which aims to deliver amazingly fast compiles (e.g. \
38                        about 3x faster than GCC when compiling Objective-C \
39                        code in a debug configuration), extremely useful error \
40                        and warning messages and to provide a platform for \
41                        building great source level tools. The included Clang \
42                        Static Analyzer is a tool that automatically finds bugs in \
43                        your code, and is a great example of the sort of tool \
44                        that can be built using the Clang frontend as a \
45                        library to parse C/C++ code.
46
47    depends_lib         port:llvm-${llvm_version} port:libffi
48    depends_run         port:clang_select port:ld64
49    depends_build       port:cctools
50    depends_skip_archcheck-append cctools ld64 subversion
51
52    default_variants    +analyzer
53}
54
55#fetch.type              svn
56#svn.revision            180025
57
58#set compiler_rt_rev     ${svn.revision}
59#set libcxx_rev          ${svn.revision}
60#version                 ${llvm_version}-r${svn.revision}
61#worksrcdir              trunk
62#svn.url                 http://llvm.org/svn/llvm-project/llvm/trunk
63#worksrcdir              release_33
64#svn.url                 http://llvm.org/svn/llvm-project/llvm/branches/release_33
65#default_variants-append +assertions
66
67version                 ${llvm_version}
68epoch                   1
69master_sites            http://llvm.org/releases/${version}
70extract.suffix          .tar.gz
71distfiles               llvm-${version}.src${extract.suffix}
72worksrcdir              llvm-${version}.src
73
74checksums           llvm-3.3.src.tar.gz \
75                    rmd160  22878ad746c50b02a7ac8713dd6f8c95c7af4220 \
76                    sha256  68766b1e70d05a25e2f502e997a3cb3937187a3296595cf6e0977d5cd6727578 \
77                    cfe-3.3.src.tar.gz \
78                    rmd160  ff5d684c83b0c1aa36595dcb457da80b58eaf58f \
79                    sha256  b1b55de4ab3a57d3e0331a83e0284610191c77d924e3446498d9113d08dfb996 \
80                    compiler-rt-3.3.src.tar.gz \
81                    rmd160  943675fe098d1fc197d381f55ad9a72681652d09 \
82                    sha256  0e2f3180d6316e6c43f064fdd406c5c6515e682c5f31c57c28335b68c7525423 \
83                    libcxx-3.3.src.tar.gz \
84                    rmd160  b97ba28e87d30dfe5b4f540ce20a190ac0bcab9c \
85                    sha256  c403ed18d2992719c794cdd760dc87a948b62a7c2a07beb39eb984dfeb1679f1
86
87patchfiles      install_target.patch \
88                0001-Fix-regular-expression-to-work-with-multiple-digit-v.patch \
89                tiger.patch \
90                tiger-undefined-_CS_DARWIN_USER_-macros.patch \
91                tiger-shlib.patch
92
93patch.pre_args  -p1
94
95if {${subport} == "clang-${llvm_version}"} {
96    if {${distfiles} != ""} {
97        distfiles-append     cfe-${version}.src${extract.suffix} compiler-rt-${version}.src${extract.suffix} libcxx-${version}.src${extract.suffix}
98    }
99
100    patchfiles-append    tiger-shlib-clang.patch tiger-libclang.patch scan-build-PR-35006.patch \
101                         0001-Comment-out-SL-cctools-workaround.patch \
102                         mavericks-libc++.patch \
103                         snowleopard-cmath.patch \
104                         yosemite-deployment-target.patch \
105                         export_dynamic.patch
106
107    build.target        clang-only
108    destroot.target     install-clang
109}
110
111build.env-append        VERBOSE=1 \
112                        REQUIRES_RTTI=1 \
113                        LLVM_SUBMIT_VERSION=3 \
114                        LLVM_SUBMIT_SUBVERSION=7.1
115destroot.env-append     VERBOSE=1 \
116                        REQUIRES_RTTI=1 \
117                        LLVM_SUBMIT_VERSION=3 \
118                        LLVM_SUBMIT_SUBVERSION=7.1
119
120configure.dir           ${workpath}/build
121build.dir               ${configure.dir}
122
123configure.optflags
124configure.cppflags
125configure.ldflags
126configure.cmd           ${worksrcpath}/configure
127configure.pre_args-delete --prefix=${prefix}
128configure.args          --enable-bindings=none --enable-libffi --enable-shared --enable-jit \
129                        --enable-optimized --disable-profiling --enable-pic \
130                        --enable-debug-symbols --disable-debug-runtime \
131                        --prefix="${sub_prefix}" --disable-assertions
132
133if {${subport} == "llvm-${llvm_version}"} {
134    select.group        llvm
135    select.file         ${filespath}/mp-${subport}
136} elseif {${subport} == "clang-${llvm_version}"} {
137    select.group        clang
138    select.file         ${filespath}/mp-${subport}
139}
140
141# g++-4.0 fails to build some of the newer C++ for ppc
142# Intel looks ok, but I prefer using gcc-4.2 for consistency
143compiler.blacklist gcc-4.0
144
145variant universal {
146    build.env-append \
147        UNIVERSAL=1 \
148        UNIVERSAL_ARCH="[get_canonical_archs]"
149    destroot.env-append \
150        UNIVERSAL=1 \
151        UNIVERSAL_ARCH="[get_canonical_archs]"
152
153    post-extract {
154        # workaround a bug in Apple's shipped gcc driver-driver, patched in
155        # ours with driverdriver-num_infiles.patch
156        if {${configure.compiler} == "gcc-4.0" ||
157            ${configure.compiler} == "gcc-4.2" ||
158            ${configure.compiler} == "llvm-gcc-4.2"} {
159            system "echo \"static int ___ignoreme;\" > ${worksrcpath}/tools/llvm-shlib/ignore.c"
160        }
161    }
162}
163
164variant assertions description "Enable assertions for error detection (has performance impacts, especially on JIT)" {
165    configure.args-delete --disable-assertions
166    configure.args-append --enable-assertions
167}
168
169if {${subport} eq "clang-${llvm_version}"} {
170    # Don't self-host.  We may have issues if we have a slightly newer llvm version that
171    # is not binary compatible with the older clang version we're trying to use.
172
173    compiler.blacklist-append macports-clang-${llvm_version}
174}
175
176# blacklist current and future versions if they're not available in order to
177# help break potential dependency cycles.
178foreach ver {3.3 3.4 3.5 3.6 3.7 3.8 3.9 devel} {
179    if {![file exists ${prefix}/bin/clang-mp-${ver}]} {
180        compiler.blacklist-append macports-clang-${ver}
181    }
182}
183
184platform darwin {
185    if {${build_arch} eq "i386"} {
186        configure.pre_args-append --build=i686-apple-darwin${os.major}
187    } elseif {${build_arch} eq "ppc"} {
188        configure.pre_args-append --build=powerpc-apple-darwin${os.major}
189    } elseif {${build_arch} eq "ppc64"} {
190        configure.pre_args-append --build=powerpc64-apple-darwin${os.major}
191    } else {
192        configure.pre_args-append --build=${build_arch}-apple-darwin${os.major}
193    }
194
195    if {[string match "*ppc*" [get_canonical_archs]]} {
196        # http://trac.macports.org/ticket/33987
197        configure.args-append --with-optimize-option=-Os
198        configure.optflags    -Os
199    }
200
201    if {${subport} == "clang-${llvm_version}" && ${os.major} <= 9} {
202        patchfiles-append leopard-no-asan.patch 0001-Leopard-Default-to-fno-blocks.patch
203    }
204
205    # TODO: The llvm build system sets a 10.1 deployment target on Yosemite
206    if {[vercmp ${macosx_deployment_target} 10.10] >= 0} {
207        macosx_deployment_target 10.9
208    }
209
210    if {${os.major} < 9} {
211        # Tiger's DevTools make has issues with the nested ifs in compiler-rt
212        depends_run-append      port:gmake
213        build.cmd               ${prefix}/bin/gmake
214
215        post-configure {
216            reinplace "/^RPATH/s/=.*/=/" ${configure.dir}/Makefile.config
217        }
218    }
219}
220
221post-extract {
222    if {${subport} == "clang-${llvm_version}"} {
223        #system "cd ${worksrcpath}/tools && svn co -r ${svn.revision} http://llvm.org/svn/llvm-project/cfe/trunk clang"
224        #system "cd ${worksrcpath}/tools && svn co -r ${svn.revision} http://llvm.org/svn/llvm-project/cfe/branches/release_33 clang"
225        file rename ${workpath}/cfe-${llvm_version}.src ${worksrcpath}/tools/clang
226
227        #system "cd ${worksrcpath}/projects && svn co -r ${compiler_rt_rev} http://llvm.org/svn/llvm-project/compiler-rt/trunk compiler-rt"
228        #system "cd ${worksrcpath}/projects && svn co -r ${compiler_rt_rev} http://llvm.org/svn/llvm-project/compiler-rt/branches/release_33 compiler-rt"
229        file rename ${workpath}/compiler-rt-${llvm_version}.src ${worksrcpath}/projects/compiler-rt
230
231        #system "cd ${worksrcpath}/projects && svn co -r ${libcxx_rev} http://llvm.org/svn/llvm-project/libcxx/trunk libcxx"
232        #system "cd ${worksrcpath}/projects && svn co -r ${libcxx_rev} http://llvm.org/svn/llvm-project/libcxx/branches/release_33 libcxx"
233        file rename ${workpath}/libcxx-${llvm_version}.src ${worksrcpath}/projects/libcxx
234    }
235}
236
237post-patch {
238    if {${subport} == "clang-${llvm_version}"} {
239        # http://trac.macports.org/ticket/33272
240        if {![variant_isset arm_runtime]} {
241            reinplace {/^SubDirs/ s/arm//} ${worksrcpath}/projects/compiler-rt/lib/Makefile.mk
242            reinplace {/^UniversalArchs/ s/arm[^ )]* *//g} ${worksrcpath}/projects/compiler-rt/make/platform/clang_darwin.mk
243
244            reinplace {/cc_kext_ios5/ s/^/#/} ${worksrcpath}/projects/compiler-rt/make/platform/clang_darwin.mk
245            reinplace {s/cc_kext_ios5.a//} ${worksrcpath}/tools/clang/runtime/compiler-rt/Makefile
246        }
247 
248        reinplace {s/VERBOSE := 0/VERBOSE := 1/} ${worksrcpath}/projects/compiler-rt/make/config.mk
249    }
250}
251
252post-destroot {
253    file mkdir ${destroot}${prefix}/share/doc
254    file rename ${destroot}${sub_prefix}/docs/llvm ${destroot}${prefix}/share/doc/${subport}
255
256    foreach bin [glob ${destroot}${sub_prefix}/bin/*] {
257        set bin_filename [string map "${sub_prefix} ${prefix}" ${bin}]-${suffix}
258        set exec_path [string map "${destroot}${sub_prefix} ${sub_prefix}" ${bin}]
259
260        xinstall -m 755 "${filespath}/llvm-bin" "${bin_filename}"
261        reinplace "s:EXEC_PATH:${exec_path}:" "${bin_filename}"
262    }
263
264    if {${subport} == "llvm-${llvm_version}"} {
265        # r156389 (a5d2435409858728970202226d0bbbee508fe408) temporarilary removed llvm man pages
266        #foreach man [glob ${destroot}${sub_prefix}/share/man/man1/*.1] {
267        #    set basename [string map "${destroot}${sub_prefix}/share/man/man1/ {}" ${man}]
268        #    file rename ${man} ${destroot}${prefix}/share/man/man1/[string map ".1 -${suffix}.1" ${basename}]
269        #}
270
271        foreach liba [glob ${destroot}${sub_prefix}/lib/*dylib] {
272            set liba_nodr [string map "${destroot} {}" ${liba}]
273            system "install_name_tool -id ${liba_nodr} ${liba}"
274
275            foreach libb [glob ${destroot}${sub_prefix}/lib/*dylib] {
276                set libb_base [string map "${destroot}${sub_prefix}/lib/ {}" ${libb}]
277                set libb_nodr [string map "${destroot} {}" ${libb}]
278
279                system "install_name_tool -change @executable_path/../lib/${libb_base} ${libb_nodr} ${liba}"
280            }
281        }
282    } elseif {${subport} == "clang-${llvm_version}"} {
283        system "ditto ${worksrcpath}/projects/libcxx/include ${destroot}${sub_prefix}/lib/c++/v1"
284
285        # http://trac.macports.org/ticket/33207
286        ln -s ${prefix}/libexec/ld64/ld ${destroot}${sub_prefix}/bin/ld
287
288        system "install_name_tool -id ${sub_prefix}/lib/libclang.dylib ${destroot}${sub_prefix}/lib/libclang.dylib"
289        system "install_name_tool -change @executable_path/../lib/libLLVM-${llvm_version}svn.dylib ${sub_prefix}/lib/libLLVM-${llvm_version}svn.dylib ${destroot}${sub_prefix}/lib/libclang.dylib"
290        system "install_name_tool -change @executable_path/../lib/libLLVM-${llvm_version}.dylib ${sub_prefix}/lib/libLLVM-${llvm_version}.dylib ${destroot}${sub_prefix}/lib/libclang.dylib"
291
292        if {${os.major} > 9} {
293            # http://trac.macports.org/ticket/38527
294            system "install_name_tool -id ${sub_prefix}/lib/clang/${llvm_version}/lib/darwin/libclang_rt.asan_osx_dynamic.dylib ${destroot}${sub_prefix}/lib/clang/${llvm_version}/lib/darwin/libclang_rt.asan_osx_dynamic.dylib"
295        }
296    }
297}
298
299if {${subport} == "llvm-${llvm_version}"} {
300    variant ocaml description {Enable generation of OCaml binding} {
301        depends_lib-append   port:ocaml
302
303        configure.args-delete --enable-bindings=none
304        configure.args-append --enable-bindings=ocaml
305
306        destroot.args-append  OVERRIDE_libdir=${sub_prefix}/lib
307    }
308} elseif {${subport} == "clang-${llvm_version}"} {
309    variant arm_runtime description {Build and install the arm runtime for iOS development (requires iOS SDK)} {}
310
311    # The iOS SDK was shipped with all Xcode releases after 4.0
312    if {[info exists xcodeversion] && [vercmp "4.0" ${xcodeversion}] <= 0} {
313       default_variants-append +arm_runtime
314    }
315
316    set pythonver ""
317    set pythonverdot ""
318
319    if {![variant_isset python25] && ![variant_isset python26]} {
320        default_variants-append +python27
321    }
322
323    variant python25 conflicts python26 python27 description {Use python 2.5} {
324        set pythonver 25
325        set pythonverdot 2.5
326        depends_build-append port:python25
327        configure.args-append --with-python=${prefix}/bin/python2.5
328    }
329
330    variant python26 conflicts python25 python27 description {Use python 2.6} {
331        set pythonver 26
332        set pythonverdot 2.6
333        depends_build-append port:python26
334        configure.args-append --with-python=${prefix}/bin/python2.6
335    }
336
337    variant python27 conflicts python25 python26 description {Use python 2.7} {
338        set pythonver 27
339        set pythonverdot 2.7
340        depends_build-append port:python27
341        configure.args-append --with-python=${prefix}/bin/python2.7
342    }
343
344    variant analyzer description {Install clang static analyzer} {
345        if {[string equal "${pythonver}" ""]} {
346            ui_error "You must select a python variant to use the clang static analyzer (+analyzer)"
347            error "Invalid variant combination"
348        }
349
350        depends_run-append port:perl5 port:python${pythonver}
351
352        post-patch {
353            reinplace "s|/usr/bin/env perl|${prefix}/bin/perl5|g" \
354                ${worksrcpath}/tools/clang/tools/scan-build/ccc-analyzer \
355                ${worksrcpath}/tools/clang/tools/scan-build/c++-analyzer \
356                ${worksrcpath}/tools/clang/tools/scan-build/scan-build
357            reinplace "s|/usr/bin/env python|${prefix}/bin/python${pythonverdot}|g" \
358                ${worksrcpath}/tools/clang/tools/scan-build/set-xcode-analyzer \
359                ${worksrcpath}/tools/clang/tools/scan-view/scan-view
360        }
361
362        post-destroot {
363            file mkdir ${destroot}${sub_prefix}/libexec
364            file copy ${worksrcpath}/tools/clang/tools/scan-build ${destroot}${sub_prefix}/libexec/scan-build
365            file copy ${worksrcpath}/tools/clang/tools/scan-view ${destroot}${sub_prefix}/libexec/scan-view
366
367            file delete -force ${destroot}${sub_prefix}/libexec/scan-build/.svn
368            file delete -force ${destroot}${sub_prefix}/libexec/scan-view/.svn
369            file delete -force ${destroot}${sub_prefix}/libexec/scan-view/Resources/.svn
370
371            ln -s ${sub_prefix}/libexec/scan-build/scan-build ${destroot}${sub_prefix}/bin/scan-build
372            ln -s ${sub_prefix}/libexec/scan-view/scan-view ${destroot}${sub_prefix}/bin/scan-view
373            ln -s ${sub_prefix}/bin ${destroot}${sub_prefix}/libexec/scan-build/bin
374
375            xinstall -m 755 "${filespath}/llvm-bin" "${destroot}${prefix}/bin/scan-build-${suffix}"
376            reinplace "s:EXEC_PATH:${sub_prefix}/bin/scan-build:" "${destroot}${prefix}/bin/scan-build-${suffix}"
377
378            xinstall -m 755 "${filespath}/llvm-bin" "${destroot}${prefix}/bin/scan-view-${suffix}"
379            reinplace "s:EXEC_PATH:${sub_prefix}/bin/scan-view:" "${destroot}${prefix}/bin/scan-view-${suffix}"
380        }
381    }
382
383    if {${os.platform} eq "darwin" && ${os.major} > 15} {
384        depends_build
385        depends_lib
386        depends_run
387        archive_sites
388        pre-fetch {
389            ui_error "${subport} is not supported on macOS Sierra or newer."
390            return -code error {unsupported platform}
391        }
392    }
393}
394
395livecheck.type          none
Note: See TracBrowser for help on using the repository browser.