Re: undefined reference to `__chkstk_ms'

Keith Marshall <[email protected]>
Newsgroups gmane.comp.gnu.mingw.user
Organization MinGW.org Project
Message-ID <[email protected]>
On 27/05/19 09:05, Rastislav Stanik wrote:
> I've hit a problem when compiling my project with
> gcc --version
> gcc (x86_64-win32-sjlj-rev0, Built by MinGW-W64 project) 8.1.0

First, let's make it completely clear: this compiler originates from a
third party project which illegally uses our registered trademark,
without our authorization; it is NOT a MinGW product, and is not
supported here.

> I'm trying to build a 32-bit (using -m32) shared library that uses
> PCRE (Perl Compatible Regular Expressions library) compiled by myself
> using the same compiler. At linking stage I get a report about
> missing symbol __chkstk_ms:
> 
> {MinGW-root}/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/lib/../lib32/libmingw32.a(lib32_libmingw32_a-pseudo-reloc.o):pseudo-reloc.c:(.text+0x18d):
> undefined reference to `__chkstk_ms'
> 
> Reference to __chkstk_ms() is added by compiler when some function
> declares local variables exceeding page size (~4k).

Amongst other reasons.

> In my case the function that exceeds the limit is in PRCE, so I
> cannot simply work around it in my code. The function __chkstk_ms()
> is provided by libgcc.a located in directory
> 
>   {MinGW-root}/lib/gcc/x86_64-w64-mingw32/8.1.0/32/
> 
> So if I add linking of that libgcc.a then the linking stage succeeds.
> But I also have to ensure that libgcc.a is in link search path.
> 
> Questions:
> - why the compiler does not add libgcc.a by itself when it added
> __chkstk_ms() by itself?

Our distribution does exactly that; irrespective of whether or not
__chkstk_ms() is referenced, -lgcc is specified by default, and the
appropriate path is also specified.

> - if I add -lgcc, why do I also have to add path with -L? Shouldn't
> the directory be in the default linker search path? - is there a
> solution that will keep working after next release of MinGW/GCC when
> the path to libgcc changes?

You aren't using a genuine MinGW product, so who knows?  A possible
explanation could be that your build system is trying to invoke ld
directly, rather than letting gcc do the linking ... you don't show the
actual link command.  If you don't indulge in that misguided shortcut,
then this problem should not arise, with our GCC-8.2.0

-- 
Regards,
Keith.

Public key available from keys.gnupg.net
Key fingerprint: C19E C018 1547 DE50 E1D4 8F53 C0AD 36C6 347E 5A3F

_______________________________________________
MinGW-Users mailing list
[email protected]

This list observes the Etiquette found at
http://www.mingw.org/Mailing_Lists.
We ask that you be polite and do the same.  Disregard for the list etiquette may cause your account to be moderated.

_______________________________________________
You may change your MinGW Account Options or unsubscribe at:
https://lists.osdn.me/mailman/listinfo/mingw-users
Also: mailto:[email protected]?subject=unsubscribe
signature.asc (application/pgp-signature, 836 B)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.20 (GNU/Linux)

iQIcBAEBAgAGBQJc6/xrAAoJEMCtNsY0flo/cCUQAKoM3X/GznWi1NKmvPDZuezl
BH6H7ZUHYi8ZAgidXYAqKzfxHHDb3p8IjWagRAfMDW9DHPA9BmhgB3DXTjLBRpY7
vt3uNLL9G9B4/oEbYBHe79+ybFZ8sxRi6yRFCZj/MhLC1MkXqPFjyRm2WlNNUbY8
n56vzPNqqNhY/XDCLxY3FFmFrZXcwEobEx31Bm4GxiSnLDJUwd6uz30pHyNu/jBh
ElyCGd8z4ivgWTmUqYXepWp/rDS91di4H3DE+jFoP6w0MYCy0TuAH7SV4bZtCRob
8gcgU/uBKD03uo1hBWTUl6KjDGN6DpPm4NOojiMdN2It/esScXuXzRMMjvf0ANla
nslPLvBCAfN851qWUP4zQaSAkQLUsOQP72kNQ3D6OSWSYpJjAKeSlg0XX5FMzMb1
IeNzHckEweZgb4HdJJcj1k9Rq2M7IhTo6UU1uPVR/TsHbqXw8um22AcEKy2OqwlL
DeU8fMLCxv9yYfuIfX0lQNcHav1nKqmVarQWpn31tVaV2WkS1z9uJF1MUFVtrUU+
jlwnvRBucZlMMIKqC2RQzCKguSYDZSYtPsGptBxR36UUpW0KlkA8Tup5vLygCfp6
GJ/Ki5mumkRpf8dQmNNqzqOkRM44PgnIKtvaxBgCrkWZKwts8v9lK/a1nEegzFnQ
MPHP7eHBr4KXrRzWtYn9
=fFxr
-----END PGP SIGNATURE-----
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.