public inbox for cygwin-patches@cygwin.com
 help / color / mirror / Atom feed
* [PATCH] Cygwin: Makefile: Build new DLL with the name 'cygwin0.dll'
@ 2022-12-21 13:49 Jon Turney
  2022-12-21 15:58 ` [PATCH] Cygwin: Makefile: Also make 'cygwin0.dll' Jon Turney
  2022-12-21 16:18 ` [PATCH] Cygwin: Makefile: Drop all the "test dll" considerations Jon Turney
  0 siblings, 2 replies; 5+ messages in thread
From: Jon Turney @ 2022-12-21 13:49 UTC (permalink / raw)
  To: cygwin-patches; +Cc: Jon Turney

Build the new DLL with the name 'cygwin0.dll', rather than
'new-cygwin1.dll', as that's what the testsuite expects.

It still gets installed with the name 'cygwin1.dll'.

Fixes: 90236c3a2cf6 ("Cygwin: Makefile: build new-cygwin1.dll in a single step")
---
 winsup/cygwin/Makefile.am | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/winsup/cygwin/Makefile.am b/winsup/cygwin/Makefile.am
index 0200f6e2a..96c1dc491 100644
--- a/winsup/cygwin/Makefile.am
+++ b/winsup/cygwin/Makefile.am
@@ -40,7 +40,7 @@ toolincludedir=$(tooldir)/include
 # Parameters used in building the cygwin.dll.
 
 DLL_NAME=cygwin1.dll
-NEW_DLL_NAME=new-cygwin1.dll
+NEW_DLL_NAME=cygwin0.dll
 DEF_FILE=cygwin.def
 LIB_NAME=libcygwin.a
 TEST_LIB_NAME=libcygwin0.a
-- 
2.39.0


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH] Cygwin: Makefile: Also make 'cygwin0.dll'
  2022-12-21 13:49 [PATCH] Cygwin: Makefile: Build new DLL with the name 'cygwin0.dll' Jon Turney
@ 2022-12-21 15:58 ` Jon Turney
  2022-12-21 16:18 ` [PATCH] Cygwin: Makefile: Drop all the "test dll" considerations Jon Turney
  1 sibling, 0 replies; 5+ messages in thread
From: Jon Turney @ 2022-12-21 15:58 UTC (permalink / raw)
  To: cygwin-patches; +Cc: Jon Turney

Hard-link the new DLL with the name 'cygwin0.dll', as that's what the
testsuite expects. (Must be a hardlink as the Windows loader needs to be
able to traverse the link).

Fixes: 90236c3a2cf6 ("Cygwin: Makefile: build new-cygwin1.dll in a single step")
---
 winsup/cygwin/Makefile.am | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/winsup/cygwin/Makefile.am b/winsup/cygwin/Makefile.am
index 0200f6e2a..5ea962ccd 100644
--- a/winsup/cygwin/Makefile.am
+++ b/winsup/cygwin/Makefile.am
@@ -41,6 +41,7 @@ toolincludedir=$(tooldir)/include
 
 DLL_NAME=cygwin1.dll
 NEW_DLL_NAME=new-cygwin1.dll
+TEST_DLL_NAME=cygwin0.dll
 DEF_FILE=cygwin.def
 LIB_NAME=libcygwin.a
 TEST_LIB_NAME=libcygwin0.a
@@ -622,6 +623,9 @@ $(LIB_NAME): $(DEF_FILE) $(LIBCOS) | $(NEW_DLL_NAME)
 $(TEST_LIB_NAME): $(LIB_NAME)
 	$(AM_V_GEN)perl -p -e 'BEGIN{binmode(STDIN); binmode(STDOUT);}; s/cygwin1/cygwin0/g' < $? > $@
 
+$(TEST_DLL_NAME): $(NEW_DLL_NAME)
+	$(AM_V_GEN)ln -f $(NEW_DLL_NAME) $(TEST_DLL_NAME)
+
 # sublibs
 # import libraries for some subset of symbols indicated by given objects
 speclib=\
