JUCE 5.2.1: Open() with O_CREAT missing argument


#1

Hi,
I encountered an error while compiling with gcc (Ubuntu 4.8.4-2ubuntu1~14.04.3) 4.8.4:

In function ‘__open_alias’,
    inlined from ‘openPipe’ at ../../../Juce/modules/juce_core/native/juce_posix_NamedPipe.cpp:158:55,
    inlined from ‘read’ at ../../../Juce/modules/juce_core/native/juce_posix_NamedPipe.cpp:60:103,
    inlined from ‘read’ at ../../../Juce/modules/juce_core/native/juce_posix_NamedPipe.cpp:224:117:
/usr/include/x86_64-linux-gnu/bits/fcntl2.h:50:26: error: call to ‘__open_missing_mode’ declared with attribute error: open with O_CREAT in second argument needs 3 arguments
    __open_missing_mode ();

So the problem comes from Juce_posix_NamedPipe.cpp , line 158:
const int p = ::open (name.toUTF8(), flags);

So I guess the code should check if the flags has O_CREAT and in this case add a third argument like 00644 for example (from FileOutputStream::openHandle()). So it could be something like:

 if(flags & O_CREAT)
{
   const int p = ::open (name.toUTF8(), flags, 00644);
   ...
}
else
{
   const int p = ::open (name.toUTF8(), flags);
   ...
}

Cheers

PS: The problem appeared with JUCE 5.2.1.


#2

This is really odd as the flags can never be O_CREAT (openPipe is never called with O_CREAT). Can you try adding jassert ((flags & O_CREAT) == 0); just before the open call? Maybe that will make the compiler understand that O_CREAT is never used there?


#3

After several tests and researches, including your solution, I figured out the problem. The new Projucer (5.2.1.) adds link-time optimization LTO (-flto) to the linker flags. As I use an external library without LTO, the linking with my plugin failed. The previous version (5.2.0) only adds LTO to the C++ flags, that’s why I didn’t have the problem. So for now, I disabled LTO until I find a way to compile the external library with LTO…