Use -S for library installations except for -DNO_ROOT builds.


Use -S for library installations except for -DNO_ROOT builds.

Also disable this if NO_SAFE_LIBINSTALL is defined.

There is little harm in always using -S and it fixes several issues:

  • A race during 'make libraries' where, for example, libgcc_s is being installed while another library is trying to link against it. This is possible because libgcc_s is connected in both _prereq_libs and _startup_libs. The first build (_prereq_libs) sets MK_PROFILE=no while the 2nd pass (_startup_libs) enables MK_PROFILE. Thus the libgcc_s library *is* present in WORLDTMP for other libraries to link to, so serializing further items in _startup_libs is not required. Just ensuring that libgcc_s is installed atomically (via rename(2)) is enough. [1]
  • Installation to a running system where some library that cannot be detected, copied and used from the temporary INSTALLTMP with LD_LIBRARY_PATH that the build itself uses for installation. Such an example is having the install an NSS module for user lookups that install(1) uses while concurrently installing the module in another process. This is not a problem for the FreeBSD base build but can be for downstream vendors. While this is a very specific case, installation to a running system with non-atomic library installation is prone to many problems. A further step still is to install in proper dependency ordering.

Reported by: dhw many times [1]
Sponsored by: Dell EMC Isilon
MFC after: 2 weeks


bdreweryAuthored on
rS322564: bsdgrep: Use implied working directory for -r if no directories are passed