Gentoo Archives: gentoo-commits

From: "Andreas K. Hüttel" <dilfridge@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: profiles/features/clang/
Date: Sun, 05 Dec 2021 11:19:14
Message-Id: 1638703125.6890ef4bc1a8b3a67c9da1059091ffe775d4083b.dilfridge@gentoo
1 commit: 6890ef4bc1a8b3a67c9da1059091ffe775d4083b
2 Author: Alex Revin <2b57 <AT> pm <DOT> me>
3 AuthorDate: Sat Dec 4 23:13:04 2021 +0000
4 Commit: Andreas K. Hüttel <dilfridge <AT> gentoo <DOT> org>
5 CommitDate: Sun Dec 5 11:18:45 2021 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=6890ef4b
7
8 profiles: add clang profile feature
9
10 Signed-off-by: Alex Revin <2b57 <AT> pm.me>
11 Closes: https://github.com/gentoo/gentoo/pull/23187
12 Signed-off-by: Andreas K. Hüttel <dilfridge <AT> gentoo.org>
13
14 profiles/features/clang/eapi | 1 +
15 profiles/features/clang/make.defaults | 58 ++++++++++++++++++++++++++++++++++
16 profiles/features/clang/package.mask | 16 ++++++++++
17 profiles/features/clang/package.use | 17 ++++++++++
18 profiles/features/clang/packages | 14 ++++++++
19 profiles/features/clang/packages.build | 14 ++++++++
20 profiles/features/clang/use.force | 1 +
21 7 files changed, 121 insertions(+)
22
23 diff --git a/profiles/features/clang/eapi b/profiles/features/clang/eapi
24 new file mode 100644
25 index 000000000000..7f8f011eb73d
26 --- /dev/null
27 +++ b/profiles/features/clang/eapi
28 @@ -0,0 +1 @@
29 +7
30
31 diff --git a/profiles/features/clang/make.defaults b/profiles/features/clang/make.defaults
32 new file mode 100644
33 index 000000000000..014816b37253
34 --- /dev/null
35 +++ b/profiles/features/clang/make.defaults
36 @@ -0,0 +1,58 @@
37 +# use Clang as a primary compiler
38 +CC="clang"
39 +CXX="clang++"
40 +
41 +# libtool needs this
42 +LD="ld.lld"
43 +
44 +# linker flags
45 +LDFLAGS="${LDFLAGS} -fuse-ld=lld -rtlib=compiler-rt -unwindlib=libunwind -Wl,--as-needed"
46 +
47 +# hardening flags
48 +SOME_HARDENING_CFLAGS="-fPIC -fstack-protector-strong -D_FORTIFY_SOURCE=2"
49 +SOME_HARDENING_LDFLAGS="-Wl,-z,relro,-z,now -pie"
50 +
51 +# enable some hardening by default
52 +CFLAGS="${CFLAGS} ${SOME_HARDENING_FLAGS}"
53 +CXXFLAGS="${CXXFLAGS} ${SOME_HARDENING_FLAGS}"
54 +LDFLAGS="${LDFLAGS} ${SOME_HARDENING_LDFLAGS}"
55 +
56 +# use LLVM-provided binutils
57 +AR="llvm-ar"
58 +AS="llvm-as"
59 +NM="llvm-nm"
60 +STRIP="llvm-strip"
61 +RANLIB="llvm-ranlib"
62 +OBJCOPY="llvm-objcopy"
63 +STRINGS="llvm-strings"
64 +OBJDUMP="llvm-objdump"
65 +READELF="llvm-readelf"
66 +ADDR2LINE="llvm-addr2line"
67 +
68 +
69 +# bootstrap USE for stage1
70 +
71 +# curl needed by cmake
72 +BOOTSTRAP_USE="$BOOTSTRAP_USE ssl curl_ssl_openssl"
73 +
74 +# Clang needs this
75 +BOOTSTRAP_USE="${BOOTSTRAP_USE} python_single_target_python3_9"
76 +
77 +# sys-devel/llvm
78 +BOOTSTRAP_USE="${BOOTSTRAP_USE} -gold"
79 +
80 +# sys-devel/clang, sys-devel/clang-runtime, sys-libs/llvm-libunwind, sys-libs/libcxx, sys-libs/libcxxabi
81 +BOOTSTRAP_USE="${BOOTSTRAP_USE} compiler-rt clang libunwind"
82 +
83 +# sys-devel/clang
84 +BOOTSTRAP_USE="${BOOTSTRAP_USE} default-compiler-rt default-lld default-libcxx llvm-libunwind"
85 +
86 +# sys-devel/clang-runtime
87 +# sanitizers are disabled for now
88 +BOOTSTRAP_USE="${BOOTSTRAP_USE} libcxx -sanitize"
89 +
90 +# sys-libs/libcxxabi
91 +BOOTSTRAP_USE="${BOOTSTRAP_USE} libcxxabi"
92 +
93 +# llvm & clang: explicitly disable all extra targets, otherwise linking stage2 fails
94 +BOOTSTRAP_USE="${BOOTSTRAP_USE} -llvm_targets_BPF -llvm_targets_AMDGPU -llvm_targets_NVPTX -llvm_targets_BPF"
95
96 diff --git a/profiles/features/clang/package.mask b/profiles/features/clang/package.mask
97 new file mode 100644
98 index 000000000000..0b6b883d274a
99 --- /dev/null
100 +++ b/profiles/features/clang/package.mask
101 @@ -0,0 +1,16 @@
102 +# mask LLVM 13, since it breaks tcl, which breaks sqlite and so on
103 +
104 +>sys-devel/llvm-12.0.1
105 +>sys-devel/llvm-common-12.0.1
106 +
107 +>sys-libs/compiler-rt-12.0.1
108 +>sys-libs/compiler-rt-sanitizers-12.0.1
109 +
110 +>sys-devel/clang-12.0.1
111 +>sys-devel/clang-common-12.0.1
112 +>sys-devel/clang-runtime-12.0.1
113 +
114 +>sys-devel/lld-12.0.1
115 +>sys-libs/libcxx-12.0.1
116 +>sys-libs/libcxxabi-12.0.1
117 +>sys-libs/llvm-libunwind-12.0.1
118
119 diff --git a/profiles/features/clang/package.use b/profiles/features/clang/package.use
120 new file mode 100644
121 index 000000000000..5d568cb8cb66
122 --- /dev/null
123 +++ b/profiles/features/clang/package.use
124 @@ -0,0 +1,17 @@
125 +# use lld by default
126 +sys-devel/llvm -gold
127 +
128 +# use all defaults
129 +sys-devel/clang compiler-rt default-compiler-rt default-lld default-libcxx llvm-libunwind
130 +sys-libs/compiler-rt clang
131 +
132 +# disable sanitizers for now
133 +sys-devel/clang-runtime compiler-rt libcxx -sanitize
134 +# sys-libs/compiler-rt-sanitizers clang
135 +
136 +sys-libs/libcxx libunwind libcxxabi
137 +sys-libs/libcxxabi libunwind
138 +sys-libs/llvm-libunwind compiler-rt
139 +
140 +# libgcrypt doesn't like optimizations
141 +dev-libs/libgcrypt o-flag-munging
142
143 diff --git a/profiles/features/clang/packages b/profiles/features/clang/packages
144 new file mode 100644
145 index 000000000000..9536b85862f3
146 --- /dev/null
147 +++ b/profiles/features/clang/packages
148 @@ -0,0 +1,14 @@
149 +# now part of @system set
150 +*sys-devel/lld
151 +*sys-devel/llvm
152 +*sys-devel/clang
153 +*sys-libs/libcxx
154 +*sys-libs/libcxxabi
155 +*sys-libs/compiler-rt
156 +*sys-libs/llvm-libunwind
157 +
158 +# not needed with clang
159 +-*sys-devel/gcc
160 +-*sys-devel/gcc-config
161 +-*sys-devel/binutils
162 +-*sys-devel/binutils-config
163
164 diff --git a/profiles/features/clang/packages.build b/profiles/features/clang/packages.build
165 new file mode 100644
166 index 000000000000..fd1e69e329e3
167 --- /dev/null
168 +++ b/profiles/features/clang/packages.build
169 @@ -0,0 +1,14 @@
170 +# will be pulled by stage1
171 +sys-libs/compiler-rt
172 +sys-libs/libcxxabi
173 +sys-libs/libcxx
174 +sys-devel/llvm
175 +sys-devel/lld
176 +sys-devel/clang
177 +sys-libs/llvm-libunwind
178 +
179 +# remove gcc & friends
180 +-sys-devel/gcc
181 +-sys-devel/gcc-config
182 +-sys-devel/binutils
183 +-sys-devel/binutils-config
184
185 diff --git a/profiles/features/clang/use.force b/profiles/features/clang/use.force
186 new file mode 100644
187 index 000000000000..e671fa21003e
188 --- /dev/null
189 +++ b/profiles/features/clang/use.force
190 @@ -0,0 +1 @@
191 +clang