We're currently using Studio 12/CC 5.9 and our C++ application includes an internal static library into which we embed several of our own dtrace userland probes (USDT).
We're looking at updating to Studio 12.3/CC 5.12 but have run into problems with the dtrace probes in release/optimised builds only.
The basic build process for the library is as follows:
1) Use dtrace -h to generate a probe header file from a foo.d definition file
2) Compile (C++) source file foo.cpp which references the macros from (1) to create foo.obj
3) Use dtrace -G to generate a dtrace probe object foo_probe.obj and update foo.obj
4) Use CC -xar to create a static library libfoo.a containing both objects from (3)
This works fine in debug builds with both CC 5.9 and CC 5.12, however release builds with CC 5.12 fail when we try to link a binary against the static library with "Undefined symbol" errors referencing the dtrace probe functions in foo.obj.
I noticed that with CC 5.12 step (4) above seems to 'undo' the changes made to foo.obj file at step (3). I also noticed that step (4) is much slower with 5.12, hence suggesting that the compiler is doing some extra work, which then led me down the path of removing -xipo=2 from my commandline, at which point I get a library which I can link ok without missing symbols.
1) Have there been changes to CC -xar which would explain this (eg previously -xipo=2 was ignored for archive creation)?
2) If it does 'make sense' that I'm having problems here, is there any better solution than simply removing -xipo=2 from the library creation step? Obviously I'd like to get the performance benefits if possible, but I suppose that it may simply not be compatible with the way dtrace USDT providers work...?
The way that -xipo works is that at link time it recompiles all the object files doing inlining and optimisation between the files at that point. This will have the effect of undoing the dtrace -G processing, leaving just the raw dtrace function calls.
You are using archive libraries so one workaround is to use the flag -xipo_archive=... to either none - meaning don't process the archive libraries or readonly which will inline code from the archive libraries but won't inline code into the archive libraries.