Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

#2130 WSL: undefined reference to _isascii

WSL
assigned
Earnie Boyd
None
Bug
none
Unknown
False
2014-12-31
2013-11-07
Keith Marshall
No

Following the packaging issues for gettext-0.18.3, as identified on ticket [#2128], and just for grins, I thought I would try building gettext-0.18.3.1 using WSL 4.1-dev. First, it blew up as a result of the issue which has caused me to reopen [#2012].

After relocating the _fileno() declaration within stdio.h, to work around this, it then blew up again, as a result of multiple undefined references to _isascii, from various translation units within the gettext-tools package subdir. Following up, in WSL's include/ctype.h I see:

#ifndef _NO_OLDNAMES
/* Not _CRTIMP */ 
int __cdecl __MINGW_NOTHROW isascii (int);
int __cdecl __MINGW_NOTHROW toascii (int);
int __cdecl __MINGW_NOTHROW iscsymf (int);
int __cdecl __MINGW_NOTHROW iscsym (int);
#endif  /* Not _NO_OLDNAMES */

which provides the declaration for the isascii() function, among others which are declared as "deprecated" by MSDN, and which would be represented by this _isascii symbol within some library, (presumably expected to be exported from MSVCRT.DLL). Unfortunately, this is one of those cases where MSDN is wrong: these functions are more than deprecated; they no longer exist, (if indeed they ever did), in MSVCRT.DLL. The only related symbols within MSVCRT.DLL, as identified by pexports, are ___isascii, ___toascii, ___iscsym, and ___iscsymf, corresponding to these include/ctype.h declarations:

#ifndef __STRICT_ANSI__
int __cdecl __MINGW_NOTHROW __isascii (int);
int __cdecl __MINGW_NOTHROW __toascii (int);
int __cdecl __MINGW_NOTHROW __iscsymf (int);    /* Valid first character in C symbol */
int __cdecl __MINGW_NOTHROW __iscsym (int);     /* Valid character in C symbol (after first) */

#if !(defined (__NO_INLINE__) || defined (__NO_CTYPE_INLINES))
__CRT_INLINE int __cdecl __MINGW_NOTHROW __isascii(int c) {return ((c & ~0x7F) == 0);} 
__CRT_INLINE int __cdecl __MINGW_NOTHROW __toascii(int c) {return (c & 0x7F);}
__CRT_INLINE int __cdecl __MINGW_NOTHROW __iscsymf(int c) {return (isalpha(c) || (c == '_'));}
__CRT_INLINE int __cdecl __MINGW_NOTHROW __iscsym(int c)  {return  (isalnum(c) || (c == '_'));}
#endif /* __NO_CTYPE_INLINES */

One might expect the undecorated POSIX-style function names to be mapped via redirections in libmoldnames.a, but I can find no evidence of this, either in current WSL or in my old mingwrt-3.x CVS sandbox; this rather begs the question: how did previous builders of gettext for mingw32 overcome this obstacle? I can do so, by patching include/ctype.h thus:

--- a/include/ctype.h   2013-10-21 21:20:17.374295039 +0100
+++ b/include/ctype.h   2013-11-06 22:47:26.361827981 +0000
@@ -239,12 +239,19 @@ __CRT_INLINE int __cdecl __MINGW_NOTHROW
 #ifndef    _NO_OLDNAMES
 /* Not _CRTIMP */ 
 int __cdecl __MINGW_NOTHROW isascii (int);
 int __cdecl __MINGW_NOTHROW toascii (int);
 int __cdecl __MINGW_NOTHROW iscsymf (int);
 int __cdecl __MINGW_NOTHROW iscsym (int);
+
+#if !(defined (__NO_INLINE__) || defined (__NO_CTYPE_INLINES))
+__CRT_INLINE int __cdecl __MINGW_NOTHROW isascii(int c) {return ((c & ~0x7F) == 0);} 
+__CRT_INLINE int __cdecl __MINGW_NOTHROW toascii(int c) {return (c & 0x7F);}
+__CRT_INLINE int __cdecl __MINGW_NOTHROW iscsymf(int c) {return (isalpha(c) || (c == '_'));}
+__CRT_INLINE int __cdecl __MINGW_NOTHROW iscsym(int c)  {return  (isalnum(c) || (c == '_'));}
+#endif /* __NO_CTYPE_INLINES */
 #endif /* Not _NO_OLDNAMES */

 #endif /* Not __STRICT_ANSI__ */

 #ifdef __cplusplus
 }

With this in place, upstream gettext-0.18.3.1 compiles OOTB, with no apparent problems, (although, since I've cross-compiled it, I have not run "make check"). This may represent a partial solution to the issue; a complete solution would also require the provision of actual implementations, say within libmoldnames.a

Related

Issues: #2012
Issues: #2128

Discussion

  • Keith Marshall
    Keith Marshall
    2013-11-07

    • Description has changed:

    Diff:

    --- old
    +++ new
    @@ -1,6 +1,6 @@
     Following the packaging issues for gettext-0.18.3, as identified on ticket [#2128], and just for grins, I thought I would try building gettext-0.18.3.1 using WSL 4.1-dev.  First, it blew up as a result of the issue which has caused me to reopen [#2012].
    
    -After relocating the `_fileno()` declaration within stdio.h, it then blew up again, as a result of multiple undefined references to `_isascii`, from various translation units within the gettext-tools package subdir.  Following up, in WSL's include/ctype.h I see:
    +After relocating the `_fileno()` declaration within stdio.h, to work around this, it then blew up again, as a result of multiple undefined references to `_isascii`, from various translation units within the gettext-tools package subdir.  Following up, in WSL's include/ctype.h I see:
    

    #ifndef _NO_OLDNAMES