imported from OmniOS Try to get more FILE's on 32bit systems, or limit itself to not cross the limit if it fails --- binutils-2.43.1/bfd/cache.c.orig +++ binutils-2.43.1/bfd/cache.c @@ -95,7 +95,24 @@ if (getrlimit (RLIMIT_NOFILE, &rlim) == 0 && rlim.rlim_cur != (rlim_t) RLIM_INFINITY) + { +#if defined(__illumos__) && defined(_ILP32) + /* + * illumos stdio for 32-bit has an ABI-constrained limit that + * the UNIX file descriptor must be 255 or less. + * + * This can be corrected by enabling extended FILE stdio, which + * we do here if the reported rlimit allows us to do so. + */ + if (rlim.rlim_cur > 256 && + enable_extended_FILE_stdio(-1, -1) == -1) { + perror("Can't enable extended FILE"); + /* Cap it at 250 to not break stdio. */ + max = 250; + } else +#endif /* __illumos__ */ max = rlim.rlim_cur / 8; + } else #endif #ifdef _SC_OPEN_MAX