Closed rwst closed 6 years ago
Attachment: ntl-10.3.0.log
sagelib is the culprit. It has libstdc++ hardcoded:
../logs/pkgs/sagelib-8.2.beta5.log:[212/474] [211/474] clang++ -pthread -shared -L/home/ralf/sage/local/lib -Wl,-rpath,/home/ralf/sage/local/lib -L/home/ralf/sage/local/lib -L/home/ralf/sage/local/lib -L/home/ralf/sage/local/lib -L/home/ralf/sage/local/lib -L/home/ralf/sage/local/lib -Wl,-rpath,/home/ralf/sage/local/lib -L/home/ralf/sage/local/lib -L/home/ralf/sage/local/lib -L/home/ralf/sage/local/lib -L/home/ralf/sage/local/lib build/temp.linux-x86_64-2.7/build/cythonized/sage/libs/ntl/ntl_ZZ_pX.o -L/home/ralf/sage/local/lib -L/home/ralf/sage/local/lib -lntl -lgmp -lm -lstdc++ -lpython2.7 -o build/lib.linux-x86_64-2.7/sage/libs/ntl/ntl_ZZ_pX.so -lpari
This is the relevant part of src/setup.py
:
# Libraries: add stdc++ if needed and sort them
libs = kwds.get('libraries', [])
if cplusplus:
libs = libs + ['stdc++']
Description changed:
---
+++
@@ -1,3 +1,4 @@
+sagelib build with --stdlib=libc++ still uses libstdc++ for ntl_ZZ.so
ralf@ark:~/sage/pynac> ldd /home/ralf/sage/local/lib/python2.7/site-packages/sage/libs/ntl/ntl_ZZ.so
It seems best to add "--stdlib=libc++"
(else the libstdc++ is linked) only if it is already in CFLAGS. See also #24705.
Testing this manually works, except for element_givaro.pyx
which still gets compiled without the "--stdlib=libc++"
directive.
Never mind, I got it compiled, yeah, now testing.
Replying to @rwst:
It seems best to add
"--stdlib=libc++"
(else the libstdc++ is linked) only if it is already in CFLAGS. See also #24705.
Do you mean #24707?
Replying to @rwst:
This is the relevant part of
src/setup.py
:# Libraries: add stdc++ if needed and sort them libs = kwds.get('libraries', []) if cplusplus: libs = libs + ['stdc++']
Sorry, I don't get it: What would you replace it with, so that the sage library will not use libstdc++
if --stdlib=libc++
is provided?
Replying to @simon-king-jena:
Replying to @rwst:
This is the relevant part of
src/setup.py
:# Libraries: add stdc++ if needed and sort them libs = kwds.get('libraries', []) if cplusplus: libs = libs + ['stdc++']
Sorry, I don't get it: What would you replace it with, so that the sage library will not use
libstdc++
if--stdlib=libc++
is provided?
At the moment we're still experimenting with flags, see #24707 comment:9. But I already think that the line above needs to be changed to libs = libs + ['c++']
in order to get -lc++
in the link command.
Replying to @rwst:
At the moment we're still experimenting with flags, see #24707 comment:9. But I already think that the line above needs to be changed to
libs = libs + ['c++']
in order to get-lc++
in the link command.
But certainly not unconditionally. Or do we want to build with -lc++
when using gcc?
Replying to @simon-king-jena:
But certainly not unconditionally. Or do we want to build with
-lc++
when using gcc?
Of course (EDIT: not).
This still doesn't catch all ways to smuggle -lstdc++
in the cython file linking stage of sagelib.
New commits:
0e4016e | 24705: Do not hardcode the C++ stdlib in setup.py |
Description changed:
---
+++
@@ -1,7 +1,14 @@
-sagelib build with --stdlib=libc++ still uses libstdc++ for ntl_ZZ.so
+sage build with the following flags still uses libstdc++ for some cythonized so files:
-ralf@ark:~/sage/pynac> ldd /home/ralf/sage/local/lib/python2.7/site-packages/sage/libs/ntl/ntl_ZZ.so
+export CC="clang"
+export CXX="clang++ --stdlib=libc++"
+export CXXFLAGS="$CXXFLAGS --stdlib=libc++"
+export LDFLAGS="$LDFLAGS -lc++ --stdlib=libc++"
+ + +
+> ldd /home/ralf/sage/local/lib/python2.7/site-packages/sage/libs/ntl/ntl_ZZ.so
linux-vdso.so.1 (0x00007ffc8f3f1000)
libntl.so.33 => /home/ralf/sage/local/lib/libntl.so.33 (0x00007f823f6d7000)
libgmp.so.23 => /home/ralf/sage/local/lib/libgmp.so.23 (0x00007f823f448000)
Attachment: sagelib-8.2.beta5.log
I did
export CC="clang"
export CXX="clang++ --stdlib=libc++
export CXXFLAGS="$CXXFLAGS -I/usr/include/libcxxabi/ --stdlib=libc++"
export LDFLAGS="$LDFLAGS -lc++ --stdlib=libc++"
make build
The build process goes pretty far, however it hangs (for an hour or so) in sagelib. See the attached log.
I am a bit late to this party - sorry. I don't have this problem at all with my clang configured to use libc++ by default. Is it possible to have readelf -d /home/ralf/sage/local/lib/python2.7/site-packages/sage/libs/ntl/ntl_ZZ.so
on the object initially posted?
So this ticket is wontfix. Use these flags:
export CC="clang"
export CXX="clang++"
export CLANG_DEFAULT_CXX_STDLIB="libc++"
Replying to @rwst:
So this ticket is wontfix. Use these flags:
export CC="clang" export CXX="clang++" export CLANG_DEFAULT_CXX_STDLIB="libc++"
Do you claim that this is enough to override what is written in setup.py???
Recall that Sage's setup.py forces usage of libstdc++
and not libc++
.
Replying to @simon-king-jena:
Do you claim that this is enough to override what is written in setup.py???
Please let me first test whether the given flags are enough to let the branch from #24710 build on ubuntu. Or do you even claim that with your flags scipy will build without modifications?
setup.py
adds -lstdc++
to the flags used for linking but that can still be discarded by the compiler driver used. I can build sage with clang without altering setup.py
so you should be able to. I am glad that Ralph found that environment variable.
Replying to @simon-king-jena:
Replying to @simon-king-jena:
Do you claim that this is enough to override what is written in setup.py???
Please let me first test whether the given flags are enough to let the branch from #24710 build on ubuntu. Or do you even claim that with your flags scipy will build without modifications?
I do not make such claims without testing first.
Attachment: giac-1.4.9.45.p1.log
I just tried with the branch from #24710 and with the flags stated in comment:19. But giac fails to build, see attachment: giac-1.4.9.45.p1.log
Replying to @simon-king-jena:
I just tried with the branch from #24710 and with the flags stated in comment:19. But giac fails to build, see attachment: giac-1.4.9.45.p1.log
It looks like you need #24696
Replying to @kiwifb:
Replying to @simon-king-jena:
I just tried with the branch from #24710 and with the flags stated in comment:19. But giac fails to build, see attachment: giac-1.4.9.45.p1.log
It looks like you need #24696
OK, trying again with #24710 and #24696
Hooray, it builds now! I didn't run tests though. Anyway, to summarize what I did on ubuntu:
export CC="clang"
export CXX="clang++"
export CLANG_DEFAULT_CXX_STDLIB="libc++"
So, your finding out about CLANG_DEFAULT_CXX_STDLIB
was great!
Side-remarks:
I just realise that using #24710 was supposed to be not needed (it was closed as invalid).
Anyway, a data point concerning timings, after installing meataxe:
With gcc
sage: M = random_matrix(GF(9,'x'), 5000)
sage: type(M)
<type 'sage.matrix.matrix_gfpn_dense.Matrix_gfpn_dense'>
sage: N = random_matrix(GF(9,'x'), 5000)
sage: %timeit _=M-N
10 loops, best of 3: 20.5 ms per loop
sage: %timeit _=M*N
1 loop, best of 3: 46.5 s per loop
With clang:
sage: M = random_matrix(GF(9,'x'), 5000)
sage: type(M)
<type 'sage.matrix.matrix_gfpn_dense.Matrix_gfpn_dense'>
sage: N = random_matrix(GF(9,'x'), 5000)
sage: %timeit _=M-N
10 loops, best of 3: 20.5 ms per loop
sage: %timeit _=M*N
1 loop, best of 3: 53.2 s per loop
Since meataxe is heavily used in the computations that I really care about (group cohomology), I am not so happy about a slow-down of almost 15%. So, probably I won't use clang in my computations. Nonetheless, it is good for portability that clang can also be used on ubuntu.
I get several segfaults when testing sage.homology. Is that to be expected?
Should this ticket be closed?
Replying to @jdemeyer:
Should this ticket be closed?
I think so. Certainly the test failure should be for a different ticket.
sage build with the following flags still uses libstdc++ for some cythonized so files:
CC: @kiwifb @simon-king-jena @jdemeyer
Component: build
Branch/Commit: u/rws/do_not_hardcode_the_c___stdlib_in_setup_py @
0e4016e
Issue created by migration from https://trac.sagemath.org/ticket/24705