Subject: Patches for guile on MSYS2

From: Hannes Müller <[email-masked]>
Date: Sun, 03 Dec 2017 19:53:55 +0100

Dear Maintainer,

Hereby I ask to apply the following patches for inclusion. They are
already used downstream in guile on MSYS2.

Best regards
Hannes

From dd6c5b70fa0dc66b569a1aacd84b45e417af0372 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Hannes=20M=C3=BCller?= <[email-masked]>
Date: Wed, 26 Apr 2017 10:41:47 +0200
Subject: [PATCH] Remove version in file name of dynamic library guile-readline
To: [email-masked]

* guile-readline/Makefile.am: Add -avoid-version to guile_readline_la_LDFLAGS.
  Dynamic library guile-readline resides in a "major-version"."minor-version"
  directory. Therefore no additional versioning is required. The patch allows
  standard installation on MSYS2, which is done without .la files.
---
 guile-readline/Makefile.am | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/guile-readline/Makefile.am b/guile-readline/Makefile.am
index ade7dd09d..36c2f5415 100644
--- a/guile-readline/Makefile.am
+++ b/guile-readline/Makefile.am
@@ -51,7 +51,8 @@ guile_readline_la_LIBADD =				\
   $(READLINE_LIBS)					\
   ../libguile/libguile-@GUILE_EFFECTIVE_VERSION@.la ../lib/libgnu.la
 
-guile_readline_la_LDFLAGS = -export-dynamic -no-undefined -module
+guile_readline_la_LDFLAGS = -export-dynamic		\
+			    -no-undefined -module -avoid-version
 
 BUILT_SOURCES = readline.x
 
-- 
2.12.1

From 35904c82828ec1ba285385192f0578f6cd9f7792 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Hannes=20M=C3=BCller?= <[email-masked]>
Date: Tue, 17 Oct 2017 19:42:51 +0200
Subject: [PATCH] In tests add dynamic-link to msys-2.0 for host-type msys
To: [email-masked]

* test-suite/standalone/test-ffi (global): MSYS2 behaves like Cygwin. Therefore
  treat it alike by adding (dynamic-link "msys-2.0").

* test-suite/standalone/test-foreign-object-scm (global): MSYS2 behaves like
  Cygwin. Therefore treat it alike by adding (dynamic-link "msys-2.0").
---
 test-suite/standalone/test-ffi                | 3 +++
 test-suite/standalone/test-foreign-object-scm | 3 +++
 2 files changed, 6 insertions(+)

diff --git a/test-suite/standalone/test-ffi b/test-suite/standalone/test-ffi
index 0e6ab45d1..eb0a0d28f 100755
--- a/test-suite/standalone/test-ffi
+++ b/test-suite/standalone/test-ffi
@@ -269,6 +269,9 @@ exec guile -q -s "$0" "$@"
                  ;; into linked DLLs. Thus one needs to link to the core
                  ;; C library DLL explicitly.
                  (dynamic-link "cygwin1"))
+                ((string-contains %host-type "msys")
+                 ;; MSYS2 behaves like Cygwin
+                 (dynamic-link "msys-2.0"))
                 (else
                  (dynamic-link))))
 
diff --git a/test-suite/standalone/test-foreign-object-scm b/test-suite/standalone/test-foreign-object-scm
index fd4669aa9..0c4114d2a 100755
--- a/test-suite/standalone/test-foreign-object-scm
+++ b/test-suite/standalone/test-foreign-object-scm
@@ -35,6 +35,9 @@ exec guile -q -s "$0" "$@"
                          ;; needs to link to the core C library DLL
                          ;; explicitly.
                          (dynamic-link "cygwin1"))
