On Sat, Jan 14, 2017 at 03:00:20PM +0100, Kooda wrote:
> On Fri, 13 Jan 2017 16:08:02 +1300
> Evan Hanson <ev...@foldling.org> wrote:
> 
> > Hi hackers,
> > 
> > Another small patch for Windows. This one fixes a symbol visibility
> > problem when building CHICKEN on Cygwin (64-bit), where the following
> > currently occurs:
> > […]
> 
> Tested on windows 10 with latest Cygwin, both CHICKEN 4 and 5. It
> builds fine, tests pass and I was also able to run and serve requests
> with spiffy. :)

Hi guys,

Thanks for the patch, Evan, and thanks for testing, Kooda!

I have no access to a true 64-bit build of Windows, so I tested on
Windows 7 (x86) with Cygwin, but unfortunately this patch now actually
_introduces_ warnings there: "implicit declaration of initgroups" and
"implicit declaration of strlcpy".

Defining _XOPEN_SOURCE causes the __BSD_VISIBLE macro in the Cygwin
headers to get set to 0 (regardless of our defining _BSD_SOURCE),
which then hides all the BSD extensions like initrgroups and strlcpy.

I really hate playing this stupid game of whack-a-mole with header
definitions (there seems to be no sane combination of definitions that
will work on all OSes).  Instead, I think it's better to just give in
and add the --std=gnu99 on all platforms where we're using gcc and clang.
I'd appreciate if you guys could test this on a x86_64 Windows to see
if that also fixes the warnings you saw before.

This has also been suggested by Christian in #1107, but I was afraid of
adding it because it probably won't work on any compiler aside gcc/clang,
but this preprocessor madness is getting out of hand, and this seems
like a simpler approach and so far it seems to work everywhere.  If this
is not acceptable, we could also try defining _GNU_SOURCE instead.  Like
the Cygwin headers say "this defines everything and the kitchen sink".

