• Vincent Pelletier's avatar
    Tolerate open and fopen being called before our own constructor. · e42b7314
    Vincent Pelletier authored
    An easy example of this is coreutils' "ls", when linked against libselinux:
    libselinux will/may call fopen("/proc/filesystems", "re") during its own
    constructor, which may be called before our.
    Another example is inkscape, which contains static C++ classes (such as
    Inkscape::Util::UnitTable::UnitTable) which may themselves call (f)open.
    C++ runtime seems to call such static constructors before our contructor,
    leading to the same issue. GCC documentation (as of version 8.0.1) says:
      However, at present, the order in which constructors for C++ objects
      with static storage duration and functions decorated with attribute
      constructor are invoked is unspecified. In mixed declarations,
      attribute init_priority can be used to impose a specific ordering.
    e42b7314