[Gc] Re:

Kai Tietz ktietz70 at googlemail.com
Tue Mar 6 05:46:11 PST 2012


Hi Ivan,

this issue is pretty simple.  The define _DLL is missused.  _DLL is
defined on mingw targets if a shared msvcrt.dll is used.  It has
nothing to do at all with building a DLL, nor it is wise to use it in
user-code.

The mingw-w64 defines _DLL as there is no other runtime for it beside
the msvcrt.dll version.  By this boehm-gc assumes always happily (even
in static version) that it shall decorate for imports if user includes
the header. (btw the same would happen for VC, if there wouldn't be an
explicit define telling it not do so).

I rely here on DLL_EXPORT (and if actual boehm-gc is built only!) that
declspec dllexport is done.  So the shared version of it as DLL gets
the proper exports.

I am a bit curious why it should fail, as mingw supports
pseudo-relocations, which solves such issues without flaws.

Regards,
Kai

2012/3/6 Ivan Maidanski <ivmai at mail.ru>:
> Hi Kai,
>
> I found recent commit to gcc/boehmgc regarding DLL_EXPORT handling -
> https://github.com/ivmai/bdwgc/commit/6488760cc5b3829bd81d442f0e95cd248f9bcf4d
>
> 1. Could you please describe the purpose - AFAIK, GCC (at least Cygwin port) could create dll exporting functions even if they are not tagged with dllexport.
> 2. I tried to apply your patch (slightly modified - shown below) to recent GC and failed because -D DLL_EXPORT is specified only during compilation of libgc modules but not during compilation of tests causing "GC_print_stats undefined" error.
>
> My alternative solution is to define GC_DLL if --enable-shared with --disable-static.
> See commit https://github.com/ivmai/bdwgc/commit/505b041e15e243e0f33540363ac40797e2bff4f4
>
> Regards.
>
> PS. The patch that failed for the recent BDWGC:
>
> diff --git a/include/gc_config_macros.h b/include/gc_config_macros.h
> index b340f49..d4b7231 100644
> --- a/include/gc_config_macros.h
> +++ b/include/gc_config_macros.h
> @@ -164,8 +164,9 @@
>  # endif
>  #endif /* _WIN32_WCE */
>
> -#if defined(_DLL) && !defined(GC_NOT_DLL) && !defined(GC_DLL) \
> -        && !defined(__GNUC__)
> +#if !defined(GC_NOT_DLL) && !defined(GC_DLL) \
> +    && ((defined(_DLL) && !defined(__GNUC__)) \
> +        || (defined(DLL_EXPORT) && defined(GC_BUILD)))
>  # define GC_DLL
>  #endif



-- 
|  (\_/) This is Bunny. Copy and paste
| (='.'=) Bunny into your signature to help
| (")_(") him gain world domination



More information about the Gc mailing list