@@ -664,7 +668,7 @@ libssp.a: $(LIB_NAME) $(wildcard $(newlib_build)/libc/ssp/*.o)
 # all
 #
 
-all-local: $(LIB_NAME) $(TEST_LIB_NAME) $(SUBLIBS)
+all-local: $(LIB_NAME) $(TEST_LIB_NAME) $(TEST_DLL_NAME) $(SUBLIBS)
 
 #
 # clean
-- 
2.39.0


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH] Cygwin: Makefile: Drop all the "test dll" considerations
  2022-12-21 13:49 [PATCH] Cygwin: Makefile: Build new DLL with the name 'cygwin0.dll' Jon Turney
  2022-12-21 15:58 ` [PATCH] Cygwin: Makefile: Also make 'cygwin0.dll' Jon Turney
@ 2022-12-21 16:18 ` Jon Turney
  2023-01-06 14:38   ` [PATCH] Cygwin: Run testsuite against the just-built DLL Jon Turney
  1 sibling, 1 reply; 5+ messages in thread
From: Jon Turney @ 2022-12-21 16:18 UTC (permalink / raw)
  To: cygwin-patches; +Cc: Jon Turney

After 90236c3a2cf6, the testsuite is failing, as the cygwin0.dll that
the implib testsuite programs are linked with references doesn't exist
anymore.

We don't need to make and link with a specially named DLL, as the cygwin
DLL (for a long time now) takes into consideration the path it's
executing from to define separate "cygwin installations", which don't
interact.

Fixes: 90236c3a2cf6 ("Cygwin: Makefile: build new-cygwin1.dll in a single step")
---
 winsup/cygwin/Makefile.am              | 9 ++-------
 winsup/testsuite/winsup.api/winsup.exp | 2 +-
 2 files changed, 3 insertions(+), 8 deletions(-)

diff --git a/winsup/cygwin/Makefile.am b/winsup/cygwin/Makefile.am
index 0200f6e2a..2faa867f9 100644
--- a/winsup/cygwin/Makefile.am
+++ b/winsup/cygwin/Makefile.am
@@ -43,7 +43,6 @@ DLL_NAME=cygwin1.dll
 NEW_DLL_NAME=new-cygwin1.dll
 DEF_FILE=cygwin.def
 LIB_NAME=libcygwin.a
-TEST_LIB_NAME=libcygwin0.a
 
 #
 # sources
@@ -618,10 +617,6 @@ LIBCOS=$(addsuffix .o,$(basename $(LIB_FILES)))
 $(LIB_NAME): $(DEF_FILE) $(LIBCOS) | $(NEW_DLL_NAME)
 	$(AM_V_GEN)$(srcdir)/scripts/mkimport $(toolopts) $(NEW_FUNCTIONS) $@ cygdll.a $(wordlist 2,99,$^)
 
-# cygwin import library used by testsuite
-$(TEST_LIB_NAME): $(LIB_NAME)
-	$(AM_V_GEN)perl -p -e 'BEGIN{binmode(STDIN); binmode(STDOUT);}; s/cygwin1/cygwin0/g' < $? > $@
-
 # sublibs
 # import libraries for some subset of symbols indicated by given objects
 speclib=\
@@ -664,7 +659,7 @@ libssp.a: $(LIB_NAME) $(wildcard $(newlib_build)/libc/ssp/*.o)
 # all
 #
 
-all-local: $(LIB_NAME) $(TEST_LIB_NAME) $(SUBLIBS)
+all-local: $(LIB_NAME) $(SUBLIBS)
 
 #
 # clean
@@ -675,7 +670,7 @@ clean-local:
 	-rm -f $(DEF_FILE) sigfe.s
 	-rm -f cygwin.sc cygdll.a cygwin.map
 	-rm -f $(NEW_DLL_NAME)
-	-rm -f $(LIB_NAME) $(TEST_LIB_NAME) $(SUBLIBS)
+	-rm -f $(LIB_NAME) $(SUBLIBS)
 	-rm -f version.cc
 	-rm -f tlsoffsets
 
diff --git a/winsup/testsuite/winsup.api/winsup.exp b/winsup/testsuite/winsup.api/winsup.exp
index 584aa5755..f755c82d9 100644
--- a/winsup/testsuite/winsup.api/winsup.exp
+++ b/winsup/testsuite/winsup.api/winsup.exp
@@ -61,7 +61,7 @@ foreach src [lsort [glob -nocomplain $srcdir/$subdir/*.c $srcdir/$subdir/*/*.{cc
     if [ file exists "$srcdir/$subdir/$basename.exp" ] then {
 	source "$srcdir/$subdir/$basename.exp"
     } else {
-	ws_spawn "$CC -nodefaultlibs -mwin32 $CFLAGS $src $add_includes $add_libs $runtime_root/binmode.o -lgcc $runtime_root/libcygwin0.a -lkernel32 -luser32 -o $base.exe"
+	ws_spawn "$CC -nodefaultlibs -mwin32 $CFLAGS $src $add_includes $add_libs $runtime_root/binmode.o -lgcc $runtime_root/libcygwin.a -lkernel32 -luser32 -o $base.exe"
 	if { $rv } {
 	    fail "$testcase (compile)"
 	} else {
-- 
2.39.0


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH] Cygwin: Run testsuite against the just-built DLL
  2022-12-21 16:18 ` [PATCH] Cygwin: Makefile: Drop all the "test dll" considerations Jon Turney
@ 2023-01-06 14:38   ` Jon Turney
  2023-01-09 11:12     ` Corinna Vinschen
  0 siblings, 1 reply; 5+ messages in thread
From: Jon Turney @ 2023-01-06 14:38 UTC (permalink / raw)
  To: cygwin-patches; +Cc: Jon Turney

Since 4e7817498efc, we're just running the tests against the installed
DLL.  We're arranging to put the build directory on the path, but since
it doesn't contain cygwin1.dll (since it's built with a different name
and renamed on installation), that doesn't have any effect.

Arrange to place the just-built DLL into a directory which the testsuite
can place on it's path (while running the test, but not while compiling
it).

Also fix any remaining references to cygwin0.dll in testsuite,
documentation and comments.

Fixes: 4e7817498efc ("Cygwin: Makefile: Drop all the "test dll" considerations")
---

Notes:
    This flips a couple of tests from passing to failing, since they try to
    use system(), which doesn't work, because there is no /usr/bin/bash in
    the Cygwin 'installation' at testsuite/runtime/.
    
    I think perhaps the best solution long-term is to remove all these
    fragile hacks to try to run the testsuite on top of an existing Cygwin,
    and instead the CI should save the result of 'make install' in an
    archive, and a job should unpack that and run the testsuite on it...

 winsup/cygwin/Makefile.am               | 8 +++++---
 winsup/cygwin/scripts/analyze_sigfe     | 2 +-
 winsup/testsuite/Makefile.am            | 3 ++-
 winsup/testsuite/README                 | 9 +++------
 winsup/testsuite/config/default.exp     | 2 +-
 winsup/testsuite/winsup.api/cygload.exp | 2 +-
 winsup/testsuite/winsup.api/winsup.exp  | 8 +++++---
 7 files changed, 18 insertions(+), 16 deletions(-)

diff --git a/winsup/cygwin/Makefile.am b/winsup/cygwin/Makefile.am
index 2faa867f9..125358b4b 100644
--- a/winsup/cygwin/Makefile.am
+++ b/winsup/cygwin/Makefile.am
@@ -577,9 +577,9 @@ LIBSERVER = $(cygserver_blddir)/libcygserver.a
 $(LIBSERVER):
 	$(MAKE) -C $(cygserver_blddir) libcygserver.a
 
-# We build as cygwin0.dll and rename at install time to overcome native
+# We build as new-cygwin1.dll and rename at install time to overcome native
 # rebuilding issues (we don't want the build tools to see a partially built
-# cygwin.dll and attempt to use it instead of the old one).
+# cygwin1.dll and attempt to use it instead of the old one).
 
 # linker script
 LDSCRIPT=cygwin.sc
@@ -601,6 +601,8 @@ $(NEW_DLL_NAME): $(LDSCRIPT) libdll.a $(VERSION_OFILES) $(LIBSERVER)\
 	$(newlib_build)/libm.a \
 	$(newlib_build)/libc.a \
 	-lgcc -lkernel32 -lntdll -Wl,-Map,cygwin.map
+	@$(MKDIR_P) ${target_builddir}/winsup/testsuite/runtime/
+	$(AM_V_at)$(INSTALL_PROGRAM) $(NEW_DLL_NAME) ${target_builddir}/winsup/testsuite/runtime/$(DLL_NAME)
 
 # cygwin import library
 toolopts=--cpu=@target_cpu@ --ar=@AR@ --as=@AS@ --nm=@NM@ --objcopy=@OBJCOPY@
@@ -712,7 +714,7 @@ install-ldif:
 uninstall-hook: uninstall-headers uninstall-ldif uninstall-libs
 
 uninstall-libs:
-	rm -f $(DESTDIR)$(bindir)/cygwin1.dll
+	rm -f $(DESTDIR)$(bindir)/$(DLL_NAME)
 	rm -f $(DESTDIR)$(toollibdir)/libg.a
 
 uninstall-headers:
diff --git a/winsup/cygwin/scripts/analyze_sigfe b/winsup/cygwin/scripts/analyze_sigfe
index 8704eea48..f6bda2355 100755
--- a/winsup/cygwin/scripts/analyze_sigfe
+++ b/winsup/cygwin/scripts/analyze_sigfe
@@ -9,7 +9,7 @@
 # This will do a crude test to see if the (NO)?SIGFE stuff is used properly
 # in cygwin.din.  It is not perfect so do not use it to do a wholesale replacement.
 #
-# Input is the output of 'objdump --disassemble --demangle cygwin0.dll'.
+# Input is the output of 'objdump --disassemble --demangle new-cygwin1.dll'.
 #
 use strict;
 use vars qw'$v';
diff --git a/winsup/testsuite/Makefile.am b/winsup/testsuite/Makefile.am
index ac68934d0..a7b435c46 100644
--- a/winsup/testsuite/Makefile.am
+++ b/winsup/testsuite/Makefile.am
@@ -45,7 +45,8 @@ testdll_tmpdir = $(shell cygpath -ma $(tmpdir) | sed -e 's#^\([A-Z]\):#/cygdrive
 
 site-extra.exp: ../config.status Makefile
 	@rm -f ./tmp0
-	@echo "set runtime_root \"`pwd`/../cygwin\"" >> ./tmp0
+	@echo "set runtime_root \"`pwd`/runtime\"" >> ./tmp0
+	@echo "set libdir \"`pwd`/../cygwin\"" >> ./tmp0
 	@echo "set CC \"$(CC)\"" >> ./tmp0
 	@echo "set CFLAGS \"\"" >> ./tmp0
 	@echo "set MINGW_CXX \"$(MINGW_CXX)\"" >> ./tmp0
diff --git a/winsup/testsuite/README b/winsup/testsuite/README
index 2f6749bb8..c22b06594 100644
--- a/winsup/testsuite/README
+++ b/winsup/testsuite/README
@@ -2,10 +2,9 @@
 
 Here are some notes about adding and using this testsuite.
 
-First, all the programs are linked with libcygwin0.a, which is just
-like libcygwin.a, except that it wants cygwin0.dll, not
-cygwin1.dll.  The testsuite adds the winsup build directory to the
-PATH so that cygwin0.dll can be found by windows during testing.
+The testsuite adds a directory containing the just built cygwin1.dll to the PATH
+(during the run step) so that it can be found by the Windows loader during
+testing.
 
 Because we'll probably run into complaints about using two DLLs, we
 run cygrun.exe for each test.  All this does is run the test with
@@ -36,5 +35,3 @@ Cross-checking is not supported.
 
 To test a subset of the test-suite, use
 $ make check CYGWIN_TESTSUITE_TESTS=regexp
-
-
diff --git a/winsup/testsuite/config/default.exp b/winsup/testsuite/config/default.exp
index 7ef16ee6a..ad91caa03 100644
--- a/winsup/testsuite/config/default.exp
+++ b/winsup/testsuite/config/default.exp
@@ -1,7 +1,7 @@
 proc winsup_version {} {
     global env
     global runtime_root
-    clone_output "\n[exec grep -a ^%%% $runtime_root/cygwin0.dll]\n"
+    clone_output "\n[exec grep -a ^%%% $runtime_root/cygwin1.dll]\n"
     if { [info exists env(CYGWIN)] } {
         clone_output "CYGWIN=$env(CYGWIN)\n"
     } else {
diff --git a/winsup/testsuite/winsup.api/cygload.exp b/winsup/testsuite/winsup.api/cygload.exp
index 8ba8249bb..e378820ad 100644
--- a/winsup/testsuite/winsup.api/cygload.exp
+++ b/winsup/testsuite/winsup.api/cygload.exp
@@ -32,7 +32,7 @@ if { $rv != {0 {}} } {
         set redirect_output /dev/null
     }
     set windows_runtime_root [exec cygpath -m $runtime_root]
-    ws_spawn "./mingw-cygload.exe -cygwin $windows_runtime_root/cygwin0.dll > $redirect_output"
+    ws_spawn "./mingw-cygload.exe -cygwin $windows_runtime_root/cygwin1.dll > $redirect_output"
     if { $rv != {0 {}} } {
         verbose -log "cygload: $rv"
         fail "cygload (execute)"
diff --git a/winsup/testsuite/winsup.api/winsup.exp b/winsup/testsuite/winsup.api/winsup.exp
index f755c82d9..e81ead304 100644
--- a/winsup/testsuite/winsup.api/winsup.exp
+++ b/winsup/testsuite/winsup.api/winsup.exp
@@ -14,9 +14,9 @@ set ltp_libs "$ltp_libs"
 set add_includes $ltp_includes
 set add_libs $ltp_libs
 
-set test_filter ""
+set orig_path "$env(PATH)"
 
-set env(PATH) "$runtime_root:$env(PATH)"
+set test_filter ""
 
 if { [info exists env(CYGWIN_TESTSUITE_TESTS)] } {
     set test_filter "$env(CYGWIN_TESTSUITE_TESTS)"
@@ -61,7 +61,7 @@ foreach src [lsort [glob -nocomplain $srcdir/$subdir/*.c $srcdir/$subdir/*/*.{cc
     if [ file exists "$srcdir/$subdir/$basename.exp" ] then {
 	source "$srcdir/$subdir/$basename.exp"
     } else {
-	ws_spawn "$CC -nodefaultlibs -mwin32 $CFLAGS $src $add_includes $add_libs $runtime_root/binmode.o -lgcc $runtime_root/libcygwin.a -lkernel32 -luser32 -o $base.exe"
+	ws_spawn "$CC -nodefaultlibs -mwin32 $CFLAGS $src $add_includes $add_libs $libdir/binmode.o -lgcc $libdir/libcygwin.a -lkernel32 -luser32 -o $base.exe"
 	if { $rv } {
 	    fail "$testcase (compile)"
 	} else {
@@ -71,8 +71,10 @@ foreach src [lsort [glob -nocomplain $srcdir/$subdir/*.c $srcdir/$subdir/*/*.{cc
 	       set redirect_output /dev/null
 	    }
 	    file mkdir $tmpdir/$base
+	    set env(PATH) "$runtime_root:$env(PATH)"
 	    ws_spawn "$cygrun ./$base.exe $testdll_tmpdir/$base > $redirect_output"
 	    file delete -force $tmpdir/$base
+	    set env(PATH) "$orig_path"
 	    if { $rv } {
 		fail "$testcase (execute)"
 		if { $xfail_expected } {
-- 
2.39.0


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] Cygwin: Run testsuite against the just-built DLL
  2023-01-06 14:38   ` [PATCH] Cygwin: Run testsuite against the just-built DLL Jon Turney
@ 2023-01-09 11:12     ` Corinna Vinschen
  0 siblings, 0 replies; 5+ messages in thread
From: Corinna Vinschen @ 2023-01-09 11:12 UTC (permalink / raw)
  To: cygwin-patches

On Jan  6 14:38, Jon Turney wrote:
> Since 4e7817498efc, we're just running the tests against the installed
> DLL.  We're arranging to put the build directory on the path, but since
> it doesn't contain cygwin1.dll (since it's built with a different name
> and renamed on installation), that doesn't have any effect.
> 
> Arrange to place the just-built DLL into a directory which the testsuite
> can place on it's path (while running the test, but not while compiling
> it).
> 
> Also fix any remaining references to cygwin0.dll in testsuite,
> documentation and comments.
> 
> Fixes: 4e7817498efc ("Cygwin: Makefile: Drop all the "test dll" considerations")
> ---
> 
> Notes:
>     This flips a couple of tests from passing to failing, since they try to
>     use system(), which doesn't work, because there is no /usr/bin/bash in
>     the Cygwin 'installation' at testsuite/runtime/.
>     
>     I think perhaps the best solution long-term is to remove all these
>     fragile hacks to try to run the testsuite on top of an existing Cygwin,
>     and instead the CI should save the result of 'make install' in an
>     archive, and a job should unpack that and run the testsuite on it...
> 
>  winsup/cygwin/Makefile.am               | 8 +++++---
>  winsup/cygwin/scripts/analyze_sigfe     | 2 +-
>  winsup/testsuite/Makefile.am            | 3 ++-
>  winsup/testsuite/README                 | 9 +++------
>  winsup/testsuite/config/default.exp     | 2 +-
>  winsup/testsuite/winsup.api/cygload.exp | 2 +-
>  winsup/testsuite/winsup.api/winsup.exp  | 8 +++++---
>  7 files changed, 18 insertions(+), 16 deletions(-)

All your patches to the testsuite are auto-approved.

Just go ahead with whatever you deem right.  We can handle any question
on IRC.


Thanks,
Corinna

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2023-01-09 11:12 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-12-21 13:49 [PATCH] Cygwin: Makefile: Build new DLL with the name 'cygwin0.dll' Jon Turney
2022-12-21 15:58 ` [PATCH] Cygwin: Makefile: Also make 'cygwin0.dll' Jon Turney
2022-12-21 16:18 ` [PATCH] Cygwin: Makefile: Drop all the "test dll" considerations Jon Turney
2023-01-06 14:38   ` [PATCH] Cygwin: Run testsuite against the just-built DLL Jon Turney
2023-01-09 11:12     ` Corinna Vinschen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).