Ticket #61636: Portfile_gcc_devel_arm

File Portfile_gcc_devel_arm, 12.7 KB (added by jpanetta (Julian Panetta), 4 years ago)

Portfile for building gcc11 on arm

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
6PortGroup           active_variants              1.1
7PortGroup           conflicts_build              1.0
8
9epoch               1
10name                gcc-develarm
11version             11-20201122
12revision            0
13subport             libgcc-develarm { revision 0 }
14platforms           darwin
15categories          lang
16maintainers         nomaintainer
17# an exception in the license allows dependents to not be GPL
18license             {GPL-3+ Permissive}
19description         The GNU compiler collection, prerelease BETA snapshot.
20long_description    The GNU compiler collection, including front ends for \
21                    C, C++, Objective-C, Objective-C++ and Fortran. \
22                    This is a prerelease BETA version! built from GCC snapshots.
23
24homepage            https://gcc.gnu.org/
25
26PortGroup github    1.0
27github.setup        iains gcc-darwin-arm64 6b589e6cb14fb74eaac99411a64083ff32fada85
28
29checksums           rmd160  005cdb1c71ee78234d3db08853e873cbae320854 \
30                    sha256  fe70b2caedf6f23b1caa9bf478b195be7d6801bd10836fb2419c85446034bbe9 \
31                    size    121028082
32
33depends_lib         port:cctools \
34                    port:gmp \
35                    path:lib/pkgconfig/isl.pc:isl \
36                    port:ld64 \
37                    port:libiconv \
38                    port:libmpc \
39                    port:mpfr \
40                    port:zlib
41depends_run         port:gcc_select \
42                    port:libgcc-develarm
43depends_build       port:texinfo
44
45depends_skip_archcheck-append gcc_select ld64 cctools
46license_noconflict  gmp mpfr ppl libmpc zlib
47
48set major           [lindex [split ${version} .-] 0]
49
50platform darwin {
51    configure.pre_args-append --build=${build_arch}-apple-darwin${os.major}
52}
53
54set gcc_configure_langs {c c++ objc obj-c++ lto fortran}
55if {${subport} eq "gcc-develarm"} {
56    lappend gcc_configure_langs jit
57}
58
59configure.dir       ${workpath}/build
60configure.cmd       ${worksrcpath}/configure
61configure.args      --enable-languages=[join ${gcc_configure_langs} ","] \
62                    --libdir=${prefix}/lib/${name} \
63                    --includedir=${prefix}/include/${name} \
64                    --infodir=${prefix}/share/info \
65                    --mandir=${prefix}/share/man \
66                    --datarootdir=${prefix}/share/gcc-develarm \
67                    --with-local-prefix=${prefix} \
68                    --with-system-zlib \
69                    --disable-nls \
70                    --program-suffix=-mp-develarm \
71                    --with-gxx-include-dir=${prefix}/include/${name}/c++/ \
72                    --with-gmp=${prefix} \
73                    --with-mpfr=${prefix} \
74                    --with-mpc=${prefix} \
75                    --with-isl=${prefix} \
76                    --enable-stage1-checking \
77                    --disable-multilib \
78                    --enable-lto \
79                    --enable-libstdcxx-time \
80                    --with-build-config=bootstrap-debug \
81                    --with-as=${prefix}/bin/as \
82                    --with-ld=${prefix}/bin/ld \
83                    --with-ar=${prefix}/bin/ar \
84                    --with-bugurl=https://trac.macports.org/newticket \
85                    --enable-host-shared
86
87# see https://lists.macports.org/pipermail/macports-dev/2017-August/036209.html
88# --disable-tls does not limit functionality
89# it only determines how std::call_once works
90configure.args-append \
91                    --disable-tls
92
93configure.env-append \
94                    AR_FOR_TARGET=${prefix}/bin/ar \
95                    AS_FOR_TARGET=${prefix}/bin/as \
96                    LD_FOR_TARGET=${prefix}/bin/ld \
97                    NM_FOR_TARGET=${prefix}/bin/nm \
98                    OBJDUMP_FOR_TARGET=${prefix}/bin/objdump \
99                    RANLIB_FOR_TARGET=${prefix}/bin/ranlib \
100                    STRIP_FOR_TARGET=${prefix}/bin/strip \
101                    OTOOL=${prefix}/bin/otool \
102                    OTOOL64=${prefix}/bin/otool
103
104pre-configure {
105
106    # Set package info
107    configure.args-append --with-pkgversion="MacPorts ${name} ${version}_${revision}${portvariants}"
108
109    if {${configure.sdkroot} ne ""} {
110        # We should be using --with-build-sysroot here.  Using --with-sysroot
111        # changes the behavior of the installed gcc to look in that sysroot
112        # by default instead of /.  Using --with-build-sysroot is supposed
113        # to be used during the build but not impact the installed product.
114        # Unfortunately, the build fails because the value doesn't get
115        # plumbed everywhere it is supposed to.
116        #
117        # https://trac.macports.org/ticket/53726
118        # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79885
119        configure.args-append --with-sysroot="${configure.sdkroot}"
120    }
121
122}
123
124# https://trac.macports.org/ticket/29067
125# https://trac.macports.org/ticket/29104
126# https://trac.macports.org/ticket/47996
127# https://trac.macports.org/ticket/58493
128compiler.blacklist-append {clang < 800} gcc-4.0 *gcc-4.2 {llvm-gcc-4.2 < 2336.1} {macports-clang-3.[4-7]}
129
130# at present, clang-9.0+ can't build gcc devel
131# https://trac.macports.org/ticket/59253
132# compiler.blacklist-append macports-clang-9.0 macports-clang-10
133
134# "-stdlib" would be passed on to the bootstrap compiler if present
135configure.cxx_stdlib
136
137build.dir           ${configure.dir}
138build.target        bootstrap-lean
139use_parallel_build  yes
140
141destroot.target     install install-info-host
142
143# Is this gcc release supported here.
144if { ${os.major} < 11 } {
145    known_fail      yes
146    pre-fetch {
147        ui_error "${name} ${version} is not supported on Darwin ${os.major}"
148        return -code error "incompatible OS X version"
149    }
150}
151
152# gcc cannot build if libunwind-headers is active
153conflicts_build-append libunwind-headers
154
155# List of dylibs to be installed
156# Note that we really don't want to include libgcc_ext.10.[45].dylib here, but install_name_tool
157# doesn't know how to change the id of stubs, and it's easier than recreating them for each
158# gcc port.
159set dylibs {libgcc_ext.10.4.dylib libgcc_ext.10.5.dylib libgcc_s.1.dylib libgfortran.5.dylib libquadmath.0.dylib libstdc++.6.dylib libobjc-gnu.4.dylib libgomp.1.dylib libitm.1.dylib libssp.0.dylib libasan.6.dylib libubsan.1.dylib libatomic.1.dylib}
160
161if {${subport} eq "libgcc-develarm"} {
162
163    # Set conflict against port providing primary runtime
164    if { ${os.major} < 10 } {
165        conflicts libgcc libgcc7
166    } else {
167        conflicts libgcc libgcc10
168    }
169
170    # http://trac.macports.org/ticket/35770
171    # http://trac.macports.org/ticket/38814
172    # While there can be multiple versions of these runtimes in a single
173    # process, it is not possible to pass objects between different versions,
174    # so we simplify this by having the libgcc port provide the newest version
175    # of these runtimes for all versions of gcc to use.
176    #
177    # If there is a binary incompatible change to the runtime in a future
178    # version of gcc, then the latest version of gcc to provide a given ABI
179    # version should continue to provide a subport for that and older gcc
180    # versions.
181
182    depends_run
183    depends_lib-delete   port:zlib
184    depends_build-append {*}${depends_lib}
185    depends_lib          port:zlib
186
187    configure.args-replace \
188        --libdir=${prefix}/lib/${name} \
189        --libdir=${prefix}/lib/libgcc
190
191    # see https://trac.macports.org/ticket/54766
192    configure.args-replace \
193        --includedir=${prefix}/include/${name} \
194        --includedir=${prefix}/include/gcc
195
196    configure.args-replace \
197        --with-gxx-include-dir=${prefix}/include/${name}/c++/ \
198        --with-gxx-include-dir=${prefix}/include/gcc/c++/
199
200    # TODO: Possibly disable bootstrap with appropriate configure flags.
201    #       the problem is that libstdc++'s configure script tests for tls support
202    #       using the running compiler (not gcc for which libstdc++ is being built).
203    #       Thus when we build with clang, we get a mismatch
204    # http://trac.macports.org/ticket/36116
205    #compiler.blacklist-append {clang < 425}
206    #configure.args-append --disable-bootstrap
207    #build.target        all
208
209    post-destroot {
210
211        # Temporary working dir for dylibs
212        file mkdir ${destroot}${prefix}/lib/libgcc.merged
213
214        # loop over libs to install
215        foreach dylib ${dylibs} {
216
217            # Different OS versions (e.g. Leopard) or architectures (e.g. 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/libgcc/${dylib}]} {
221                continue
222            }
223
224            move ${destroot}${prefix}/lib/libgcc/${dylib} ${destroot}${prefix}/lib/libgcc.merged
225            if {[variant_isset universal]} {
226                foreach archdir [glob ${destroot}${prefix}/lib/libgcc/*/] {
227                    set archdir_nodestroot [string map "${destroot}/ /" ${archdir}]
228                    if {[file exists ${archdir}/${dylib}]} {
229                        system "install_name_tool -id ${prefix}/lib/libgcc/${dylib} ${archdir}/${dylib}"
230                        foreach link [glob -tails -directory ${archdir} *.dylib] {
231                            system "install_name_tool -change ${archdir_nodestroot}${link} ${prefix}/lib/libgcc/${link} ${archdir}/${dylib}"
232                        }
233                        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}"
234                    }
235                }
236            }
237
238            # strip debug symbols to supress debugger warnings:
239            # http://trac.macports.org/attachment/ticket/34831
240            if {! [string match *libgcc_ext* ${dylib}]} {
241                system "strip -x ${destroot}${prefix}/lib/libgcc.merged/${dylib}"
242            }
243        }
244
245        file delete -force ${destroot}${prefix}/bin
246        file delete -force ${destroot}${prefix}/share
247        file delete -force ${destroot}${prefix}/lib/libgcc
248        file delete -force ${destroot}${prefix}/libexec
249
250        move ${destroot}${prefix}/lib/libgcc.merged ${destroot}${prefix}/lib/libgcc
251
252        # For binary compatibility with binaries that linked against the old libstdcxx port
253        ln -s libgcc/libstdc++.6.dylib ${destroot}${prefix}/lib/libstdc++.6.dylib
254    }
255
256} else {
257
258    post-destroot {
259
260        file delete ${destroot}${prefix}/share/info/dir
261
262        foreach file [glob ${destroot}${prefix}/share/{info,man/man7}/*] {
263            set extension [file extension ${file}]
264            set newfile [regsub "${extension}$" ${file} "-mp-develarm${extension}"]
265            file rename ${file} ${newfile}
266        }
267
268        # loop over libs to install
269        foreach dylib ${dylibs} {
270            # Different OS versions (e.g. Leopard) or architectures (e.g. PPC) don't produce all the dylibs
271            # https://trac.macports.org/ticket/40098
272            # https://trac.macports.org/ticket/40100
273            if {[file exists ${destroot}${prefix}/lib/${name}/${dylib}]} {
274                delete ${destroot}${prefix}/lib/${name}/${dylib}
275                ln -s ${prefix}/lib/libgcc/${dylib} ${destroot}${prefix}/lib/${name}/${dylib}
276            }
277            if {[variant_isset universal]} {
278                foreach archdir [glob ${destroot}${prefix}/lib/${name}/*/] {
279                    if {[file exists ${archdir}/${dylib}]} {
280                        delete ${archdir}/${dylib}
281                        ln -s ${prefix}/lib/libgcc/${dylib} ${archdir}/${dylib}
282                    }
283                }
284            }
285        }
286
287    }
288
289    select.group        gcc
290    select.file         ${filespath}/mp-${name}
291}
292
293platform powerpc {
294    configure.universal_archs ppc ppc64
295}
296platform i386 {
297    configure.universal_archs i386 x86_64
298}
299variant universal {
300    configure.args-delete --disable-multilib
301}
302# the generated compiler doesn't accept -arch
303configure.env-append \
304    "CPP=${configure.cc} -E" \
305    "CXXCPP=${configure.cxx} -E"
306build.env-append \
307    "CPP=${configure.cc} -E" \
308    "CXXCPP=${configure.cxx} -E"
309configure.cc-append [get_canonical_archflags]
310configure.cc_archflags
311configure.cxx-append ${configure.cxx_archflags}
312configure.cxx_archflags
313configure.objc_archflags
314configure.ld_archflags
315configure.universal_cflags
316configure.universal_cxxflags
317configure.universal_ldflags
318configure.universal_args
319
320livecheck.type      regex
321livecheck.url       ftp://gcc.gnu.org/pub/gcc/snapshots/
322livecheck.regex     LATEST-${major} -> (${major}-\[0-9\]+)