Name mangling with SunStudio C++ - Solaris

This is a discussion on Name mangling with SunStudio C++ - Solaris ; Hi, I am working on getting audacity to compile under Solaris 10 (05/08). I have made considerable progress, and have a working version made using gcc. Today I have been attempting to do the same using the SunStudio compilers, and ...

+ Reply to Thread
Results 1 to 6 of 6

Thread: Name mangling with SunStudio C++

  1. Name mangling with SunStudio C++

    Hi,

    I am working on getting audacity to compile under Solaris 10 (05/08). I
    have made considerable progress, and have a working version made using gcc.

    Today I have been attempting to do the same using the SunStudio compilers,
    and have run into a problem in the final linking stage, which I believe to
    be related to the C++ name mangling. Details are below, but in summary, I
    have the final linking step which is a bit like this (full verison later):

    CC -o ../audacity AColor.o AboutDialog.o AudacityApp.o AudioIO.o
    [snip bunch of objects]
    Screenshot.o Shuttle.o ShuttleGui.o ShuttlePrefs.o SmartRecordDialog.o
    [snip bunch of objects]
    export/ExportMultiple.o export/ExportMP2.o export/ExportMP3.o
    [...]
    .../lib-src/libsndfile.a ../lib-src/libresample.a ../lib-src/libnyquist.a
    .../lib-src/libvamp-hostsdk.a ../lib-src/expat.a ../lib-src/allegro.a
    .../lib-src/FileDialog.a ../lib-src/portaudio-v19/lib/libportaudio.a
    .../lib-src/portmixer/libportmixer.a libaudacity.a -lvorbisenc -lvorbisfile
    -lvorbis -logg -mt -L/usr/X11R6/lib -L/usr/openwin/lib
    -lwx_gtk2_richtext-2.8 -lwx_gtk2_aui-2.8 -lwx_gtk2_xrc-2.8 -lwx_gtk2_qa-2.8
    -lwx_gtk2_html-2.8 -lwx_gtk2_adv-2.8 -lwx_gtk2_core-2.8 -lwx_base_xml-2.8
    -lwx_base_net-2.8 -lwx_base-2.8 -lrt
    -I/usr/local/lib/wx/include/gtk2-ansi-release-2.8
    -I/usr/local/include/wx-2.8 -D_FILE_OFFSET_BITS=64 -D_LARGE_FILES
    -D__WXGTK__ -lwx_base_net-2.8 -lwx_gtk2_core-2.8 -lwx_base_xml-2.8
    -lwx_gtk2_html-2.8 -lwx_base-2.8 -lwx_gtk2_qa-2.8 -lwx_gtk2_adv-2.8
    -lwx_gtk2_richtext-2.8 -lwx_gtk2_aui-2.8 -lwx_gtk2_xrc-2.8 -lgtk-x11-2.0
    -lglib-2.0 -lgobject-2.0 -lm -lpthread

    Undefined first referenced
    symbol in file
    wxRadioButton*ShuttleGuiBase::TieRadioButton(const wxString&,const int)
    export/ExportMP3.o
    ld: fatal: Symbol referencing errors. No output written to ../audacity
    gmake[1]: *** [../audacity] Error 1

    Now the ShuttleGuiBase::TieRadioButton stuff is defined in ShuttleGui.cpp,
    and so I would have thought that when ExportMP3.cpp went to use it it would
    be happy to see it already there, but it seems that is not the case. I am
    not at all good at C++, but this does strike me as looking like a name
    mangling issue. I used elfdump on ShuttleGui.o and ExportMP3.o as follows
    (sorry for long lines):

    custard 9% elfdump -s ShuttleGui.o | grep Tie | grep Radio
    [358] 0x00009680 0x0000041f FUNC GLOB D 0 .text __1cOShuttleGuiBaseOTieRadioButton6MrknIwxString_r nLWrappedType__pnNwxRadioButton__
    [390] 0x0000ae00 0x00000041 FUNC GLOB D 0 .text __1cOShuttleGuiBaseOTieRadioButton6MrknIwxString_i _pnNwxRadioButton__
    [391] 0x0000ae50 0x00000177 FUNC GLOB D 0 .text __1cOShuttleGuiBaseOTieRadioButton6MrknIwxString_3 _pnNwxRadioButton__
    custard 10% elfdump -s export/ExportMP3.o | grep Tie
    [187] 0x00000000 0x00000000 FUNC GLOB D 0 UNDEF __1cOShuttleGuiBaseOTieRadioButton6MrknIwxString_k i_pnNwxRadioButton__
    [192] 0x00000000 0x00000000 FUNC GLOB D 0 UNDEF __1cOShuttleGuiBaseJTieChoice6MrknIwxString_3kirkn NwxArrayString_rknKwxArray

    I was expecting to see the same mangled names, but that is not the case.

    Am I looking at the wrong thing here?

    Either way, does anyone have any suggestions as to what I might best do
    next?

    As I said earlier, I have this working with gcc, so that is good. I was
    hoping to also get a version working with SunStudio, as that is often
    better.




    custard 12% CC -V
    CC: Sun C++ 5.9 SunOS_i386 Patch 124864-01 2007/07/25

    I have built the wxWidgets on GTK2, using SunStudio:

    custard 18% wx-config --version
    2.8.8

    I am using audacity-src-1.3.5-beta. I had to do a couple of minor fixes to
    get libsndfile to work, and to fix some use of max and min in libnyquist,
    but other than that all seemed to go smoothly. The final step where it
    fails is this:

    gmake[1]: Entering directory `/net/chicken/export/home0/tristram/tmp/audacity-src-1.3.5-beta/src'
    CC -o ../audacity AColor.o AboutDialog.o AudacityApp.o AudioIO.o
    AutoRecovery.o BatchCommandDialog.o BatchCommands.o BatchProcessDialog.o
    Benchmark.o Dependencies.o Envelope.o FFT.o FileIO.o FileNames.o
    FreqWindow.o HelpText.o HistoryWindow.o ImageManipulation.o
    InterpolateAudio.o LabelDialog.o LabelTrack.o Languages.o LangChoice.o
    Legacy.o Matrix.o Menus.o Mix.o NoteTrack.o PitchName.o
    PlatformCompatibility.o Printing.o Project.o Resample.o RingBuffer.o
    Screenshot.o Shuttle.o ShuttleGui.o ShuttlePrefs.o SmartRecordDialog.o
    Snap.o Spectrum.o SplashDialog.o Tags.o Theme.o TimeDialog.o TimeTrack.o
    Track.o TrackArtist.o TrackPanel.o TrackPanelAx.o UndoManager.o
    UploadDialog.o VoiceKey.o WaveClip.o WaveTrack.o WrappedType.o
    commands/CommandManager.o commands/Keyboard.o effects/Effect.o
    effects/SimpleMono.o effects/SimplePairedTwoTrack.o
    effects/SoundTouchEffect.o effects/LoadEffects.o effects/Amplify.o
    effects/AutoDuck.o effects/BassBoost.o effects/ChangePitch.o
    effects/ChangeSpeed.o effects/ChangeTempo.o effects/ClickRemoval.o
    effects/Compressor.o effects/DtmfGen.o effects/Echo.o
    effects/Equalization.o effects/Fade.o effects/FindClipping.o
    effects/Invert.o effects/Leveller.o effects/Noise.o effects/NoiseRemoval.o
    effects/Normalize.o effects/Phaser.o effects/Repair.o effects/Repeat.o
    effects/Reverse.o effects/Silence.o effects/SpikeCleaner.o
    effects/StereoToMono.o effects/ToneGen.o effects/TruncSilence.o
    effects/TwoPassSimpleMono.o effects/Wahwah.o export/Export.o
    export/ExportMultiple.o export/ExportMP2.o export/ExportMP3.o
    export/ExportOGG.o export/ExportFLAC.o export/ExportPCM.o export/ExportCL.o
    import/Import.o import/ImportFLAC.o import/ImportLOF.o import/ImportMIDI.o
    import/ImportMP3.o import/ImportOGG.o import/ImportPCM.o import/ImportRaw.o
    import/RawAudioGuess.o prefs/AudioIOPrefs.o prefs/BatchPrefs.o
    prefs/DirectoriesPrefs.o prefs/FileFormatPrefs.o prefs/GUIPrefs.o
    prefs/KeyConfigPrefs.o prefs/MousePrefs.o prefs/PrefsDialog.o
    prefs/QualityPrefs.o prefs/SmartRecordPrefs.o prefs/SpectrumPrefs.o
    prefs/ThemePrefs.o toolbars/ControlToolBar.o toolbars/DeviceToolBar.o
    toolbars/EditToolBar.o toolbars/MeterToolBar.o toolbars/MixerToolBar.o
    toolbars/SelectionBar.o toolbars/ToolBar.o toolbars/ToolDock.o
    toolbars/ToolManager.o toolbars/ToolsToolBar.o
    toolbars/TranscriptionToolBar.o widgets/treebook.o widgets/AButton.o
    widgets/ASlider.o widgets/AttachableScrollBar.o widgets/ErrorDialog.o
    widgets/ExpandingToolBar.o widgets/Grabber.o widgets/Grid.o
    widgets/ImageRoll.o widgets/LinkingHtmlWindow.o widgets/Meter.o
    widgets/MultiDialog.o widgets/Ruler.o widgets/TimeTextCtrl.o
    widgets/Warning.o xml/XMLFileReader.o xml/XMLWriter.o
    effects/nyquist/Nyquist.o effects/nyquist/LoadNyquist.o
    effects/vamp/VampEffect.o effects/vamp/LoadVamp.o
    effects/ladspa/LoadLadspa.o effects/ladspa/LadspaEffect.o
    .../lib-src/libsndfile.a ../lib-src/libresample.a ../lib-src/libnyquist.a
    .../lib-src/libvamp-hostsdk.a ../lib-src/expat.a ../lib-src/allegro.a
    .../lib-src/FileDialog.a ../lib-src/portaudio-v19/lib/libportaudio.a
    .../lib-src/portmixer/libportmixer.a libaudacity.a -lvorbisenc -lvorbisfile
    -lvorbis -logg -mt -L/usr/X11R6/lib -L/usr/openwin/lib
    -lwx_gtk2_richtext-2.8 -lwx_gtk2_aui-2.8 -lwx_gtk2_xrc-2.8 -lwx_gtk2_qa-2.8
    -lwx_gtk2_html-2.8 -lwx_gtk2_adv-2.8 -lwx_gtk2_core-2.8 -lwx_base_xml-2.8
    -lwx_base_net-2.8 -lwx_base-2.8 -lrt ShuttleGui.o
    -I/usr/local/lib/wx/include/gtk2-ansi-release-2.8
    -I/usr/local/include/wx-2.8 -D_FILE_OFFSET_BITS=64 -D_LARGE_FILES
    -D__WXGTK__ -lwx_base_net-2.8 -lwx_gtk2_core-2.8 -lwx_base_xml-2.8
    -lwx_gtk2_html-2.8 -lwx_base-2.8 -lwx_gtk2_qa-2.8 -lwx_gtk2_adv-2.8
    -lwx_gtk2_richtext-2.8 -lwx_gtk2_aui-2.8 -lwx_gtk2_xrc-2.8 -lgtk-x11-2.0
    -lglib-2.0 -lgobject-2.0 -lm -lpthread
    ld: warning: file ShuttleGui.o: attempted multiple inclusion of file
    Undefined first referenced
    symbol in file
    wxRadioButton*ShuttleGuiBase::TieRadioButton(const wxString&,const int) export/ExportMP3.o
    ld: fatal: Symbol referencing errors. No output written to ../audacity
    gmake[1]: *** [../audacity] Error 1





    --
    Dr Tristram J. Scott
    Energy Consultant

  2. Re: Name mangling with SunStudio C++

    On Thu, 25 Sep 2008 15:36:00 GMT, Tristram Scott
    wrote:
    > Hi,
    >
    > I am working on getting audacity to compile under Solaris 10 (05/08). I
    > have made considerable progress, and have a working version made using gcc.


    Use Sun nm (/usr/ccs/bin/nm) with the -C option to see unmangled
    symbols. If it can't unmangle them, then it probably means that they
    were compiled with GCC. Which leads me to say that you must compile
    everything with the same C++ compiler (C should be compatible between
    compilers). And use gnm for GCC (assuming you're using the /usr/sfw/bin
    version of GCC).

    A bientot
    Paul
    --
    Paul Floyd http://paulf.free.fr

  3. Re: Name mangling with SunStudio C++

    Paul Floyd wrote:
    > On Thu, 25 Sep 2008 15:36:00 GMT, Tristram Scott
    > wrote:
    >> Hi,
    >>
    >> I am working on getting audacity to compile under Solaris 10 (05/08). I
    >> have made considerable progress, and have a working version made using gcc.

    >
    > Use Sun nm (/usr/ccs/bin/nm) with the -C option to see unmangled
    > symbols. If it can't unmangle them, then it probably means that they
    > were compiled with GCC. Which leads me to say that you must compile
    > everything with the same C++ compiler (C should be compatible between
    > compilers). And use gnm for GCC (assuming you're using the /usr/sfw/bin
    > version of GCC).
    >


    Sorry if I wasn't totally clear. I shelved the gcc based installation and
    have started clean with the attempted SunStudio version.

    Excuse the long lines again:

    custard 6% nm -C ShuttleGui.o | grep Tie | grep Radio
    [391] | 44624| 375|FUNC |GLOB |0 |85 |wxRadioButton*ShuttleGuiBase::TieRadioButton(cons t wxString&,const wxString&)
    [__1cOShuttleGuiBaseOTieRadioButton6MrknIwxString_3 _pnNwxRadioButton__]
    [390] | 44544| 65|FUNC |GLOB |0 |85 |wxRadioButton*ShuttleGuiBase::TieRadioButton(cons t wxString&,int)
    [__1cOShuttleGuiBaseOTieRadioButton6MrknIwxString_i _pnNwxRadioButton__]
    [358] | 38528| 1055|FUNC |GLOB |0 |85 |wxRadioButton*ShuttleGuiBase::TieRadioButton(cons t wxString&,WrappedType&)
    [__1cOShuttleGuiBaseOTieRadioButton6MrknIwxString_r nLWrappedType__pnNwxRadioButton__]
    custard 7% nm -C export/ExportMP3.o | grep Tie
    [192] | 0| 0|FUNC |GLOB |0 |UNDEF |wxChoice*ShuttleGuiBase::TieChoice(const wxString&,const wxString&,const int,const wxArrayString&,const wxArrayInt&)
    [__1cOShuttleGuiBaseJTieChoice6MrknIwxString_3kirkn NwxArrayString_rknKwxArrayInt__pnIwxChoice__]
    [187] | 0| 0|FUNC |GLOB |0 |UNDEF |wxRadioButton*ShuttleGuiBase::TieRadioButton(cons t wxString&,const int)
    [__1cOShuttleGuiBaseOTieRadioButton6MrknIwxString_k i_pnNwxRadioButton__]

    So it looks like we have in ShuttleGui.o:

    wxRadioButton*ShuttleGuiBase::TieRadioButton(const wxString&,int)

    and in export/ExportMP3.o:

    wxRadioButton*ShuttleGuiBase::TieRadioButton(const wxString&,const int)

    Might it be displeased at the difference between the int and the const int
    definitions? I clearly don't know enough about C++ to get heavily into
    this code, but to the extent that it looks like C I am happy to get my
    hands dirty. I'll have a go at modifying this in ExportMP3.cpp and see
    where I can get to.

    Thanks for your advice.

    --
    Dr Tristram J. Scott
    Energy Consultant

  4. Re: Name mangling with SunStudio C++

    Tristram Scott wrote:
    > Paul Floyd wrote:


    [snip]

    >> Use Sun nm (/usr/ccs/bin/nm) with the -C option to see unmangled
    >> symbols.


    [snip]

    >
    > So it looks like we have in ShuttleGui.o:
    >
    > wxRadioButton*ShuttleGuiBase::TieRadioButton(const wxString&,int)
    >
    > and in export/ExportMP3.o:
    >
    > wxRadioButton*ShuttleGuiBase::TieRadioButton(const wxString&,const int)
    >
    > Might it be displeased at the difference between the int and the const int
    > definitions? I clearly don't know enough about C++ to get heavily into
    > this code, but to the extent that it looks like C I am happy to get my
    > hands dirty. I'll have a go at modifying this in ExportMP3.cpp and see
    > where I can get to.


    Okay, this was indeed the problem. I looked at both ExportMP3.cpp and
    ShuttleGui.cpp as well as their respective header files. It seems that the
    problem was in the implementation of
    wxRadioButton * ShuttleGuiBase::TieRadioButton( ) in ShuttleGui.cpp.

    It now reads like this:

    /// This function must be within a StartRadioButtonGroup - EndRadioButtonGroup pair.
    wxRadioButton * ShuttleGuiBase::TieRadioButton(
    const wxString &Prompt,
    const int iValue)
    {
    WrappedType WrappedRef((int) iValue );
    return TieRadioButton( Prompt, WrappedRef );
    }

    The diffs are:

    custard 27% diff ShuttleGui.cpp ~/tmp/audacity-src-1.3.5-beta/src/ShuttleGui.cpp
    1528c1528
    < const int iValue)
    ---
    > int iValue)

    1530c1530
    < WrappedType WrappedRef((int) iValue );
    ---
    > WrappedType WrappedRef( iValue );



    Thanks for your help Paul. I now have a working version compiled with
    SunStudio.

    I will see about getting the few required changes integrated into the main
    source code for the project.

    --
    Dr Tristram J. Scott
    Energy Consultant

  5. Re: Name mangling with SunStudio C++


    "Tristram Scott" wrote:
    > So it looks like we have in ShuttleGui.o:
    >
    > wxRadioButton*ShuttleGuiBase::TieRadioButton(const wxString&,int)
    >
    > and in export/ExportMP3.o:
    >
    > wxRadioButton*ShuttleGuiBase::TieRadioButton(const wxString&,const int)
    >
    > Might it be displeased at the difference between the int and the const int
    > definitions?


    Yes.

    Even if it wasn't, that would not be a good idea.
    The "const" will cause the optimizer to make assumptions
    that are false if the variable actually is not const.


    Thomas

  6. Re: Name mangling with SunStudio C++

    On Thu, 25 Sep 2008 18:39:56 GMT, Tristram Scott
    wrote:
    >
    > So it looks like we have in ShuttleGui.o:
    >
    > wxRadioButton*ShuttleGuiBase::TieRadioButton(const wxString&,int)
    >
    > and in export/ExportMP3.o:
    >
    > wxRadioButton*ShuttleGuiBase::TieRadioButton(const wxString&,const int)


    Hi

    Firstly a bit of C++. For function arguments (and return values), cv
    (const or volatile) qualification has no effect at the topmost level. So
    the 'const' in 'const int' doesn't serve any real purpose.

    Now for some Sun Studio. I believe that it uses name mangling that dates
    back to c-front and the ARM. In this case I don't think that Sun Studio
    conforms to the standard. Unfortunately, fixing it would break backwards
    compatibility, which Sun is unlikely to do. If you look at such a
    function compiled with GCC, then you'll see that the const gets
    stripped, so GCC does not have this problem.

    Lastly for my opinion. I don't particularly like 'decorating' code like
    this to try to make the intent 'clearer' (assuming that was the reason
    behind it). My advice is to write simple code and document it (e.g.,
    with Doxygen).

    A bientot
    Paul
    --
    Paul Floyd http://paulf.free.fr

+ Reply to Thread