···1-diff --git a/3rdparty/stout/include/Makefile.am b/3rdparty/stout/include/Makefile.am
2-index 1f2ee85..b0b08d8 100644
3---- a/3rdparty/stout/include/Makefile.am
4-+++ b/3rdparty/stout/include/Makefile.am
5-@@ -64,7 +64,6 @@ nobase_include_HEADERS = \
6- stout/os/chroot.hpp \
7- stout/os/close.hpp \
8- stout/os/constants.hpp \
9-- stout/os/direntsize.hpp \
10- stout/os/environment.hpp \
11- stout/os/exists.hpp \
12- stout/os/fcntl.hpp \
13-@@ -108,7 +107,6 @@ nobase_include_HEADERS = \
14- stout/os/posix/chown.hpp \
15- stout/os/posix/chroot.hpp \
16- stout/os/posix/close.hpp \
17-- stout/os/posix/direntsize.hpp \
18- stout/os/posix/exists.hpp \
19- stout/os/posix/fcntl.hpp \
20- stout/os/posix/fork.hpp \
21-@@ -134,7 +132,6 @@ nobase_include_HEADERS = \
22- stout/os/windows/bootid.hpp \
23- stout/os/windows/chroot.hpp \
24- stout/os/windows/close.hpp \
25-- stout/os/windows/direntsize.hpp \
26- stout/os/windows/exists.hpp \
27- stout/os/windows/fcntl.hpp \
28- stout/os/windows/fork.hpp \
29-diff --git a/3rdparty/stout/include/stout/os/direntsize.hpp b/3rdparty/stout/include/stout/os/direntsize.hpp
30-deleted file mode 100644
31-index 819f99a..0000000
32---- a/3rdparty/stout/include/stout/os/direntsize.hpp
33-+++ /dev/null
34-@@ -1,26 +0,0 @@
35--// Licensed under the Apache License, Version 2.0 (the "License");
36--// you may not use this file except in compliance with the License.
37--// You may obtain a copy of the License at
38--//
39--// http://www.apache.org/licenses/LICENSE-2.0
40--//
41--// Unless required by applicable law or agreed to in writing, software
42--// distributed under the License is distributed on an "AS IS" BASIS,
43--// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
44--// See the License for the specific language governing permissions and
45--// limitations under the License.
46--
47--#ifndef __STOUT_OS_DIRENTSIZE_HPP__
48--#define __STOUT_OS_DIRENTSIZE_HPP__
49--
50--
51--// For readability, we minimize the number of #ifdef blocks in the code by
52--// splitting platform specifc system calls into separate directories.
53--#ifdef __WINDOWS__
54--#include <stout/os/windows/direntsize.hpp>
55--#else
56--#include <stout/os/posix/direntsize.hpp>
57--#endif // __WINDOWS__
58--
59--
60--#endif // __STOUT_OS_DIRENTSIZE_HPP__
61-diff --git a/3rdparty/stout/include/stout/os/posix/direntsize.hpp b/3rdparty/stout/include/stout/os/posix/direntsize.hpp
62-deleted file mode 100644
63-index 9d8f72e..0000000
64---- a/3rdparty/stout/include/stout/os/posix/direntsize.hpp
65-+++ /dev/null
66-@@ -1,42 +0,0 @@
67--// Licensed under the Apache License, Version 2.0 (the "License");
68--// you may not use this file except in compliance with the License.
69--// You may obtain a copy of the License at
70--//
71--// http://www.apache.org/licenses/LICENSE-2.0
72--//
73--// Unless required by applicable law or agreed to in writing, software
74--// distributed under the License is distributed on an "AS IS" BASIS,
75--// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
76--// See the License for the specific language governing permissions and
77--// limitations under the License.
78--
79--#ifndef __STOUT_OS_POSIX_DIRENTSIZE_HPP__
80--#define __STOUT_OS_POSIX_DIRENTSIZE_HPP__
81--
82--#include <dirent.h>
83--#include <unistd.h>
84--
85--
86--namespace os {
87--
88--inline size_t dirent_size(DIR* dir)
89--{
90-- // Calculate the size for a "directory entry".
91-- long name_max = fpathconf(dirfd(dir), _PC_NAME_MAX);
92--
93-- // If we don't get a valid size, check NAME_MAX, but fall back on
94-- // 255 in the worst case ... Danger, Will Robinson!
95-- if (name_max == -1) {
96-- name_max = (NAME_MAX > 255) ? NAME_MAX : 255;
97-- }
98--
99-- size_t name_end = (size_t) offsetof(dirent, d_name) + name_max + 1;
100--
101-- size_t size = (name_end > sizeof(dirent) ? name_end : sizeof(dirent));
102--
103-- return size;
104--}
105--
106--} // namespace os {
107--
108--#endif // __STOUT_OS_POSIX_DIRENTSIZE_HPP__
109-diff --git a/3rdparty/stout/include/stout/os/windows/direntsize.hpp b/3rdparty/stout/include/stout/os/windows/direntsize.hpp
110-deleted file mode 100644
111-index 7c8c7a0..0000000
112---- a/3rdparty/stout/include/stout/os/windows/direntsize.hpp
113-+++ /dev/null
114-@@ -1,43 +0,0 @@
115--// Licensed under the Apache License, Version 2.0 (the "License");
116--// you may not use this file except in compliance with the License.
117--// You may obtain a copy of the License at
118--//
119--// http://www.apache.org/licenses/LICENSE-2.0
120--//
121--// Unless required by applicable law or agreed to in writing, software
122--// distributed under the License is distributed on an "AS IS" BASIS,
123--// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
124--// See the License for the specific language governing permissions and
125--// limitations under the License.
126--
127--#ifndef __STOUT_OS_WINDOWS_DIRENTSIZE_HPP__
128--#define __STOUT_OS_WINDOWS_DIRENTSIZE_HPP__
129--
130--#include <stout/internal/windows/dirent.hpp>
131--
132--#include <stout/windows.hpp>
133--
134--
135--namespace os {
136--
137--inline size_t dirent_size(DIR* dir)
138--{
139-- // NOTE: Size calculation logic here is much simpler than on POSIX because
140-- // our implementation of `dirent` is constant-sized. In particular, on POSIX,
141-- // we usually have to calculate the maximum name size for a path before we
142-- // can alloc a correctly-size `dirent`, but on Windows, `dirent.d_name` is
143-- // always `MAX_PATH` bytes in size.
144-- //
145-- // This follows closely from the Windows standard API data structures for
146-- // manipulating and querying directories. For example, the structures
147-- // `WIN32_FIND_DATA`[1] (which in many ways is the Windows equivalent of
148-- // `dirent`) has a field `cFileName` (which is much like `d_name`) that is
149-- // also `MAX_PATH` in size.
150-- //
151-- // [1] https://msdn.microsoft.com/en-us/library/windows/desktop/aa365740(v=vs.85).aspx
152-- return sizeof(dirent);
153--}
154--
155--} // namespace os {
156--
157--#endif // __STOUT_OS_WINDOWS_DIRENTSIZE_HPP__
···1+{ stdenv, lib, version, src
2, autoreconfHook, zlib, gtest
3, ...
4}:
···20 outputs = [ "out" "lib" ];
2122 buildInputs = [ autoreconfHook zlib ];
23+24+ # The generated C++ code uses static initializers which mutate a global data
25+ # structure. This causes problems for an executable when:
26+ #
27+ # 1) it dynamically links to two libs, both of which contain generated C++ for
28+ # the same proto file, and
29+ # 2) the two aforementioned libs both dynamically link to libprotobuf.
30+ #
31+ # One solution is to statically link libprotobuf, that way the global
32+ # variables are not shared; in fact, this is necessary for the python Mesos
33+ # binding to not crash, as the python lib contains two C extensions which
34+ # both refer to the same proto schema.
35+ #
36+ # See: https://github.com/NixOS/nixpkgs/pull/19064#issuecomment-255082684
37+ # https://github.com/google/protobuf/issues/1489
38+ dontDisableStatic = true;
39+ configureFlags = [
40+ "CFLAGS=-fPIC"
41+ "CXXFLAGS=-fPIC"
42+ ];
4344 doCheck = true;
45