[gnutls-devel] libtasn1 | Cross compilation issue (#28)
Read-only notification of GnuTLS library development activities
gnutls-devel at lists.gnutls.org
Tue Feb 9 18:44:20 CET 2021
Roman Bolshakov commented:
I'm not sure if the issue is fixed. I can reproduce if libtasn1 is compiled with -O1.
Neither libgnu.a nor c-ctype.o have symbol of `c_isdigit`:
```
$ nm lib/gl/.libs/libgnu.a
lib/gl/.libs/libgnu.a(c-ctype.o):
0000000000000000 t ltmp0
lib/gl/.libs/libgnu.a(strverscmp.o):
0000000000000000 T _strverscmp
00000000000000ec s _strverscmp.next_state
00000000000000f8 s _strverscmp.result_type
0000000000000000 t ltmp0
00000000000000ec s ltmp1
0000000000000120 s ltmp2
$ nm lib/gl/c-ctype.o
0000000000000000 t ltmp0
```
If c-ctype.c is compiled with -E flag we can see that `c_isdigit` is declared as `static __attribute__ ((__unused__))`:
```
static __attribute__ ((__unused__)) _Bool
c_isdigit (int c)
{
switch (c)
{
case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9':
return 1;
default:
return 0;
}
}
```
The function is static and compiler doesn't see if it's used so it optimizes it out and that's why the symbol is not available in c-ctype.o.
If we look closer how `c_isdigit` is defined we can notice it's defined with `C_CTYPE_INLINE`:
```
C_CTYPE_INLINE bool
c_isdigit (int c)
{
switch (c)
{
_C_CTYPE_DIGIT:
return true;
default:
return false;
}
}
```
The symbol is assigned to `_GL_EXTERN_INLINE` in c-ctype.c:
```
#include <config.h>
#define C_CTYPE_INLINE _GL_EXTERN_INLINE
#include "c-ctype.h"
```
_GL_EXTERN_INLINE is supposed to be [portable "extern inline"](https://www.gnu.org/software/gnulib/manual/html_node/extern-inline.html) but it doesn't seem to work as intended on modern macOS. I think the issue is caused by incorrect _GL_EXTERN_INLINE definition inside gnulib.
--
Reply to this email directly or view it on GitLab: https://gitlab.com/gnutls/libtasn1/-/issues/28#note_505357689
You're receiving this email because of your account on gitlab.com.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.gnupg.org/pipermail/gnutls-devel/attachments/20210209/95e5ab4f/attachment.html>
More information about the Gnutls-devel
mailing list