Hello.

I was going to submit `--disable-utils` as a separate patch but in the context 
adding the FAQ, it makes sense to include it to a single patch together.

Radek

---
>From f0240097f681335c6b2373f4a04685ee687bdeef Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Radek=20Barto=C5=88?= <radek.bar...@microsoft.com>
Date: Sat, 21 Jun 2025 22:56:58 +0200
Subject: [PATCH v3] Cygwin: configure: add possibility to skip build of
 cygserver and utils
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

This patch adds configure options allowing to disable build of cygserver
and Cygwin utilities. This is useful when one needs to build only
cygwin1.dll and crt0.o with stage1 compiler that is not yet capable of
linking executables as it is missing cygwin1.dll and crt0.o.

Signed-off-by: Radek BartoĊˆ <radek.bar...@microsoft.com>
---
 winsup/Makefile.am             | 20 ++++++++++++++++++--
 winsup/configure.ac            | 12 ++++++++++++
 winsup/cygserver/Makefile.am   |  2 ++
 winsup/doc/faq-programming.xml | 14 +++++++++++++-
 4 files changed, 45 insertions(+), 3 deletions(-)

diff --git a/winsup/Makefile.am b/winsup/Makefile.am
index 9efdd4cb1..877c4e6b9 100644
--- a/winsup/Makefile.am
+++ b/winsup/Makefile.am
@@ -14,10 +14,26 @@ cygdoc_DATA = \
        CYGWIN_LICENSE \
        COPYING
 
-SUBDIRS = cygwin cygserver utils testsuite
+SUBDIRS = cygwin testsuite
+
+if BUILD_CYGSERVER
+SUBDIRS += cygserver
+endif
+
+if BUILD_UTILS
+SUBDIRS += utils
+endif
 
 if BUILD_DOC
 SUBDIRS += doc
 endif
 
-cygserver utils testsuite: cygwin
+testsuite: cygwin
+
+if BUILD_CYGSERVER
+cygserver: cygwin
+endif
+
+if BUILD_UTILS
+utils: cygwin
+endif
diff --git a/winsup/configure.ac b/winsup/configure.ac
index 18adf3d97..e7ac814b1 100644
--- a/winsup/configure.ac
+++ b/winsup/configure.ac
@@ -83,6 +83,18 @@ AC_ARG_ENABLE(doc,
              enable_doc=yes)
 AM_CONDITIONAL(BUILD_DOC, [test $enable_doc != "no"])
 
+# Disabling build of cygserver and utils is needed for zero-bootstrap build of
+# stage 1 Cygwin toolchain where the linker is not able to produce executables
+# yet.
+AC_ARG_ENABLE(cygserver,
+             [AS_HELP_STRING([--disable-cygserver], [do not build 
cygserver])],,
+             enable_cygserver=yes)
+AM_CONDITIONAL(BUILD_CYGSERVER, [test $enable_cygserver != "no"])
+AC_ARG_ENABLE(utils,
+             [AS_HELP_STRING([--disable-utils], [do not build utils])],,
+             enable_utils=yes)
+AM_CONDITIONAL(BUILD_UTILS, [test $enable_utils != "no"])
+
 AC_CHECK_PROGS([DOCBOOK2XTEXI], [docbook2x-texi db2x_docbook2texi])
 if test -z "$DOCBOOK2XTEXI" ; then
     if test "x$enable_doc" != "xno"; then
diff --git a/winsup/cygserver/Makefile.am b/winsup/cygserver/Makefile.am
index ec7a62240..efb578e53 100644
--- a/winsup/cygserver/Makefile.am
+++ b/winsup/cygserver/Makefile.am
@@ -12,7 +12,9 @@ cygserver_flags=$(cxxflags_common) -Wimplicit-fallthrough=5 
-Werror -DSYSCONFDIR
 AM_CXXFLAGS = $(CFLAGS)
 
 noinst_LIBRARIES = libcygserver.a
+if BUILD_CYGSERVER
 sbin_PROGRAMS = cygserver
+endif
 bin_SCRIPTS = cygserver-config
 
 cygserver_SOURCES = \
diff --git a/winsup/doc/faq-programming.xml b/winsup/doc/faq-programming.xml
index 39610b916..1090c5507 100644
--- a/winsup/doc/faq-programming.xml
+++ b/winsup/doc/faq-programming.xml
@@ -698,8 +698,20 @@ Building these programs can be disabled with the 
<literal>--without-cross-bootst
 option to <literal>configure</literal>.
 </para>
 
+<para>
+Build of <literal>cygserver</literal> can be skipped with
+<literal>--disable-cygserver</literal> and build of other Cygwin utilities with
+<literal>--disable-utils</literal>. This is particularly useful (together
+with <literal>--without-cross-bootstrap</literal> and
+<literal>--disable-dumper</literal> options) when only
+<literal>cygwin1.dll</literal> and <literal>crt0.o</literal> are needed for
+stage2 compiler when being built with stage1 compiler which does not support
+linking executables yet (because of missing <literal>cygwin1.dll</literal> and
+<literal>crt0.o</literal>).
+</para>
+
 <!-- If you want to run the tests <literal>busybox</literal> and
-     <literal>cygutils-extra<literal> are also required. -->
+     <literal>cygutils-extra</literal> are also required. -->
 
 <para>
 Building the documentation also requires the <literal>dblatex</literal>,
-- 
2.50.1.vfs.0.0

Attachment: v3-0001-Cygwin-configure-add-possibility-to-skip-build-of-cygserver-and-utils.patch
Description: v3-0001-Cygwin-configure-add-possibility-to-skip-build-of-cygserver-and-utils.patch

Reply via email to