-
Notifications
You must be signed in to change notification settings - Fork 59
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
272 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,118 @@ | ||
#!/usr/bin/bash | ||
# | ||
# {{{ CDDL HEADER | ||
# | ||
# This file and its contents are supplied under the terms of the | ||
# Common Development and Distribution License ("CDDL"), version 1.0. | ||
# You may only use this file in accordance with the terms of version | ||
# 1.0 of the CDDL. | ||
# | ||
# A full copy of the text of the CDDL should have accompanied this | ||
# source. A copy of the CDDL is also available via the Internet at | ||
# http://www.illumos.org/license/CDDL. | ||
# }}} | ||
|
||
# Copyright 2024 OmniOS Community Edition (OmniOSce) Association. | ||
|
||
. ../../lib/build.sh | ||
|
||
PROG=clang | ||
PKG=ooce/developer/clang-19 | ||
VER=19.1.0 | ||
SUMMARY="C language family frontend for LLVM" | ||
DESC="The Clang project provides a language front-end and tooling " | ||
DESC+="infrastructure for languages in the C language family (C, C++, " | ||
DESC+="Objective C/C++, OpenCL, CUDA, and RenderScript) for the LLVM project" | ||
|
||
min_rel 151051 | ||
|
||
set_arch 64 | ||
set_clangver | ||
set_builddir llvm-project-$VER.src/$PROG | ||
|
||
SKIP_RTIME_CHECK=1 | ||
NO_SONAME_EXPECTED=1 | ||
|
||
MAJVER=${VER%%.*} | ||
MINVER=${VER%.*} | ||
set_patchdir patches-$MAJVER | ||
|
||
# Using the = prefix to require the specific matching version of llvm | ||
BUILD_DEPENDS_IPS="=ooce/developer/llvm-$MAJVER@$VER" | ||
|
||
RUN_DEPENDS_IPS=" | ||
=ooce/developer/llvm-$MAJVER@$MINVER | ||
developer/gcc$GCCVER | ||
" | ||
|
||
OPREFIX=$PREFIX | ||
PREFIX+=/llvm-$MAJVER | ||
|
||
PKGDIFFPATH="${PREFIX#/}/lib/$PROG" | ||
PKGDIFF_HELPER=" | ||
s:$PKGDIFFPATH/[0-9][0-9.]*:$PKGDIFFPATH/VERSION: | ||
" | ||
|
||
XFORM_ARGS=" | ||
-DPREFIX=${PREFIX#/} | ||
-DOPREFIX=${OPREFIX#/} | ||
-DPROG=$PROG | ||
-DPKGROOT=llvm-$MAJVER | ||
-DMEDIATOR=$PROG -DMEDIATOR_VERSION=$MAJVER | ||
-DVERSION=$MAJVER | ||
" | ||
|
||
post_install() { | ||
for a in "${!TRIPLETS[@]}"; do | ||
cfgfile="$DESTDIR$PREFIX/bin/${TRIPLETS[$a]}.cfg" | ||
if cross_arch $a; then | ||
# TODO: globbing only works reliably as long as we just have | ||
# one cross compiler version per arch. | ||
crossgccver=`pkg_ver $a/gcc*` | ||
crossgccver=${crossgccver%%.*} | ||
cxxinc="$CROSSTOOLS/$a/${TRIPLETS[$a]}/include/c++/$crossgccver" | ||
$CAT << EOF >| $cfgfile | ||
--gcc-install-dir=$CROSSTOOLS/$a/lib/gcc/${TRIPLETS[$a]}/$crossgccver | ||
-fuse-ld=$CROSSTOOLS/$a/bin/ld | ||
-stdlib++-isystem$cxxinc | ||
-stdlib++-isystem$cxxinc/${TRIPLETS[$a]} | ||
-stdlib++-isystem$cxxinc/backward | ||
EOF | ||
else | ||
$CAT << EOF >| $cfgfile | ||
--gcc-install-dir=$GCCPATH/lib/gcc/${TRIPLETS[$BUILD_ARCH]}/$DEFAULT_GCC_VER | ||
EOF | ||
fi | ||
done | ||
} | ||
|
||
CONFIGURE_OPTS[amd64]= | ||
CONFIGURE_OPTS[amd64_WS]=" | ||
-DCMAKE_BUILD_TYPE=Release | ||
-DCMAKE_INSTALL_PREFIX=\"$PREFIX\" | ||
-DCMAKE_C_COMPILER=\"$CC\" | ||
-DCMAKE_CXX_COMPILER=\"$CXX\" | ||
-DCMAKE_C_LINK_FLAGS=\"${LDFLAGS[amd64]}\" | ||
-DCMAKE_CXX_LINK_FLAGS=\"${LDFLAGS[amd64]}\" | ||
-DCLANG_VENDOR=\"$DISTRO/$RELVER\" | ||
-DCLANG_DEFAULT_RTLIB=libgcc | ||
-DCLANG_DEFAULT_CXX_STDLIB=libstdc++ | ||
-DLLVM_DIR=\"$PREFIX/lib/cmake/llvm\" | ||
-DLLVM_INCLUDE_TESTS=OFF | ||
" | ||
LDFLAGS+=" -lm" | ||
# we want to end up with '$ORIGIN/../lib' as runpath and not with | ||
# '$PREFIX/lib:$ORIGIN/../lib'; yet we need to find libLLVM during build time | ||
export LD_LIBRARY_PATH="$PREFIX/lib" | ||
|
||
init | ||
download_source llvm llvm-project $VER.src | ||
patch_source | ||
prep_build cmake+ninja | ||
build -noctf # C++ | ||
strip_install | ||
make_package | ||
clean_up | ||
|
||
# Vim hints | ||
# vim:ts=4:sw=4:et:fdm=marker |
11 changes: 11 additions & 0 deletions
11
build/clang/patches-19/add-__illumos__-preprocessor-definition.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
diff -wpruN --no-dereference '--exclude=*.orig' a~/lib/Basic/Targets/OSTargets.h a/lib/Basic/Targets/OSTargets.h | ||
--- a~/lib/Basic/Targets/OSTargets.h 1970-01-01 00:00:00 | ||
+++ a/lib/Basic/Targets/OSTargets.h 1970-01-01 00:00:00 | ||
@@ -590,6 +590,7 @@ protected: | ||
void getOSDefines(const LangOptions &Opts, const llvm::Triple &Triple, | ||
MacroBuilder &Builder) const override { | ||
DefineStd(Builder, "sun", Opts); | ||
+ Builder.defineMacro("__illumos__"); | ||
DefineStd(Builder, "unix", Opts); | ||
Builder.defineMacro("__svr4__"); | ||
Builder.defineMacro("__SVR4"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
diff -wpruN --no-dereference '--exclude=*.orig' a~/lib/Driver/ToolChain.cpp a/lib/Driver/ToolChain.cpp | ||
--- a~/lib/Driver/ToolChain.cpp 1970-01-01 00:00:00 | ||
+++ a/lib/Driver/ToolChain.cpp 1970-01-01 00:00:00 | ||
@@ -1233,9 +1233,7 @@ void ToolChain::AddClangCXXStdlibIsystem | ||
} | ||
|
||
bool ToolChain::ShouldLinkCXXStdlib(const llvm::opt::ArgList &Args) const { | ||
- return getDriver().CCCIsCXX() && | ||
- !Args.hasArg(options::OPT_nostdlib, options::OPT_nodefaultlibs, | ||
- options::OPT_nostdlibxx); | ||
+ return getDriver().CCCIsCXX() && !Args.hasArg(options::OPT_nostdlibxx); | ||
} | ||
|
||
void ToolChain::AddCXXStdlibLibArgs(const ArgList &Args, | ||
diff -wpruN --no-dereference '--exclude=*.orig' a~/lib/Driver/ToolChains/Solaris.cpp a/lib/Driver/ToolChains/Solaris.cpp | ||
--- a~/lib/Driver/ToolChains/Solaris.cpp 1970-01-01 00:00:00 | ||
+++ a/lib/Driver/ToolChains/Solaris.cpp 1970-01-01 00:00:00 | ||
@@ -207,6 +207,9 @@ void solaris::Linker::ConstructJob(Compi | ||
bool NeedsSanitizerDeps = addSanitizerRuntimes(ToolChain, Args, CmdArgs); | ||
AddLinkerInputs(ToolChain, Inputs, Args, CmdArgs, JA); | ||
|
||
+ if (ToolChain.ShouldLinkCXXStdlib(Args) && !Args.hasArg(options::OPT_r)) | ||
+ ToolChain.AddCXXStdlibLibArgs(Args, CmdArgs); | ||
+ | ||
if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nodefaultlibs, | ||
options::OPT_r)) { | ||
// Use the static OpenMP runtime with -static-openmp | ||
@@ -215,8 +218,6 @@ void solaris::Linker::ConstructJob(Compi | ||
addOpenMPRuntime(CmdArgs, ToolChain, Args, StaticOpenMP); | ||
|
||
if (D.CCCIsCXX()) { | ||
- if (ToolChain.ShouldLinkCXXStdlib(Args)) | ||
- ToolChain.AddCXXStdlibLibArgs(Args, CmdArgs); | ||
CmdArgs.push_back("-lm"); | ||
} | ||
// Silence warnings when linking C code with a C++ '-stdlib' argument. | ||
@@ -419,3 +420,16 @@ void Solaris::addLibStdCxxIncludePaths( | ||
TripleStr, Multilib.includeSuffix(), DriverArgs, | ||
CC1Args); | ||
} | ||
+ | ||
+void Solaris::AddCXXStdlibLibArgs(const ArgList &Args, | ||
+ ArgStringList &CmdArgs) const { | ||
+ Generic_ELF::AddCXXStdlibLibArgs(Args, CmdArgs); | ||
+ | ||
+ if (GetCXXStdlibType(Args) != ToolChain::CST_Libstdcxx) | ||
+ return; | ||
+ | ||
+ StringRef LibSuffix = getSolarisLibSuffix(getTriple()); | ||
+ std::string MajVer = GCCInstallation.getVersion().MajorStr; | ||
+ CmdArgs.push_back(Args.MakeArgString(StringRef("-R") | ||
+ + "/usr/gcc/" + MajVer + "/lib" + LibSuffix)); | ||
+} | ||
diff -wpruN --no-dereference '--exclude=*.orig' a~/lib/Driver/ToolChains/Solaris.h a/lib/Driver/ToolChains/Solaris.h | ||
--- a~/lib/Driver/ToolChains/Solaris.h 1970-01-01 00:00:00 | ||
+++ a/lib/Driver/ToolChains/Solaris.h 1970-01-01 00:00:00 | ||
@@ -64,6 +64,9 @@ public: | ||
addLibStdCxxIncludePaths(const llvm::opt::ArgList &DriverArgs, | ||
llvm::opt::ArgStringList &CC1Args) const override; | ||
|
||
+ void AddCXXStdlibLibArgs(const llvm::opt::ArgList &Args, | ||
+ llvm::opt::ArgStringList &CmdArgs) const override; | ||
+ | ||
SanitizerMask getSupportedSanitizers() const override; | ||
|
||
const char *getDefaultLinker() const override; |
34 changes: 34 additions & 0 deletions
34
build/clang/patches-19/default-preprocessor-definition.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
$NetBSD: patch-lib_Basic_Targets_OSTargets.h,v 1.4 2019/10/19 13:54:29 adam Exp $ | ||
|
||
Sync SunOS default defines with a working reality. | ||
|
||
diff -wpruN --no-dereference '--exclude=*.orig' a~/lib/Basic/Targets/OSTargets.h a/lib/Basic/Targets/OSTargets.h | ||
--- a~/lib/Basic/Targets/OSTargets.h 1970-01-01 00:00:00 | ||
+++ a/lib/Basic/Targets/OSTargets.h 1970-01-01 00:00:00 | ||
@@ -593,22 +593,15 @@ protected: | ||
DefineStd(Builder, "unix", Opts); | ||
Builder.defineMacro("__svr4__"); | ||
Builder.defineMacro("__SVR4"); | ||
- // Solaris headers require _XOPEN_SOURCE to be set to 600 for C99 and | ||
- // newer, but to 500 for everything else. feature_test.h has a check to | ||
- // ensure that you are not using C99 with an old version of X/Open or C89 | ||
- // with a new version. | ||
- if (Opts.C99) | ||
- Builder.defineMacro("_XOPEN_SOURCE", "600"); | ||
- else | ||
- Builder.defineMacro("_XOPEN_SOURCE", "500"); | ||
+ // Compatibility with GCC to satisfy <sys/feature_tests.h> requirements. | ||
if (Opts.CPlusPlus) { | ||
- Builder.defineMacro("__C99FEATURES__"); | ||
+ Builder.defineMacro("__STDC_VERSION__", "199901L"); | ||
+ Builder.defineMacro("_XOPEN_SOURCE", "600"); | ||
Builder.defineMacro("_FILE_OFFSET_BITS", "64"); | ||
- } | ||
- // GCC restricts the next two to C++. | ||
Builder.defineMacro("_LARGEFILE_SOURCE"); | ||
Builder.defineMacro("_LARGEFILE64_SOURCE"); | ||
Builder.defineMacro("__EXTENSIONS__"); | ||
+ } | ||
if (Opts.POSIXThreads) | ||
Builder.defineMacro("_REENTRANT"); | ||
if (this->HasFloat128) |
13 changes: 13 additions & 0 deletions
13
build/clang/patches-19/no-sanitizer-runtime-lib-linking.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
diff -wpruN --no-dereference '--exclude=*.orig' a~/lib/Driver/ToolChains/CommonArgs.cpp a/lib/Driver/ToolChains/CommonArgs.cpp | ||
--- a~/lib/Driver/ToolChains/CommonArgs.cpp 1970-01-01 00:00:00 | ||
+++ a/lib/Driver/ToolChains/CommonArgs.cpp 1970-01-01 00:00:00 | ||
@@ -1366,6 +1366,9 @@ void tools::addAsNeededOption(const Tool | ||
void tools::linkSanitizerRuntimeDeps(const ToolChain &TC, | ||
const llvm::opt::ArgList &Args, | ||
ArgStringList &CmdArgs) { | ||
+ if (TC.getTriple().isOSSolaris()) | ||
+ return; | ||
+ | ||
// Force linking against the system libraries sanitizers depends on | ||
// (see PR15823 why this is necessary). | ||
addAsNeededOption(TC, Args, CmdArgs, false); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
diff -wpruN --no-dereference '--exclude=*.orig' a~/lib/Driver/ToolChains/Solaris.cpp a/lib/Driver/ToolChains/Solaris.cpp | ||
--- a~/lib/Driver/ToolChains/Solaris.cpp 1970-01-01 00:00:00 | ||
+++ a/lib/Driver/ToolChains/Solaris.cpp 1970-01-01 00:00:00 | ||
@@ -229,13 +229,6 @@ void solaris::Linker::ConstructJob(Compi | ||
addFortranRuntimeLibs(getToolChain(), Args, CmdArgs); | ||
CmdArgs.push_back("-lm"); | ||
} | ||
- if (Args.hasArg(options::OPT_fstack_protector) || | ||
- Args.hasArg(options::OPT_fstack_protector_strong) || | ||
- Args.hasArg(options::OPT_fstack_protector_all)) { | ||
- // Explicitly link ssp libraries, not folded into Solaris libc. | ||
- CmdArgs.push_back("-lssp_nonshared"); | ||
- CmdArgs.push_back("-lssp"); | ||
- } | ||
// LLVM support for atomics on 32-bit SPARC V8+ is incomplete, so | ||
// forcibly link with libatomic as a workaround. | ||
if (Arch == llvm::Triple::sparc) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
no-ssp-linking.patch | ||
default-preprocessor-definition.patch | ||
add-rpath-for-libstdcxx.patch | ||
no-sanitizer-runtime-lib-linking.patch | ||
add-__illumos__-preprocessor-definition.patch |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -128,3 +128,7 @@ depend fmri=ooce/developer/llvm-18 type=conditional \ | |
depend fmri=ooce/developer/clang-18 type=conditional \ | ||
predicate=release/[email protected] | ||
|
||
# Added llvm/clang 19 from r151051 onwards | ||
depend fmri=ooce/developer/llvm-19 type=conditional \ | ||
predicate=release/[email protected] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters