/
Portfile
740 lines (642 loc) · 34.7 KB
/
Portfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
# -*- coding: utf-8; mode: tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:ft=tcl:et:sw=4:ts=4:sts=4
# TODO:
# * Update clang and lldb subports to build against installed libLLVM/libclang
PortSystem 1.0
PortGroup select 1.0
PortGroup compiler_blacklist_versions 1.0
PortGroup active_variants 1.1
PortGroup cmake 1.0
set llvm_version 9.0
set llvm_version_no_dot 90
set clang_executable_version 9
set lldb_executable_version 9.0.0
name llvm-${llvm_version}
revision 0
subport clang-${llvm_version} { revision 0 }
subport lldb-${llvm_version} { revision 0 }
set suffix mp-${llvm_version}
set sub_prefix ${prefix}/libexec/llvm-${llvm_version}
dist_subdir llvm
categories lang
platforms darwin
license NCSA
maintainers {jeremyhu @jeremyhu} {larryv @larryv} {kencu @kencu}
if {${subport} eq "llvm-${llvm_version}"} {
homepage https://llvm.org/
description llvm is a next generation compiler infrastructure
long_description The LLVM Core libraries provide a modern source- and \
target-independent optimizer, along with code \
generation support for many popular CPUs (as well as \
some less common ones!) These libraries are built \
around a well specified code representation known as \
the LLVM intermediate representation ("LLVM IR").
depends_lib port:libedit port:libffi port:ncurses path:lib/libxar.dylib:xar port:zlib
depends_run bin:perl:perl5 port:llvm_select
} elseif {${subport} eq "clang-${llvm_version}"} {
homepage https://clang.llvm.org/
description C, C++, Objective C and Objective C++ compiler
long_description Clang is an "LLVM native" C/C++/Objective-C compiler, \
which aims to deliver amazingly fast compiles (e.g. \
about 3x faster than GCC when compiling Objective-C \
code in a debug configuration), extremely useful error \
and warning messages and to provide a platform for \
building great source level tools. The included Clang \
Static Analyzer is a tool that automatically finds bugs in \
your code, and is a great example of the sort of tool \
that can be built using the Clang frontend as a \
library to parse C/C++ code.
depends_lib port:libxml2 port:libomp port:llvm-${llvm_version}
depends_run port:clang_select port:ld64
depends_skip_archcheck-append ld64 subversion
# Older Xcode's lipo doesn't support x86_64h slices
# https://trac.macports.org/ticket/53159
# Older Xcode's ranlib doesn't understand objects produced by newer clang (malformed object (unknown load command 2))
# https://trac.macports.org/ticket/57412
if {[vercmp $xcodeversion "6.0.0"] < 0} {
depends_build-append port:cctools
depends_run-append port:cctools
depends_skip_archcheck-append cctools
}
# Avoid requiring a bootstrap version of perl5 on 10.6.
if {${os.major} >= 11} {
default_variants +analyzer
}
} elseif {${subport} eq "lldb-${llvm_version}"} {
homepage https://lldb.llvm.org/
description the LLVM debugger
long_description Lldb is the "LLVM native" debugger.
depends_lib port:libxml2 port:libomp port:llvm-${llvm_version} port:ncurses
depends_build-append port:swig-python port:doxygen
# Clang doesn't actually use any of these, but the LLVM makefile
# system overlinks its binaries. Remove (or convert to build deps?)
# after #46040 is resolved.
depends_lib-append port:libedit port:libffi port:ncurses port:zlib
}
#fetch.type svn
#svn.revision 365158
#depends_extract-append port:subversion
#set compiler_rt_rev ${svn.revision}
#set libcxx_rev ${svn.revision}
#set clang-modernize_rev ${svn.revision}
#version ${llvm_version}-r${svn.revision}
#worksrcdir trunk
#svn.url https://llvm.org/svn/llvm-project/llvm/trunk
#worksrcdir release_${llvm_version_no_dot}
#svn.url https://llvm.org/svn/llvm-project/llvm/branches/release_${llvm_version_no_dot}
#default_variants-append +assertions
#default_variants-append +debug
# the backtik pkgconfig setting in the ffi config line requires pkg-config
depends_build-append port:pkgconfig
version ${llvm_version}.1
epoch 1
master_sites https://github.com/llvm/llvm-project/releases/download/llvmorg-${version}
#master_sites https://prereleases.llvm.org/${llvm_version}.0/rc2
use_xz yes
extract.suffix .tar.xz
distfiles llvm-${version}.src${extract.suffix}
worksrcdir llvm-${version}.src
if {${distfiles} ne ""} {
if {${subport} eq "llvm-${llvm_version}"} {
if {[variant_isset polly]} {
distfiles-append polly-${version}.src${extract.suffix}
}
} elseif {${subport} eq "clang-${llvm_version}"} {
distfiles-append clang-${version}.src${extract.suffix} compiler-rt-${version}.src${extract.suffix} libcxx-${version}.src${extract.suffix} clang-tools-extra-${version}.src${extract.suffix}
} elseif {${subport} eq "lldb-${llvm_version}"} {
distfiles-append clang-${version}.src${extract.suffix} lldb-${version}.src${extract.suffix}
}
}
checksums llvm-9.0.1.src.tar.xz \
rmd160 151c137ac3a514b6d32aaee5bb77dd32eb7d1f19 \
sha256 00a1ee1f389f81e9979f3a640a01c431b3021de0d42278f6508391a2f0b81c9a \
size 33035112 \
clang-9.0.1.src.tar.xz \
rmd160 424b98b3b6252f119fc06c8dfbc8fb1344531e88 \
sha256 5778512b2e065c204010f88777d44b95250671103e434f9dc7363ab2e3804253 \
size 13452780 \
compiler-rt-9.0.1.src.tar.xz \
rmd160 0a2bcf2ae22362a3c6743e3a63d3943a3f284946 \
sha256 c2bfab95c9986318318363d7f371a85a95e333bc0b34fbfa52edbd3f5e3a9077 \
size 1983828 \
libcxx-9.0.1.src.tar.xz \
rmd160 b85b557e1fa372f2f3eb854c13ca103abb671d66 \
sha256 0981ff11b862f4f179a13576ab0a2f5530f46bd3b6b4a90f568ccc6a62914b34 \
size 1813356 \
clang-tools-extra-9.0.1.src.tar.xz \
rmd160 f05643036eb0b394fe0cabb1e88fc8bc0c759837 \
sha256 b26fd72a78bd7db998a26270ec9ec6a01346651d88fa87b4b323e13049fb6f07 \
size 2175728 \
lldb-9.0.1.src.tar.xz \
rmd160 f0507a476d6ac832478dbcd72385ab4be9c8e9ce \
sha256 8a7b9fd795c31a3e3cba6ce1377a2ae5c67376d92888702ce27e26f0971beb09 \
size 9837400 \
polly-9.0.1.src.tar.xz \
rmd160 c5415f90f51ab3e3e6fbcab672bfcd52a9cc788c \
sha256 9a4ac69df923230d13eb6cd0d03f605499f6a854b1dc96a9b72c4eb075040fcf \
size 8768196
patch.pre_args -p1
patchfiles \
0001-Set-the-Mach-O-CPU-Subtype-to-ppc7400-when-targeting.patch \
0002-Define-EXC_MASK_CRASH-and-MACH_EXCEPTION_CODES-if-th.patch \
0003-MacPorts-Only-Don-t-embed-the-deployment-target-in-t.patch \
0004-Fix-build-issues-pre-Lion-due-to-missing-a-strnlen-d.patch \
0005-Threading-Only-call-pthread_setname_np-on-SnowLeopar.patch \
0006-Only-call-setpriority-PRIO_DARWIN_THREAD-0-PRIO_DARW.patch
# added by kencu for older systems support
patchfiles-append \
5000-patch-lib-support-unix-path-copyfileclone-on-older-systems.diff \
5001-patch-machoreader-strnlen.diff \
5002-patch-objdumper-strnlen.diff
# fix build on leopard
patchfiles-append 5000-patch-llvm8-tools-dsymutil-symbolmap-use-older-cfname-and-fix-uuid-on-leopard.diff
if {${subport} eq "clang-${llvm_version}"} {
patchfiles-append \
1001-MacPorts-Only-Prepare-clang-format-for-replacement-w.patch \
1002-MacPorts-Only-Fix-name-of-scan-view-executable-insid.patch \
1003-Default-to-ppc7400-for-OSX-10.5.patch \
1004-Default-to-fragile-ObjC-runtime-when-targeting-darwi.patch \
1005-Fixup-libstdc-header-search-paths-for-older-versions.patch \
1006-Fix-build-issues-pre-Lion-due-to-missing-a-strnlen-d.patch \
1007-Fix-float.h-to-work-on-Snow-Leopard-and-earlier.patch \
2001-xray-Define-O_CLOEXEC-for-older-SDKs-that-don-t-have.patch \
2002-Work-around-no-libdispatch-on-10.6.patch \
3001-Fix-missing-long-long-math-prototypes-when-using-the.patch \
3002-implement-atomic-using-mutex-lock_guard-for-64b-ops-.patch \
openmp-locations.patch
# fix build on leopard
patchfiles-append \
5001-patch-libcxx-src-new-posix-memalign-leopard.diff \
5002-patch-toolchains-darwin-add-back-pre-10.6-link-libs.diff
# fix incorrect disabling of bad_optional/variant/any_access on 10.13
# https://github.com/macports/macports-base/pull/179
patchfiles-append patch-libcxx-includes-config-optional-1013.diff
# https://llvm.org/bugs/show_bug.cgi?id=25681
if {${worksrcdir} eq "trunk" || ${worksrcdir} eq "release_${llvm_version_no_dot}"} {
# Cannot set cppflags due to https://cmake.org/Bug/view.php?id=12928
# Cannot set cxxflags due to https://llvm.org/bugs/show_bug.cgi?id=25904
#configure.cxxflags-append -DSVN_REVISION='"${svn.revision}"'
post-patch {
reinplace "1 i \\
#define SVN_REVISION \"${svn.revision}\"
" ${worksrcpath}/tools/clang/lib/Basic/Version.cpp
}
}
}
if {${subport} eq "lldb-${llvm_version}"} {
# lldb needs the clang sources present, so we apply the applicable patches.
patchfiles-append \
1001-MacPorts-Only-Prepare-clang-format-for-replacement-w.patch \
1002-MacPorts-Only-Fix-name-of-scan-view-executable-insid.patch \
1003-Default-to-ppc7400-for-OSX-10.5.patch \
1004-Default-to-fragile-ObjC-runtime-when-targeting-darwi.patch \
1005-Fixup-libstdc-header-search-paths-for-older-versions.patch \
1006-Fix-build-issues-pre-Lion-due-to-missing-a-strnlen-d.patch \
1007-Fix-float.h-to-work-on-Snow-Leopard-and-earlier.patch \
openmp-locations.patch
# https://llvm.org/bugs/show_bug.cgi?id=25681
if {${worksrcdir} eq "trunk" || ${worksrcdir} eq "release_${llvm_version_no_dot}"} {
# Cannot set cppflags due to https://cmake.org/Bug/view.php?id=12928
# Cannot set cxxflags due to https://llvm.org/bugs/show_bug.cgi?id=25904
#configure.cxxflags-append -DSVN_REVISION='"${svn.revision}"'
post-patch {
reinplace "1 i \\
#define SVN_REVISION \"${svn.revision}\"
" ${worksrcpath}/tools/clang/lib/Basic/Version.cpp
}
}
}
configure.post_args ../${worksrcdir}
default configure.dir {${workpath}/build}
default build.dir {${workpath}/build}
cmake.install_prefix ${sub_prefix}
# clang shared libraries are not all installed in ${cmake.install_prefix}/lib
# so we have to let the llvm/clang cmake scripts handle the @rpath setting
# See:
# https://llvm.org/bugs/show_bug.cgi?id=31425
# https://trac.macports.org/ticket/53299
configure.args-delete \
-DCMAKE_INSTALL_NAME_DIR=${cmake.install_prefix}/lib \
-DCMAKE_INSTALL_RPATH=${cmake.install_prefix}/lib \
-DCMAKE_SYSTEM_PREFIX_PATH="${prefix}\;/usr"
configure.args-append \
-DCMAKE_SYSTEM_PREFIX_PATH="${cmake.install_prefix}\;${prefix}\;/usr"
configure.args-append \
-DLLVM_LINK_LLVM_DYLIB=ON \
-DLLVM_ENABLE_ASSERTIONS=OFF \
-DLLVM_ENABLE_RTTI=ON \
-DLLVM_INCLUDE_TESTS=OFF \
-DLLVM_INCLUDE_EXAMPLES=OFF \
-DLLVM_ENABLE_FFI=ON \
-DLLVM_BINDINGS_LIST=none \
-DFFI_INCLUDE_DIR=`pkg-config --cflags-only-I libffi | sed 's/-I//'` \
-DFFI_LIBRARY_DIR=${prefix}/lib
if {${subport} eq "llvm-${llvm_version}"} {
select.group llvm
select.file ${filespath}/mp-${subport}
} elseif {${subport} eq "clang-${llvm_version}"} {
select.group clang
select.file ${filespath}/mp-${subport}
# CMAKE_LINKER is used to determine the value for HOST_LINK_VERSION
configure.args-append \
-DCMAKE_LINKER=${prefix}/bin/ld \
-DCLANG_INCLUDE_TESTS=OFF \
-DCLANG_ENABLE_STATIC_ANALYZER=OFF \
-DCLANG_ENABLE_ARCMT=OFF \
-DDARWIN_PREFER_PUBLIC_SDK=ON \
-DLLVM_BUILD_RUNTIME=ON \
-DLIBCXX_ENABLE_SHARED=OFF \
-DLIBCXX_INSTALL_LIBRARY=OFF
# TODO: libc++ shouldn't be built at all.
# https://llvm.org/bugs/show_bug.cgi?id=25666
if {${os.major} <= 13} {
# We unfortunately don't have an option to just turn off tsan
# https://llvm.org/bugs/show_bug.cgi?id=27715
configure.args-append \
-DCOMPILER_RT_BUILD_SANITIZERS=OFF
}
if {${os.major} <= 13} {
# libfuzzer uses TLS, fails on 10.9 and less
# possibly fixable, see https://trac.macports.org/ticket/58291
configure.args-append \
-DCOMPILER_RT_BUILD_LIBFUZZER=OFF
}
if {${os.major} <= 15} {
# XRAY uses TLS, MAP_ANONYMOUS, and clock_gettime, so disable it
# on systems that don't currently support these features
# see https://trac.macports.org/ticket/57130
# https://bugs.llvm.org/show_bug.cgi?id=38959
# https://bugs.llvm.org/show_bug.cgi?id=38958
configure.args-append \
-DCOMPILER_RT_BUILD_XRAY=OFF
}
} elseif {${subport} eq "lldb-${llvm_version}"} {
#select.group lldb
#select.file ${filespath}/mp-${subport}
configure.args-append \
-DLLDB_CODESIGN_IDENTITY=- \
-DCLANG_ENABLE_ARCMT=OFF \
-DCLANG_INCLUDE_TESTS=OFF \
-DCLANG_ENABLE_STATIC_ANALYZER=OFF \
-DLLVM_BUILD_RUNTIME=ON \
-DLIBCXX_ENABLE_SHARED=OFF \
-DLIBCXX_INSTALL_LIBRARY=OFF
}
# llvm-3.5 and later requires a C++11 runtime
# Xcode 4.3's clang (318.x) fails per https://trac.macports.org/ticket/44161
# Xcode 4.5's clang (421.11.66) fails due to http://llvm.org/bugs/show_bug.cgi?id=20184
# Xcode 4.6.3's clang (425.0.28) fails due to http://trac.macports.org/ticket/46897
# Xcode 4.6.3's clang (425.0.28) fails due to https://llvm.org/bugs/show_bug.cgi?id=30384
# Xcode 5.1's clang (clang-503.0.40) has codegen issues (resulting compiler crashes)
# Xcode 6.2's clang (600.0.57) fails due to https://llvm.org/bugs/show_bug.cgi?id=25753
compiler.blacklist *gcc* {clang < 602}
# clang older than 3.5 fail due to https://llvm.org/bugs/show_bug.cgi?id=25753
# new llvms build with clang-3.4 but have codegen issues resulting compiler crashes
compiler.blacklist-append macports-clang-3.3 macports-clang-3.4
# Override the normal compiler fallback list entirely since we have
# such specific requirements.
compiler.fallback clang
# 3.7 is already needed to bootstrap cmake, so is a good last resort
# when the system clang is too old.
if {${os.platform} eq "darwin" && ${os.major} < 18} {
compiler.fallback-append macports-clang-3.7
}
if {${subport} eq "lldb-${llvm_version}"} {
# Xcode 6.4's clang (602.0.53) fails to build lldb with 'thread-local storage is not supported for the current target'
compiler.blacklist-append {clang < 700}
}
# I'm not sure the exact version of Xcode that has a good enough libtool, but 3.2.6 seems to get past this when 3.1.4 doesn't:
# /Developer/usr/bin/libtool: for architecture x86_64 object: CMakeFiles/LLVMSupport.dir/PluginLoader.cpp.o malformed object (unknown load command 1)
# /Developer/usr/bin/libtool: for architecture: (null) file: CMakeFiles/LLVMSupport.dir/PluginLoader.cpp.o is not an object file (not allowed in a library)
# /Developer/usr/bin/libtool: for architecture i386 object: CMakeFiles/LLVMSupport.dir/PluginLoader.cpp.o malformed object (unknown load command 1)
if {[string match macports-clang-* ${configure.compiler}]} {
depends_build-append port:cctools
depends_skip_archcheck-append cctools
}
# Set CMAKE_LIBTOOL if we're using MacPorts-provided cctools
if {[lsearch -exact $PortInfo(depends_build) port:cctools] != -1} {
configure.args-append \
-DCMAKE_LIBTOOL=${prefix}/bin/libtool
}
# use the system python27 if present
if {${os.platform} eq "darwin" && ${os.major} >= 11} {
set pythonfullpath /usr/bin/python2.7
} else {
set pythonfullpath ${prefix}/bin/python2.7
depends_lib-append port:python27
}
configure.args-append -DPYTHON_EXECUTABLE=${pythonfullpath}
platform darwin {
# Note that we are forcing this choice. This means that anything linking
# against llvm-3.5 needs to also be using libc++. This is possibly
# problematic, but luckily there is just a limited set of such dependents.
configure.cxx_stdlib libc++
depends_lib-append port:libcxx
supported_archs i386 x86_64
pre-fetch {
if {![file exists /usr/lib/libc++.dylib]} {
ui_error "$name requires a C++11 runtime, which your configuration does not allow"
error "unsupported configuration"
}
}
}
variant universal {
post-extract {
# workaround a bug in Apple's shipped gcc driver-driver, patched in
# ours with driverdriver-num_infiles.patch
if {${configure.compiler} eq "gcc-4.0" ||
${configure.compiler} eq "gcc-4.2" ||
${configure.compiler} eq "llvm-gcc-4.2"} {
system "echo \"static int ___ignoreme;\" > ${worksrcpath}/tools/llvm-shlib/ignore.c"
}
}
}
variant assertions description "Enable assertions for error detection (has performance impacts, especially on JIT)" {
configure.args-delete -DLLVM_ENABLE_ASSERTIONS=OFF
configure.args-append -DLLVM_ENABLE_ASSERTIONS=ON
}
platform darwin {
if {[string match "*ppc*" [get_canonical_archs]]} {
# http://trac.macports.org/ticket/33987
configure.optflags -Os
}
if {${subport} eq "clang-${llvm_version}" && [vercmp $xcodeversion 5.0] < 0} {
# https://llvm.org/bugs/show_bug.cgi?id=13671
patchfiles-append leopard-no-asan.patch
configure.args-append -DCOMPILER_RT_BUILD_SANITIZERS=OFF
}
if {${subport} eq "clang-${llvm_version}" && ${os.major} <= 9} {
patchfiles-append leopard-no-blocks.patch
}
if {${subport} eq "clang-${llvm_version}" && ${os.major} <= 10} {
# the directorywatcher code in clang-9.0+ is 10.7+
# I believe this patch could be applied always, without a system test
patchfiles-append 5003-patch-no-directory-watcher-on-snowleopard.diff
# the libcxx installed by MacPorts on darwin 10 and less does not correspond to Apple's builtin libcxx
patchfiles-append 5005-MacPorts-only-patch-libcxx-includes-disable-availability-tests.diff
}
if {${subport} eq "clang-${llvm_version}" && ${os.major} <= 14} {
configure.args-append -DCLANG_ENABLE_CLANGD=OFF
}
if {${os.major} < 11} {
# Proxy for eliminating the dependency on native TLS
# http://trac.macports.org/ticket/46887
configure.args-append -DLLVM_ENABLE_BACKTRACES=OFF
# https://llvm.org/bugs/show_bug.cgi?id=25680
configure.cxxflags-append -U__STRICT_ANSI__
}
# https://llvm.org/bugs/show_bug.cgi?id=25674
configure.cxxflags-append -std=c++11
}
pre-fetch {
if {${subport} eq "lldb-${llvm_version}"} {
if {${os.platform} eq "darwin" && ${os.major} < 16} {
depends_build
depends_lib
depends_run
archive_sites
known_fail yes
pre-fetch {
ui_error "${subport} is not supported on this os version at present."
return -code error {unsupported platform}
}
}
}
}
post-extract {
# Get HTTP proxy arguments if required, assuming we can use the same proxy for all repositories
set proxy_args [portfetch::svn_proxy_args https://llvm.org/svn/llvm-project/cfe/trunk]
if {${subport} eq "llvm-${llvm_version}"} {
if {[variant_isset polly]} {
if {${worksrcdir} eq "trunk"} {
system -W ${worksrcpath}/tools "svn ${proxy_args} co -r ${svn.revision} https://llvm.org/svn/llvm-project/polly/trunk polly"
} elseif {${worksrcdir} eq "release_${llvm_version_no_dot}" } {
system -W ${worksrcpath}/tools "svn ${proxy_args} co -r ${svn.revision} https://llvm.org/svn/llvm-project/polly/branches/release_${llvm_version_no_dot} polly"
} else {
file rename ${workpath}/polly-${version}.src ${worksrcpath}/tools/polly
}
}
} elseif {${subport} eq "clang-${llvm_version}"} {
if {${worksrcdir} eq "trunk"} {
system -W ${worksrcpath}/tools "svn ${proxy_args} co -r ${svn.revision} https://llvm.org/svn/llvm-project/cfe/trunk clang"
system -W ${worksrcpath}/projects "svn ${proxy_args} co -r ${compiler_rt_rev} https://llvm.org/svn/llvm-project/compiler-rt/trunk compiler-rt"
system -W ${worksrcpath}/projects "svn ${proxy_args} co -r ${libcxx_rev} https://llvm.org/svn/llvm-project/libcxx/trunk libcxx"
system -W ${worksrcpath}/tools/clang/tools "svn ${proxy_args} co -r ${clang-modernize_rev} https://llvm.org/svn/llvm-project/clang-tools-extra/trunk extra"
} elseif {${worksrcdir} eq "release_${llvm_version_no_dot}" } {
system -W ${worksrcpath}/tools "svn ${proxy_args} co -r ${svn.revision} https://llvm.org/svn/llvm-project/cfe/branches/release_${llvm_version_no_dot} clang"
system -W ${worksrcpath}/projects "svn ${proxy_args} co -r ${compiler_rt_rev} https://llvm.org/svn/llvm-project/compiler-rt/branches/release_${llvm_version_no_dot} compiler-rt"
system -W ${worksrcpath}/projects "svn ${proxy_args} co -r ${libcxx_rev} https://llvm.org/svn/llvm-project/libcxx/branches/release_${llvm_version_no_dot} libcxx"
system -W ${worksrcpath}/tools/clang/tools "svn ${proxy_args} co -r ${clang-modernize_rev} https://llvm.org/svn/llvm-project/clang-tools-extra/branches/release_${llvm_version_no_dot} extra"
} else {
file rename ${workpath}/clang-${version}.src ${worksrcpath}/tools/clang
file rename ${workpath}/compiler-rt-${version}.src ${worksrcpath}/projects/compiler-rt
file rename ${workpath}/libcxx-${version}.src ${worksrcpath}/projects/libcxx
file rename ${workpath}/clang-tools-extra-${version}.src ${worksrcpath}/tools/clang/tools/extra
}
} elseif {${subport} eq "lldb-${llvm_version}"} {
if {${worksrcdir} eq "trunk"} {
system -W ${worksrcpath}/tools "svn ${proxy_args} co -r ${svn.revision} https://llvm.org/svn/llvm-project/cfe/trunk clang"
system -W ${worksrcpath}/tools "svn ${proxy_args} co -r ${svn.revision} https://llvm.org/svn/llvm-project/lldb/trunk lldb"
} elseif {${worksrcdir} eq "release_${llvm_version_no_dot}" } {
system -W ${worksrcpath}/tools "svn ${proxy_args} co -r ${svn.revision} https://llvm.org/svn/llvm-project/cfe/branches/release_${llvm_version_no_dot} clang"
system -W ${worksrcpath}/tools "svn ${proxy_args} co -r ${svn.revision} https://llvm.org/svn/llvm-project/lldb/branches/release_${llvm_version_no_dot} lldb"
} else {
file rename ${workpath}/clang-${version}.src ${worksrcpath}/tools/clang
file rename ${workpath}/lldb-${version}.src ${worksrcpath}/tools/lldb
}
}
}
if {${subport} eq "clang-${llvm_version}"} {
destroot {
system "cd ${destroot.dir}/tools/clang && ${destroot.cmd} ${destroot.pre_args} ${destroot.target} ${destroot.post_args}"
system "cd ${destroot.dir}/projects/compiler-rt && ${destroot.cmd} ${destroot.pre_args} ${destroot.target} ${destroot.post_args}"
system "cd ${destroot.dir}/projects/libcxx && ${destroot.cmd} ${destroot.pre_args} ${destroot.target} ${destroot.post_args}"
delete ${destroot}${sub_prefix}/bin/clang
file rename ${destroot}${sub_prefix}/bin/clang-${clang_executable_version} ${destroot}${sub_prefix}/bin/clang
reinplace "s|/bin/clang-${clang_executable_version}|/bin/clang|g" \
"${destroot}${sub_prefix}/lib/cmake/clang/ClangTargets-release.cmake"
}
}
if {${subport} eq "lldb-${llvm_version}"} {
post-patch {
reinplace "s|@@PREFIX@@|${prefix}|" \
${worksrcpath}/tools/clang/lib/Driver/ToolChains/Clang.cpp \
${worksrcpath}/tools/clang/lib/Driver/ToolChains/CommonArgs.cpp
reinplace "s|@CLANG_FORMAT_PATH@|${prefix}/bin/clang-format-${suffix}|g" \
${worksrcpath}/tools/clang/tools/clang-format/clang-format-bbedit.applescript \
${worksrcpath}/tools/clang/tools/clang-format/clang-format-diff.py \
${worksrcpath}/tools/clang/tools/clang-format/clang-format-sublime.py \
${worksrcpath}/tools/clang/tools/clang-format/clang-format.el \
${worksrcpath}/tools/clang/tools/clang-format/clang-format.py
}
build.dir ${build.dir}/tools/lldb
post-activate {
ui_msg "Please follow the instructions at https://lldb.llvm.org/resources/build.html#code-signing-on-macos and then codesign lldb-server with:"
if {${os.major} >= 13} {
ui_msg " sudo codesign --force --deep --preserve-metadata=identifier,entitlements,resource-rules,requirements,flags,team-identifier --sign <identity> ${sub_prefix}/bin/lldb-server"
} else {
ui_msg " sudo codesign --force --deep --preserve-metadata=identifier,entitlements,resource-rules,requirements --sign <identity> ${sub_prefix}/bin/lldb-server"
}
}
}
post-destroot {
foreach bin [glob ${destroot}${sub_prefix}/bin/*] {
set bin_filename [string map "${sub_prefix} ${prefix}" ${bin}]-${suffix}
set exec_path [string map "${destroot}${sub_prefix} ${sub_prefix}" ${bin}]
# see https://trac.macports.org/ticket/54985
if {${os.platform} eq "darwin" && [vercmp ${xcodeversion} 4.6] < 0} {
xinstall -m 755 "${filespath}/llvm-bin-compat" "${bin_filename}"
} else {
xinstall -m 755 "${filespath}/llvm-bin" "${bin_filename}"
}
reinplace "s:EXEC_PATH:${exec_path}:" "${bin_filename}"
}
if {${subport} eq "llvm-${llvm_version}"} {
# r156389 (a5d2435409858728970202226d0bbbee508fe408) temporarilary removed llvm man pages
#foreach man [glob ${destroot}${sub_prefix}/share/man/man1/*.1] {
# set basename [string map "${destroot}${sub_prefix}/share/man/man1/ {}" ${man}]
# file rename ${man} ${destroot}${prefix}/share/man/man1/[string map ".1 -${suffix}.1" ${basename}]
#}
# https://llvm.org/bugs/show_bug.cgi?id=19465
if {[variant_isset polly]} {
ln -s LLVMPolly.so ${destroot}${sub_prefix}/lib/LLVMPolly.dylib
}
} elseif {${subport} eq "clang-${llvm_version}"} {
system "ditto ${worksrcpath}/projects/libcxx/include ${destroot}${sub_prefix}/lib/c++/v1"
# http://trac.macports.org/ticket/33207
ln -s ${prefix}/libexec/ld64/ld ${destroot}${sub_prefix}/bin/ld
} elseif {${subport} eq "lldb-${llvm_version}"} {
delete ${destroot}${prefix}/bin/debugserver-${suffix}
}
}
if {${os.major} < 11} {
variant emulated_tls description { enable c11/c++11 thread support on older systems using emulated-tls } {
# use emulated-tls to support thread_local on systems prior to 10.7
# requires linking against macports-libstdc++ or libc++ / libc++abi with cxa_thread_atexit
# the test for default emulated-tls has been moved into the backend
# this patch is needed for llvm and clang builds
patchfiles-append \
9000-patch-llvm-7.0-support-emulated-tls.diff
if {${subport} eq "clang-${llvm_version}"} {
patchfiles-append \
9000-patch-clang-7.0-support-emulated-tls.diff
}
}
default_variants-append +emulated_tls
}
if {${subport} eq "llvm-${llvm_version}"} {
variant polly description {Provide the polly polyhedral optimizer} {}
# Unless upstream reverts to their old OCaml detection mechanism,
# this variant will be broken until #46161 is resolved.
variant ocaml description {Enable generation of OCaml binding} {
depends_lib-append port:ocaml
configure.args-delete -DLLVM_BINDINGS_LIST=none
configure.args-append -DLLVM_BINDINGS_LIST=ocaml
destroot.args-append OVERRIDE_libdir=${sub_prefix}/lib
}
} elseif {${subport} eq "clang-${llvm_version}"} {
if {[variant_isset assertions]} {
# Need to match llvm +-assertions
require_active_variants port:llvm-${llvm_version} assertions
} else {
# Need to match llvm +-assertions
require_active_variants port:llvm-${llvm_version} {} assertions
}
variant analyzer description {Install clang static analyzer} {
# these have to be switched on or off together
configure.args-replace -DCLANG_ENABLE_STATIC_ANALYZER=OFF \
-DCLANG_ENABLE_STATIC_ANALYZER=ON
configure.args-replace -DCLANG_ENABLE_ARCMT=OFF \
-DCLANG_ENABLE_ARCMT=ON
depends_run-append port:perl5
post-patch {
reinplace "s|/usr/bin/env perl|${prefix}/bin/perl5|g" \
${worksrcpath}/tools/clang/tools/scan-build/libexec/ccc-analyzer \
${worksrcpath}/tools/clang/tools/scan-build/libexec/c++-analyzer \
${worksrcpath}/tools/clang/tools/scan-build/bin/scan-build
reinplace "s|/usr/bin/env python|${pythonfullpath}|g" \
${worksrcpath}/tools/clang/tools/scan-build/bin/set-xcode-analyzer \
${worksrcpath}/tools/clang/tools/scan-view/bin/scan-view
}
}
if { ${cxx_stdlib} eq "libc++" && ${os.major} < 13 } {
variant defaultlibcxx description {default to -stdlib=libc++ if not otherwise specified} {
# on systems older than darwin 13, if macports.conf is configured to stdlib=libc++
# then make that the default if not otherwise specified. This matches the behaviour of newer systems.
patchfiles-append 9003-patch-clang-7.0-default-to-libcxx-on-all-systems.diff
}
default_variants-append +defaultlibcxx
}
variant libstdcxx description {-stdlib=macports-libstdc++ searches for MacPorts libstdc++} {
patchfiles-append 9001-macports-libstdcxx.diff
post-patch {
reinplace "s|@@MACPORTS_GCC_INCLUDE_DIR@@|${prefix}/include/gcc/c++|g" \
${worksrcpath}/tools/clang/lib/Frontend/InitHeaderSearch.cpp \
${worksrcpath}/tools/clang/lib/Driver/ToolChains/Darwin.cpp
reinplace "s|@@MACPORTS_HOST_NAME@@|${build_arch}-apple-darwin${os.major}|g" \
${worksrcpath}/tools/clang/lib/Driver/ToolChains/Darwin.cpp
reinplace "s|@@MACPORTS_libstdc++@@|${prefix}/lib/libgcc/libstdc++.6.dylib|g" \
${worksrcpath}/tools/clang/lib/Driver/ToolChains/Darwin.cpp
# GCC was built for ${build_arch}-apple-darwin${os.major}
# if GCC was also built universal, it has an extra include directory
# if ${build_arch} is 32-bit, there is an extra 64-bit subdirectory
# if ${build_arch} is 64-bit, there is an extra 32-bit subdirectory
# MacPorts GCC can not compile across platforms
switch ${build_arch} {
x86_64 {
set gcc_subdirectory_ppc ""
set gcc_subdirectory_ppc64 "ppc64"
set gcc_subdirectory_i386 "i386"
set gcc_subdirectory_x86_64 ""
}
i386 {
set gcc_subdirectory_ppc ""
set gcc_subdirectory_ppc64 "ppc64"
set gcc_subdirectory_i386 ""
set gcc_subdirectory_x86_64 "x86_64"
}
ppc64 {
set gcc_subdirectory_ppc "ppc"
set gcc_subdirectory_ppc64 ""
set gcc_subdirectory_i386 ""
set gcc_subdirectory_x86_64 "x86_64"
}
ppc {
set gcc_subdirectory_ppc ""
set gcc_subdirectory_ppc64 "ppc64"
set gcc_subdirectory_i386 ""
set gcc_subdirectory_x86_64 "x86_64"
}
}
reinplace "s|@@MACPORTS_GCC_SUBDIRECTORY_x86_64@@|${gcc_subdirectory_x86_64}|g" \
${worksrcpath}/tools/clang/lib/Driver/ToolChains/Darwin.cpp
reinplace "s|@@MACPORTS_GCC_SUBDIRECTORY_i386@@|${gcc_subdirectory_i386}|g" \
${worksrcpath}/tools/clang/lib/Driver/ToolChains/Darwin.cpp
reinplace "s|@@MACPORTS_GCC_SUBDIRECTORY_ppc64@@|${gcc_subdirectory_ppc64}|g" \
${worksrcpath}/tools/clang/lib/Driver/ToolChains/Darwin.cpp
reinplace "s|@@MACPORTS_GCC_SUBDIRECTORY_ppc@@|${gcc_subdirectory_ppc}|g" \
${worksrcpath}/tools/clang/lib/Driver/ToolChains/Darwin.cpp
}
}
default_variants-append +libstdcxx
post-patch {
reinplace "s|@@PREFIX@@|${prefix}|" \
${worksrcpath}/tools/clang/lib/Driver/ToolChains/Clang.cpp \
${worksrcpath}/tools/clang/lib/Driver/ToolChains/CommonArgs.cpp
reinplace "s|@CLANG_FORMAT_PATH@|${prefix}/bin/clang-format-${suffix}|g" \
${worksrcpath}/tools/clang/tools/clang-format/clang-format-bbedit.applescript \
${worksrcpath}/tools/clang/tools/clang-format/clang-format-diff.py \
${worksrcpath}/tools/clang/tools/clang-format/clang-format-sublime.py \
${worksrcpath}/tools/clang/tools/clang-format/clang-format.el \
${worksrcpath}/tools/clang/tools/clang-format/clang-format.py
}
post-destroot {
file mkdir ${destroot}${sub_prefix}/libexec
file copy ${worksrcpath}/tools/clang/tools/clang-format ${destroot}${sub_prefix}/libexec/clang-format
file delete -force ${destroot}${sub_prefix}/libexec/clang-format/.svn
file delete -force ${destroot}${sub_prefix}/libexec/clang-format/Makefile
file delete -force ${destroot}${sub_prefix}/libexec/clang-format/Release+Debug+Asserts
file delete -force ${destroot}${sub_prefix}/libexec/clang-format/CMakeLists.txt
file delete -force ${destroot}${sub_prefix}/libexec/clang-format/ClangFormat.cpp
}
}
livecheck.type none