Closed
Description
What steps will reproduce the problem? 1. Compile the attached c code as a dll 2. Compile the attached go code using the dll produced during previous step (see build.bat in the attached zip file) What is the expected output? Executable file What do you see instead? C:\Users\Simon\AppData\Local\Temp\go-build373913279\_\C_\GoEcho.a(_all.o): malformed pe file: unexpected flags for PE section .idata$7 Which compiler are you using (5g, 6g, 8g, gccgo)? 8g Which operating system are you using? Windows 8 / x64 Which version are you using? (run 'go version') go version devel +b3017cc3e17b Wed Apr 10 21:41:54 2013 -0700 windows/386 The same steps produces the expected result when using go1.0.3 Please provide any additional information below. >> go env set GOARCH=386 set GOBIN= set GOCHAR=8 set GOEXE=.exe set GOHOSTARCH=386 set GOHOSTOS=windows set GOOS=windows set GOPATH=C:\Users\Simon\Go set GORACE= set GOROOT=C:\go set GOTOOLDIR=C:\go\pkg\tool\windows_386 set CC=gcc set GOGCCFLAGS=-g -O2 -m32 -mthreads set CGO_ENABLED=1 >>gcc -v Utilisation des specs internes. COLLECT_GCC=gcc COLLECT_LTO_WRAPPER=c:/mingw/bin/../libexec/gcc/mingw32/4.7.2/lto-wrapper.exe Target: mingw32 Configuré avec: ../gcc-4.7.2/configure --enable-languages=c,c++,ada,fortran,objc ,obj-c++ --disable-sjlj-exceptions --with-dwarf2 --enable-shared --enable-libgom p --disable-win32-registry --enable-libstdcxx-debug --disable-build-poststage1-w ith-cxx --enable-version-specific-runtime-libs --build=mingw32 --prefix=/mingw Modèle de thread: win32 gcc version 4.7.2 (GCC) >> go build -x WORK=C:\Users\Simon\AppData\Local\Temp\go-build019044383 mkdir -p $WORK\_\C_\GoEcho\_obj\ cd C:\GoEcho C:\go\pkg\tool\windows_386\cgo.exe -objdir $WORK\_\C_\GoEcho\_obj\ -- -I. -I $WO RK\_\C_\GoEcho\_obj\ main.go C:\go\pkg\tool\windows_386\8c.exe -F -V -w -I $WORK\_\C_\GoEcho\_obj\ -I C:\go\p kg\windows_386 -o $WORK\_\C_\GoEcho\_obj\_cgo_defun.8 -D GOOS_windows -D GOARCH_ 386 $WORK\_\C_\GoEcho\_obj\_cgo_defun.c gcc -I . -g -O2 -m32 -mthreads -print-libgcc-file-name gcc -I . -g -O2 -m32 -mthreads -I. -I $WORK\_\C_\GoEcho\_obj\ -o $WORK\_\C_\GoEc ho\_obj\_cgo_main.o -c $WORK\_\C_\GoEcho\_obj\_cgo_main.c gcc -I . -g -O2 -m32 -mthreads -I. -I $WORK\_\C_\GoEcho\_obj\ -o $WORK\_\C_\GoEc ho\_obj\_cgo_export.o -c $WORK\_\C_\GoEcho\_obj\_cgo_export.c gcc -I . -g -O2 -m32 -mthreads -I. -I $WORK\_\C_\GoEcho\_obj\ -o $WORK\_\C_\GoEc ho\_obj\main.cgo2.o -c $WORK\_\C_\GoEcho\_obj\main.cgo2.c gcc -I . -g -O2 -m32 -mthreads -o $WORK\_\C_\GoEcho\_obj\_cgo_.o $WORK\_\C_\GoEc ho\_obj\_cgo_main.o $WORK\_\C_\GoEcho\_obj\_cgo_export.o $WORK\_\C_\GoEcho\_obj\ main.cgo2.o libecho_dll.a C:\go\pkg\tool\windows_386\cgo.exe -objdir $WORK\_\C_\GoEcho\_obj\ -dynimport $W ORK\_\C_\GoEcho\_obj\_cgo_.o -dynout $WORK\_\C_\GoEcho\_obj\_cgo_import.c C:\go\pkg\tool\windows_386\8c.exe -F -V -w -I $WORK\_\C_\GoEcho\_obj\ -I C:\go\p kg\windows_386 -o $WORK\_\C_\GoEcho\_obj\_cgo_import.8 -D GOOS_windows -D GOARCH _386 $WORK\_\C_\GoEcho\_obj\_cgo_import.c gcc -I . -g -O2 -m32 -mthreads -o $WORK\_\C_\GoEcho\_obj\_all.o $WORK\_\C_\GoEch o\_obj\_cgo_export.o $WORK\_\C_\GoEcho\_obj\main.cgo2.o libecho_dll.a -Wl,-r -no stdlib -lmingwex -lmingw32 c:/mingw/bin/../lib/gcc/mingw32/4.7.2/libgcc.a C:\go\pkg\tool\windows_386\8g.exe -o $WORK\_\C_\GoEcho\_obj\_go_.8 -p _/C_/GoEch o -D _/C_/GoEcho -I $WORK $WORK\_\C_\GoEcho\_obj\_cgo_gotypes.go $WORK\_\C_\GoEc ho\_obj\main.cgo1.go C:\go\pkg\tool\windows_386\pack.exe grcP $WORK $WORK\_\C_\GoEcho.a $WORK\_\C_\Go Echo\_obj\_go_.8 $WORK\_\C_\GoEcho\_obj\_cgo_import.8 $WORK\_\C_\GoEcho\_obj\_cg o_defun.8 $WORK\_\C_\GoEcho\_obj\_all.o cd . C:\go\pkg\tool\windows_386\8l.exe -o GoEcho.exe -L $WORK $WORK\_\C_\GoEcho.a # _/C_/GoEcho C:\Users\Simon\AppData\Local\Temp\go-build019044383\_\C_\GoEcho.a(_all.o): malfo rmed pe file: unexpected flags for PE section .idata$7 Steps used to create the dll, the c and the go executables: cd GccEcho gcc -c Echo.c -DECHO_EXPORTS gcc -shared -o echo_dll.dll Echo.o -Wl,--out-implib,libecho_dll.a gcc -c main.c gcc -o main_dll.exe main.o -L. -lecho_dll cd ..\GoEcho copy ..\GccEcho\Echo.h copy ..\GccEcho\libecho_dll.a copy ..\GccEcho\echo_dll.dll go build The C test program links against the .a file and executes without problem. I tried to reproduce the issue on linux x64 with a .so library, and the build succeeded. It seems to be windows related. This issue may be related to issue #5106, but it seems to me that the build goes one step ahead in my case. Do not hesitate if you want me to perform some other tests or give more detailed information. Simon
Attachments:
- GoIssue_src.zip (1700 bytes)