PS: I also noticed that "$time foo" doesn't work in either the Cygwin nor
the Mingw-msys shells (they have a builtin "time", but for some reason
using $time causes it not to see this), so I've attached a second patch
with a slightly different workaround for missing "time" than the
workaround we added in cfdeb4ab.  Yay for broken systems :(

The patch simply tries to run "time echo ''" from a variable, and if it
fails sets $time to ":".  See also this Stack Overflow question for more
information about how to make it work and how broken things really are:
http://unix.stackexchange.com/questions/104579/catch-command-not-found-from-shell-script
If this doesn't work, we could spawn a new shell with -c "$time ...", to
make it see the expanded version of the $time variable, but let's try
this first.

Cheers,
Peter
From 2ea5467dfeb343bf0527d1bea298ccf01b7d491a Mon Sep 17 00:00:00 2001
From: Peter Bex <pe...@more-magic.net>
Date: Sat, 14 Jan 2017 20:27:30 +0100
Subject: [PATCH 1/2] Pass --std=gnu99 gcc or clang is default

This ensures more consistent behaviour of header files.

See also #1107
---
 Makefile.aix        | 2 +-
 Makefile.android    | 2 +-
 Makefile.bsd        | 2 +-
 Makefile.cygwin     | 2 +-
 Makefile.haiku      | 2 +-
 Makefile.hurd       | 2 +-
 Makefile.ios        | 2 +-
 Makefile.linux      | 2 +-
 Makefile.macosx     | 2 +-
 Makefile.mingw      | 2 +-
 Makefile.mingw-msys | 2 +-
 Makefile.solaris    | 2 +-
 NEWS                | 4 ++++
 13 files changed, 16 insertions(+), 12 deletions(-)

diff --git a/Makefile.aix b/Makefile.aix
index 3a2b6c0..26c196a 100644
--- a/Makefile.aix
+++ b/Makefile.aix
@@ -34,7 +34,7 @@ ARCH ?= $(shell sh $(SRCDIR)/config-arch.sh)
 # options
 
 C_COMPILER = gcc
-C_COMPILER_OPTIONS ?= -fno-strict-aliasing -fwrapv -DHAVE_CHICKEN_CONFIG_H -maix64 -Os
+C_COMPILER_OPTIONS ?= -fno-strict-aliasing -fwrapv -DHAVE_CHICKEN_CONFIG_H -maix64 -Os --std=gnu99
 ifdef DEBUGBUILD
 C_COMPILER_OPTIMIZATION_OPTIONS ?= -g -Wall -Wno-unused
 else
diff --git a/Makefile.android b/Makefile.android
index 8350ca7..8dd4c1a 100644
--- a/Makefile.android
+++ b/Makefile.android
@@ -31,7 +31,7 @@ ARCH ?= $(shell sh $(SRCDIR)/config-arch.sh)
 
 # options
 
-C_COMPILER_OPTIONS ?= -fno-strict-aliasing -fwrapv -DHAVE_CHICKEN_CONFIG_H
+C_COMPILER_OPTIONS ?= -fno-strict-aliasing -fwrapv -DHAVE_CHICKEN_CONFIG_H --std=gnu99
 ifdef DEBUGBUILD
 C_COMPILER_OPTIMIZATION_OPTIONS ?= -g -Wall -Wno-unused
 else
diff --git a/Makefile.bsd b/Makefile.bsd
index 02b5131..751836a 100644
--- a/Makefile.bsd
+++ b/Makefile.bsd
@@ -31,7 +31,7 @@ SRCDIR ?= ./
 ARCH ?= $(shell sh $(SRCDIR)/config-arch.sh)
 
 # options
-C_COMPILER_OPTIONS ?= -fno-strict-aliasing -fwrapv -DHAVE_CHICKEN_CONFIG_H
+C_COMPILER_OPTIONS ?= -fno-strict-aliasing -fwrapv -DHAVE_CHICKEN_CONFIG_H --std=gnu99
 
 ifdef DEBUGBUILD
 C_COMPILER_OPTIMIZATION_OPTIONS ?= -g -Wall -Wno-unused
diff --git a/Makefile.cygwin b/Makefile.cygwin
index 54c589d..f80ac1a 100644
--- a/Makefile.cygwin
+++ b/Makefile.cygwin
@@ -42,7 +42,7 @@ RC_COMPILER = windres
 LINKER = gcc
 TARGET_RC_COMPILER ?= $(RC_COMPILER)
 
-C_COMPILER_OPTIONS ?= -fno-strict-aliasing -fwrapv -DHAVE_CHICKEN_CONFIG_H
+C_COMPILER_OPTIONS ?= -fno-strict-aliasing -fwrapv -DHAVE_CHICKEN_CONFIG_H --std=gnu99
 ifdef DEBUGBUILD
 C_COMPILER_OPTIMIZATION_OPTIONS ?= -g -Wall -Wno-unused
 else
diff --git a/Makefile.haiku b/Makefile.haiku
index 3120f30..682a5e9 100644
--- a/Makefile.haiku
+++ b/Makefile.haiku
@@ -31,7 +31,7 @@ ARCH ?= $(shell sh $(SRCDIR)/config-arch.sh)
 
 # options
 
-C_COMPILER_OPTIONS ?= -fno-strict-aliasing -fwrapv -DHAVE_CHICKEN_CONFIG_H
+C_COMPILER_OPTIONS ?= -fno-strict-aliasing -fwrapv -DHAVE_CHICKEN_CONFIG_H --std=gnu99
 ifdef DEBUGBUILD
 C_COMPILER_OPTIMIZATION_OPTIONS ?= -g -Wall -Wno-unused
 else
diff --git a/Makefile.hurd b/Makefile.hurd
index 696fbcb..83ac4ca 100644
--- a/Makefile.hurd
+++ b/Makefile.hurd
@@ -32,7 +32,7 @@ ARCH ?= $(shell sh $(SRCDIR)/config-arch.sh)
 
 # options
 
-C_COMPILER_OPTIONS ?= -fno-strict-aliasing -fwrapv -DHAVE_CHICKEN_CONFIG_H
+C_COMPILER_OPTIONS ?= -fno-strict-aliasing -fwrapv -DHAVE_CHICKEN_CONFIG_H --std=gnu99
 ifdef DEBUGBUILD
 C_COMPILER_OPTIMIZATION_OPTIONS ?= -g -Wall -Wno-unused
 else
diff --git a/Makefile.ios b/Makefile.ios
index 54b88b3..7661c8f 100644
--- a/Makefile.ios
+++ b/Makefile.ios
@@ -42,7 +42,7 @@ STATICBUILD = 1
 # for Xcode 4:  C_COMPILER ?= $(XCODE_DEVELOPER)/Platforms/iPhoneOS.platform/iPhoneOS.platform/Developer/usr/bin
 C_COMPILER ?= $(XCODE_TOOLPATH)/gcc
 LIBRARIAN ?= $(XCODE_DEVELOPER)/Platforms/iPhoneOS.platform/Developer/usr/bin/ar
-C_COMPILER_OPTIONS ?= -no-cpp-precomp -fno-strict-aliasing -fwrapv -fno-common -DHAVE_CHICKEN_CONFIG_H -mno-thumb -isysroot $(XCODE_SDK) -arch $(ARCH)
+C_COMPILER_OPTIONS ?= -no-cpp-precomp -fno-strict-aliasing -fwrapv -fno-common -DHAVE_CHICKEN_CONFIG_H -mno-thumb -isysroot $(XCODE_SDK) -arch $(ARCH) --std=gnu99
 ifdef DEBUGBUILD
 C_COMPILER_OPTIMIZATION_OPTIONS ?= -g -Wall -Wno-unused
 else
diff --git a/Makefile.linux b/Makefile.linux
index aa0a771..7541bd7 100644
--- a/Makefile.linux
+++ b/Makefile.linux
@@ -32,7 +32,7 @@ ARCH ?= $(shell sh $(SRCDIR)/config-arch.sh)
 
 # options
 
-C_COMPILER_OPTIONS ?= -fno-strict-aliasing -fwrapv -DHAVE_CHICKEN_CONFIG_H
+C_COMPILER_OPTIONS ?= -fno-strict-aliasing -fwrapv -DHAVE_CHICKEN_CONFIG_H --std=gnu99
 ifdef DEBUGBUILD
 C_COMPILER_OPTIMIZATION_OPTIONS ?= -g -Wall -Wno-unused
 else
diff --git a/Makefile.macosx b/Makefile.macosx
index 6cf4f04..5952b12 100644
--- a/Makefile.macosx
+++ b/Makefile.macosx
@@ -39,7 +39,7 @@ POSTINSTALL_PROGRAM = $(XCODE_TOOL_PATH)/install_name_tool
 
 # options
 
-C_COMPILER_OPTIONS ?= -fno-strict-aliasing -fwrapv -fno-common -DHAVE_CHICKEN_CONFIG_H
+C_COMPILER_OPTIONS ?= -fno-strict-aliasing -fwrapv -fno-common -DHAVE_CHICKEN_CONFIG_H --std=gnu99
 ifdef DEBUGBUILD
 C_COMPILER_OPTIMIZATION_OPTIONS ?= -g -Wall -Wno-unused
 else
diff --git a/Makefile.mingw b/Makefile.mingw
index c249f45..aaea198 100644
--- a/Makefile.mingw
+++ b/Makefile.mingw
@@ -43,7 +43,7 @@ EXE = .exe
 # options
 
 C_COMPILER ?= gcc
-C_COMPILER_OPTIONS ?= -fno-strict-aliasing -fwrapv -DHAVE_CHICKEN_CONFIG_H
+C_COMPILER_OPTIONS ?= -fno-strict-aliasing -fwrapv -DHAVE_CHICKEN_CONFIG_H --std=gnu99
 ifdef DEBUGBUILD
 C_COMPILER_OPTIMIZATION_OPTIONS ?= -g -Wall -Wno-unused
 else
diff --git a/Makefile.mingw-msys b/Makefile.mingw-msys
index 5b2aab9..201f6eb 100644
--- a/Makefile.mingw-msys
+++ b/Makefile.mingw-msys
@@ -39,7 +39,7 @@ EXE = .exe
 
 # options
 
-C_COMPILER_OPTIONS ?= -fno-strict-aliasing -fwrapv -DHAVE_CHICKEN_CONFIG_H
+C_COMPILER_OPTIONS ?= -fno-strict-aliasing -fwrapv -DHAVE_CHICKEN_CONFIG_H --std=gnu99
 ifdef DEBUGBUILD
 C_COMPILER_OPTIMIZATION_OPTIONS ?= -g -Wall -Wno-unused
 else
diff --git a/Makefile.solaris b/Makefile.solaris
index 03f372c..ff679f5 100644
--- a/Makefile.solaris
+++ b/Makefile.solaris
@@ -43,7 +43,7 @@ DISABLE_ANNOTATIONS=
 endif
 C_COMPILER_OPTIONS ?= -errtags -xdebugformat=stabs $(DISABLE_ANNOTATIONS) -DHAVE_CHICKEN_CONFIG_H
 else
-C_COMPILER_OPTIONS ?= -fno-strict-aliasing -fwrapv -DHAVE_CHICKEN_CONFIG_H
+C_COMPILER_OPTIONS ?= -fno-strict-aliasing -fwrapv -DHAVE_CHICKEN_CONFIG_H --std=gnu99
 endif
 
 ifdef DEBUGBUILD
diff --git a/NEWS b/NEWS
index ac51659..ee8339d 100644
--- a/NEWS
+++ b/NEWS
@@ -20,6 +20,10 @@
     in, they are restored (fixes #1336, thanks to Joo ChurlSoo).
     This was a regression caused by the fix for #1227.
 
+- Build system
+   - On platforms where gcc or clang are the default, the --std=gnu99
+     option is used to get more consistent header behaviour (#1107).
+
 4.11.1
 
 - Security fixes
-- 
2.1.4

From b49cc15d925bef4c7dd3fc43585c1b14bf1d6a01 Mon Sep 17 00:00:00 2001
From: Peter Bex <pe...@more-magic.net>
Date: Sat, 14 Jan 2017 21:24:21 +0100
Subject: [PATCH 2/2] Add a workaround for "time" builtin on bash (cygwin)

---
 tests/runtests.sh | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/tests/runtests.sh b/tests/runtests.sh
index 164c1f4..abb8576 100755
--- a/tests/runtests.sh
+++ b/tests/runtests.sh
@@ -87,7 +87,16 @@ SETUP_PREFIX="${SETUP_PREFIX} -e (register-program \"csi\" (make-pathname ${TEST
 TYPESDB=../types.db
 cp $TYPESDB test-repository/types.db
 
-time=`command >/dev/null -v time && echo time || :`
+time=time
+# On some Bash versions (Cygwin), calling the time builtin from a
+# variable breaks, and some systems don't ship with time(1) or a
+# builtin...
+set +e
+$time echo '' > /dev/null 2> /dev/null
+if [ "$?" -eq 127 ]; then
+    time=':'
+fi
+set -e
 compile="../csc -types ${TYPESDB} -ignore-repository ${COMPILE_OPTIONS} -o a.out"
 compile2="../csc -compiler ${CHICKEN} -v -I${TEST_DIR}/.. -L${TEST_DIR}/.. -include-path ${TEST_DIR}/.."
 compile_s="../csc -s -types ${TYPESDB} -ignore-repository ${COMPILE_OPTIONS}"
-- 
2.1.4

From 71120e32b07b4926e50a10452b3b741c90187a04 Mon Sep 17 00:00:00 2001
From: Peter Bex <pe...@more-magic.net>
Date: Sat, 14 Jan 2017 20:44:47 +0100
Subject: [PATCH 2/2] Add a workaround for "time" builtin on bash (cygwin)

---
 tests/runtests.sh | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/tests/runtests.sh b/tests/runtests.sh
index ab65cf4..8ef4ac9 100755
--- a/tests/runtests.sh
+++ b/tests/runtests.sh
@@ -63,7 +63,16 @@ SETUP_PREFIX="${SETUP_PREFIX} -e (register-program \"csi\" (make-pathname ${TEST
 TYPESDB=../types.db
 cp $TYPESDB test-repository/types.db
 
-time=`command >/dev/null -v time && echo time || :`
+time=time
+# On some Bash versions (Cygwin), calling the time builtin from a
+# variable breaks, and some systems don't ship with time(1) or a
+# builtin...
+set +e
+$time echo '' > /dev/null 2> /dev/null
+if [ "$?" -eq 127 ]; then
+    time=':'
+fi
+set -e
 compile="../csc -types ${TYPESDB} -ignore-repository ${COMPILE_OPTIONS} -o a.out"
 compile2="../csc -compiler $CHICKEN -v -I${TEST_DIR}/.. -L${TEST_DIR}/.. -include-path ${TEST_DIR}/.."
 compile_s="../csc -s -types ${TYPESDB} -ignore-repository ${COMPILE_OPTIONS} -v -I${TEST_DIR}/.. -L${TEST_DIR}/.. -include-path ${TEST_DIR}/.."
-- 
2.1.4

Attachment: signature.asc
Description: Digital signature

_______________________________________________
Chicken-hackers mailing list
Chicken-hackers@nongnu.org
https://lists.nongnu.org/mailman/listinfo/chicken-hackers

Reply via email to