Skip to content

Commit

Permalink
contrib/clang-rt-mingw-w64: new package (18.1.8)
Browse files Browse the repository at this point in the history
  • Loading branch information
z-erica committed Jul 23, 2024
1 parent 95ddd70 commit 41dfdb8
Show file tree
Hide file tree
Showing 6 changed files with 124 additions and 0 deletions.
1 change: 1 addition & 0 deletions contrib/clang-rt-mingw-w64-aarch64
1 change: 1 addition & 0 deletions contrib/clang-rt-mingw-w64-armv7
1 change: 1 addition & 0 deletions contrib/clang-rt-mingw-w64-i686
1 change: 1 addition & 0 deletions contrib/clang-rt-mingw-w64-x86_64
119 changes: 119 additions & 0 deletions contrib/clang-rt-mingw-w64/template.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
pkgname = "clang-rt-mingw-w64"
pkgver = "18.1.8"
pkgrel = 0
build_style = "cmake"
configure_args = [
"-DCMAKE_BUILD_TYPE=Release",
"-DCMAKE_SYSTEM_NAME=Windows",
"-Wno-dev",
f"-DCMAKE_INSTALL_PREFIX=/usr/lib/clang/{pkgver[0:pkgver.find('.')]}",
# prevent executable checks
"-DCMAKE_TRY_COMPILE_TARGET_TYPE=STATIC_LIBRARY",
# only build that target
"-DCOMPILER_RT_DEFAULT_TARGET_ONLY=ON",
# tools
"-DCMAKE_C_COMPILER=/usr/bin/clang",
"-DCMAKE_AR=/usr/bin/llvm-ar",
"-DCMAKE_NM=/usr/bin/llvm-nm",
"-DCMAKE_RANLIB=/usr/bin/llvm-ranlib",
"-DLLVM_CONFIG_PATH=/usr/bin/llvm-config",
# TODO: these require libcxx
"-DCOMPILER_RT_BUILD_ORC=OFF",
"-DCOMPILER_RT_BUILD_LIBFUZZER=OFF",
# lld complains about unknown arguments (-z, --version-script)
"-DCOMPILER_RT_BUILD_SANITIZERS=OFF",
# FIXME: these install headers to a common location, so can't split by target
"-DCOMPILER_RT_BUILD_MEMPROF=OFF",
"-DCOMPILER_RT_BUILD_PROFILE=OFF",
"-DCOMPILER_RT_BUILD_XRAY=OFF",
# don't take flags from profile
"-DCMAKE_C_FLAGS=",
"-DCMAKE_CXX_FLAGS=",
"-DCMAKE_LD_FLAGS=",
]
make_cmd = "make"
cmake_dir = "compiler-rt"
hostmakedepends = [
"clang-tools-extra",
"cmake",
"python",
"llvm-devel",
]
depends = []
pkgdesc = "Clang runtime libraries for Windows development"
maintainer = "Erica Z <[email protected]>"
license = "Apache-2.0"
url = "https://llvm.org"
source = f"https://github.com/llvm/llvm-project/releases/download/llvmorg-{pkgver}/llvm-project-{pkgver}.src.tar.xz"
sha256 = "0b58557a6d32ceee97c8d533a59b9212d87e0fc4d2833924eb6c611247db2f2a"
debug_level = 0
hardening = ["!int", "!scp", "!var-init"]
# crosstoolchain
options = ["!cross", "!check", "!lto", "empty"]

_targets = ["x86_64", "i686", "aarch64", "armv7"]

for _an in _targets:
hostmakedepends += [
f"mingw-w64-headers-{_an}",
]
depends += [f"clang-rt-mingw-w64-{_an}={pkgver}-r{pkgrel}"]


def do_configure(self):
from cbuild.util import cmake

for an in _targets:
at = an + "-w64-mingw32"
with self.stamp(f"{an}_configure") as s:
s.check()
cmake.configure(
self,
f"build-{an}",
self.cmake_dir,
[
*self.configure_args,
f"-DCMAKE_SYSROOT=/usr/{at}",
f"-DCMAKE_ASM_COMPILER_TARGET={at}",
f"-DCMAKE_C_COMPILER_TARGET={at}",
f"-DCMAKE_CXX_COMPILER_TARGET={at}",
],
cross_build=False,
generator="Unix Makefiles",
)


def do_build(self):
from cbuild.util import cmake

for an in _targets:
with self.stamp(f"{an}_build") as s:
s.check()
cmake.build(self, f"build-{an}")


def do_install(self):
from cbuild.util import cmake

for an in _targets:
cmake.install(self, f"build-{an}")


def _gen(an, at):
@subpackage(f"clang-rt-mingw-w64-{an}")
def _subp(self):
self.subdesc = f"{an} support"
# strip: not supported for COFF
self.options = ["!strip"]
match an:
case "aarch64" | "x86_64":
suffix = an
case "i686":
suffix = "i386"
case "armv7":
suffix = "arm"
return [f"usr/lib/clang/*/lib/windows/*-{suffix}.a"]


for _an in _targets:
_gen(_an, _an + "-w64-mingw32")
1 change: 1 addition & 0 deletions contrib/clang-rt-mingw-w64/update.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pkgname = "llvmorg"

0 comments on commit 41dfdb8

Please sign in to comment.