Files
Joshua Root 5b981e1cc8 spirv-llvm-translator-22: clear patchfiles correctly
Previously this was setting one patchfile with the empty string as the
filename.
2026-06-26 19:36:30 +10:00

612 lines
26 KiB
Tcl

# -*- 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
PortSystem 1.0
PortGroup active_variants 1.1
PortGroup cmake 1.1
PortGroup legacysupport 1.1
PortGroup conflicts_build 1.0
# Do not propagate c/c++ standards as set by base
cmake.set_c_standard no
cmake.set_cxx_standard no
# link legacysupport statically for compilers
legacysupport.use_static yes
# Sysconf wrapping causes issues so disable
legacysupport.disable_function_wrap yes
categories lang
platforms {darwin >= 16}
license NCSA
maintainers nomaintainer
set llvm_version 22
set clang_exe_version ${llvm_version}
version ${llvm_version}.1.8
name llvm-${llvm_version}
revision 0
subport mlir-${llvm_version} { revision 0 }
subport clang-${llvm_version} { revision 0 }
subport lldb-${llvm_version} { revision 0 }
subport flang-${llvm_version} { revision 0 }
subport libclc-${llvm_version} { revision 0 }
master_sites https://github.com/llvm/llvm-project/releases/download/llvmorg-${version}
distname llvm-project-${version}.src
use_xz yes
checksums ${distname}${extract.suffix} \
rmd160 41c884bbc716222fdef373d28eb41fcf014cf62b \
sha256 922f1817a0df7b1489272d18134ee0087a8b068828f87ac63b9861b1a9965888 \
size 167061596
dist_subdir llvm
set suffix mp-${llvm_version}
set sub_prefix ${prefix}/libexec/llvm-${llvm_version}
worksrcdir ${worksrcdir}/llvm
# https://github.com/macports/macports-ports/commit/a83a493bc21cbe7e14b1f5884379649ec8f31bae#commitcomment-132530885
conflicts_build-append libunwind libunwind-headers
# hand-tweaked, approximately c++ standard 2017
compiler.blacklist *gcc* {clang < 1001} macports-clang-3.*
# work/build/include/c++/v1/optional:224:5: error: destructor cannot be marked constexpr
# _LIBCPP_CONSTEXPR_AFTER_CXX17 ~__optional_destruct_base()
compiler.blacklist-append {clang < 1204} {macports-clang-[5-9].0} {macports-clang-1[0-3]}
if {${os.major} >= 17 || ${os.platform} ne "darwin"} {
compiler.fallback clang macports-clang-17
} else {
compiler.fallback clang macports-clang-16
}
cmake.generator Ninja
cmake.install_prefix ${sub_prefix}
cmake.build_type Release
configure.pre_args-replace \
-DCMAKE_BUILD_WITH_INSTALL_RPATH:BOOL=ON \
-DCMAKE_BUILD_WITH_INSTALL_RPATH:BOOL=OFF
configure.pre_args-replace \
-DCMAKE_SYSTEM_PREFIX_PATH="${prefix}\;${cmake.install_prefix}\;/usr" \
-DCMAKE_SYSTEM_PREFIX_PATH="${cmake.install_prefix}\;${prefix}\;/usr"
configure.args-append \
-DLLVM_LINK_LLVM_DYLIB=ON \
-DLLVM_NO_INSTALL_NAME_DIR_FOR_BUILD_TREE=ON \
-DLLVM_ENABLE_RTTI=ON \
-DLLVM_INCLUDE_TESTS=OFF \
-DLLVM_INCLUDE_EXAMPLES=OFF \
-DLLVM_ENABLE_FFI=ON \
-DFFI_INCLUDE_DIR=${prefix}/include \
-DFFI_LIBRARY_DIR=${prefix}/lib \
-DLLVM_ENABLE_BINDINGS=OFF
# Remove for now. See https://trac.macports.org/ticket/70333
# Probably need to detect when Xcode is available
# -DLLVM_CREATE_XCODE_TOOLCHAIN=ON
# Disable iOS support
# To Be reviewed with later versions
# https://reviews.llvm.org/D133273
configure.args-append -DCOMPILER_RT_ENABLE_IOS=OFF
# work around universal i386 SIMD issue with blake3
# https://trac.macports.org/ticket/71694
if {${universal_possible} && [variant_isset universal]} {
if {"i386" in ${configure.universal_archs}} {
configure.args-append -DLLVM_DISABLE_ASSEMBLY_FILES=ON
}
}
# cctools is needed to handle objects from newer clang toolchains
if {[string match macports-clang-* ${configure.compiler}]} {
depends_build-append port:cctools
depends_skip_archcheck-append cctools
configure.args-append -DCMAKE_LIBTOOL=${prefix}/bin/libtool
}
set py_ver 3.14
set py_ver_nodot [string map {. {}} ${py_ver}]
depends_build-append port:python${py_ver_nodot} \
port:py${py_ver_nodot}-pygments \
port:py${py_ver_nodot}-yaml
set pythonfullpath ${prefix}/bin/python${py_ver}
configure.args-append -DPython3_EXECUTABLE=${pythonfullpath}
platform darwin {
configure.cxx_stdlib libc++
depends_lib-append port:libcxx
}
patch.dir ${workpath}/${distname}
patch.pre_args-replace -p0 -p1
patchfiles-append \
0001-MacPorts-only-clang-use-MP-omp-locations.patch \
0002-MacPorts-Only-Don-t-embed-the-deployment-target-in-t.patch \
0003-MacPorts-Only-Prepare-clang-format-for-replacement-w.patch \
0004-MacPorts-Only-Fix-name-of-scan-view-executable-insid.patch \
0006-Define-EXC_MASK_CRASH-and-MACH_EXCEPTION_CODES-if-th.patch \
0007-Threading-Only-call-pthread_setname_np-if-we-have-it.patch \
0008-Threading-Only-call-setpriority-PRIO_DARWIN_THREAD-0.patch \
0009-lib-Support-Unix-Path.inc-define-COPYFILE_CLONE-if-n.patch \
0012-compiler-rt-add-some-defs-missing-in-older-SDKs.patch \
0019-10.6-and-less-use-emulated-TLS-before-10.7.patch \
0025-lldb-add-defines-needed-for-older-SDKs.patch \
0032-Add-Missing-Fortran-Features-includes.patch \
0035-define-KERN_DENIED-when-missing.patch \
0036-no-rpath.patch \
1234-stop-on-linker-error.patch
if {${os.platform} eq "darwin" && ${os.major} < 14} {
patchfiles-append 0016-10.10-and-less-compiler-rt-find-macosx-sdk.patch
}
if {${os.platform} eq "darwin" && ${os.major} < 16} {
# error: 'TARGET_OS_OSX' is not defined, evaluates to 0 [-Werror,-Wundef-prefix=TARGET_OS_]
patchfiles-append 0100-define-target-os-osx.patch
}
if {${os.platform} eq "darwin" && ${os.major} < 16} {
# Avoid attempts to use 'clonefile'
# llvm/lib/Support/Unix/Path.inc:1476:10: error: use of undeclared identifier 'clonefile'
patchfiles-append 0031-Avoid-Use-Of-Clonefile.patch
}
if {${os.platform} eq "darwin" && ${os.major} < 14} {
# Revert use of pthread/qos.h that is only available on macOS10.10 and newer
# https://trac.macports.org/ticket/65626#comment:5
# Created by reverting the commit
# https://github.com/llvm/llvm-project/commit/9902a0945d22cd5757b16ebe85fe07059723aa09
# > git revert 9902a0945d22cd5757b16ebe85fe07059723aa09
patchfiles-append 0110-Avoid-Pthread-QOS.patch
}
if {${os.platform} eq "darwin" && ${os.major} < 12} {
# On OSX10.7 and older revert call to add_security_warnings as fails with
# add_security_warnings Function invoked with incorrect arguments
post-patch {
reinplace "s|add_security_warnings\(|\#add_security_warnings\(|" \
${patch.dir}/compiler-rt/lib/builtins/CMakeLists.txt \
${patch.dir}/compiler-rt/cmake/Modules/CompilerRTDarwinUtils.cmake
}
}
if {${os.platform} eq "darwin" && ${os.major} <= 16} {
# error: 'utimensat' is only available on macOS 10.13 or newer
patchfiles-append 0041-no-Werror-unguarded-availability-new.patch
}
if {${os.platform} eq "darwin" && ${os.major} < 19} {
# https://trac.macports.org/ticket/68522
# Undefined symbols for architecture x86_64:
# "__availability_version_check", referenced from:
# ___isPlatformVersionAtLeast in libclang_rt.osx.a(os_version_check.c.o)
# __initializeAvailabilityCheck in libclang_rt.osx.a(os_version_check.c.o)
# Upstream discussion at https://reviews.llvm.org/D150397
patchfiles-append 0130-10.14-and-less-availability.patch
}
if {${os.platform} eq "darwin" && ${os.major} <= 16} {
# https://github.com/llvm/llvm-project/issues/64226
patchfiles-append 0042-mbstate_t-not-defined.patch
}
post-patch {
if {${subport} ne "spirv-llvm-translator-${llvm_version}"} {
reinplace "s|@@PREFIX@@|${prefix}|" \
${patch.dir}/clang/lib/Driver/ToolChains/Clang.cpp \
${patch.dir}/clang/lib/Driver/ToolChains/CommonArgs.cpp
reinplace "s|@CLANG_FORMAT_PATH@|${prefix}/bin/clang-format-${suffix}|g" \
${patch.dir}/clang/tools/clang-format/clang-format-bbedit.applescript \
${patch.dir}/clang/tools/clang-format/clang-format-diff.py \
${patch.dir}/clang/tools/clang-format/clang-format-sublime.py \
${patch.dir}/clang/tools/clang-format/clang-format.el \
${patch.dir}/clang/tools/clang-format/clang-format.py
}
}
livecheck.type regex
livecheck.url https://github.com/llvm/llvm-project/tags
livecheck.regex llvmorg-([quotemeta ${llvm_version}.]\[\\d.\]+)\\.tar\\.gz
# libc++ link step fails on OSX10.10 and older to correctly use static legacy support lib.
if {${os.platform} eq "darwin" && ${os.major} <= [option legacysupport.newest_darwin_requires_legacy] } {
post-patch {
reinplace "s|LIBCXX_LIBRARIES \"\"|LIBCXX_LIBRARIES \"[legacysupport::get_library_link_flags]\"|" ${patch.dir}/libcxx/CMakeLists.txt
}
}
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-append port:libedit port:libffi port:libxml2 \
port:zlib port:zstd
depends_run-append port:llvm_select-${llvm_version}
configure.args-append \
-DLLVM_ENABLE_PROJECTS="polly"
}
if {${subport} eq "mlir-${llvm_version}"} {
homepage https://mlir.llvm.org
description The MLIR project is a novel approach to building reusable \
and extensible compiler infrastructure.
long_description {*}${description} MLIR aims to address software fragmentation, \
improve compilation for heterogeneous hardware, significantly \
reduce the cost of building domain specific compilers, and aid \
in connecting existing compilers together.
depends_lib-append port:llvm-${llvm_version} port:zlib port:zstd
configure.args-append \
-DLLVM_ENABLE_PROJECTS="mlir"
}
if { ${subport} eq "clang-${llvm_version}" } {
homepage https://clang.llvm.org/
description C, C++, Objective C and Objective C++ compiler
long_description The Clang project provides a language front-end and tooling infrastructure \
for languages in the C language family (C, C++, Objective C/C++, OpenCL, \
CUDA, and RenderScript) for the LLVM project.
depends_lib-append port:zlib port:zstd
depends_run-append port:clang_select-${llvm_version} port:cctools
platforms {darwin >= 19}
configure.args-append \
-DLLVM_ENABLE_PROJECTS="clang\;clang-tools-extra\;lld" \
-DLLVM_ENABLE_RUNTIMES="libcxx\;libcxxabi\;libunwind\;compiler-rt" \
-DLIBCXX_ENABLE_SHARED=ON \
-DLIBCXX_INSTALL_LIBRARY=ON \
-DLIBCXX_INSTALL_LIBRARY_DIR=${sub_prefix}/lib/libc++ \
-DLIBCXXABI_INSTALL_LIBRARY_DIR=${sub_prefix}/lib/libc++ \
-DLIBUNWIND_INSTALL_LIBRARY_DIR=${sub_prefix}/lib/libunwind
# https://github.com/llvm/llvm-project/issues/155531
# https://github.com/llvm/llvm-project/issues/155606
configure.args-append \
-DLIBCXX_ENABLE_VENDOR_AVAILABILITY_ANNOTATIONS=ON
}
if { ${subport} eq "flang-${llvm_version}" } {
homepage https://flang.llvm.org/
description LLVM Fortran compiler
long_description {*}${description}
# https://trac.macports.org/ticket/72156
platforms {darwin >= 21}
# CMakeLists.txt: flang isn't supported on 32 bit CPUs
supported_archs arm64 x86_64
configure.args-append \
-DLLVM_ENABLE_PROJECTS="clang\;flang\;mlir" \
-DLLVM_ENABLE_RUNTIMES="compiler-rt" \
-DLIBCXX_ENABLE_SHARED=OFF \
-DLIBCXX_INSTALL_LIBRARY=OFF
depends_lib-append port:clang-${llvm_version} port:mlir-${llvm_version}
# https://trac.macports.org/ticket/72931
build.mem_per_job 3072
}
if { ${subport} eq "clang-${llvm_version}" || ${subport} eq "flang-${llvm_version}" } {
depends_lib-append port:ld64 port:libomp port:llvm-${llvm_version}
depends_skip_archcheck-append ld64
# 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
# the orc submodule is not building at present - can't find c_api.h
# https://trac.macports.org/ticket/65578
configure.args-append -DCOMPILER_RT_BUILD_ORC=OFF
if {${os.platform} eq "darwin" && ${os.major} <= 18} {
# on systems that might build i386, we need atomic builtins
# https://trac.macports.org/ticket/58712
configure.args-append -DCOMPILER_RT_EXCLUDE_ATOMIC_BUILTIN=OFF
}
if {${os.platform} eq "darwin" && ${os.major} <= 14} {
# compiler-rt does a broad search for an SDK it likes, but this
# search fails on older systems that don't have a MacOSX.sdk
# TODO: apply this always to all systems?
if {${configure.sdkroot} eq ""} {set configure.sdkroot "/"}
configure.args-append -DDARWIN_osx_SYSROOT="${configure.sdkroot}"
}
if {${os.platform} eq "darwin" && ${os.major} <= 17} {
# sanitizers in compiler_rt fail to build on older systems
# might be fixable with the use of newer SDK and/or effort if motivated
# all three toggles are needed to force them off
# Extended to 10.11 and older, see https://trac.macports.org/ticket/65887
# Extend to 10.13 and older, see https://trac.macports.org/ticket/72150
configure.args-append -DCOMPILER_RT_BUILD_SANITIZERS=OFF \
-DCOMPILER_RT_BUILD_XRAY=OFF \
-DCOMPILER_RT_BUILD_MEMPROF=OFF
}
if {${os.platform} eq "darwin" && ${os.major} <= 11} {
# xpc.h available 10.7 but doesn't support nullable features
configure.args-append -DCLANGD_BUILD_XPC=OFF
}
}
if {${subport} eq "lldb-${llvm_version}"} {
homepage https://lldb.llvm.org/
description the LLVM debugger
long_description lldb is the "LLVM native" debugger.
depends_lib-append port:libedit port:libxml2 port:ncurses port:python${py_ver_nodot} port:xz port:zlib
depends_lib-append port:llvm-${llvm_version} port:clang-${llvm_version}
depends_build-append port:swig-python path:bin/doxygen:doxygen
depends_run-append port:lldb_select-${llvm_version}
# error: use of undeclared identifier 'CPU_SUBTYPE_ARM64E
platforms {darwin >= 18}
configure.args-append \
-DLLDB_CODESIGN_IDENTITY=- \
-DLLDB_ENABLE_LUA=OFF
set worksrcpath ${workpath}/${distname}/lldb
notes "Please follow the instructions at https://lldb.llvm.org/resources/build.html#code-signing-on-macos and then codesign lldb-server with:\n--------------------\n"
notes-append "${sub_prefix}/scripts/lldb/macos-setup-codesign.sh"
if {${os.major} >= 13} {
notes-append "sudo codesign --force --deep --preserve-metadata=identifier,entitlements,resource-rules,requirements,flags,team-identifier --sign lldb_codesign ${sub_prefix}/bin/lldb-server"
} else {
notes-append "sudo codesign --force --deep --preserve-metadata=identifier,entitlements,resource-rules,requirements --sign lldb_codesign ${sub_prefix}/bin/lldb-server"
}
}
if {${subport} eq "libclc-${llvm_version}"} {
homepage https://libclc.llvm.org/
description OpenCL library
long_description libclc is an implementation of the library requirements \
of the OpenCL C programming language
depends_build-append \
port:llvm-${llvm_version} \
port:clang-${llvm_version} \
port:spirv-llvm-translator-${llvm_version}
worksrcdir ${distname}/libclc
}
subport spirv-llvm-translator-${llvm_version} {
version ${llvm_version}.1.3
revision 0
homepage https://github.com/KhronosGroup/SPIRV-LLVM-Translator
description LLVM/SPIR-V Bi-Directional Translator
long_description A library and tool for translation between LLVM IR and \
SPIR-V.
master_sites-append https://github.com/KhronosGroup/SPIRV-LLVM-Translator/archive/v${version}
set dist SPIRV-LLVM-Translator-${version}
distfiles-append $dist.tar.gz
checksums-append $dist.tar.gz \
rmd160 eae29f2f1902f5b8134f52fe52251d4ed857e76f \
sha256 8d3d5c31c1ff355dbbf87046f1b94cd1ab5390439a817679ec71484df74cac18 \
size 1871217
# Bundle the SPIRV-Headers commit required by this translator version;
# it postdates all released SPIRV-Headers tags.
set spirv_headers_commit b8a32968473ce852a809b9de5f04f02a5a9dfa78
master_sites-append https://github.com/KhronosGroup/SPIRV-Headers/archive/:spirv_headers
distfiles-append ${spirv_headers_commit}.tar.gz:spirv_headers
checksums-append ${spirv_headers_commit}.tar.gz \
rmd160 6ff3b44d75ad4deace3898adaeba644fc5b05f8c \
sha256 ac53436ab612fbc6e294c775a5031f5a6710ec10bb536dea333fb10c30ea24c3 \
size 566287
depends_build-append \
port:spirv-tools
depends_lib-append \
port:llvm-${llvm_version}
# Build standalone against installed llvm-${llvm_version}; skip the large
# LLVM source tarball and the LLVM-specific patches.
# SPIRV-LLVM-Translator uses RULE_LAUNCH_COMPILE to embed ccache in ninja
# rules directly; disable it via the upstream cmake variable.
configure.args-append \
-DCCACHE_ALLOWED=OFF
extract.cmd gzip
extract.only ${dist}.tar.gz ${spirv_headers_commit}.tar.gz
patchfiles
worksrcdir ${dist}
configure.args-append -DLLVM_SPIRV_INCLUDE_TESTS=OFF \
-DLLVM_EXTERNAL_SPIRV_HEADERS_SOURCE_DIR=${workpath}/SPIRV-Headers-${spirv_headers_commit}
build.target llvm-spirv
livecheck.url ${homepage}/tags
livecheck.regex v([quotemeta ${llvm_version}.]\[\\d.\]+)\\.tar\\.gz
}
variant tests description {Enable building of test code} {
depends_test-append port:py${py_ver_nodot}-psutil
test.run yes
configure.args-append -DLLVM_INCLUDE_TESTS=ON
test.target check
if {${subport} eq "clang-${llvm_version}"} {
test.target check-all
}
if {${subport} eq "lldb-${llvm_version}"} {
pre-fetch {
ui_error "running the test suite on ${subport} is not supported on this os version at present."
return -code error {unsupported platform}
}
}
}
post-destroot {
if {[file exists ${destroot}${sub_prefix}/bin/clang]} {
# remove the clang symlink and replace it with the actual binary
delete ${destroot}${sub_prefix}/bin/clang
file rename ${destroot}${sub_prefix}/bin/clang-${clang_exe_version} ${destroot}${sub_prefix}/bin/clang
}
# If only 'flang-new' created, link to 'flang'
if {[file exists ${destroot}${sub_prefix}/bin/flang-new]} {
if {![file exists ${destroot}${sub_prefix}/bin/flang]} {
file rename ${sub_prefix}/bin/flang-new ${destroot}${sub_prefix}/bin/flang
} else {
file delete ${destroot}${sub_prefix}/bin/flang-new
}
}
# Move flang-N to flang
if {[file exists ${destroot}${sub_prefix}/bin/flang-${llvm_version}]} {
file delete ${destroot}${sub_prefix}/bin/flang
file rename ${destroot}${sub_prefix}/bin/flang-${llvm_version} ${destroot}${sub_prefix}/bin/flang
}
# generate a versioned wrapper script for each file in the bin directory
foreach bin [glob -nocomplain ${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}"} {
# https://llvm.org/bugs/show_bug.cgi?id=19465
ln -s LLVMPolly.so ${destroot}${sub_prefix}/lib/LLVMPolly.dylib
}
if {[file exists ${destroot}${sub_prefix}/lib/cmake/clang/ClangTargets-release.cmake]} {
# fix the cmake scripts to point to the versioned files
reinplace "s|/bin/clang-${clang_exe_version}|/bin/clang|g" \
"${destroot}${sub_prefix}/lib/cmake/clang/ClangTargets-release.cmake"
}
if { ${subport} eq "clang-${llvm_version}" || ${subport} eq "flang-${llvm_version}" } {
# http://trac.macports.org/ticket/33207
ln -s ${prefix}/libexec/ld64/ld ${destroot}${sub_prefix}/bin/ld
}
if {${subport} eq "lldb-${llvm_version}"} {
delete ${destroot}${prefix}/bin/debugserver-${suffix}
set lldb_scripts_srcdir ${worksrcpath}/scripts
set lldb_scripts_destdir ${destroot}${sub_prefix}/scripts/lldb
xinstall -d ${lldb_scripts_destdir}
xinstall -m 755 -W ${lldb_scripts_srcdir} \
macos-setup-codesign.sh \
${lldb_scripts_destdir}
}
if {${subport} ne "llvm-${llvm_version}"} {
# Need to deactivate current version before traversing destroot to remove
# 'already installed' files
if {![catch {set installed [lindex [registry_active ${subport}] 0]}]} {
registry_deactivate_composite ${subport} "" [list ports_nodepcheck 1]
}
# Then search for files in destroot provided by other local (sub)ports deps and remove
fs-traverse destroot_f ${destroot} {
if {![file isdirectory $destroot_f]} {
set f [string replace $destroot_f 0 [string length $destroot]-1]
if {[file exists ${f}]} {
ui_debug "${f} already exists -> Removed from destroot"
file delete ${destroot_f}
}
}
}
}
}
if {${subport} eq "clang-${llvm_version}"} {
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" \
${patch.dir}/clang/tools/scan-build/libexec/ccc-analyzer \
${patch.dir}/clang/tools/scan-build/libexec/c++-analyzer \
${patch.dir}/clang/tools/scan-build/bin/scan-build
}
}
# Avoid requiring a bootstrap version of perl5 on 10.6.
if {${os.major} >= 11} {
default_variants +analyzer
}
variant libstdcxx description {-stdlib=libstdc++_macports searches for MacPorts libstdc++} {
patchfiles-append 0005-clang-support-macports-libstdcxx.patch
post-patch {
reinplace "s|@@MACPORTS_GCC_INCLUDE_DIR@@|${prefix}/include/gcc/c++|g" \
${patch.dir}/clang/lib/Lex/InitHeaderSearch.cpp \
${patch.dir}/clang/lib/Driver/ToolChains/Darwin.cpp
reinplace "s|@@MACPORTS_HOST_NAME@@|${configure.build_arch}-apple-darwin${os.major}|g" \
${patch.dir}/clang/lib/Driver/ToolChains/Darwin.cpp
reinplace "s|@@MACPORTS_libstdc++@@|${prefix}/lib/libgcc/libstdc++.6.dylib|g" \
${patch.dir}/clang/lib/Driver/ToolChains/Darwin.cpp
# GCC was built for ${configure.build_arch}-apple-darwin${os.major}
# if GCC was also built universal, it has an extra include directory
# if ${configure.build_arch} is 32-bit, there is an extra 64-bit subdirectory
# if ${configure.build_arch} is 64-bit, there is an extra 32-bit subdirectory
# MacPorts GCC cannot compile across platforms
switch ${configure.build_arch} {
x86_64 {
reinplace {s|@@MACPORTS_TEST_32_64@@|getTriple().getArch() == llvm::Triple::x86_64 ? "" : "i386"|g} \
${patch.dir}/clang/lib/Driver/ToolChains/Darwin.cpp
}
i386 {
reinplace {s|@@MACPORTS_TEST_32_64@@|getTriple().getArch() == llvm::Triple::x86_64 ? "x86_64" : ""|g} \
${patch.dir}/clang/lib/Driver/ToolChains/Darwin.cpp
}
ppc64 {
reinplace {s|@@MACPORTS_TEST_32_64@@|getTriple().getArch() == llvm::Triple::ppc64 ? "" : "ppc"|g} \
${patch.dir}/clang/lib/Driver/ToolChains/Darwin.cpp
}
ppc {
reinplace {s|@@MACPORTS_TEST_32_64@@|getTriple().getArch() == llvm::Triple::ppc64 ? "ppc64" : ""|g} \
${patch.dir}/clang/lib/Driver/ToolChains/Darwin.cpp
}
arm64 {
reinplace {s|@@MACPORTS_TEST_32_64@@|""|g} \
${patch.dir}/clang/lib/Driver/ToolChains/Darwin.cpp
}
}
}
}
if { ${cxx_stdlib} eq "libstdc++" } {
default_variants-append +libstdcxx
}
}