Menu

#609 Optimization/link problem at gcc -O1

closed-fixed
nobody
binutils (105)
2004-07-26
2004-07-15
No

This fails on MinGW GCC 3.4.1 RC, as well as vanilla FSF
GCC 3.4.0 and FSF GCC head.

It's not a minimal testcase, and not even proper C, and
I have not done too much past this to analyze the
failure beyond get this testcase. I'm sort of frazzled at
the moment.

ixx reported that this causing build failures in dna
analysis tool. a websearch indicates that this may be
causing failures in quite a few other programs also. the
code itself is distilled from mingwrt head.

This fails with:
gcc -O1 -shared p.c -o p.dll
but not with:
gcc -O1 -shared p.c -o p.dll

Errors:
Info: resolving ___mb_cur_max by linking to
__imp____mb_cur_max (auto-import)
Info: resolving __pctype by linking to __imp___pctype
(auto-import)
fu000001.o(.idata$3+0xc): undefined reference to
`libmsvcrt_a_iname'
fu000003.o(.idata$3+0xc): undefined reference to
`libmsvcrt_a_iname'
nmth000000.o(.idata$4+0x0): undefined reference to
`_nm____mb_cur_max'
nmth000002.o(.idata$4+0x0): undefined reference to
`_nm___pctype'

Testcase:

extern int __mb_cur_max;
extern unsigned short* _pctype;

extern __inline__ int isdigit(int c) {
return (__mb_cur_max == 1 ? (_pctype[c] & 0x0004)
: _isctype(c, 0x0004));
}

extern __inline__ int isspace(int c) {
return (__mb_cur_max == 1 ? (_pctype[c] & 0x0008)
: _isctype(c, 0x0008));
}

int llama() {
if (!isdigit(0) && isspace(0))
return 1;

return 0;
}

Discussion

  • Aaron W. LaFramboise

    Logged In: YES
    user_id=1040098

    This also fails on gcc 3.2.3, so its not a regression from
    that. I don't know anything anything earlier.

     
  • Danny Smith

    Danny Smith - 2004-07-15
    • labels: 103944 --> binutils
    • assigned_to: dannysmith --> nobody
     
  • Danny Smith

    Danny Smith - 2004-07-15

    Logged In: YES
    user_id=11494

    The auto-import extension doesn't work when linking against
    an import lib built with dlltool -- in this case libmsvcrt.a. You
    actually need to build a dll from source to allow auto-
    importing from that dll

    Danny

     
  • Danny Smith

    Danny Smith - 2004-07-15

    Logged In: YES
    user_id=11494

    I remember a similar problem occurring over a year ago. In
    that case, an outdated check for GCC version was causing a
    #define __attribute__(x) /* Nothing */

    This disabled the dllimport attribute for __mb_cur_max and
    so engaged the auto-import functionality.

    Danny

     
  • Aaron W. LaFramboise

    Logged In: YES
    user_id=1040098

    This appears to be primarily due to a perl bug. While I would
    prefer more descriptive or intuitive messages or behavior from
    the compiler or linker, the tools are working properly here.
    This ticket can be closed.

     
  • Danny Smith

    Danny Smith - 2004-07-26
    • status: open --> closed-fixed