linker options for C code in ext/interpreters and other stuff in sagelib

63 views
Skip to first unread message

Dima Pasechnik

unread,
Mar 27, 2017, 11:42:40 AM3/27/17
to sage-devel
On #22679 I am getting errors like

        import sage.ext.interpreters.wrapper_cdf
    ImportError: /usr/home/dima/Sage/sage/local/lib/python2.7/site-packages/sage/ext/interpreters/wrapper_cdf.so:  Undefined symbol "cpow"

Here cpow should come from cephes package, which creates SAGE_LOCAL/lib/libm.so
---but it does not.
Where does one set up linking options for C/C++ code that goes into sagelib?
(in this case, for src/sage/ext/interpreters/interp_cdf.c)
This does not seem to be documented anywhere.

Thanks,
Dima



Dima Pasechnik

unread,
Mar 27, 2017, 1:58:38 PM3/27/17
to sage-devel
here is one concrete example:

"extra_link_args" in src/build/cythonized/sage/ext/interpreters/wrapper_cdf.c
has "-lpari" in it.

Where is this specified?

Note that this C file is apparently generated from 
src/sage/ext/interpreters/wrapper_cdf.pyx
which is 
"Automatically generated by /usr/home/dima/Sage/sage/src/sage_setup/autogen/interpreters.py"
(apparently from thin air :-))


(IMHO my problem will be solved if I find out how to add '-lm' next to that '-lpari')

Thanks,
Dima

François Bissey

unread,
Mar 27, 2017, 5:15:12 PM3/27/17
to sage-...@googlegroups.com
The generated sage/ext/interpreters/wrapper_cdf.pxd has the following
statement:
cimport sage.libs.cypari2.types

That would pull `-lpari`. To add `-lm` you would have to add
a line
#distutils: libraries = m
at the top of the same .pxd file, you'll have to dig a bit
inside sage_setup/autogen/interpreters.py to work out
where and how to insert it. The class "InterpreterSpec"
has a "pxd_header" which I think is right place for it.

Francois
> --
> You received this message because you are subscribed to the Google
> Groups "sage-devel" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to sage-devel+...@googlegroups.com
> <mailto:sage-devel+...@googlegroups.com>.
> To post to this group, send email to sage-...@googlegroups.com
> <mailto:sage-...@googlegroups.com>.
> Visit this group at https://groups.google.com/group/sage-devel.
> For more options, visit https://groups.google.com/d/optout.

Jeroen Demeyer

unread,
Mar 28, 2017, 3:32:53 AM3/28/17
to sage-...@googlegroups.com
On 2017-03-27 23:15, François Bissey wrote:
> The generated sage/ext/interpreters/wrapper_cdf.pxd has the following
> statement:
> cimport sage.libs.cypari2.types
>
> That would pull `-lpari`.

That's not actually true. Just using the *types* from PARI doesn't need
linking against PARI. It's cysignals which pulls -lpari.

> To add `-lm` you would have to add
> a line
> #distutils: libraries = m
> at the top of the same .pxd file

Actually, the .pyx file. If something is needed for the .pxd file, the
"# distutils" declaration should be in the .pxd file. But this is not
the case here, so it should be in the .pyx file.

Dima Pasechnik

unread,
Mar 28, 2017, 4:04:39 AM3/28/17
to sage-devel
Thanks.
Does such  "#distutils: libraries = blah " automatically imply that libblah from $SAGE_LOCAL/lib/ will be linked?
 

Francois Bissey

unread,
Mar 28, 2017, 4:07:45 AM3/28/17
to sage-...@googlegroups.com
Unless you add -L$some_path, it should be the first one tried. If it is not found or
incompatible, system paths will be tried.

Francois Bissey

unread,
Mar 28, 2017, 4:13:13 AM3/28/17
to sage-...@googlegroups.com

> On 28/03/2017, at 21:07, Francois Bissey <francoi...@canterbury.ac.nz> wrote:
>
>> Does such "#distutils: libraries = blah " automatically imply that libblah from $SAGE_LOCAL/lib/ will be linked?
>>
>
> Unless you add -L$some_path, it should be the first one tried. If it is not found or
> incompatible, system paths will be tried.

Actually, is this for freeBSD? What is the linker used? We may not have the right
mechanism in place for freeBSD.

François

Dima Pasechnik

unread,
Mar 28, 2017, 7:00:19 AM3/28/17
to sage-devel


On Tuesday, March 28, 2017 at 9:13:13 AM UTC+1, François wrote:

> On 28/03/2017, at 21:07, Francois Bissey <francoi...@canterbury.ac.nz> wrote:
>
>> Does such  "#distutils: libraries = blah " automatically imply that libblah from $SAGE_LOCAL/lib/ will be linked?
>>
>
> Unless you add -L$some_path, it should be the first one tried. If it is not found or
> incompatible, system paths will be tried.

Actually, is this for freeBSD?

yes it is.
 
What is the linker used? We may not have the right
mechanism in place for freeBSD.

$ ld -v
GNU ld (GNU Binutils) 2.27
 

François
Reply all
Reply to author
Forward
0 new messages