source: trunk/dports/lang/gcc5/Portfile @ 148017

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

gcc5: add a patch to avoid internal compiler error, closing #51170

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 11.1 KB
Line 
1# -*- coding: utf-8; mode: tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:filetype=tcl:et:sw=4:ts=4:sts=4
2# $Id: Portfile 148017 2016-04-24 20:47:46Z takeshi@macports.org $
3
4PortSystem 1.0
5PortGroup select 1.0
6PortGroup compiler_blacklist_versions 1.0
7
8name                gcc5
9subport             libgcc {}
10
11epoch               2
12version             5.3.0
13revision            1
14platforms           darwin
15categories          lang
16maintainers         mww openmaintainer
17# an exception in the license allows dependents to not be GPL
18license             {GPL-3+ Permissive}
19description         The GNU compiler collection
20long_description    The GNU compiler collection, including front ends for \
21                    C, C++, Objective-C, Objective-C++, Fortran and Java.
22
23homepage            http://gcc.gnu.org/
24master_sites        ftp://ftp.funet.fi/pub/mirrors/sources.redhat.com/pub/gcc/releases/gcc-${version}/ \
25                    ftp://ftp.gwdg.de/pub/linux/gcc/releases/gcc-${version}/ \
26                    ftp://gcc.ftp.nluug.nl/mirror/languages/gcc/releases/gcc-${version}/ \
27                    ftp://gcc.gnu.org/pub/gcc/releases/gcc-${version}/ \
28                    gnu:gcc/gcc-${version}
29
30distname            gcc-${version}
31use_bzip2           yes
32
33checksums           rmd160  b06fec59ceb37aeb042bdb9e1703e53d0834d085 \
34                    sha256  b84f5592e9218b73dbae612b5253035a7b34a9a1f7688d2e1bfaaf7267d5c4db
35
36depends_lib         port:cctools \
37                    port:gmp \
38                    path:lib/pkgconfig/isl.pc:isl \
39                    port:ld64 \
40                    path:lib/libgcc/libgcc_s.1.dylib:libgcc \
41                    port:libiconv \
42                    port:libmpc \
43                    port:mpfr
44
45depends_skip_archcheck-append gcc_select ld64 cctools
46license_noconflict  gmp mpfr ppl libmpc
47
48# Handle OS X deployment targets correctly (GCC PR target/63810
49# <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63810>).
50patchfiles-append   macosx-version-min.patch
51# Avoid internal compiler error: in prune_uninit_phi_opnds_in_unrealizable_paths (GCC PR tree-optimization/69013
52# <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69013>).
53patchfiles-append   patch-gcc-tree-ssa-uninit.c.diff
54
55set major           [lindex [split ${version} .-] 0]
56
57platform darwin {
58    configure.pre_args-append --build=${build_arch}-apple-darwin${os.major}
59}
60
61configure.dir       ${workpath}/build
62configure.cmd       ${worksrcpath}/configure
63configure.args      --enable-languages=c,c++,objc,obj-c++,lto,fortran,java \
64                    --libdir=${prefix}/lib/${name} \
65                    --includedir=${prefix}/include/${name} \
66                    --infodir=${prefix}/share/info \
67                    --mandir=${prefix}/share/man \
68                    --datarootdir=${prefix}/share/gcc-${major} \
69                    --with-local-prefix=${prefix} \
70                    --with-system-zlib \
71                    --disable-nls \
72                    --program-suffix=-mp-${major} \
73                    --with-gxx-include-dir=${prefix}/include/${name}/c++/ \
74                    --with-gmp=${prefix} \
75                    --with-mpfr=${prefix} \
76                    --with-mpc=${prefix} \
77                    --with-isl=${prefix} \
78                    --enable-stage1-checking \
79                    --disable-multilib \
80                    --enable-lto \
81                    --enable-libstdcxx-time \
82                    --with-as=${prefix}/bin/as \
83                    --with-ld=${prefix}/bin/ld \
84                    --with-ar=${prefix}/bin/ar \
85                    --with-bugurl=https://trac.macports.org/newticket
86
87configure.env-append \
88                    AR_FOR_TARGET=${prefix}/bin/ar \
89                    AS_FOR_TARGET=${prefix}/bin/as \
90                    LD_FOR_TARGET=${prefix}/bin/ld \
91                    NM_FOR_TARGET=${prefix}/bin/nm \
92                    OBJDUMP_FOR_TARGET=${prefix}/bin/objdump \
93                    RANLIB_FOR_TARGET=${prefix}/bin/ranlib \
94                    STRIP_FOR_TARGET=${prefix}/bin/strip \
95                    OTOOL=${prefix}/bin/otool \
96                    OTOOL64=${prefix}/bin/otool
97
98pre-configure {
99    configure.args-append --with-pkgversion="MacPorts ${name} ${version}_${revision}${portvariants}"
100
101    # TODO: Remove when base automatically creates configure.dir (2.2.1?).
102    file mkdir ${configure.dir}
103}
104
105# http://trac.macports.org/ticket/29067
106compiler.blacklist-append gcc-4.0
107
108# http://trac.macports.org/ticket/29104
109compiler.blacklist-append {llvm-gcc-4.2 < 2336.1}
110
111# https://trac.macports.org/ticket/47996
112compiler.blacklist-append {clang < 300}
113
114# "-stdlib" would be passed on to the bootstrap compiler if present
115configure.cxx_stdlib
116
117build.dir           ${configure.dir}
118build.target        bootstrap
119use_parallel_build  yes
120
121destroot.target     install install-info-host
122
123if {${subport} eq "libgcc"} {
124    conflicts       libgcc-devel
125
126    # http://trac.macports.org/ticket/35770
127    # http://trac.macports.org/ticket/38814
128    # While there can be multiple versions of these runtimes in a single
129    # process, it is not possible to pass objects between different versions,
130    # so we simplify this by having the libgcc port provide the newest version
131    # of these runtimes for all versions of gcc to use.
132    #
133    # If there is a binary incompatible change to the runtime in a future
134    # version of gcc, then the latest version of gcc to provide a given ABI
135    # version should continue to provide a subport for that and older gcc
136    # versions.
137
138    depends_lib-delete path:lib/libgcc/libgcc_s.1.dylib:libgcc
139
140    configure.args-delete --libdir=${prefix}/lib/${name}
141    configure.args-append --libdir=${prefix}/lib/libgcc
142
143    configure.args-delete --enable-languages=c,c++,objc,obj-c++,lto,fortran,java
144    configure.args-append --enable-languages=c,c++,objc,obj-c++,lto,fortran
145
146    # TODO: Possibly disable bootstrap with appropriate configure flags.
147    #       the problem is that libstdc++'s configure script tests for tls support
148    #       using the running compiler (not gcc for which libstdc++ is being built).
149    #       Thus when we build with clang, we get a mismatch
150    # http://trac.macports.org/ticket/36116
151    #compiler.blacklist-append {clang < 425}
152    #configure.args-append --disable-bootstrap
153    #build.target        all
154
155    post-destroot {
156        file mkdir ${destroot}${prefix}/lib/libgcc.merged
157
158        # Note that we really don't want to include libgcc_ext.10.[45].dylib here, but install_name_tool
159        # doesn't know how to change the id of stubs, and it's easier than recreating them for each
160        # gcc port.
161        set dylibs {libgcc_ext.10.4.dylib libgcc_ext.10.5.dylib libgcc_s.1.dylib libgfortran.3.dylib libquadmath.0.dylib libstdc++.6.dylib libobjc-gnu.4.dylib libgomp.1.dylib libitm.1.dylib libssp.0.dylib libasan.0.dylib libatomic.1.dylib}
162
163        foreach dylib ${dylibs} {
164            # Different OS versions (eg: Leopard) or architectures (eg: PPC) don't produce all the dylibs
165            # https://trac.macports.org/ticket/40098
166            # https://trac.macports.org/ticket/40100
167            if {! [file exists ${destroot}${prefix}/lib/libgcc/${dylib}]} {
168                continue
169            }
170
171            move ${destroot}${prefix}/lib/libgcc/${dylib} ${destroot}${prefix}/lib/libgcc.merged
172            if {[variant_isset universal]} {
173                foreach archdir [glob ${destroot}${prefix}/lib/libgcc/*/] {
174                    set archdir_nodestroot [string map "${destroot}/ /" ${archdir}]
175                    if {[file exists ${archdir}/${dylib}]} {
176                        system "install_name_tool -id ${prefix}/lib/libgcc/${dylib} ${archdir}/${dylib}"
177                        foreach link ${dylibs} {
178                            system "install_name_tool -change ${archdir_nodestroot}${link} ${prefix}/lib/libgcc/${link} ${archdir}/${dylib}"
179                        }
180                        system "lipo -create -output ${destroot}${prefix}/lib/libgcc.merged/${dylib}~ ${destroot}${prefix}/lib/libgcc.merged/${dylib} ${archdir}/${dylib} && mv ${destroot}${prefix}/lib/libgcc.merged/${dylib}~ ${destroot}${prefix}/lib/libgcc.merged/${dylib}"
181                    }
182                }
183            }
184
185            # strip debug symbols to supress debugger warnings:
186            # http://trac.macports.org/attachment/ticket/34831
187            if {! [string match *libgcc_ext* ${dylib}]} {
188                system "strip -x ${destroot}${prefix}/lib/libgcc.merged/${dylib}"
189            }
190        }
191
192        file delete -force ${destroot}${prefix}/bin             
193        file delete -force ${destroot}${prefix}/share
194        file delete -force ${destroot}${prefix}/include
195        file delete -force ${destroot}${prefix}/lib/libgcc
196        file delete -force ${destroot}${prefix}/libexec
197
198        move ${destroot}${prefix}/lib/libgcc.merged ${destroot}${prefix}/lib/libgcc
199
200        # For binary compatibility with binaries that linked against the old libstdcxx port
201        ln -s libgcc/libstdc++.6.dylib ${destroot}${prefix}/lib/libstdc++.6.dylib
202    }
203} else {
204depends_run-append         port:gcc_select
205
206post-destroot {
207    file delete ${destroot}${prefix}/share/info/dir
208
209    foreach file [glob ${destroot}${prefix}/share/{info,man/man7}/*] {
210        set extension [file extension ${file}]
211        set newfile [regsub "${extension}$" ${file} "-mp-${major}${extension}"]
212
213        file rename ${file} ${newfile}
214    }
215
216    foreach dylib {libgcc_ext.10.4.dylib libgcc_ext.10.5.dylib libgcc_s.1.dylib libgfortran.3.dylib libquadmath.0.dylib libstdc++.6.dylib libobjc-gnu.4.dylib libgomp.1.dylib libitm.1.dylib libssp.0.dylib libasan.0.dylib libatomic.1.dylib} {
217        # Different OS versions (eg: Leopard) or architectures (eg: PPC) don't produce all the dylibs
218        # https://trac.macports.org/ticket/40098
219        # https://trac.macports.org/ticket/40100
220        if {[file exists ${destroot}${prefix}/lib/${name}/${dylib}]} {
221            delete ${destroot}${prefix}/lib/${name}/${dylib}
222            ln -s ${prefix}/lib/libgcc/${dylib} ${destroot}${prefix}/lib/${name}/${dylib}
223        }
224
225        if {[variant_isset universal]} {
226            foreach archdir [glob ${destroot}${prefix}/lib/${name}/*/] {
227                if {[file exists ${archdir}/${dylib}]} {
228                    delete ${archdir}/${dylib}
229                    ln -s ${prefix}/lib/libgcc/${dylib} ${archdir}/${dylib}
230                }
231            }
232        }
233    }
234    move ${destroot}${prefix}/lib/${name}/pkgconfig/libgcj-${major}.pc ${destroot}${prefix}/lib/pkgconfig/
235}
236
237select.group        gcc
238select.file         ${filespath}/mp-${name}
239
240}
241
242platform powerpc {
243    configure.universal_archs ppc ppc64
244}
245platform i386 {
246    configure.universal_archs i386 x86_64
247}
248variant universal {
249    configure.args-delete --disable-multilib
250}
251# the generated compiler doesn't accept -arch
252configure.env-append CPP="${configure.cc} -E"
253build.env-append CPP="${configure.cc} -E"
254configure.cc-append [get_canonical_archflags]
255configure.cc_archflags
256configure.cxx-append ${configure.cxx_archflags}
257configure.cxx_archflags
258configure.objc_archflags
259configure.ld_archflags
260configure.universal_cflags
261configure.universal_cxxflags
262configure.universal_ldflags
263configure.universal_args
264
265livecheck.type      regex
266livecheck.url       http://ftp.gnu.org/gnu/gcc/
267livecheck.regex     gcc-(${major}\\.\[0-9.\]+)/
Note: See TracBrowser for help on using the repository browser.