https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109898
Bug ID: 109898 Summary: 'make install -j' sometimes corrupts 'dir' file for .info files due to parallel 'install-info' calls Product: gcc Version: 14.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: other Assignee: unassigned at gcc dot gnu.org Reporter: slyfox at gcc dot gnu.org Target Milestone: --- In https://github.com/NixOS/nixpkgs/issues/229470 Arnout Engelen noticed that 'make install -j' sometimes installs incomplete '$prefix/share/info/dir' file. This happens because 'make install-info' when running in parallel is executing equivalent of: if /<<NIX>>/bash-5.2-p15/bin/bash -c 'install-info --version' >/dev/null 2>&1; then \ install-info --dir-file=/<<NIX>>/x86_64-unknown-linux-musl-stage-static-gcc-14.0.0/share/info/dir /<<NIX>>/x86_64-unknown-linux-musl-stage-static-gcc-14.0.0/share/info/gcc.info; \ if /<<NIX>>/bash-5.2-p15/bin/bash -c 'install-info --version' >/dev/null 2>&1; then \ install-info --dir-file=/<<NIX>>/x86_64-unknown-linux-musl-stage-static-gcc-14.0.0/share/info/dir /<<NIX>>/x86_64-unknown-linux-musl-stage-static-gcc-14.0.0/share/info/gccinstall.info; \ if /<<NIX>>/bash-5.2-p15/bin/bash -c 'install-info --version' >/dev/null 2>&1; then \ install-info --dir-file=/<<NIX>>/x86_64-unknown-linux-musl-stage-static-gcc-14.0.0/share/info/dir /<<NIX>>/x86_64-unknown-linux-musl-stage-static-gcc-14.0.0/share/info/cppinternals.info; \ if /<<NIX>>/bash-5.2-p15/bin/bash -c 'install-info --version' >/dev/null 2>&1; then \ install-info --dir-file=/<<NIX>>/x86_64-unknown-linux-musl-stage-static-gcc-14.0.0/share/info/dir /<<NIX>>/x86_64-unknown-linux-musl-stage-static-gcc-14.0.0/share/info/cpp.info; \ if /<<NIX>>/bash-5.2-p15/bin/bash -c 'install-info --version' >/dev/null 2>&1; then \ install-info --dir-file=/<<NIX>>/x86_64-unknown-linux-musl-stage-static-gcc-14.0.0/share/info/dir /<<NIX>>/x86_64-unknown-linux-musl-stage-static-gcc-14.0.0/share/info/gccint.info; \ On it's own 'install-info' does not lock $prefix/share/info/dir file atomically. As a result multiple parallel executions of 'install-info' compete and occasionally throw away work of one another. Right now `nixpkgs` works it around as https://github.com/NixOS/nixpkgs/pull/229898: --- gcc-12.2.0/gcc/Makefile.in 2022-08-19 10:09:52.280658631 +0200 +++ gcc-12.2.0-new/gcc/Makefile.in 2023-05-04 14:35:44.401420184 +0200 @@ -3781,6 +3781,11 @@ fi; \ fi +# We don't care about the order in which the info files are built, but +# install-info doesn't support multiple parallel invocations writing to +# the same `dir-file`, so we have to disable parallelism for that reason: +.NOTPARALLEL: install-info + # Install the info files. # $(INSTALL_DATA) might be a relative pathname, so we can't cd into srcdir # to do the install. It might not be enough to handle language-specific 'install-info' targets. What would be the best way to handle this race condition?