buildsys: build locale headers in-tree, not via a recursive sub-make
With UCLIBC_HAS_LOCALE=y the locale data (the gen_* host tools and
locale_data.c) is generated at build time. The "headers" recipe built the
locale headers with a recursive
$(MAKE) -C extra/locale locale_headers
while the top-level make independently builds the same host tools and
locale_data.c -- locale_data.o is a libc object, so the top make needs
locale_data.c as well. Because the sub-make runs in a different working
directory ($(top_builddir) resolves to ../../ instead of ./), the two
makes refer to e.g. gen_ldc under two different path strings and each
builds it. Under -jN the builds overlap: one make executes the host tool
while the other is still writing it, and the build dies with
.../extra/locale/gen_ldc: Text file busy
make[1]: *** [extra/locale/locale_data.c] Error 127
This recursion, and the parallel-build trouble around it, has a long
history:
2007-11-09 693245823 Carmelo Amoroso
"Fix build system to generate locale data instead of using
pregenerated ones" -- switched to generated locale data and turned
"$(MAKE) locale_headers" into "$(MAKE) -C extra/locale
locale_headers", introducing the differing-CWD path mismatch.
2008-10-08 6f98f3f2b Bernhard Reutner-Fischer
"fix building locale (pre- and generated, even parallel)" -- dropped
the recursion.
2009-10-17 c94314fa6 Austin Foxley
"build system changes needed for nptl" -- re-introduced the
"$(MAKE) -C extra/locale" recursion in the nptl pregen restructure.
2015-07-05 449109519 Waldemar Brodkorb
"fix parallel build issue when LOCALES are enabled" -- moved the
recursion but kept "-C extra/locale".
2016-09-27 4c68c74d9 Waldemar Brodkorb
"locale: disable parallel build as it is broken here" -- masked the
race with a blanket ".NOTPARALLEL:" serializing the whole build.
2026-05-26 755281340 Ramin Moussavi
"build: scope .NOTPARALLEL to locale targets only, restore parallel
build" -- narrowed that serialization back to the locale data
targets, re-enabling parallel builds tree-wide; but it only moved
the serialization, it did not remove the duplicate build, so the
race resurfaced (seen with make -j on a CPU-oversubscribed host).
Fix the root cause: extra/locale/Makefile.in is include-d into the top
Makefile, so the recursion is unnecessary. Drop it and make
$(locale_headers-y) a normal prerequisite of "headers". The locale data is
then built once, in a single make, with consistent paths; its generation
stays serialized by the scoped .NOTPARALLEL. Parallel builds work and the
race is gone.
Fixes: 755281340 ("build: scope .NOTPARALLEL to locale targets only, restore parallel build")
Signed-off-by: Ramin Moussavi <ramin.moussavi@yacoub.de>