From 6e7679a26006dbaa2920fbaeb0d9b4673735232f Mon Sep 17 00:00:00 2001 From: Alex Soto Date: Thu, 28 May 2026 11:52:18 -0400 Subject: [PATCH] [make] Serialize AppleDocReader doc injection AppleDocReader backs up a shared Xcode SQLite database while injecting docs into the generated platform XML files. When make builds the iOS, macOS, tvOS, and Mac Catalyst XML docs in parallel, multiple AppleDocReader processes can race on that database and fail with SQLite Error 5: database is locked. Run AppleDocReader under a shared lockf lock so the rest of the build can remain parallel while the database access is serialized. --- src/Makefile | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Makefile b/src/Makefile index 703dc110204..81b2b7e0913 100644 --- a/src/Makefile +++ b/src/Makefile @@ -67,6 +67,8 @@ endif DOTNET_GENERATOR_FLAGS=$(GENERATOR_FLAGS) --lib=$(DOTNET_BCL_DIR) -attributelib:$(DOTNET_BINDING_ATTRIBUTES) $(DOTNET_REFERENCES) DOTNET_GENERATOR=$(DOTNET_BUILD_DIR)/bgen/bgen DOTNET_BINDING_ATTRIBUTES=$(DOTNET_BUILD_DIR)/Xamarin.Apple.BindingAttributes.dll +APPLE_DOC_READER=$(TOP)/packages/appledocreader.$(ADR_RUNTIME_IDENTIFIER)/$(ADR_NUGET_VERSION)/tools/any/$(ADR_RUNTIME_IDENTIFIER)/AppleDocReader +APPLE_DOC_READER_LOCK=$(BUILD_DIR)/.appledocreader.lock # # Specific warnings that we want reported as errors by generator @@ -347,8 +349,9 @@ $(DOTNET_DESTDIR)/$($(2)_NUGET_REF_NAME)/ref/$(DOTNET_TFM)/Microsoft.$(1).xml: $ $$(Q) $(CP) $$< $$@ ifndef NO_XCODE +# AppleDocReader backs up a shared Xcode SQLite database, so serialize invocations. $($(2)_DOTNET_BUILD_DIR)/doc/Microsoft.$(1).xml: $($(2)_DOTNET_BUILD_DIR)/ref/Microsoft.$(1).xml $($(2)_DOTNET_BUILD_DIR)/ref/Microsoft.$(1).dll build/.build-adr-stamp | $($(2)_DOTNET_BUILD_DIR)/doc - $$(Q_GEN) $(TOP)/packages/appledocreader.$(ADR_RUNTIME_IDENTIFIER)/$(ADR_NUGET_VERSION)/tools/any/$(ADR_RUNTIME_IDENTIFIER)/AppleDocReader inject docs --assembly="$(abspath $($(2)_DOTNET_BUILD_DIR)/ref/Microsoft.$(1).dll)" --input="$(abspath $($(2)_DOTNET_BUILD_DIR)/ref/Microsoft.$(1).xml)" --output="$(abspath $$@)" --xcode="$(DEVELOPER_DIR)/../.." --runtimeDll="$(DOTNET_BCL_DIR)/System.Runtime.dll" -f + $$(Q_GEN) /usr/bin/lockf "$(APPLE_DOC_READER_LOCK)" "$(APPLE_DOC_READER)" inject docs --assembly="$(abspath $($(2)_DOTNET_BUILD_DIR)/ref/Microsoft.$(1).dll)" --input="$(abspath $($(2)_DOTNET_BUILD_DIR)/ref/Microsoft.$(1).xml)" --output="$(abspath $$@)" --xcode="$(DEVELOPER_DIR)/../.." --runtimeDll="$(DOTNET_BCL_DIR)/System.Runtime.dll" -f else # Without Xcode, skip AppleDocReader and just copy the XML $($(2)_DOTNET_BUILD_DIR)/doc/Microsoft.$(1).xml: $($(2)_DOTNET_BUILD_DIR)/ref/Microsoft.$(1).xml | $($(2)_DOTNET_BUILD_DIR)/doc