[ITK] [ITK-dev] Workaround for dynamic_cast on Mac OSX
Isaiah Norton
isaiah.norton at gmail.com
Mon Nov 14 14:53:44 EST 2016
Hi Matt,
> Here are the tests:
> http://review.source.kitware.com/#/c/21755/
where reasonable export specification is added in both ITK and the
> client libraries. But, dynamic_cast fails on OSX:
The export changes in this merge request don't seem to be related to the
casts that are failing. A small change [1] allows all of the tests to pass.
Of course, many more export annotations would be required for general
applicability.
There is a compiler option that could potentially address the issue
"-fvisibility-ms-compat" -- see [2]. As mentioned on that page, these RTTI
type_info issues *also break exception handling*, so simply changing all of
the ITK `dynamic_cast` uses to a custom implementation will not fully
address the issue (I have encountered this a number of times in Slicer: ITK
exceptions thrown by dynamic libraries are incorrectly identified).
Alternatively, if there is concern about symbol bloat (I've seen some
threads to that effect related to SimpleITK) then a linker script could be
used to export all `_ZTN*` symbols.
Best,
Isaiah
[1]
```
diff --git a/Modules/Core/Common/include/itkImage.h
b/Modules/Core/Common/include/itkImage.h
index 2e601c2..9592957 100644
--- a/Modules/Core/Common/include/itkImage.h
+++ b/Modules/Core/Common/include/itkImage.h
@@ -72,7 +72,7 @@ namespace itk
* \endwiki
*/
template< typename TPixel, unsigned int VImageDimension = 2 >
-class Image:public ImageBase< VImageDimension >
+class ITK_ABI_EXPORT Image:public ImageBase< VImageDimension >
{
public:
/** Standard class typedefs */
```
[2]
https://developer.apple.com/library/content/technotes/tn2185/_index.html#//apple_ref/doc/uid/DTS10004200-CH1-SUBSECTION2
and
https://developer.apple.com/library/content/technotes/tn2185/_index.html#//apple_ref/doc/uid/DTS10004200-CH1-SUBSECTION6
On Sat, Nov 12, 2016 at 12:01 AM, Matt McCormick <matt.mccormick at kitware.com
> wrote:
> Here are the tests:
>
> http://review.source.kitware.com/#/c/21755/
>
> where reasonable export specification is added in both ITK and the
> client libraries. But, dynamic_cast fails on OSX:
>
> https://open.cdash.org/testDetails.php?test=499059765&build=4637669
>
>
> Matt
>
> On Thu, Nov 10, 2016 at 3:21 PM, Johnson, Hans J <hans-johnson at uiowa.edu>
> wrote:
> > I agree with Marcus. At least until it is very clear that not using
> dynamic_cast is the only solution to a broken compiler, I am very weary of
> “doing what works today”.
> >
> > Hans
> >
> >
> > --
> >
> >
> > On 11/10/16, 1:11 PM, "Insight-developers on behalf of Marcus D.
> Hanwell" <insight-developers-bounces at itk.org on behalf of
> marcus.hanwell at kitware.com> wrote:
> >
> > On Tue, Nov 8, 2016 at 5:01 PM, Matt McCormick
> > <matt.mccormick at kitware.com> wrote:
> > > Hi folks,
> > >
> > > As we have wrestled with in Slicer, along with other applications
> > > where ITK is used in multiple shared libraries, dynamic_cast can
> fail
> > > on Mac OSX.
> > >
> > > I summarized the cause of the problem and steps for the proposed
> solution here:
> > >
> > > https://issues.itk.org/jira/browse/ITK-3490
> > >
> > > Feedback is welcome. The effort is targeted for the ITK 4.11.0
> release.
> > >
> > From the issue it is not clear to me why you can't fix the symbol
> > visibility issues, or which of these cases it causing the breakage.
> > Reading the linked blog post it seems like Apple/Clang is doing the
> > right thing, and C++ libraries must be careful to use consistent
> > symbol visibility.
> >
> > I would be interested in further details on which case or cases are
> > causing dynamic_cast to fail, and why using consistent symbol
> > visibility in the interfaces is not feasible/possible.
> >
> > Thanks,
> >
> > Marcus
> > _______________________________________________
> > Powered by www.kitware.com
> >
> > Visit other Kitware open-source projects at
> > http://www.kitware.com/opensource/opensource.html
> >
> > Kitware offers ITK Training Courses, for more information visit:
> > http://kitware.com/products/protraining.php
> >
> > Please keep messages on-topic and check the ITK FAQ at:
> > http://www.itk.org/Wiki/ITK_FAQ
> >
> > Follow this link to subscribe/unsubscribe:
> > http://public.kitware.com/mailman/listinfo/insight-developers
> >
> >
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Kitware offers ITK Training Courses, for more information visit:
> http://kitware.com/products/protraining.php
>
> Please keep messages on-topic and check the ITK FAQ at:
> http://www.itk.org/Wiki/ITK_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://public.kitware.com/mailman/listinfo/insight-developers
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/community/attachments/20161114/2801ba3c/attachment.html>
-------------- next part --------------
_______________________________________________
Powered by www.kitware.com
Visit other Kitware open-source projects at
http://www.kitware.com/opensource/opensource.html
Kitware offers ITK Training Courses, for more information visit:
http://kitware.com/products/protraining.php
Please keep messages on-topic and check the ITK FAQ at:
http://www.itk.org/Wiki/ITK_FAQ
Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/insight-developers
More information about the Community
mailing list