Skip to content

Commit 0147828

Browse files
committed
adding clang 20
1 parent ac87c46 commit 0147828

12 files changed

+284
-0
lines changed

build/clang/build-20.sh

+115
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
#!/usr/bin/bash
2+
#
3+
# {{{ CDDL HEADER
4+
#
5+
# This file and its contents are supplied under the terms of the
6+
# Common Development and Distribution License ("CDDL"), version 1.0.
7+
# You may only use this file in accordance with the terms of version
8+
# 1.0 of the CDDL.
9+
#
10+
# A full copy of the text of the CDDL should have accompanied this
11+
# source. A copy of the CDDL is also available via the Internet at
12+
# http://www.illumos.org/license/CDDL.
13+
# }}}
14+
15+
# Copyright 2025 OmniOS Community Edition (OmniOSce) Association.
16+
17+
. ../../lib/build.sh
18+
19+
PROG=clang
20+
PKG=ooce/developer/clang-20
21+
VER=20.1.0
22+
SUMMARY="C language family frontend for LLVM"
23+
DESC="The Clang project provides a language front-end and tooling "
24+
DESC+="infrastructure for languages in the C language family (C, C++, "
25+
DESC+="Objective C/C++, OpenCL, CUDA, and RenderScript) for the LLVM project"
26+
27+
min_rel 151053
28+
29+
set_arch 64
30+
set_clangver
31+
set_builddir llvm-project-$VER.src/$PROG
32+
33+
SKIP_RTIME_CHECK=1
34+
NO_SONAME_EXPECTED=1
35+
36+
MAJVER=${VER%%.*}
37+
MINVER=${VER%.*}
38+
set_patchdir patches-$MAJVER
39+
40+
# Using the = prefix to require the specific matching version of llvm
41+
BUILD_DEPENDS_IPS="=ooce/developer/llvm-$MAJVER@$VER"
42+
43+
RUN_DEPENDS_IPS="
44+
=ooce/developer/llvm-$MAJVER@$MINVER
45+
developer/gcc$GCCVER
46+
"
47+
48+
OPREFIX=$PREFIX
49+
PREFIX+=/llvm-$MAJVER
50+
51+
PKGDIFFPATH="${PREFIX#/}/lib/$PROG"
52+
PKGDIFF_HELPER="
53+
s:$PKGDIFFPATH/[0-9][0-9.]*:$PKGDIFFPATH/VERSION:
54+
"
55+
56+
XFORM_ARGS="
57+
-DPREFIX=${PREFIX#/}
58+
-DOPREFIX=${OPREFIX#/}
59+
-DPROG=$PROG
60+
-DPKGROOT=llvm-$MAJVER
61+
-DMEDIATOR=$PROG -DMEDIATOR_VERSION=$MAJVER
62+
-DVERSION=$MAJVER
63+
"
64+
65+
post_install() {
66+
for a in "${!TRIPLETS[@]}"; do
67+
cfgfile="$DESTDIR$PREFIX/bin/${TRIPLETS[$a]}.cfg"
68+
if cross_arch $a; then
69+
# TODO: globbing only works reliably as long as we just have
70+
# one cross compiler version per arch.
71+
crossgccver=`pkg_ver $a/gcc*`
72+
crossgccver=${crossgccver%%.*}
73+
cxxinc="$CROSSTOOLS/$a/${TRIPLETS[$a]}/include/c++/$crossgccver"
74+
$CAT << EOF >| $cfgfile
75+
--gcc-install-dir=$CROSSTOOLS/$a/lib/gcc/${TRIPLETS[$a]}/$crossgccver
76+
-fuse-ld=$CROSSTOOLS/$a/bin/ld
77+
EOF
78+
else
79+
$CAT << EOF >| $cfgfile
80+
--gcc-install-dir=$GCCPATH/lib/gcc/${TRIPLETS[$BUILD_ARCH]}/$DEFAULT_GCC_VER
81+
EOF
82+
fi
83+
done
84+
}
85+
86+
CONFIGURE_OPTS[amd64]=
87+
CONFIGURE_OPTS[amd64_WS]="
88+
-DCMAKE_BUILD_TYPE=Release
89+
-DCMAKE_INSTALL_PREFIX=\"$PREFIX\"
90+
-DCMAKE_C_COMPILER=\"$CC\"
91+
-DCMAKE_CXX_COMPILER=\"$CXX\"
92+
-DCMAKE_C_LINK_FLAGS=\"${LDFLAGS[amd64]}\"
93+
-DCMAKE_CXX_LINK_FLAGS=\"${LDFLAGS[amd64]}\"
94+
-DCLANG_VENDOR=\"$DISTRO/$RELVER\"
95+
-DCLANG_DEFAULT_RTLIB=libgcc
96+
-DCLANG_DEFAULT_CXX_STDLIB=libstdc++
97+
-DLLVM_DIR=\"$PREFIX/lib/cmake/llvm\"
98+
-DLLVM_INCLUDE_TESTS=OFF
99+
"
100+
LDFLAGS+=" -lm"
101+
# we want to end up with '$ORIGIN/../lib' as runpath and not with
102+
# '$PREFIX/lib:$ORIGIN/../lib'; yet we need to find libLLVM during build time
103+
export LD_LIBRARY_PATH="$PREFIX/lib"
104+
105+
init
106+
download_source llvm llvm-project $VER.src
107+
patch_source
108+
prep_build cmake+ninja
109+
build -noctf # C++
110+
strip_install
111+
make_package
112+
clean_up
113+
114+
# Vim hints
115+
# vim:ts=4:sw=4:et:fdm=marker
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
diff -wpruN --no-dereference '--exclude=*.orig' a~/lib/Basic/Targets.cpp a/lib/Basic/Targets.cpp
2+
--- a~/lib/Basic/Targets.cpp 1970-01-01 00:00:00
3+
+++ a/lib/Basic/Targets.cpp 1970-01-01 00:00:00
4+
@@ -160,6 +160,10 @@ std::unique_ptr<TargetInfo> AllocateTarg
5+
return std::make_unique<OHOSTargetInfo<AArch64leTargetInfo>>(Triple,
6+
Opts);
7+
}
8+
+
9+
+ case llvm::Triple::Solaris:
10+
+ return std::make_unique<SolarisTargetInfo<AArch64leTargetInfo>>(Triple,
11+
+ Opts);
12+
case llvm::Triple::NetBSD:
13+
return std::make_unique<NetBSDTargetInfo<AArch64leTargetInfo>>(Triple,
14+
Opts);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
diff -wpruN --no-dereference '--exclude=*.orig' a~/lib/Basic/Targets/OSTargets.h a/lib/Basic/Targets/OSTargets.h
2+
--- a~/lib/Basic/Targets/OSTargets.h 1970-01-01 00:00:00
3+
+++ a/lib/Basic/Targets/OSTargets.h 1970-01-01 00:00:00
4+
@@ -594,6 +594,7 @@ protected:
5+
void getOSDefines(const LangOptions &Opts, const llvm::Triple &Triple,
6+
MacroBuilder &Builder) const override {
7+
DefineStd(Builder, "sun", Opts);
8+
+ Builder.defineMacro("__illumos__");
9+
DefineStd(Builder, "unix", Opts);
10+
Builder.defineMacro("__svr4__");
11+
Builder.defineMacro("__SVR4");
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
diff -wpruN --no-dereference '--exclude=*.orig' a~/lib/Driver/ToolChain.cpp a/lib/Driver/ToolChain.cpp
2+
--- a~/lib/Driver/ToolChain.cpp 1970-01-01 00:00:00
3+
+++ a/lib/Driver/ToolChain.cpp 1970-01-01 00:00:00
4+
@@ -1280,9 +1280,7 @@ void ToolChain::AddClangCXXStdlibIsystem
5+
}
6+
7+
bool ToolChain::ShouldLinkCXXStdlib(const llvm::opt::ArgList &Args) const {
8+
- return getDriver().CCCIsCXX() &&
9+
- !Args.hasArg(options::OPT_nostdlib, options::OPT_nodefaultlibs,
10+
- options::OPT_nostdlibxx);
11+
+ return getDriver().CCCIsCXX() && !Args.hasArg(options::OPT_nostdlibxx);
12+
}
13+
14+
void ToolChain::AddCXXStdlibLibArgs(const ArgList &Args,
15+
diff -wpruN --no-dereference '--exclude=*.orig' a~/lib/Driver/ToolChains/Solaris.cpp a/lib/Driver/ToolChains/Solaris.cpp
16+
--- a~/lib/Driver/ToolChains/Solaris.cpp 1970-01-01 00:00:00
17+
+++ a/lib/Driver/ToolChains/Solaris.cpp 1970-01-01 00:00:00
18+
@@ -206,6 +206,9 @@ void solaris::Linker::ConstructJob(Compi
19+
bool NeedsSanitizerDeps = addSanitizerRuntimes(ToolChain, Args, CmdArgs);
20+
AddLinkerInputs(ToolChain, Inputs, Args, CmdArgs, JA);
21+
22+
+ if (ToolChain.ShouldLinkCXXStdlib(Args) && !Args.hasArg(options::OPT_r))
23+
+ ToolChain.AddCXXStdlibLibArgs(Args, CmdArgs);
24+
+
25+
if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nodefaultlibs,
26+
options::OPT_r)) {
27+
// Use the static OpenMP runtime with -static-openmp
28+
@@ -214,8 +217,6 @@ void solaris::Linker::ConstructJob(Compi
29+
addOpenMPRuntime(C, CmdArgs, ToolChain, Args, StaticOpenMP);
30+
31+
if (D.CCCIsCXX()) {
32+
- if (ToolChain.ShouldLinkCXXStdlib(Args))
33+
- ToolChain.AddCXXStdlibLibArgs(Args, CmdArgs);
34+
CmdArgs.push_back("-lm");
35+
}
36+
// Silence warnings when linking C code with a C++ '-stdlib' argument.
37+
@@ -419,3 +420,16 @@ void Solaris::addLibStdCxxIncludePaths(
38+
TripleStr, Multilib.includeSuffix(), DriverArgs,
39+
CC1Args);
40+
}
41+
+
42+
+void Solaris::AddCXXStdlibLibArgs(const ArgList &Args,
43+
+ ArgStringList &CmdArgs) const {
44+
+ Generic_ELF::AddCXXStdlibLibArgs(Args, CmdArgs);
45+
+
46+
+ if (GetCXXStdlibType(Args) != ToolChain::CST_Libstdcxx)
47+
+ return;
48+
+
49+
+ StringRef LibSuffix = getSolarisLibSuffix(getTriple());
50+
+ std::string MajVer = GCCInstallation.getVersion().MajorStr;
51+
+ CmdArgs.push_back(Args.MakeArgString(StringRef("-R")
52+
+ + "/usr/gcc/" + MajVer + "/lib" + LibSuffix));
53+
+}
54+
diff -wpruN --no-dereference '--exclude=*.orig' a~/lib/Driver/ToolChains/Solaris.h a/lib/Driver/ToolChains/Solaris.h
55+
--- a~/lib/Driver/ToolChains/Solaris.h 1970-01-01 00:00:00
56+
+++ a/lib/Driver/ToolChains/Solaris.h 1970-01-01 00:00:00
57+
@@ -64,6 +64,9 @@ public:
58+
addLibStdCxxIncludePaths(const llvm::opt::ArgList &DriverArgs,
59+
llvm::opt::ArgStringList &CC1Args) const override;
60+
61+
+ void AddCXXStdlibLibArgs(const llvm::opt::ArgList &Args,
62+
+ llvm::opt::ArgStringList &CmdArgs) const override;
63+
+
64+
SanitizerMask getSupportedSanitizers() const override;
65+
66+
const char *getDefaultLinker() const override;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
$NetBSD: patch-lib_Basic_Targets_OSTargets.h,v 1.4 2019/10/19 13:54:29 adam Exp $
2+
3+
Sync SunOS default defines with a working reality.
4+
5+
diff -wpruN --no-dereference '--exclude=*.orig' a~/lib/Basic/Targets/OSTargets.h a/lib/Basic/Targets/OSTargets.h
6+
--- a~/lib/Basic/Targets/OSTargets.h 1970-01-01 00:00:00
7+
+++ a/lib/Basic/Targets/OSTargets.h 1970-01-01 00:00:00
8+
@@ -597,22 +597,15 @@ protected:
9+
DefineStd(Builder, "unix", Opts);
10+
Builder.defineMacro("__svr4__");
11+
Builder.defineMacro("__SVR4");
12+
- // Solaris headers require _XOPEN_SOURCE to be set to 600 for C99 and
13+
- // newer, but to 500 for everything else. feature_test.h has a check to
14+
- // ensure that you are not using C99 with an old version of X/Open or C89
15+
- // with a new version.
16+
- if (Opts.C99)
17+
- Builder.defineMacro("_XOPEN_SOURCE", "600");
18+
- else
19+
- Builder.defineMacro("_XOPEN_SOURCE", "500");
20+
+ // Compatibility with GCC to satisfy <sys/feature_tests.h> requirements.
21+
if (Opts.CPlusPlus) {
22+
- Builder.defineMacro("__C99FEATURES__");
23+
+ Builder.defineMacro("__STDC_VERSION__", "201112L");
24+
+ Builder.defineMacro("_XOPEN_SOURCE", "600");
25+
Builder.defineMacro("_FILE_OFFSET_BITS", "64");
26+
- }
27+
- // GCC restricts the next two to C++.
28+
Builder.defineMacro("_LARGEFILE_SOURCE");
29+
Builder.defineMacro("_LARGEFILE64_SOURCE");
30+
Builder.defineMacro("__EXTENSIONS__");
31+
+ }
32+
if (Opts.POSIXThreads)
33+
Builder.defineMacro("_REENTRANT");
34+
if (this->HasFloat128)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
diff -wpruN --no-dereference '--exclude=*.orig' a~/lib/Driver/ToolChains/CommonArgs.cpp a/lib/Driver/ToolChains/CommonArgs.cpp
2+
--- a~/lib/Driver/ToolChains/CommonArgs.cpp 1970-01-01 00:00:00
3+
+++ a/lib/Driver/ToolChains/CommonArgs.cpp 1970-01-01 00:00:00
4+
@@ -1360,6 +1360,9 @@ void tools::addAsNeededOption(const Tool
5+
void tools::linkSanitizerRuntimeDeps(const ToolChain &TC,
6+
const llvm::opt::ArgList &Args,
7+
ArgStringList &CmdArgs) {
8+
+ if (TC.getTriple().isOSSolaris())
9+
+ return;
10+
+
11+
// Force linking against the system libraries sanitizers depends on
12+
// (see PR15823 why this is necessary).
13+
addAsNeededOption(TC, Args, CmdArgs, false);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
diff -wpruN --no-dereference '--exclude=*.orig' a~/lib/Driver/ToolChains/Solaris.cpp a/lib/Driver/ToolChains/Solaris.cpp
2+
--- a~/lib/Driver/ToolChains/Solaris.cpp 1970-01-01 00:00:00
3+
+++ a/lib/Driver/ToolChains/Solaris.cpp 1970-01-01 00:00:00
4+
@@ -228,13 +228,6 @@ void solaris::Linker::ConstructJob(Compi
5+
addFortranRuntimeLibs(getToolChain(), Args, CmdArgs);
6+
CmdArgs.push_back("-lm");
7+
}
8+
- if (Args.hasArg(options::OPT_fstack_protector) ||
9+
- Args.hasArg(options::OPT_fstack_protector_strong) ||
10+
- Args.hasArg(options::OPT_fstack_protector_all)) {
11+
- // Explicitly link ssp libraries, not folded into Solaris libc.
12+
- CmdArgs.push_back("-lssp_nonshared");
13+
- CmdArgs.push_back("-lssp");
14+
- }
15+
// LLVM support for atomics on 32-bit SPARC V8+ is incomplete, so
16+
// forcibly link with libatomic as a workaround.
17+
if (Arch == llvm::Triple::sparc) {

build/clang/patches-20/series

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
no-ssp-linking.patch
2+
default-preprocessor-definition.patch
3+
add-rpath-for-libstdcxx.patch
4+
no-sanitizer-runtime-lib-linking.patch
5+
add-__illumos__-preprocessor-definition.patch
6+
aarch64-target-support.patch

build/meta/extra-build-tools.p5m

+4
Original file line numberDiff line numberDiff line change
@@ -126,3 +126,7 @@ depend fmri=ooce/developer/llvm-19 type=conditional \
126126
depend fmri=ooce/developer/clang-19 type=conditional \
127127
predicate=release/[email protected]
128128

129+
# Added llvm/clang 20 from r151053 onwards
130+
depend fmri=ooce/developer/llvm-20 type=conditional \
131+
predicate=release/[email protected]
132+

doc/baseline

+1
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ extra.omnios ooce/developer/clang-15
8686
extra.omnios ooce/developer/clang-17
8787
extra.omnios ooce/developer/clang-18
8888
extra.omnios ooce/developer/clang-19
89+
extra.omnios ooce/developer/clang-20
8990
extra.omnios ooce/developer/cmake
9091
extra.omnios ooce/developer/cscope
9192
extra.omnios ooce/developer/cunit

doc/packages.md

+1
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@
5959
| ooce/developer/clang-17 | 17.0.6 | https://github.com/llvm/llvm-project/releases | [omniosorg](https://github.com/omniosorg)
6060
| ooce/developer/clang-18 | 18.1.8 | https://github.com/llvm/llvm-project/releases | [omniosorg](https://github.com/omniosorg)
6161
| ooce/developer/clang-19 | 19.1.7 | https://github.com/llvm/llvm-project/releases | [omniosorg](https://github.com/omniosorg)
62+
| ooce/developer/clang-20 | 20.1.0 | https://github.com/llvm/llvm-project/releases | [omniosorg](https://github.com/omniosorg)
6263
| ooce/developer/cmake | 3.31.4 | https://cmake.org/download/ | [omniosorg](https://github.com/omniosorg)
6364
| ooce/developer/cscope | 15.9 | https://sourceforge.net/projects/cscope/files/cscope/ | [omniosorg](https://github.com/omniosorg)
6465
| ooce/developer/cunit | 2.1-3 | https://sourceforge.net/projects/cunit/files/CUnit/ | [omniosorg](https://github.com/omniosorg)

tools/audit

+2
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,8 @@ audit()
237237
*/clang-18:|*/llvm-18:|*/zig-013:) [ $r -lt 151049 ] || ok=0 ;;
238238
# clang/llvm-19 are not published until r151051
239239
*/clang-19:|*/llvm-19:) [ $r -lt 151051 ] || ok=0 ;;
240+
# clang/llvm-20 are not published until r151053
241+
*/clang-20:|*/llvm-20:) [ $r -lt 151053 ] || ok=0 ;;
240242
*) ok=0 ;;
241243
esac
242244
;;

0 commit comments

Comments
 (0)