+                        ((string-contains %host-type "msys")
+                         ;; MSYS2 behaves like Cygwin
+                         (dynamic-link "msys-2.0"))
                         (else
                          (dynamic-link)))))
     (lambda (k . args)
-- 
2.14.2

From a64825ffa6be30bcb876557383dbdd106da51c99 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Hannes=20M=C3=BCller?= <[email-masked]>
Date: Tue, 17 Oct 2017 20:12:41 +0200
Subject: [PATCH] Skip tests using setrlimit for MSYS2 as done for Cygwin
To: [email-masked]

* test-suite/standalone/test-out-of-memory: MSYS2 behaves like Cygwin, i.e.
  setrlimit is not yet supported. Therefore treat it alike by skipping test.

* test-suite/standalone/test-stack-overflow: MSYS2 behaves like Cygwin, i.e.
  setrlimit is not yet supported. Therefore treat it alike by skipping test.
---
 test-suite/standalone/test-out-of-memory  | 8 ++++++++
 test-suite/standalone/test-stack-overflow | 8 ++++++++
 2 files changed, 16 insertions(+)

diff --git a/test-suite/standalone/test-out-of-memory b/test-suite/standalone/test-out-of-memory
index 221651270..4e5ecc81f 100755
--- a/test-suite/standalone/test-out-of-memory
+++ b/test-suite/standalone/test-out-of-memory
@@ -29,6 +29,14 @@ exec guile -q -s "$0" "$@"
   ;; test-stack-overflow.
   (exit 77)) ; unresolved
 
+(when (string-contains-ci (vector-ref (uname) 0) "MSYS_NT")
+  ;; attempting to use setrlimit for memory RLIMIT_AS will always
+  ;; produce an invalid argument error on MSYS2 (tested on
+  ;; MSYS_NT-6.1-WOW DLL v2.9.0).  Proceeding with the test would fill
+  ;; all available memory and probably end in a crash.  See also
+  ;; test-stack-overflow.
+  (exit 77)) ; unresolved
+
 (catch #t
   ;; Silence GC warnings.
   (lambda ()
diff --git a/test-suite/standalone/test-stack-overflow b/test-suite/standalone/test-stack-overflow
index dd54249d8..83e929159 100755
--- a/test-suite/standalone/test-stack-overflow
+++ b/test-suite/standalone/test-stack-overflow
@@ -29,6 +29,14 @@ exec guile -q -s "$0" "$@"
   ;; test-out-of-memory.
   (exit 77)) ; unresolved
 
+(when (string-contains-ci (vector-ref (uname) 0) "MSYS_NT")
+  ;; attempting to use setrlimit for memory RLIMIT_AS will always
+  ;; produce an invalid argument error on MSYS2 (tested on
+  ;; MSYS_NT-6.1-WOW DLL v2.9.0).  Proceeding with the test would fill
+  ;; all available memory and probably end in a crash.  See also
+  ;; test-out-of-memory.
+  (exit 77)) ; unresolved
+
 ;; 100 MB.
 (define *limit* (* 100 1024 1024))
 
-- 
2.14.2

From 6620b25a564f01468ab4aaa895cfcd4f75424f08 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Hannes=20M=C3=BCller?= <[email-masked]>
Date: Tue, 17 Oct 2017 20:23:39 +0200
Subject: [PATCH] Activate test-pthread-create-secondary for CYGWIN/MSYS2
To: [email-masked]

* test-suite/standalone/test-pthread-create-secondary.c [__CYGWIN__]: Add test
  also for CYGWIN/MSYS2 since it passes on these systems.
---
 test-suite/standalone/test-pthread-create-secondary.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/test-suite/standalone/test-pthread-create-secondary.c b/test-suite/standalone/test-pthread-create-secondary.c
index 14ea240a4..aedb3b8fb 100644
--- a/test-suite/standalone/test-pthread-create-secondary.c
+++ b/test-suite/standalone/test-pthread-create-secondary.c
@@ -39,7 +39,7 @@
    Maidanski.  See <http://thread.gmane.org/gmane.lisp.guile.bugs/5340>
    for details.  */
 
-#if defined __linux__						\
+#if (defined __linux__ || defined __CYGWIN__)			\
   && (GC_VERSION_MAJOR > 7					\
       || (GC_VERSION_MAJOR == 7 && GC_VERSION_MINOR > 2)	\
       || (GC_VERSION_MAJOR == 7 && GC_VERSION_MINOR == 2	\
@@ -78,7 +78,7 @@ main (int argc, char *argv[])
 }
 
 
-#else /* Linux && GC < 7.2alpha5 */
+#else /* !(Linux || Cygwin) || GC < 7.2alpha5 */
 
 int
 main (int argc, char *argv[])
-- 
2.14.2