http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57120
Bug #: 57120
Summary: Plain C link with libgcc_s_sjlj-1.dll which not needed
Classification: Unclassified
Product: gcc
Version: 4.8.1
Status: UNCONFIRMED
Severity: major
Priority: P3
Component: c
AssignedTo: [email protected]
ReportedBy: [email protected]
Here is example:
$ cat t-w32.c
long long do_div(long long a, long long b)
{
return a/b;
}
i686-w64-mingw32-gcc -shared -o t-w32.dll t-w32.c
i686-w64-mingw32-objdump -x t-w32.dll | grep "DLL Name"
gcc 4.8:
DLL Name: libgcc_s_sjlj-1.dll
DLL Name: KERNEL32.dll
DLL Name: msvcrt.dll
gcc 4.7:
DLL Name: KERNEL32.dll
DLL Name: msvcrt.dll
Then I investigate why the gcc 4.8 output dll use libgcc_s_sjlj-1.dll,
I found t-w32.dll use the following symbols in libgcc_s_sjlj-1.dll:
i686-w64-mingw32-objdump -x t-w32.dll | less
DLL Name: libgcc_s_sjlj-1.dll
vma: Hint/Ord Member-Name Bound-To
c200 41 __divdi3
c20c 119 __udivdi3
c218 121 __umoddi3
I think this is a regress, isn't it ?
I found in gcc/config/i386/mingw32.h:
/* Include in the mingw32 libraries with libgcc */
#ifdef ENABLE_SHARED_LIBGCC
#define SHARED_LIBGCC_SPEC " \
%{static|static-libgcc:-lgcc -lgcc_eh} \
%{!static: \
%{!static-libgcc: \
%{!shared: \
%{!shared-libgcc:-lgcc -lgcc_eh} \
%{shared-libgcc:-lgcc_s -lgcc} \
} \
%{shared:-lgcc_s -lgcc} \
} \
} "
#else
#define SHARED_LIBGCC_SPEC " -lgcc "
#endif
If I change '-lgcc_s -lgcc' to '-lgcc -lgcc_s', then gcc 4.8 will not use such
symbols like __divdi3 in libgcc_s_sjlj-1.dll, it back to gcc 4.7 behavior.
Because both lib/libgcc_s.a (libgcc_s_sjlj-1.dll)and
lib/gcc/i686-w64-mingw32/4.8.1/libgcc.a
export these symbols:
___divdi3
___moddi3
___moddi3
...
I think this change is hastily, should be rollback, or make
libgcc_s${LIBGCC_EH_EXTN}-1.dll
DO NOT export extra symbols which not owned their self.