Subject: | gcc in perl is broken compared to mingw.org gcc |
The GCC 4.4.3 in Strawberry Perl 5.12.3 32 bit and the GCC 4.4.7 in
Strawberry Perl 5.14.2 are broken. The latest Mingw.org release which
has GCC 4.6.2 isn't broken.
The strawberry perl GCCs are incapable of using GCC builtins under -O0
optimization level preventing the creation of any PEs which do not link
to the CRT. GCC builtins are functionally identical to #pragma intrinsic
on MSVC. A sample program is included. It is called memcpy.c.
It was compiled with "gcc memcpy.c -nostdlib -lkernel32 -o memcpy.exe
-v -Wall -O0" using the 2 different Strawberry Perl GCCs mentioned
above. Each time the S. Perl GCCs converted the __builtin_memcpy
function to memcpy, which is a CRT function, then fail when they can't
link to the CRT. Mingw.org GCC does NOT exhibit this.
I brought the problem up on the mingw mailing list here previous
http://sourceforge.net/mailarchive/message.php?msg_id=28930444 They
determined it was a problem with Strawberry Perl GCC, not Mingw.org GCC.
Reading through the Changelogs from 4.4 to 4.6 of GCC here
http://gcc.gnu.org/gcc-4.4/changes.html does not reveal anything about
this problem.
Show quoted text
_________________________________________________________________
C:\>gcc -v
Using built-in specs.
Target: i686-w64-mingw32
Configured with: ../gcc44-svn/configure --target=i686-w64-mingw32
--host=i686-w6
4-mingw32 --disable-multilib --disable-nls --disable-win32-registry
--prefix=/mi
ngw32 --with-gmp=/mingw32 --with-mpfr=/mingw32 --enable-languages=c,c++
Thread model: win32
gcc version 4.4.3 (GCC)
C:\>perl -V
Summary of my perl5 (revision 5 version 12 subversion 3) configuration:
Platform:
osname=MSWin32, osvers=5.1, archname=MSWin32-x86-multi-thread
uname='Win32 strawberryperl 5.12.3.0 #1 Sun May 15 09:44:53 2011 i386'
config_args='undef'
hint=recommended, useposix=true, d_sigaction=undef
useithreads=define, usemultiplicity=define
useperlio=define, d_sfio=undef, uselargefiles=define, usesocks=undef
use64bitint=undef, use64bitall=undef, uselongdouble=undef
usemymalloc=n, bincompat5005=undef
Compiler:
cc='gcc', ccflags =' -s -O2 -DWIN32 -DHAVE_DES_FCRYPT
-DUSE_SITECUSTOMIZE -
DPERL_IMPLICIT_CONTEXT -DPERL_IMPLICIT_SYS -fno-strict-aliasing
-mms-bitfields -
DPERL_MSVCRT_READFIX',
optimize='-s -O2',
cppflags='-DWIN32'
ccversion='', gccversion='4.4.3', gccosandvers=''
intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=1234
d_longlong=undef, longlongsize=8, d_longdbl=define, longdblsize=12
ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='long
long', lseek
size=8
alignbytes=8, prototype=define
Linker and Libraries:
ld='g++', ldflags ='-s -L"C:\sperl\perl\lib\CORE" -L"C:\sperl\c\lib"'
libpth=C:\sperl\c\lib C:\sperl\c\i686-w64-mingw32\lib
libs=-lmoldname -lkernel32 -luser32 -lgdi32 -lwinspool -lcomdlg32
-ladvapi32
-lshell32 -lole32 -loleaut32 -lnetapi32 -luuid -lws2_32 -lmpr -lwinmm
-lversion
-lodbc32 -lodbccp32 -lcomctl32
perllibs=-lmoldname -lkernel32 -luser32 -lgdi32 -lwinspool
-lcomdlg32 -ladva
pi32 -lshell32 -lole32 -loleaut32 -lnetapi32 -luuid -lws2_32 -lmpr
-lwinmm -lver
sion -lodbc32 -lodbccp32 -lcomctl32
libc=, so=dll, useshrplib=true, libperl=libperl512.a
gnulibc_version=''
Dynamic Linking:
dlsrc=dl_win32.xs, dlext=dll, d_dlsymun=undef, ccdlflags=' '
cccdlflags=' ', lddlflags='-mdll -s -L"C:\sperl\perl\lib\CORE"
-L"C:\sperl\c
\lib"'
Characteristics of this binary (from libperl):
Compile-time options: MULTIPLICITY PERL_DONT_CREATE_GVSV
PERL_IMPLICIT_CONTEXT PERL_IMPLICIT_SYS
PERL_MALLOC_WRAP PL_OP_SLAB_ALLOC USE_ITHREADS
USE_LARGE_FILES USE_PERLIO USE_PERL_ATOF
USE_SITECUSTOMIZE
Built under MSWin32
Compiled at May 15 2011 17:02:01
%ENV:
PERL_JSON_BACKEND="JSON::XS"
PERL_YAML_BACKEND="YAML"
@INC:
C:/sperl/perl/site/lib
C:/sperl/perl/vendor/lib
C:/sperl/perl/lib
.
C:\>
and
C:\>gcc -v
Using built-in specs.
Target: x86_64-w64-mingw32
Configured with: ../gcc44-svn/configure --host=x86_64-w64-mingw32
--target=x86_6
4-w64-mingw32 --disable-multilib --enable-checking=release
--prefix=/opt/mingw64
--enable-languages=c,c++,fortran --enable-libgomp
--with-gmp=/opt/mingw64 --wit
h-mpfr=/opt/mingw64 --disable-nls --disable-win32-registry
Thread model: win32
gcc version 4.4.7 20111023 (prerelease) [svn/rev.180339 - mingw-w64/oz]
(GCC)
C:\>perl -V
Summary of my perl5 (revision 5 version 14 subversion 2) configuration:
Platform:
osname=MSWin32, osvers=4.0, archname=MSWin32-x64-multi-thread
uname='Win32 strawberryperl 5.14.2.1 #1 Tue Nov 22 22:40:59 2011 x64'
config_args='undef'
hint=recommended, useposix=true, d_sigaction=undef
useithreads=define, usemultiplicity=define
useperlio=define, d_sfio=undef, uselargefiles=define, usesocks=undef
use64bitint=define, use64bitall=undef, uselongdouble=undef
usemymalloc=n, bincompat5005=undef
Compiler:
cc='gcc', ccflags =' -s -O2 -DWIN32 -DWIN64 -DCONSERVATIVE
-DPERL_TEXTMODE_
SCRIPTS -DUSE_SITECUSTOMIZE -DPERL_IMPLICIT_CONTEXT -DPERL_IMPLICIT_SYS
-fno-str
ict-aliasing -mms-bitfields',
optimize='-s -O2',
cppflags='-DWIN32'
ccversion='', gccversion='4.4.7', gccosandvers=''
intsize=4, longsize=4, ptrsize=8, doublesize=8, byteorder=12345678
d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=12
ivtype='long long', ivsize=8, nvtype='double', nvsize=8, Off_t='long
long',
lseeksize=8
alignbytes=8, prototype=define
Linker and Libraries:
ld='g++', ldflags ='-s -L"C:\sperl\perl\lib\CORE" -L"C:\sperl\c\lib"'
libpth=C:\sperl\c\lib C:\sperl\c\x86_64-w64-mingw32\lib
libs=-lmoldname -lkernel32 -luser32 -lgdi32 -lwinspool -lcomdlg32
-ladvapi32
-lshell32 -lole32 -loleaut32 -lnetapi32 -luuid -lws2_32 -lmpr -lwinmm
-lversion
-lodbc32 -lodbccp32 -lcomctl32
perllibs=-lmoldname -lkernel32 -luser32 -lgdi32 -lwinspool
-lcomdlg32 -ladva
pi32 -lshell32 -lole32 -loleaut32 -lnetapi32 -luuid -lws2_32 -lmpr
-lwinmm -lver
sion -lodbc32 -lodbccp32 -lcomctl32
libc=, so=dll, useshrplib=true, libperl=libperl514.a
gnulibc_version=''
Dynamic Linking:
dlsrc=dl_win32.xs, dlext=dll, d_dlsymun=undef, ccdlflags=' '
cccdlflags=' ', lddlflags='-mdll -s -L"C:\sperl\perl\lib\CORE"
-L"C:\sperl\c
\lib"'
Characteristics of this binary (from libperl):
Compile-time options: MULTIPLICITY PERL_DONT_CREATE_GVSV
PERL_IMPLICIT_CONTEXT PERL_IMPLICIT_SYS
PERL_MALLOC_WRAP PERL_PRESERVE_IVUV PL_OP_SLAB_ALLOC
USE_64_BIT_INT USE_ITHREADS USE_LARGE_FILES
USE_PERLIO USE_PERL_ATOF USE_SITECUSTOMIZE
Built under MSWin32
Compiled at Nov 22 2011 22:53:05
%ENV:
PERL_JSON_BACKEND="JSON::XS"
PERL_YAML_BACKEND="YAML"
@INC:
C:/sperl/perl/site/lib
C:/sperl/perl/vendor/lib
C:/sperl/perl/lib
.
C:\>
_________________________________________________________________
mingw GCC
$ gcc -v
Using built-in specs.
COLLECT_GCC=C:\sources\MinGW\bin\gcc.exe
COLLECT_LTO_WRAPPER=c:/sources/mingw/bin/../libexec/gcc/mingw32/4.6.2/lto-wrappe
r.exe
Target: mingw32
Configured with: ../gcc-4.6.2/configure
--enable-languages=c,c++,ada,fortran,obj
c,obj-c++ --disable-sjlj-exceptions --with-dwarf2 --enable-shared
--enable-libgo
mp --disable-win32-registry --enable-libstdcxx-debug
--enable-version-specific-r
untime-libs --build=mingw32 --prefix=/mingw
Thread model: win32
gcc version 4.6.2 (GCC)
$
Subject: | memcpy.c |
#include <windows.h>
int CALLBACK WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow )
{
char * str2 = "Hello World from memcpy Line 2";
int sizestr2 = sizeof("Hello World from memcpy Line 2");
char * str = HeapAlloc(GetProcessHeap(), 0, 1000);
char * str3 = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, 1000);
__builtin_memcpy(str, str3, 1000);
__builtin_memcpy(str, str2, sizestr2);
WriteFile(GetStdHandle(STD_OUTPUT_HANDLE), "Hello World from memcpy\n", sizeof("Hello World from memcpy\n"), NULL, NULL);
WriteFile(GetStdHandle(STD_OUTPUT_HANDLE), str, sizestr2, NULL, NULL);
return 1;
}