We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 0841ffc commit e056d88Copy full SHA for e056d88
lib/mapped-file-unix.cc
@@ -1,9 +1,21 @@
1
#include "common.h"
2
3
+// for getrlimit, setrlimit
4
+#include <sys/resource.h>
5
+
6
namespace mold {
7
8
MappedFile *open_file_impl(const std::string &path, std::string &error) {
9
i64 fd = ::open(path.c_str(), O_RDONLY);
10
+ // increase rlimit when EMFILE. This is required for llvm lto, since llvm
11
+ // plugin requires keeping input files open
12
+ if (fd == -1 && errno == EMFILE) {
13
+ if (struct rlimit rlim{}; getrlimit(RLIMIT_NOFILE, &rlim) == 0) {
14
+ rlim.rlim_cur = rlim.rlim_max;
15
+ setrlimit(RLIMIT_NOFILE, &rlim);
16
+ fd = ::open(path.c_str(), O_RDONLY);
17
+ }
18
19
if (fd == -1) {
20
if (errno != ENOENT)
21
error = "opening " + path + " failed: " + errno_string();
0 commit comments