#706327 dietlibc doesn't provide sqrt() function.

Package:
dietlibc-dev
Source:
dietlibc
Description:
diet libc - a libc optimized for small size
Submitter:
Tanaka Akira
Date:
2024-07-08 18:15:20 UTC
Severity:
normal
Tags:
#706327#5
Date:
2013-04-28 12:46:22 UTC
From:
To:
Package: dietlibc-dev
Version: 0.33~cvs20120325-4

I found that dietlibc doesn't provide sqrt() function.

The following program shows the problem.

  % cat tst.c
  #include <stdlib.h>
  #include <stdio.h>
  #include <math.h>

  int main(int argc, char *argv[])
  {
    double x = sqrt(atof(argv[1]));
    printf("%f\n", x);
    return 0;
  }
  % diet gcc tst.c -lm
  /usr/lib/diet/lib-x86_64/libc.a(vprintf.o): In function `vprintf':
  vprintf.c:(.text+0x3e): warning: warning: the printf functions add
several kilobytes of bloat.
  /tmp/ccvVL6p9.o: In function `main':
  tst.c:(.text+0x35): undefined reference to `sqrt'
  collect2: error: ld returned 1 exit status
  zsh: exit 1     diet gcc tst.c -lm

It seems libm.a doesn't have sqrt definition.
(Several references to sqrt are exists, though.)

  % nm /usr/lib/diet/lib/libm.a|grep sqrt
		   U sqrt
		   U sqrt
		   U sqrt
  % grep sqrt /usr/lib/diet/lib/*
  Binary file /usr/lib/diet/lib/libm.a matches

  % dpkg -l|grep dietlibc
  ii  dietlibc-dev                          0.33~cvs20120325-4
        amd64        diet libc - a libc optimized for small size
  % lsb_release -idrc
  Distributor ID:	Debian
  Description:	Debian GNU/Linux 7.0 (wheezy)
  Release:	7.0
  Codename:	wheezy

#706327#10
Date:
2013-04-28 13:39:11 UTC
From:
To:
Tanaka Akira dixit:

From what I can see, upstream only provides sqrt() for i386,
not for amd64 or other architectures.

I guess libm is not a priority. (I don’t use it myself either…)

bye,
//mirabilos