source: trunk/dports/devel/ld64/Portfile @ 135516

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

ld64: Update ld64-latest to 241.9 and add ld64-236 port with the previous version for users that can't use libc++

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 14.0 KB
Line 
1# $Id: Portfile 135516 2015-04-25 08:43:49Z jeremyhu@macports.org $
2
3PortSystem              1.0
4PortGroup               compiler_blacklist_versions 1.0
5
6name                    ld64
7epoch                   2
8version                 2
9categories              devel
10platforms               darwin
11maintainers             jeremyhu
12homepage                http://opensource.apple.com/source/${name}/
13master_sites            http://opensource.apple.com/tarballs/${name}/
14license                 APSL-2
15description             ld64 is the new mach-o linker
16long_description        ld64 combines several object files and libraries, \
17                        resolves references, and produces an ouput file.
18
19subport ld64-97 {
20    # XCode 3.2.6
21    version             97.17
22
23    checksums           ld64-97-standalone-libunwind-headers.patch \
24                        rmd160  f6da71e097aa61b1055b3fdc12cd39aafed5f492 \
25                        sha256  370d02757ea628b5dd145c099e42fc4eb88cc09cf459a59e32d14bbc9b4a105e \
26                        ld64-97.17.tar.gz \
27                        rmd160  d52df7d7f741c8bedd29cbac73dbb9db992b4795 \
28                        sha256  02bd46af0809eaa415d096d7d41c3e8e7d80f7d8d181840866fb87f036b4e089
29
30    set makefile        "Makefile-97"
31    set ld64_ver        97
32
33    compiler.blacklist-append *clang*
34
35    patchfiles \
36        ld64-version.patch \
37        ld64-97-no-LTO.patch \
38        ld64-97-ppc-branch-island.patch \
39        ld64-97-arm_types_PR38931.patch \
40        ld64-97-long-branch-warn.patch \
41        ld64-97-standalone-libunwind-headers.patch \
42        ld64-97-no-Availability.h.patch \
43        ld64-97-BaseAtomImplicitDecl.patch \
44        ld64-97-no-ppc-thread_status.patch
45
46    if {${os.major} >= 14} {
47        pre-fetch {
48            ui_error "$subport is not supported on Yosemite or later."
49            error "unsupported platform"
50        }
51    }
52}
53
54subport ld64-127 {
55    # XCode 4.2
56    # This was the last ld64 release that supported linking ppc executables.
57    version             127.2
58    revision            2
59
60    checksums           rmd160  8ee709341549a1944732daef6ebab7ef1acfcc6e \
61                        sha256  97b75547b2bd761306ab3e15ae297f01e7ab9760b922bc657f4ef72e4e052142
62
63    set makefile        "Makefile-127"
64    set ld64_ver        127
65
66    patchfiles-append \
67        ld64-version.patch \
68        ld64-134-missing-include.patch \
69        ld64-127-any-cctools.patch \
70        ld64-127-long-branch-warn.patch \
71        ld64-127-cxx_initializer_order_and_sim.patch \
72        ld64-127-ppc.patch \
73        ld64-97-no-Availability.h.patch \
74        PR-12249048.patch \
75        PR-12057707.patch \
76        PR-13282463.patch \
77        ld64-ppc-9610466.patch
78}
79
80subport ld64-136 {
81    # XCode 4.6
82    version             136
83    revision            2
84
85    checksums           rmd160  4a2930ccdd398b63a108810e90293ab96dc154a0 \
86                        sha256  99d6c4acb6d4cdf45772951dd2308222aa966763170137459a9d276674645d9e
87 
88    set makefile        "Makefile-133"
89    set ld64_ver        136
90
91    patchfiles-append \
92        ld64-version.patch \
93        ld64-133-no-CrashReporterClient.h.patch \
94        ld64-134-missing-include.patch \
95        ld64-136-i386-badAddress.patch \
96        PR-13282463.patch \
97        ld64-ppc-9610466.patch
98
99    if {${configure.cxx_stdlib} eq "libstdc++"} {
100        patchfiles-append   ld64-136-hash_set.patch
101    }
102
103    if {${os.major} <= 9} {
104        pre-fetch {
105            ui_error "$subport is not supported on Leopard or earlier.  It requires the blocks runtime."
106            error "unsupported platform"
107        }
108    }
109}
110
111subport ld64-236 {
112    # XCode 5.1
113    version             236.3
114
115    checksums           rmd160  6a3f44aa9ae57a60d2cff5b3d47be7972ad83029 \
116                        sha256  8ef36729b643201081ab45ebd8586ede8f9968bc17614b679a940faa82875ca6
117
118    # http://trac.macports.org/ticket/43737
119    # < 100 is a guess.  Xcode 4.1 might work, so I'm leaving it as an option unless someone reports a failure.
120    compiler.blacklist-append *gcc* {clang < 100}
121
122    set makefile        "Makefile-133"
123    set ld64_ver        236
124
125    patchfiles-append \
126        ld64-version.patch \
127        ld64-133-no-CrashReporterClient.h.patch \
128        ld64-134-missing-include.patch \
129        ld64-136-i386-badAddress.patch \
130        PR-16935960.patch \
131        PR-16936488.patch \
132        ld64-ppc-9610466.patch
133
134    if {${configure.cxx_stdlib} eq "libstdc++"} {
135        patchfiles-append   ld64-236-hash_set.patch
136    }
137
138    if {${os.major} <= 9} {
139        pre-fetch {
140            ui_error "$subport is not supported on Leopard or earlier.  It requires the blocks runtime."
141            error "unsupported platform"
142        }
143    }
144}
145
146subport ld64-latest {
147    # XCode 6.1
148    version             241.9
149
150    checksums           rmd160  1ee4a7be89b96a8ce3ca6f6dc803dfd0852d29b8 \
151                        sha256  3594e87c626c3b5abab6470cac6f27b367f1efcee60eb3d0f6b6d4ecf9b24230
152
153    # http://trac.macports.org/ticket/43737
154    # < 100 is a guess.  Xcode 4.1 might work, so I'm leaving it as an option unless someone reports a failure.
155    compiler.blacklist-append *gcc* {clang < 100}
156
157    set makefile        "Makefile-133"
158    set ld64_ver        latest
159
160    patchfiles-append \
161        ld64-version.patch \
162        ld64-133-no-CrashReporterClient.h.patch \
163        ld64-134-missing-include.patch \
164        ld64-136-i386-badAddress.patch \
165        ld64-ppc-9610466.patch
166
167    configure.cxx_stdlib libc++
168    depends_lib-append port:libcxx
169    supported_archs i386 x86_64
170
171    pre-fetch {
172        if {![file exists /usr/lib/libc++.dylib]} {
173            ui_error "$name requires a C++11 runtime, which your configuration does not allow"
174            error "unsupported configuration"
175        }
176    }
177
178}
179
180variant universal {}
181
182if {${subport} eq ${name}} {
183    distfiles
184    build {}
185    use_configure no
186
187    variant ld64_97 conflicts ld64_127 ld64_136 ld64_236 description {Use ld64-97 as the default linker (last version that works on Tiger)} {}
188    variant ld64_127 conflicts ld64_97 ld64_136 ld64_236 description {Use ld64-127 as the default linker (last version to support ppc)} {}
189    variant ld64_136 conflicts ld64_97 ld64_127 ld64_236 description {Use ld64-136 as the default linker (last version that works on Leopard)} {}
190    variant ld64_236 conflicts ld64_97 ld64_127 ld64_136 description {Use ld64-236 as the default linker (last version that builds against OS X's libstdc++)} {}
191
192    if {![variant_isset ld64_97] && ![variant_isset ld64_127] && ![variant_isset ld64_136]} {
193        if {${os.major} < 9} {
194            default_variants +ld64_97
195        } elseif {${os.major} < 10 || "ppc" in [get_canonical_archs]} {
196            default_variants +ld64_127
197        } elseif {${os.major} < 11} {
198            default_variants +ld64_136
199        }
200    }
201
202    if {[variant_isset ld64_97]} {
203        set ld64_ver 97
204    } elseif {[variant_isset ld64_127]} {
205        set ld64_ver 127
206    } elseif {[variant_isset ld64_136]} {
207        set ld64_ver 136
208    } elseif {[variant_isset ld64_236]} {
209        set ld64_ver 236
210    } else {
211        set ld64_ver latest
212    }
213
214    depends_run         port:ld64-${ld64_ver}
215
216    destroot {
217        ln -s dyldinfo-${ld64_ver} ${destroot}${prefix}/bin/dyldinfo
218        ln -s ld-${ld64_ver} ${destroot}${prefix}/bin/ld
219        ln -s machocheck-${ld64_ver} ${destroot}${prefix}/bin/machocheck
220        ln -s ObjectDump-${ld64_ver} ${destroot}${prefix}/bin/ObjectDump
221        ln -s rebase-${ld64_ver} ${destroot}${prefix}/bin/rebase
222        ln -s unwinddump-${ld64_ver} ${destroot}${prefix}/bin/unwinddump
223
224        file mkdir ${destroot}${prefix}/libexec/ld64
225        ln -s ld-${ld64_ver} ${destroot}${prefix}/libexec/ld64/ld
226    }
227} else {
228    depends_build       path:include/mach-o/dyld_priv.h:dyld-headers \
229                        path:include/mach-o/arm/reloc.h:libmacho-headers
230
231    if {[string match macports-clang-* ${configure.compiler}]} {
232        # For a new enough install_name_tool
233        depends_build-append port:cctools
234    }
235
236    # We don't set llvmXX as the default variant on Tiger because it would introduce a
237    # dependency cycle as llvm requires apple-gcc42 and ld64 to build correctly.  Users
238    # wanting LTO support in ld64 on Tiger can install the +llvm variant after llvm
239    # has been installed.
240
241    if {![variant_isset llvm33] && ![variant_isset llvm34] && ![variant_isset llvm35] && ![variant_isset llvm36] && ![variant_isset llvm37]} {
242        if {${os.major} >= 13} {
243            default_variants +llvm35
244        } elseif {${os.major} >= 10} {
245            default_variants +llvm34
246        } elseif {${os.major} >= 9} {
247            default_variants +llvm33
248        }
249
250        if {![variant_isset llvm33] && ![variant_isset llvm34] && ![variant_isset llvm35] && ![variant_isset llvm36] && ![variant_isset llvm37] && ${os.major} >= 9} {
251            ui_error "Your platform cannot be configured without LTO support in ld64.  Please enable one of the llvmXX variants, and try again."
252            return -code error "Your platform cannot be configured without LTO support in ld64.  Please enable one of the llvmXX variants, and try again."
253        }
254    }
255
256    set llvm_version {}
257    variant llvm33 conflicts llvm34 llvm35 llvm36 llvm37 description {Use llvm-3.3 for libLTO} {
258        set llvm_version        3.3
259        depends_lib-append      port:llvm-${llvm_version}
260    }
261
262    variant llvm34 conflicts llvm33 llvm35 llvm36 llvm37 description {Use llvm-3.4 for libLTO} {
263        set llvm_version        3.4
264        depends_lib-append      port:llvm-${llvm_version}
265    }
266
267    variant llvm35 conflicts llvm33 llvm34 llvm36 llvm37 description {Use llvm-3.5 for libLTO} {
268        set llvm_version        3.5
269        depends_lib-append      port:llvm-${llvm_version}
270    }
271
272    variant llvm36 conflicts llvm33 llvm34 llvm35 llvm37 description {Use llvm-3.6 for libLTO} {
273        set llvm_version        3.6
274        depends_lib-append      port:llvm-${llvm_version}
275    }
276
277    variant llvm37 conflicts llvm33 llvm34 llvm35 llvm36 description {Use llvm-3.7 for libLTO} {
278        set llvm_version        3.7
279        depends_lib-append      port:llvm-${llvm_version}
280    }
281
282    if {${os.major} < 10} {
283        # Leopard and earlier didn't have libunwind.h in the SDK
284        depends_build-append    path:include/libunwind.h:libunwind-headers
285    }
286
287    compiler.blacklist-append gcc-4.0
288
289    pre-fetch {
290        if {${os.major} < 9} {
291            if {${llvm_version} != ""} {
292                if {![file exists ${prefix}/bin/llvm-config-mp-${llvm_version}]} {
293                    ui_error "You must first install ld64 without llvm support to build llvm.  After llvm is installed, you can reinstall ld64 with the llvm variant."
294                    return -code error "You must first install ld64 without llvm support to build llvm.  After llvm is installed, you can reinstall ld64 with the llvm variant."
295                }
296            }
297        }
298    }
299
300    post-extract {
301        file copy ${filespath}/${makefile} ${worksrcpath}/Makefile
302    }
303
304    post-patch {
305        reinplace "s|@@VERSION@@|${version}|g" \
306            ${worksrcpath}/src/ld/Options.cpp
307
308        if {${os.major} < 9} {
309            # No CommonCrypto, use openssl
310            reinplace "s:<CommonCrypto/CommonDigest.h>:<openssl/md5.h>:" \
311                ${worksrcpath}/src/ld/MachOWriterExecutable.hpp
312            reinplace "s:CC_MD5:MD5:" \
313                ${worksrcpath}/src/ld/MachOWriterExecutable.hpp
314
315            reinplace "s:-Wl,-exported_symbol,__mh_execute_header::g" \
316                ${worksrcpath}/Makefile
317
318            foreach reg {cr ctr eax ebp ebx ecx edi edx eip esi esp lr mq r0 r1 r10 r11 r12 r13 r14 r15 r16 r17 r18 r19 r2 r20 r21 r22 r23 r24 r25 r26 r27 r28 r29 r3 r30 r31 r4 r5 r6 r7 r8 r9 rax rbp rbx rcx rdi rdx rip rsi rsp srr0 srr1 vrsave xer} {
319                reinplace "s|__${reg}|${reg}|g" ${worksrcpath}/src/ld/parsers/libunwind/Registers.hpp
320            }
321        }
322    }
323
324    configure {
325        system "cd ${worksrcpath} && ${build.cmd} src/ld/configure.h"
326    }
327
328    set cxx_stdlibflags {}
329    if {[string match *clang* ${configure.cxx}]} {
330        set cxx_stdlibflags -stdlib=${configure.cxx_stdlib}
331    }
332
333    build.args \
334        CC="${configure.cc}" \
335        CXX="${configure.cxx}" \
336        OTHER_CPPFLAGS="${configure.cppflags}" \
337        OTHER_CFLAGS="${configure.cflags} [get_canonical_archflags cc]" \
338        OTHER_CXXFLAGS="${configure.cxxflags} ${cxx_stdlibflags} [get_canonical_archflags cxx]" \
339        OTHER_LDFLAGS="${configure.ldflags} ${cxx_stdlibflags} [get_canonical_archflags ld]"
340
341    if {${os.major} >= 11} {
342        build.args-append \
343            RC_SUPPORTED_ARCHS="armv6 armv7 i386 x86_64"
344    }
345
346    destroot.args \
347        PREFIX=${prefix}
348
349    pre-build {
350        if {${llvm_version} != ""} {
351            build.args-append LLVM_CONFIG=${prefix}/bin/llvm-config-mp-${llvm_version}
352        }
353
354        if {${os.major} < 9} {
355            build.args-append OTHER_LDFLAGS_LD64=-lcrypto
356        }
357    }
358
359    post-destroot {
360        # ${prefix}/bin/ld will always use the llvm we built against
361        # ${prefix}/libexec/ld64/ld uses relative linking for use with the llvm ports
362        file mkdir ${destroot}${prefix}/libexec/ld64
363        file copy ${destroot}${prefix}/bin/ld ${destroot}${prefix}/libexec/ld64/ld-${ld64_ver}
364
365        file rename ${destroot}${prefix}/bin/dyldinfo ${destroot}${prefix}/bin/dyldinfo-${ld64_ver}
366        file rename ${destroot}${prefix}/bin/ld ${destroot}${prefix}/bin/ld-${ld64_ver}
367        file rename ${destroot}${prefix}/bin/machocheck ${destroot}${prefix}/bin/machocheck-${ld64_ver}
368        file rename ${destroot}${prefix}/bin/ObjectDump ${destroot}${prefix}/bin/ObjectDump-${ld64_ver}
369        file rename ${destroot}${prefix}/bin/rebase ${destroot}${prefix}/bin/rebase-${ld64_ver}
370        file rename ${destroot}${prefix}/bin/unwinddump ${destroot}${prefix}/bin/unwinddump-${ld64_ver}
371
372        eval delete [glob ${destroot}${prefix}/share/man/man1/*]
373
374        if {${llvm_version} != ""} {
375            system "install_name_tool -change ${prefix}/libexec/llvm-${llvm_version}/lib/libLTO.dylib \
376                    @executable_path/../lib/libLTO.dylib ${destroot}${prefix}/libexec/ld64/ld-${ld64_ver}"
377        }
378    }
379}
380
381livecheck.type          none
Note: See TracBrowser for help on using the repository browser.