[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Chicken-users] Problem with -DPIC When Building with MinGw
From: |
Patrick Brannan |
Subject: |
[Chicken-users] Problem with -DPIC When Building with MinGw |
Date: |
Fri, 24 Feb 2006 14:19:48 -0600 |
I have a question about building chicken 2.3 with mingw. Why does -DPIC
cause mingw to fail while linking the dll? Everything works fine
without -DPIC except for the dynamic extensions. I probably missed
something simple, but I don't see what it is. I'm definitely operating
at the outer edges of my gcc / linking knowledge.
The make file and an explanatory text doc are attached.
When we build chicken 2.3 with the attached build file and -DPIC defined the build
fails when linking the dll with the following output from mingw's gcc:
================================================================================
gcc -shared ./runtime.o ./library.o ./eval.o ./profiler.o ./scheduler.o
./extras.o ./match-support.o ./lolevel.o ./tinyclos.o ./pregexp.o
./utils.o ./tcp.o ./posixwin.o ./srfi-1.o ./srfi-4.o ./srfi-13.o
./srfi-14.o ./srfi-18.o ./stub.o -lws2_32 -o libchicken.dll
-Wl,--image-base=0x10000000 -Wl,--out-implib,libchicken.a
Creating library file: libchicken.a
./extras.o(.text+0x10f):extras.c: undefined reference to `_imp__C_temporary_stack'
./extras.o(.text+0x130):extras.c: undefined reference to `_imp__C_temporary_stack'
... Lots more like this. _C_temporary_stack is defined in chicken.h
================================================================================
When built with cygwin the link command is executed as follows and it works:
================================================================================
gcc -shared .libs/libchicken_la-runtime.o
.libs/libchicken_la-library.o .libs/libchicken_la-eval.o
.libs/libchicken_la-profiler.o .libs/libchicken_la-scheduler.o
.libs/libchicken_la-extras.o .libs/libchicken_la-match-support.o
.libs/libchicken_la-lolevel.o .libs/libchicken_la-tinyclos.o
.libs/libchicken_la-utils.o .libs/libchicken_la-tcp.o
.libs/libchicken_la-pcre.o .libs/libchicken_la-posix.o
.libs/libchicken_la-stub.o .libs/libchicken_la-srfi-1.o
.libs/libchicken_la-srfi-4.o .libs/libchicken_la-srfi-13.o
.libs/libchicken_la-srfi-14.o .libs/libchicken_la-srfi-18.o
/usr/lib/libpcre.dll.a -o .libs/cygchicken-0.dll
-Wl,--image-base=0x10000000 -Wl,--out-implib,.libs/libchicken.dll.a
=================================================================================
As an example here are the commands used to build runtime.o and extras.o under cygwin:
================================================================================
gcc -DHAVE_CONFIG_H -I. -I. -I. -DC_STACK_GROWS_DOWNWARD=1
-DC_INSTALL_LIB_HOME=\"/usr/local/lib/chicken\"
-DC_INSTALL_HOME=\"/usr/local/share/chicken\" -DC_USE_C_DEFAULTS
-DC_NO_PIC_NO_DLL -DC_BUILDING_LIBCHICKEN -Os -fomit-frame-pointer
-fno-strict-aliasing -Wall -Wno-unused -Wno-uninitialized
-DHAVE_ALLOCA_H -c runtime.c -DPIC -o
.libs/libchicken_la-runtime.o
gcc -DHAVE_CONFIG_H -I. -I. -I. -DC_STACK_GROWS_DOWNWARD=1
-DC_INSTALL_LIB_HOME=\"/usr/local/lib/chicken\"
-DC_INSTALL_HOME=\"/usr/local/share/chicken\" -DC_USE_C_DEFAULTS
-DC_NO_PIC_NO_DLL -DC_BUILDING_LIBCHICKEN -Os -fomit-frame-pointer
-fno-strict-aliasing -Wall -Wno-unused -Wno-uninitialized
-DHAVE_ALLOCA_H -c extras.c -DPIC -o .libs/libchicken_la-extras.o
================================================================================
Here are the commands used to build runtime.o and extras.o under mingw:
================================================================================
gcc -Os -DC_DEFAULT_TARGET_STACK_SIZE=300000 -DC_STACK_GROWS_DOWNWARD=1
-DC_NO_PIC_NO_DLL -DHAVE_LOADLIBRARY -DHAVE_GETPROCADDRESS
-DHAVE_WINDOWS_H -Wno-unused -Wno-uninitialized
-IC:/working/mingw-only/chicken-2.3 -DPIC -DC_BUILDING_LIBCHICKEN -c
runtime.c -oruntime.o
gcc -c -Os -DC_DEFAULT_TARGET_STACK_SIZE=300000
-DC_STACK_GROWS_DOWNWARD=1 -DC_NO_PIC_NO_DLL -DHAVE_LOADLIBRARY
-DHAVE_GETPROCADDRESS -DHAVE_WINDOWS_H -Wno-unused -Wno-uninitialized
-IC:/working/mingw-only/chicken-2.3 -DPIC extras.c -o extras.o
================================================================================
Using nm to look at the symbols under cygwin:
================================================================================
$ nm libchicken_la-runtime.o | grep temporary_stack
00000010 C _C_temporary_stack
00000010 C _C_temporary_stack_bottom
00000010 C _C_temporary_stack_limit
...
$ nm libchicken_la-extras.o | grep temporary_stack
U _C_temporary_stack
U _C_temporary_stack_bottom
================================================================================
Using nm to look at the symbols under mingw:
================================================================================
C:\working\mingw-only\chicken-2.3>nm runtime.o | grep temporary_stack
00000010 C _C_temporary_stack
00000010 C _C_temporary_stack_bottom
00000010 C _C_temporary_stack_limit
...
C:\working\mingw-only\chicken-2.3>nm extras.o | grep temporary_stack
U __imp__C_temporary_stack
U __imp__C_temporary_stack_bottom
================================================================================
So it is apparent that the __imp_ prefix is causing the linker to fail. Why is
this? Leaving it undefined works for chicken itself, but causes the eggs to
fail as dlls. I'm so close to getting this that I can smell it.
Cygwin gcc version: 3.4.4
Mingw gcc version: 3.4.2
Makefile.mingw
Description: Binary data
mingw-build.txt
Description: Text document
- [Chicken-users] Problem with -DPIC When Building with MinGw,
Patrick Brannan <=