Ticket #54104: Portfile

File Portfile, 12.2 KB (added by kencu (Ken), 7 years ago)

working gcc6 / libgcc Portfile for Tiger i386

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
3PortSystem 1.0
4PortGroup select 1.0
5PortGroup compiler_blacklist_versions 1.0
6
7name                gcc6
8subport             libgcc {}
9
10epoch               2
11version             6.3.0
12if {${name} eq ${subport}} {
13    revision        2
14}
15platforms           darwin
16categories          lang
17maintainers         nomaintainer
18# an exception in the license allows dependents to not be GPL
19license             {GPL-3+ Permissive}
20description         The GNU compiler collection
21long_description    The GNU compiler collection, including front ends for \
22                    C, C++, Objective-C, Objective-C++, and Fortran.
23
24homepage            http://gcc.gnu.org/
25master_sites        ftp://ftp.funet.fi/pub/mirrors/sources.redhat.com/pub/gcc/releases/gcc-${version}/ \
26                    ftp://ftp.gwdg.de/pub/linux/gcc/releases/gcc-${version}/ \
27                    ftp://gcc.ftp.nluug.nl/mirror/languages/gcc/releases/gcc-${version}/ \
28                    ftp://gcc.gnu.org/pub/gcc/releases/gcc-${version}/ \
29                    gnu:gcc/gcc-${version}
30
31distname            gcc-${version}
32use_bzip2           yes
33
34checksums           rmd160  38d297e66ff27786f52ccc2b3a006cd1b056b0f7 \
35                    sha256  f06ae7f3f790fbf0f018f6d40e844451e6bc3b7bc96e128e63b09825c1f8b29f
36
37depends_lib         port:cctools \
38                    port:gmp \
39                    path:lib/pkgconfig/isl.pc:isl \
40                    port:ld64 \
41                    path:lib/libgcc/libgcc_s.1.dylib:libgcc \
42                    port:libiconv \
43                    port:libmpc \
44                    port:mpfr
45
46depends_skip_archcheck-append gcc_select ld64 cctools
47license_noconflict  gmp mpfr ppl libmpc
48
49set major           [lindex [split ${version} .-] 0]
50
51platform darwin {
52    configure.pre_args-append --build=${build_arch}-apple-darwin${os.major}
53
54    # see https://gcc.gnu.org/ml/gcc-patches/2012-05/msg00672.html
55    patchfiles-append         patch-float128.diff
56   
57    # Tiger intel sysconf fix
58    patchfiles-append         patch-libcilkrts-runtime-sysdep-tigerfix.diff
59}
60
61configure.dir       ${workpath}/build
62configure.cmd       ${worksrcpath}/configure
63configure.args      --enable-languages=c,c++,objc,obj-c++,lto,fortran \
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-build-config=bootstrap-debug \
83                    --with-as=${prefix}/bin/as \
84                    --with-ld=${prefix}/bin/ld \
85                    --with-ar=${prefix}/bin/ar \
86                    --with-bugurl=https://trac.macports.org/newticket
87
88configure.env-append \
89                    AR_FOR_TARGET=${prefix}/bin/ar \
90                    AS_FOR_TARGET=${prefix}/bin/as \
91                    LD_FOR_TARGET=${prefix}/bin/ld \
92                    NM_FOR_TARGET=${prefix}/bin/nm \
93                    OBJDUMP_FOR_TARGET=${prefix}/bin/objdump \
94                    RANLIB_FOR_TARGET=${prefix}/bin/ranlib \
95                    STRIP_FOR_TARGET=${prefix}/bin/strip \
96                    OTOOL=${prefix}/bin/otool \
97                    OTOOL64=${prefix}/bin/otool
98
99pre-configure {
100    configure.args-append --with-pkgversion="MacPorts ${name} ${version}_${revision}${portvariants}"
101
102    if {${configure.sdkroot} ne ""} {
103        # We should be using --with-build-sysroot here.  Using --with-sysroot
104        # changes the behavior of the installed gcc to look in that sysroot
105        # by default instead of /.  Using --with-build-sysroot is supposed
106        # to be used during the build but not impact the installed product.
107        # Unfortunately, the build fails because the value doesn't get
108        # plumbed everywhere it is supposed to.
109        #
110        # https://trac.macports.org/ticket/53726
111        # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79885
112        #
113        # Note that macports toolchains will fail to compile gcc unless
114        # the DevSDK is installed due to another gcc build system bug:
115        # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80203
116        configure.args-append --with-sysroot="${configure.sdkroot}"
117    }
118
119    # TODO: Remove when base automatically creates configure.dir (2.2.1?).
120    file mkdir ${configure.dir}
121}
122
123# http://trac.macports.org/ticket/29067
124compiler.blacklist-append gcc-4.0
125
126# http://trac.macports.org/ticket/29104
127compiler.blacklist-append {llvm-gcc-4.2 < 2336.1}
128
129# https://trac.macports.org/ticket/47996
130compiler.blacklist-append {clang < 300}
131
132# "-stdlib" would be passed on to the bootstrap compiler if present
133configure.cxx_stdlib
134
135build.dir           ${configure.dir}
136build.target        bootstrap-lean
137
138#KEN - for Darwin 8 intel
139# build.pre_args          BOOT_CFLAGS=" -g -O2 -mmacosx-version-min=10.4 -Wl,-read_only_relocs,suppress" CFLAGS_FOR_TARGET=" -g -O2 -pipe -Os -mmacosx-version-min=10.4 -Wl,-read_only_relocs,suppress" CXXFLAGS_FOR_TARGET=" -g -O2 -pipe -Os -mmacosx-version-min=10.4 -Wl,-read_only_relocs,suppress"
140use_parallel_build  yes
141
142destroot.target     install install-info-host
143
144if {${subport} eq "libgcc"} {
145    conflicts       libgcc-devel
146
147    # http://trac.macports.org/ticket/35770
148    # http://trac.macports.org/ticket/38814
149    # While there can be multiple versions of these runtimes in a single
150    # process, it is not possible to pass objects between different versions,
151    # so we simplify this by having the libgcc port provide the newest version
152    # of these runtimes for all versions of gcc to use.
153    #
154    # If there is a binary incompatible change to the runtime in a future
155    # version of gcc, then the latest version of gcc to provide a given ABI
156    # version should continue to provide a subport for that and older gcc
157    # versions.
158
159    depends_lib-delete path:lib/libgcc/libgcc_s.1.dylib:libgcc
160
161    configure.args-delete --libdir=${prefix}/lib/${name}
162    configure.args-append --libdir=${prefix}/lib/libgcc
163   
164
165    # TODO: Possibly disable bootstrap with appropriate configure flags.
166    #       the problem is that libstdc++'s configure script tests for tls support
167    #       using the running compiler (not gcc for which libstdc++ is being built).
168    #       Thus when we build with clang, we get a mismatch
169    # http://trac.macports.org/ticket/36116
170    #compiler.blacklist-append {clang < 425}
171    #configure.args-append --disable-bootstrap
172    #build.target        all
173
174    post-destroot {
175        file mkdir ${destroot}${prefix}/lib/libgcc.merged
176
177        # Note that we really don't want to include libgcc_ext.10.[45].dylib here, but install_name_tool
178        # doesn't know how to change the id of stubs, and it's easier than recreating them for each
179        # gcc port.
180        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}
181
182        foreach dylib ${dylibs} {
183            # Different OS versions (eg: Leopard) or architectures (eg: PPC) don't produce all the dylibs
184            # https://trac.macports.org/ticket/40098
185            # https://trac.macports.org/ticket/40100
186            if {! [file exists ${destroot}${prefix}/lib/libgcc/${dylib}]} {
187                continue
188            }
189
190            move ${destroot}${prefix}/lib/libgcc/${dylib} ${destroot}${prefix}/lib/libgcc.merged
191            if {[variant_isset universal]} {
192                foreach archdir [glob ${destroot}${prefix}/lib/libgcc/*/] {
193                    set archdir_nodestroot [string map "${destroot}/ /" ${archdir}]
194                    if {[file exists ${archdir}/${dylib}]} {
195                        system "install_name_tool -id ${prefix}/lib/libgcc/${dylib} ${archdir}/${dylib}"
196                        foreach link ${dylibs} {
197                            system "install_name_tool -change ${archdir_nodestroot}${link} ${prefix}/lib/libgcc/${link} ${archdir}/${dylib}"
198                        }
199                        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}"
200                    }
201                }
202            }
203
204            # strip debug symbols to supress debugger warnings:
205            # http://trac.macports.org/attachment/ticket/34831
206            if {! [string match *libgcc_ext* ${dylib}]} {
207                system "strip -x ${destroot}${prefix}/lib/libgcc.merged/${dylib}"
208            }
209        }
210
211        file delete -force ${destroot}${prefix}/bin
212        file delete -force ${destroot}${prefix}/share
213        file delete -force ${destroot}${prefix}/include
214        file delete -force ${destroot}${prefix}/lib/libgcc
215        file delete -force ${destroot}${prefix}/libexec
216
217        move ${destroot}${prefix}/lib/libgcc.merged ${destroot}${prefix}/lib/libgcc
218
219        # For binary compatibility with binaries that linked against the old libstdcxx port
220        ln -s libgcc/libstdc++.6.dylib ${destroot}${prefix}/lib/libstdc++.6.dylib
221    }
222} else {
223depends_run-append         port:gcc_select
224
225post-destroot {
226    file delete ${destroot}${prefix}/share/info/dir
227
228    foreach file [glob ${destroot}${prefix}/share/{info,man/man7}/*] {
229        set extension [file extension ${file}]
230        set newfile [regsub "${extension}$" ${file} "-mp-${major}${extension}"]
231
232        file rename ${file} ${newfile}
233    }
234
235    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} {
236        # Different OS versions (eg: Leopard) or architectures (eg: PPC) don't produce all the dylibs
237        # https://trac.macports.org/ticket/40098
238        # https://trac.macports.org/ticket/40100
239        if {[file exists ${destroot}${prefix}/lib/${name}/${dylib}]} {
240            delete ${destroot}${prefix}/lib/${name}/${dylib}
241            ln -s ${prefix}/lib/libgcc/${dylib} ${destroot}${prefix}/lib/${name}/${dylib}
242        }
243
244        if {[variant_isset universal]} {
245            foreach archdir [glob ${destroot}${prefix}/lib/${name}/*/] {
246                if {[file exists ${archdir}/${dylib}]} {
247                    delete ${archdir}/${dylib}
248                    ln -s ${prefix}/lib/libgcc/${dylib} ${archdir}/${dylib}
249                }
250            }
251        }
252    }
253}
254
255select.group        gcc
256select.file         ${filespath}/mp-${name}
257
258}
259
260#KEN
261variant usegcc4abi description {default to gcc4-compatible ABI} {
262        configure.args-append --with-default-libstdcxx-abi=gcc4-compatible
263}
264
265platform powerpc {
266    configure.universal_archs ppc ppc64
267}
268platform i386 {
269    configure.universal_archs i386 x86_64
270}
271variant universal {
272    configure.args-delete --disable-multilib
273}
274# the generated compiler doesn't accept -arch
275configure.env-append \
276    CPP="${configure.cc} -E" \
277    CXXCPP="${configure.cxx} -E"
278build.env-append \
279    CPP="${configure.cc} -E" \
280    CXXCPP="${configure.cxx} -E"
281configure.cc-append [get_canonical_archflags]
282configure.cc_archflags
283configure.cxx-append ${configure.cxx_archflags}
284configure.cxx_archflags
285configure.objc_archflags
286configure.ld_archflags
287configure.universal_cflags
288configure.universal_cxxflags
289configure.universal_ldflags
290configure.universal_args
291
292livecheck.type      regex
293livecheck.url       http://ftp.gnu.org/gnu/gcc/
294livecheck.regex     gcc-(${major}\\.\[0-9.\]+)/