duplicate instantiations
Michael Goffioul
michael.goffioul at gmail.com
Tue Jun 2 16:15:24 CDT 2009
On Tue, Jun 2, 2009 at 6:44 PM, Jaroslav Hajek <highegg at gmail.com> wrote:
> Hi Michael,
>
> I just tried compiling octave with this patch:
>
> diff --git a/libcruft/misc/oct-dlldefs.h b/libcruft/misc/oct-dlldefs.h
> --- a/libcruft/misc/oct-dlldefs.h
> +++ b/libcruft/misc/oct-dlldefs.h
> @@ -26,6 +26,9 @@
> #if defined (_MSC_VER)
> #define OCTAVE_EXPORT __declspec(dllexport)
> #define OCTAVE_IMPORT __declspec(dllimport)
> +#elif __GNUC__ >= 4
> +#define OCTAVE_EXPORT __attribute__ ((visibility("default")))
> +#define OCTAVE_IMPORT OCTAVE_EXPORT
> #else
> /* All other compilers, at least for now. */
> #define OCTAVE_EXPORT
>
>
> and get a bunch of undefined references when linking liboctinterp. It
> seems that GCC requires the __attribute__ tags be added at the
> definition point. That is, we would need to tag Array<T> and other
> classes with OCTAVE_API. Would it also work for MSVC? This may be
> worth further investigations after 3.2.
> I should note that the size of liboctave was reduced by mere 5.8%,
> which is really not much.
Marking template declaration does not work for MSVC. I even
had to remove some of them in my recent patches, because it
produces compilation errors
(seehttp://hg.savannah.gnu.org/hgweb/octave/rev/3c1762c7e787).
It's odd that GCC does not work with specifying the visibility of
explicit instantiation. Googling a little, I found those 2 links. It
seems there used to be a limitation about this, but as far as I
understand, it should be fixed in >= 4.2.0.
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17470
http://developer.apple.com/DOCUMENTATION/DeveloperTools/Conceptual/CppRuntimeEnv/Articles/SymbolVisibility.html
I had hoped that the visibility attribute would work as dllexport
under MSVC, adding more uniformity between compilers.
Anyway, this is a long term issue. I'm not sure the benefit would
be huge for octave libs as they basically exports almost everything.
Thanks for looking at it.
Michael.
More information about the Octave-maintainers
mailing list