1 |
commit: 600a473dc06a2527981b2e9ecc91a69774cd04f6 |
2 |
Author: Lei Zhang <zhanglei.april <AT> gmail <DOT> com> |
3 |
AuthorDate: Sat Sep 3 11:28:24 2016 +0000 |
4 |
Commit: Alexis Ballier <aballier <AT> gentoo <DOT> org> |
5 |
CommitDate: Mon Oct 3 08:51:20 2016 +0000 |
6 |
URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=600a473d |
7 |
|
8 |
sys-libs/libcxx: update live ebuild to use cmake |
9 |
|
10 |
Notable changes: |
11 |
- gcc is now required to build libcxx against libsupc++ |
12 |
- keyword ~mips is dropped to be compatible with clang/llvm |
13 |
|
14 |
.../libcxx/files/libcxx-3.9-cmake-link-flags.patch | 23 +++ |
15 |
sys-libs/libcxx/libcxx-9999.ebuild | 216 +++++++++++---------- |
16 |
2 files changed, 139 insertions(+), 100 deletions(-) |
17 |
|
18 |
diff --git a/sys-libs/libcxx/files/libcxx-3.9-cmake-link-flags.patch b/sys-libs/libcxx/files/libcxx-3.9-cmake-link-flags.patch |
19 |
new file mode 100644 |
20 |
index 00000000..bef5bc1 |
21 |
--- /dev/null |
22 |
+++ b/sys-libs/libcxx/files/libcxx-3.9-cmake-link-flags.patch |
23 |
@@ -0,0 +1,23 @@ |
24 |
+diff --git a/CMakeLists.txt b/CMakeLists.txt |
25 |
+index d618e83..0e76525 100644 |
26 |
+--- a/CMakeLists.txt |
27 |
++++ b/CMakeLists.txt |
28 |
+@@ -293,6 +293,18 @@ remove_flags(-DNDEBUG -UNDEBUG -D_DEBUG |
29 |
+ # so they don't get transformed into -Wno and -errors respectivly. |
30 |
+ remove_flags(-Wno-pedantic -pedantic-errors -pedantic) |
31 |
+ |
32 |
++# FIXME: this is cribbed from HandleLLVMOptions.cmake. |
33 |
++if(LIBCXX_STANDALONE_BUILD) |
34 |
++ # Pass -Wl,-z,defs. This makes sure all symbols are defined. Otherwise a DSO |
35 |
++ # build might work on ELF but fail on MachO/COFF. |
36 |
++ if(NOT (${CMAKE_SYSTEM_NAME} MATCHES "Darwin" OR WIN32 OR CYGWIN OR |
37 |
++ ${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD" OR |
38 |
++ ${CMAKE_SYSTEM_NAME} MATCHES "OpenBSD") AND |
39 |
++ NOT LLVM_USE_SANITIZER) |
40 |
++ set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,-z,defs") |
41 |
++ endif() |
42 |
++endif() |
43 |
++ |
44 |
+ # Required flags ============================================================== |
45 |
+ add_compile_flags_if_supported(-std=c++11) |
46 |
+ if (NOT MSVC AND NOT LIBCXX_SUPPORTS_STD_EQ_CXX11_FLAG) |
47 |
|
48 |
diff --git a/sys-libs/libcxx/libcxx-9999.ebuild b/sys-libs/libcxx/libcxx-9999.ebuild |
49 |
index 06a6211..dc867aa 100644 |
50 |
--- a/sys-libs/libcxx/libcxx-9999.ebuild |
51 |
+++ b/sys-libs/libcxx/libcxx-9999.ebuild |
52 |
@@ -2,108 +2,134 @@ |
53 |
# Distributed under the terms of the GNU General Public License v2 |
54 |
# $Id$ |
55 |
|
56 |
-EAPI=5 |
57 |
+EAPI=6 |
58 |
|
59 |
-ESVN_REPO_URI="http://llvm.org/svn/llvm-project/libcxx/trunk" |
60 |
+# Ninja provides better scalability and cleaner verbose output, and is used |
61 |
+# throughout all LLVM projects. |
62 |
+: ${CMAKE_MAKEFILE_GENERATOR:=ninja} |
63 |
+EGIT_REPO_URI="http://llvm.org/git/libcxx.git |
64 |
+ https://github.com/llvm-mirror/libcxx.git" |
65 |
+CMAKE_MIN_VERSION=3.4.3 |
66 |
+PYTHON_COMPAT=( python2_7 ) |
67 |
|
68 |
-[ "${PV%9999}" != "${PV}" ] && SCM="subversion" || SCM="" |
69 |
+[[ ${PV} == 9999 ]] && SCM="git-r3" || SCM="" |
70 |
|
71 |
-inherit ${SCM} flag-o-matic toolchain-funcs multilib multilib-minimal |
72 |
+inherit ${SCM} cmake-multilib python-any-r1 toolchain-funcs |
73 |
|
74 |
DESCRIPTION="New implementation of the C++ standard library, targeting C++11" |
75 |
HOMEPAGE="http://libcxx.llvm.org/" |
76 |
-if [ "${PV%9999}" = "${PV}" ] ; then |
77 |
- SRC_URI="http://llvm.org/releases/${PV}/${P}.src.tar.xz" |
78 |
+if [[ ${PV} != 9999 ]] ; then |
79 |
+ SRC_URI="http://llvm.org/releases/${PV}/${P}.src.tar.xz |
80 |
+ test? ( http://llvm.org/releases/${PV}/llvm-${PV}.src.tar.xz )" |
81 |
S="${WORKDIR}/${P}.src" |
82 |
+ LLVM_S="${WORKDIR}/llvm-${PV}.src" |
83 |
else |
84 |
SRC_URI="" |
85 |
+ LLVM_S="${WORKDIR}/llvm" |
86 |
fi |
87 |
|
88 |
LICENSE="|| ( UoI-NCSA MIT )" |
89 |
SLOT="0" |
90 |
-if [ "${PV%9999}" = "${PV}" ] ; then |
91 |
- KEYWORDS="~amd64 ~mips ~x86 ~amd64-fbsd ~x86-fbsd ~amd64-linux ~x86-linux" |
92 |
+if [[ ${PV} != 9999 ]] ; then |
93 |
+ KEYWORDS="~amd64 ~x86 ~amd64-fbsd ~x86-fbsd ~amd64-linux ~x86-linux" |
94 |
else |
95 |
KEYWORDS="" |
96 |
fi |
97 |
IUSE="elibc_glibc elibc_musl +libcxxrt libunwind +static-libs test" |
98 |
REQUIRED_USE="libunwind? ( libcxxrt )" |
99 |
|
100 |
-RDEPEND="libcxxrt? ( >=sys-libs/libcxxrt-0.0_p20130725[libunwind?,static-libs?,${MULTILIB_USEDEP}] ) |
101 |
+RDEPEND="libcxxrt? ( sys-libs/libcxxrt[libunwind=,static-libs?,${MULTILIB_USEDEP}] ) |
102 |
!libcxxrt? ( >=sys-devel/gcc-4.7:=[cxx] )" |
103 |
+# llvm-3.9.0 needed because its cmake files installation path changed, which is |
104 |
+# needed by libcxx |
105 |
DEPEND="${RDEPEND} |
106 |
- test? ( sys-devel/clang ) |
107 |
- app-arch/xz-utils" |
108 |
+ test? ( sys-devel/clang[${MULTILIB_USEDEP}] |
109 |
+ ${PYTHON_DEPS} ) |
110 |
+ app-arch/xz-utils |
111 |
+ >=sys-devel/llvm-3.9.0[${MULTILIB_USEDEP}]" |
112 |
|
113 |
DOCS=( CREDITS.TXT ) |
114 |
|
115 |
+PATCHES=( |
116 |
+ # Add link flag "-Wl,-z,defs" to avoid underlinking; this is needed in a |
117 |
+ # out-of-tree build. |
118 |
+ "${FILESDIR}/${PN}-3.9-cmake-link-flags.patch" |
119 |
+) |
120 |
+ |
121 |
pkg_setup() { |
122 |
- if ! use libcxxrt ; then |
123 |
- ewarn "You have disabled USE=libcxxrt. This will build ${PN} against" |
124 |
- ewarn "libsupc++. Please note that this is not well supported." |
125 |
- ewarn "In particular, static linking will not work." |
126 |
+ use test && python_setup |
127 |
+ |
128 |
+ if ! use libcxxrt && ! tc-is-gcc ; then |
129 |
+ eerror "To build ${PN} against libsupc++, you have to use gcc. Other" |
130 |
+ eerror "compilers are not supported. Please set CC=gcc and CXX=g++" |
131 |
+ eerror "and try again." |
132 |
+ die |
133 |
fi |
134 |
- if [[ $(gcc-version) < 4.7 ]] && [[ $(tc-getCXX) != *clang++* ]] ; then |
135 |
- eerror "${PN} needs to be built with clang++ or gcc-4.7 or later." |
136 |
- eerror "Please use gcc-config to switch to gcc-4.7 or later version." |
137 |
+ if tc-is-gcc && [[ $(gcc-version) < 4.7 ]] ; then |
138 |
+ eerror "${PN} needs to be built with gcc-4.7 or later (or other" |
139 |
+ eerror "conformant compilers). Please use gcc-config to switch to" |
140 |
+ eerror "gcc-4.7 or later version." |
141 |
die |
142 |
fi |
143 |
} |
144 |
|
145 |
-src_prepare() { |
146 |
- cp -f "${FILESDIR}/Makefile" lib/ || die |
147 |
- use elibc_musl && epatch "${FILESDIR}/${P}-musl-support.patch" |
148 |
- multilib_copy_sources |
149 |
-} |
150 |
+src_unpack() { |
151 |
+ [[ ${PV} != 9999 ]] && default && return |
152 |
|
153 |
-src_configure() { |
154 |
- export LIBS="-lpthread -lrt -lc -l$(usex libunwind unwind gcc_s)" |
155 |
- if use libcxxrt ; then |
156 |
- append-cppflags -DLIBCXXRT "-I${EPREFIX}/usr/include/libcxxrt/" |
157 |
- LIBS="-lcxxrt ${LIBS}" |
158 |
- cp "${EPREFIX}/usr/include/libcxxrt/"*.h "${S}/include" |
159 |
- else |
160 |
- # Very hackish, see $HOMEPAGE |
161 |
- # If someone has a clever idea, please share it! |
162 |
- local includes="$(echo | ${CHOST}-g++ -Wp,-v -x c++ - -fsyntax-only 2>&1 | grep -C 2 '#include.*<...>' | tail -n 2 | sed -e 's/^ /-I/' | tr '\n' ' ')" |
163 |
- local libcxx_gcc_dirs="$(echo | ${CHOST}-g++ -Wp,-v -x c++ - -fsyntax-only 2>&1 | grep -C 2 '#include.*<...>' | tail -n 2 | tr '\n' ' ')" |
164 |
- append-cppflags -D__GLIBCXX__ ${includes} |
165 |
- LIBS="-lsupc++ ${LIBS}" |
166 |
- local libsupcxx_includes="cxxabi.h bits/c++config.h bits/os_defines.h bits/cpu_defines.h bits/cxxabi_tweaks.h bits/cxxabi_forced.h" |
167 |
- for i in ${libsupcxx_includes} ; do |
168 |
- local found="" |
169 |
- [ -d "${S}/include/$(dirname ${i})/" ] || mkdir -p "${S}/include/$(dirname ${i})" |
170 |
- for j in ${libcxx_gcc_dirs} ; do |
171 |
- if [ -f "${j}/${i}" ] ; then |
172 |
- cp "${j}/${i}" "${S}/include/$(dirname ${i})/" || die |
173 |
- found=yes |
174 |
- fi |
175 |
- done |
176 |
- [ -n "${found}" ] || die "Header not found: ${i}" |
177 |
- done |
178 |
+ if use test; then |
179 |
+ # needed for tests |
180 |
+ git-r3_fetch "http://llvm.org/git/llvm.git |
181 |
+ https://github.com/llvm-mirror/llvm.git" |
182 |
fi |
183 |
+ git-r3_fetch |
184 |
|
185 |
- tc-export AR CC CXX |
186 |
- |
187 |
- append-ldflags "-Wl,-z,defs" # make sure we are not underlinked |
188 |
+ if use test; then |
189 |
+ git-r3_checkout http://llvm.org/git/llvm.git \ |
190 |
+ "${WORKDIR}"/llvm |
191 |
+ fi |
192 |
+ git-r3_checkout |
193 |
} |
194 |
|
195 |
-multilib_src_compile() { |
196 |
- cd "${BUILD_DIR}/lib" || die |
197 |
- emake shared |
198 |
- use static-libs && emake static |
199 |
+multilib_src_configure() { |
200 |
+ local cxxabi cxxabi_incs |
201 |
+ if use libcxxrt; then |
202 |
+ cxxabi=libcxxrt |
203 |
+ cxxabi_incs="${EPREFIX}/usr/include/libcxxrt" |
204 |
+ else |
205 |
+ local gcc_inc="${EPREFIX}/usr/lib/gcc/${CHOST}/$(gcc-fullversion)/include/g++-v$(gcc-major-version)" |
206 |
+ cxxabi=libsupc++ |
207 |
+ cxxabi_incs="${gcc_inc};${gcc_inc}/${CHOST}" |
208 |
+ fi |
209 |
+ |
210 |
+ local libdir=$(get_libdir) |
211 |
+ local mycmakeargs=( |
212 |
+ -DLLVM_LIBDIR_SUFFIX=${libdir#lib} |
213 |
+ -DLIBCXX_ENABLE_SHARED=ON |
214 |
+ -DLIBCXX_ENABLE_STATIC=$(usex static-libs) |
215 |
+ -DLIBCXX_CXX_ABI=${cxxabi} |
216 |
+ -DLIBCXX_CXX_ABI_INCLUDE_PATHS=${cxxabi_incs} |
217 |
+ # we're using our own mechanism for generating linker scripts |
218 |
+ -DLIBCXX_ENABLE_ABI_LINKER_SCRIPT=OFF |
219 |
+ -DLIBCXX_HAS_MUSL_LIBC=$(usex elibc_musl) |
220 |
+ -DLIBCXX_HAS_GCC_S_LIB=$(usex !libunwind) |
221 |
+ -DLIBCXX_INCLUDE_TESTS=$(usex test) |
222 |
+ -DCMAKE_SHARED_LINKER_FLAGS=$(usex libunwind "-lunwind" "") |
223 |
+ ) |
224 |
+ if use test; then |
225 |
+ mycmakeargs+=( |
226 |
+ -DLLVM_MAIN_SRC_DIR=${LLVM_S} |
227 |
+ ) |
228 |
+ fi |
229 |
+ cmake-utils_src_configure |
230 |
} |
231 |
|
232 |
-# Tests fail for now, if anybody is able to fix them, help is very welcome. |
233 |
multilib_src_test() { |
234 |
- cd "${BUILD_DIR}/test" |
235 |
- LD_LIBRARY_PATH="${BUILD_DIR}/lib:${LD_LIBRARY_PATH}" \ |
236 |
- CC="clang++ $(get_abi_CFLAGS) ${CXXFLAGS}" \ |
237 |
- HEADER_INCLUDE="-I${BUILD_DIR}/include" \ |
238 |
- SOURCE_LIB="-L${BUILD_DIR}/lib" \ |
239 |
- LIBS="-lm $(usex libcxxrt -lcxxrt "")" \ |
240 |
- ./testit || die |
241 |
- # TODO: fix link against libsupc++ |
242 |
+ local clang_path=$(type -P "${CHOST:+${CHOST}-}clang" 2>/dev/null) |
243 |
+ |
244 |
+ [[ -n ${clang_path} ]] || die "Unable to find ${CHOST}-clang for tests" |
245 |
+ sed -i -e "/cxx_under_test/s^\".*\"^\"${clang_path}\"^" test/lit.site.cfg || die |
246 |
+ |
247 |
+ cmake-utils_src_make check-libcxx |
248 |
} |
249 |
|
250 |
# Usage: deps |
251 |
@@ -122,49 +148,39 @@ END_LDSCRIPT |
252 |
} |
253 |
|
254 |
gen_static_ldscript() { |
255 |
- if use libcxxrt ; then |
256 |
- # Move it first. |
257 |
- mv "${ED}/usr/$(get_libdir)/libc++.a" "${ED}/usr/$(get_libdir)/libc++_static.a" || die |
258 |
- |
259 |
- # Generate libc++.a ldscript for inclusion of its dependencies so that |
260 |
- # clang++ -stdlib=libc++ -static works out of the box. |
261 |
- local deps="${EPREFIX}/usr/$(get_libdir)/libc++_static.a ${EPREFIX}/usr/$(get_libdir)/libcxxrt.a" |
262 |
- # On Linux/glibc it does not link without libpthread or libdl. It is |
263 |
- # fine on FreeBSD. |
264 |
- use elibc_glibc && deps="${deps} ${EPREFIX}/usr/$(get_libdir)/libpthread.a ${EPREFIX}/usr/$(get_libdir)/libdl.a" |
265 |
- |
266 |
- # unlike libgcc_s, libunwind is not implicitly linked |
267 |
- use libunwind && deps="${deps} ${EPREFIX}/usr/$(get_libdir)/libunwind.a" |
268 |
- |
269 |
- gen_ldscript "${deps}" > "${ED}/usr/$(get_libdir)/libc++.a" |
270 |
- fi |
271 |
- # TODO: Generate a libc++.a ldscript when building against libsupc++ |
272 |
+ local libdir=$(get_libdir) |
273 |
+ local cxxabi_lib=$(usex libcxxrt "libcxxrt.a" "libsupc++.a") |
274 |
+ |
275 |
+ # Move it first. |
276 |
+ mv "${ED}/usr/${libdir}/libc++.a" "${ED}/usr/${libdir}/libc++_static.a" || die |
277 |
+ # Generate libc++.a ldscript for inclusion of its dependencies so that |
278 |
+ # clang++ -stdlib=libc++ -static works out of the box. |
279 |
+ local deps="libc++_static.a ${cxxabi_lib}" |
280 |
+ # On Linux/glibc it does not link without libpthread or libdl. It is |
281 |
+ # fine on FreeBSD. |
282 |
+ use elibc_glibc && deps+=" libpthread.a libdl.a" |
283 |
+ # unlike libgcc_s, libunwind is not implicitly linked |
284 |
+ use libunwind && deps+=" libunwind.a" |
285 |
+ |
286 |
+ gen_ldscript "${deps}" > "${ED}/usr/${libdir}/libc++.a" || die |
287 |
} |
288 |
|
289 |
gen_shared_ldscript() { |
290 |
- if use libcxxrt ; then |
291 |
- mv "${ED}/usr/$(get_libdir)/libc++.so" "${ED}/usr/$(get_libdir)/libc++_shared.so" || die |
292 |
- local deps="${EPREFIX}/usr/$(get_libdir)/libc++_shared.so ${EPREFIX}/usr/$(get_libdir)/libcxxrt.so" |
293 |
- use libunwind && deps="${deps} ${EPREFIX}/usr/$(get_libdir)/libunwind.so" |
294 |
- gen_ldscript "${deps}" > "${ED}/usr/$(get_libdir)/libc++.so" |
295 |
- fi |
296 |
- # TODO: Generate the linker script for other configurations too. |
297 |
+ local libdir=$(get_libdir) |
298 |
+ # libsupc++ doesn't have a shared version |
299 |
+ local cxxabi_lib=$(usex libcxxrt "libcxxrt.so" "libsupc++.a") |
300 |
+ |
301 |
+ mv "${ED}/usr/${libdir}/libc++.so" "${ED}/usr/${libdir}/libc++_shared.so" || die |
302 |
+ local deps="libc++_shared.so ${cxxabi_lib}" |
303 |
+ use libunwind && deps+=" libunwind.so" |
304 |
+ |
305 |
+ gen_ldscript "${deps}" > "${ED}/usr/${libdir}/libc++.so" || die |
306 |
} |
307 |
|
308 |
multilib_src_install() { |
309 |
- cd "${BUILD_DIR}/lib" |
310 |
- if use static-libs ; then |
311 |
- dolib.a libc++.a |
312 |
- gen_static_ldscript |
313 |
- fi |
314 |
- dolib.so libc++.so* |
315 |
+ cmake-utils_src_install |
316 |
gen_shared_ldscript |
317 |
-} |
318 |
- |
319 |
-multilib_src_install_all() { |
320 |
- einstalldocs |
321 |
- insinto /usr/include/c++/v1 |
322 |
- doins -r include/* |
323 |
+ use static-libs && gen_static_ldscript |
324 |
} |
325 |
|
326 |
pkg_postinst() { |