Bug in Projucer Linux project exporters for plug-ins

projucer

#1

Hi everyone,

on Linux, gcc defaults to make all symbols visible when building shared object binaries such as plug-ins. This results in funny side effects or even crashes when either several instances of the same plug-in or different plug-ins with a common code base and therefore identical symbol names are loaded into a DAW.
The Projucer tries to take care of that but does it wrongly: it sets “-fVisibility=hidden” as a linker flag but it should rather set it as a C compiler flag.

So, the following changes should be made:

jucer_ProjectExport_Make.h:

void writeLinkerFlags (OutputStream& out, const BuildConfiguration& config) const
{
    out << "  JUCE_LDFLAGS += $(TARGET_ARCH) -L$(JUCE_BINDIR) -L$(JUCE_LIBDIR)";
    
    {
        StringArray flags (makefileExtraLinkerFlags);
        if (flags.size() > 0)
            out << " " << getCleanedStringArray (flags).joinIntoString (" ");
    }
    
    [...]

}

and:

StringArray getTargetSettings (const BuildConfiguration& config) const
{
    [...]

    if (getTargetFileType() == sharedLibraryOrDLL || getTargetFileType() == pluginBundle)
    {
        s.add (String ("JUCE_CFLAGS_") + getTargetVarName() + String (" := -fPIC -fvisibility=hidden"));
        
        [...]
        
    }
    
    [...]
    
}

jucer_ProjectExport_CodeBlocks.h:

StringArray getCompilerFlags (const BuildConfiguration& config, CodeBlocksTarget& target) const
{
    [...]

    if (config.exporter.isLinux())
    {
        if (target.isDynamicLibrary() || getProject().getProjectType().isAudioPlugin())
            flags.add ("-fPIC -fvisibility=hidden");
        
        [...]
        
    }
    
    [...]
    
}

Best wishes,

Wolfram