-4

I want to slightly modify libm's sin function (source: s_sin.c) to experiment with something numerical. However, I don't see how to compile the modified source.

I would like to avoid doing "./configure, make". So, to resolve all dependencies, I tried to compile s_sin.c with libm.a in my system. But my compiler quickly rejects the compilation as it cannot find the header file "mydefs.h" in the source file. There are many such header files in the source.

My question is: what is the easiest way for experimenting with changing a single math function in GNU libm and the compiling it? Thanks.

zell
  • 9,830
  • 10
  • 62
  • 115
  • 1
    Why do you want to avoid `./configure; make`? That should go into the question (because it is the normal build procedure). You might be interested by some `--prefix` passed to `configure`, and/or by [chroot(2)](http://man7.org/linux/man-pages/man2/chroot.2.html) facilities such as [schroot](https://wiki.debian.org/Schroot). Otherwise, your question is some [XY problem](http://xyproblem.info). In all cases, you should **edit your question** to motivate it and give a lot more information (and context) – Basile Starynkevitch Jun 17 '18 at 16:55
  • You could also play with [musl-libc](http://musl-libc.org/) since it is designed to co-exist with `glibc` – Basile Starynkevitch Jun 17 '18 at 16:57
  • Also, you could `./configure; make` without the next `make install` and play with the `libc` in your build tree – Basile Starynkevitch Jun 17 '18 at 17:00

1 Answers1

2

I would like to avoid doing "./configure, make".

You cannot avoid that (since it is the usual build procedure), but you could pass more arguments to configure. Try configure --help first. You could avoid the next make install (or pass some DESTDIR=/tmp/somedir/ to it).

My question is: what is the easiest way for experimenting with changing a single math function in GNU libm and the compiling it?

I would recommend a small chroot(2)-ed environment. Debian has schroot and debootstrap to make that reasonably easy.

Then you still do ./configure -perhaps with a different --prefix ...- followed by make. You may or not want make install

Consider perhaps playing with musl-libc, since it can coexist with your system's libc

BTW, sin is an unusual function (like many in -lm). You could set a breakpoint there to check that most of your system programs don't use it. Don't forget to backup the system's libc and have some static shell running just in case (perhaps sash, because many core utilities are builtin: a static sash contains internal variants of tar, cp, mv etc... that don't depend on any external libc)

Your could also add (temporarily) some #define sin(x) mysin(x) in some header (e.g. /usr/include/math.h) or use LD_PRELOAD tricks.

(it is unclear what you really want to do. libm.so is only used by programs, not by itself; what actual numerical experiments do you want to do ??).

Basile Starynkevitch
  • 223,805
  • 18
  • 296
  • 547