MinGW Pike 7.8.866: the good, the bad, the ugly
Chris Angelico <[email protected]>
| Newsgroups | gmane.comp.lang.pike.user |
|---|---|
| Message-ID | <CAPTjJmoMUy_vfpjsmUsyKyiEBAp+XLCf4fbZGaAApW655zV53g@mail.gmail.com> |
Today I reopened my project to build Pike on Windows, partly because
there's no .msi binary available for 7.8.866 yet, but largely just
because I'd like to try my hand at getting the build going :)
The good:
It works! I managed to get a fairly complete build, with all the
basics; it's just a standard MinGW installation, then extract the Pike
source tarball, and do the usual build. I ended up with this:
make CONFIGUREARGS="CFLAGS=-Wno-all --without-COM --prefix=C:/"
Suppressing warnings was a measure I took after dealing with one too
many compilation failures, and having to weed through piles of
warnings to find the one error that stopped the build. I think it'd be
fine to build without that option, though.
The COM module has compilation failures, not sure whether that's
because of bugs in it or limitations in MinGW or something else
altogether. Removing it from the build worked fine.
Setting the prefix to C:/ means it installs into
C:/pike/7.8.866/{bin,lib}, which is more convenient for transferring
to another computer than the default (which has it looking for
master.pike somewhere under the MinGW tree - fine if that's where you
installed it, not so fine for deploying elsewhere).
Deploying this requires very little. Just copy in the Pike tree, and
grab libintl-8.dll from the MinGW bin directory and plop it in.
I also managed to get GTK2 to work, which is important to me :) Wasn't
hard; just installed Windows GTK libraries according to their README,
and ran a 'make reconfigure'. I love it when stuff just works like
that. Didn't try any other libraries with external deps, though.
The bad:
The installer probably won't work - 'make install' says this:
c:/Pike-v7.8.866/bin/install.pike:61: Warning:
"Standards.UUID.make_version3 not available."
c:/Pike-v7.8.866/bin/install.pike:62: Warning: "Wix support disabled."
But since I'm not running Microsoft's compiler, I probably don't have
the tools for building an MSI anyway.
There's something wrong with the dumping of the System module, so
deleting lib/modules/System.pmod.o silences some warnings. (It seems
to work fine, just doesn't dump/reload.)
For some reason, Gz isn't failing properly :) In config.info it's
listed as dependencies failed, but instead of simply not existing, or
being an empty module, it exists and spews a bunch of errors.
Obviously I need to hunt down an appropriate zlib dev library to make
it work, but it'd be nice if it would fail more cleanly.
The ugly:
For some reason, Hilfe's "start backend" doesn't seem to work with
GTK2. I can use call_out no problem:
C:\>pike\7.8.866\bin\pike
Pike v7.8 release 866 running Hilfe v3.5 (Incremental Pike Frontend)
> start backend
> call_out(write,1,"Hello, world!\n");
(1) Result: ({ /* 2 elements */
Tools.Hilfe.StdinHilfe()->safe_write,
"Hello, world!\n"
})
> Hello, world!
And I can use GTK2 with explicit calls to the backend:
C:\>pike\7.8.866\bin\pike
Pike v7.8 release 866 running Hilfe v3.5 (Incremental Pike Frontend)
> GTK2.setup_gtk();
(1) Result: ({ /* 1 element */
"Pike GTK"
})
> GTK2.Window(0)->set_title("Hello, world!")->add(GTK2.Label("This is a test."))->show_all()->signal_connect("delete-event",lambda() {exit(0);});
(2) Result: 11
> while (1) Pike.DefaultBackend(3600.0);
And a stand-alone script works fine, doing the same thing and
returning -1 from main.
But trying to use GTK2 with 'start backend' leaves the window hanging.
Not sure why; possibly some kind of problem with threading??
Also, it took me seven Pike patches and one MinGW patch to make this
work. Some are fairly straight-forward and won't break stuff;
others... are gross hacks. Looking for comments on them; all are
attached. They all apply cleanly to 8.0 trunk except for the
master.pike.in change, which has had some unrelated changes; an
alternative patch for that one is provided (numbered 0002 instead of
0005 - the 0005 one applies to 7.8.866).
Happy to shoot the binary across to anyone for testing, if there's
interest. Would be interesting to know what important stuff is
missing.
ChrisA
0001-builtin_functions-Syntactic-fix-to-elif.patch
(text/x-patch, 736 B)
From 427ee94a1f438ebb163d29539e028cc40dd886ef Mon Sep 17 00:00:00 2001 From: Chris Angelico <[email protected]> Date: Mon, 7 Jul 2014 22:42:16 +1000 Subject: [PATCH 1/7] builtin_functions: Syntactic fix to #elif --- src/builtin_functions.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/builtin_functions.c b/src/builtin_functions.c index 0fab843..1cb6fee 100644 --- a/src/builtin_functions.c +++ b/src/builtin_functions.c @@ -7133,7 +7133,7 @@ PMOD_EXPORT void f__memory_usage(INT32 args) struct svalue *ss; #ifdef USE_DL_MALLOC struct mallinfo mi = dlmallinfo(); -#elif HAVE_MALLINFO +#elif defined(HAVE_MALLINFO) struct mallinfo mi = mallinfo(); #endif pop_n_elems(args); -- 1.9.4.msysgit.0
0002-Mark-do_abort-as-noreturn-to-suppress-a-warning.patch
(text/x-patch, 729 B)
From 54a210aa44e3c1eba6c060f53f5eae529e25d350 Mon Sep 17 00:00:00 2001 From: Chris Angelico <[email protected]> Date: Mon, 7 Jul 2014 22:42:38 +1000 Subject: [PATCH 2/7] Mark do_abort as noreturn to suppress a warning --- src/error.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/error.c b/src/error.c index 53f6d4d..e5ba92f 100644 --- a/src/error.c +++ b/src/error.c @@ -555,7 +555,7 @@ PMOD_EXPORT void exit_on_error(const void *msg) #ifdef __NT__ /* Wrapper around abort() to avoid interactive requesters on NT. */ int fnordel=0; -static void do_abort() +static void do_abort() ATTRIBUTE((noreturn)) { if (!d_flag && !getenv("PIKE_DEBUG")) { exit(-6); /* -SIGIOT */ -- 1.9.4.msysgit.0
0003-Eliminate-warnings-and-possible-errors-from-pointer-.patch
(text/x-patch, 1.7 KB)
From 320795807d763154c3d0925a4961990362671c1b Mon Sep 17 00:00:00 2001 From: Chris Angelico <[email protected]> Date: Mon, 7 Jul 2014 22:43:41 +1000 Subject: [PATCH 3/7] Eliminate warnings and possible errors from pointer type mismatches --- src/modules/system/nt.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/modules/system/nt.c b/src/modules/system/nt.c index 1b31509..7b65720 100644 --- a/src/modules/system/nt.c +++ b/src/modules/system/nt.c @@ -913,7 +913,7 @@ static void low_encode_user_info_2(USER_INFO_2 *tmp) push_int(tmp->usri2_units_per_week); if(tmp->usri2_logon_hours) - push_string(make_shared_binary_string(tmp->usri2_logon_hours,21)); + push_string(make_shared_binary_string((const char *)tmp->usri2_logon_hours,21)); else push_int(0); @@ -964,7 +964,7 @@ static void low_encode_user_info_11(USER_INFO_11 *tmp) push_int(tmp->usri11_units_per_week); if(tmp->usri11_logon_hours) - push_string(make_shared_binary_string(tmp->usri11_logon_hours,21)); + push_string(make_shared_binary_string((const char *)tmp->usri11_logon_hours,21)); else push_int(0); @@ -3658,7 +3658,7 @@ static void f_sctx_gencontext(INT32 args) pop_n_elems(args); push_int(sctx->done?1:0); - push_string(make_shared_binary_string(sctx->buf, sctx->cBuf)); + push_string(make_shared_binary_string((const char *)sctx->buf, sctx->cBuf)); f_aggregate(2); } @@ -3676,7 +3676,7 @@ static void f_sctx_getlastcontext(INT32 args) return; } push_int(sctx->done?1:0); - push_string(make_shared_binary_string(sctx->buf, sctx->cBuf)); + push_string(make_shared_binary_string((const char *)sctx->buf, sctx->cBuf)); f_aggregate(2); } -- 1.9.4.msysgit.0
0004-MinGW-doesn-t-have-STRUNCATE-for-some-reason-use-the.patch
(text/x-patch, 888 B)
From f493439466fbbffda87f1995d5edbb19752312ae Mon Sep 17 00:00:00 2001 From: Chris Angelico <[email protected]> Date: Mon, 7 Jul 2014 22:44:19 +1000 Subject: [PATCH 4/7] MinGW doesn't have STRUNCATE for some reason; use the number directly --- src/fdlib.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/fdlib.c b/src/fdlib.c index b5c7437..7e1677d 100644 --- a/src/fdlib.c +++ b/src/fdlib.c @@ -58,7 +58,7 @@ PMOD_EXPORT void set_errno_from_win32_error (unsigned long err) /* Let through any error that _dosmaperr didn't map, and which * doesn't conflict with the errno range in msvcrt. */ - if (errno == EINVAL && err > STRUNCATE /* 80 */) { + if (errno == EINVAL && err > 80 /* STRUNCATE */) { switch (err) { /* Special cases for the error codes above STRUNCATE that * _dosmaperr actively map to EINVAL. */ -- 1.9.4.msysgit.0
0005-Total-hacks-to-get-MinGW-working-DO-NOT-APPLY.patch
(text/x-patch, 1.2 KB)
From dfdb4bae7df5dab5365626ad4bdde198198ae6e4 Mon Sep 17 00:00:00 2001 From: Chris Angelico <[email protected]> Date: Mon, 7 Jul 2014 22:44:42 +1000 Subject: [PATCH 5/7] Total hacks to get MinGW working - DO NOT APPLY! --- lib/master.pike.in | 5 +++++ src/modules/system/nt.c | 3 +++ 2 files changed, 8 insertions(+) diff --git a/lib/master.pike.in b/lib/master.pike.in index 82c9fbc..fa7b907 100644 --- a/lib/master.pike.in +++ b/lib/master.pike.in @@ -2295,6 +2295,11 @@ class dirnode protected void create(string d, object|void h) { + // MinGW hack by CJA + if (has_prefix(lower_case(d), "c:/c/")) { + d = "C:" + replace(d[4..], "/", "\\"); + } + resolv_debug ("dirnode(%O,%O) created\n",d,h); dirname=d; compilation_handler=h; diff --git a/src/modules/system/nt.c b/src/modules/system/nt.c index 7b65720..187f960 100644 --- a/src/modules/system/nt.c +++ b/src/modules/system/nt.c @@ -56,6 +56,9 @@ #include <NewAPIs.h> #endif +/* CJA hack: MinGW fix per http://sourceforge.net/p/mingw/bugs/1089/ */ +typedef ITEMIDLIST *PIDLIST_ABSOLUTE; + #include "program.h" #include "stralloc.h" #include "threads.h" -- 1.9.4.msysgit.0
0006-Link-directly-to-_dosmaperr-instead-of-importing-it.patch
(text/x-patch, 1.1 KB)
From b1605b4769c01e03038636b94f650d6c0aa2de8d Mon Sep 17 00:00:00 2001 From: Chris Angelico <[email protected]> Date: Mon, 7 Jul 2014 23:02:47 +1000 Subject: [PATCH 6/7] Link directly to _dosmaperr() instead of importing it. Importing seems not to be working. I have no idea why it's done this way, or what the consequences of this change are, so consider this a hack. --- src/fdlib.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/fdlib.c b/src/fdlib.c index 7e1677d..f6dbc68 100644 --- a/src/fdlib.c +++ b/src/fdlib.c @@ -48,13 +48,13 @@ int first_free_handle; #endif /* _dosmaperr is internal but still exported in the dll interface. */ -__declspec(dllimport) void __cdecl _dosmaperr(unsigned long); +/* __declspec(dllimport) void _dosmaperr(int); */ PMOD_EXPORT void set_errno_from_win32_error (unsigned long err) { /* _dosmaperr handles the common I/O errors from GetLastError, but * not the winsock codes. */ - _dosmaperr (err); + _dosmaperr ((int)err); /* Let through any error that _dosmaperr didn't map, and which * doesn't conflict with the errno range in msvcrt. */ -- 1.9.4.msysgit.0
0007-Embed-regexp.h-into-the-one-place-where-it-s-used.patch
(text/x-patch, 1.5 KB)
From 56a0c197778c830e884b61237e7d42402bce0f38 Mon Sep 17 00:00:00 2001 From: Chris Angelico <[email protected]> Date: Mon, 7 Jul 2014 23:03:30 +1000 Subject: [PATCH 7/7] Embed regexp.h into the one place where it's used --- lib/include/regexp.h | 11 ----------- src/modules/Regexp/module.pmod.in | 12 +++++++++++- 2 files changed, 11 insertions(+), 12 deletions(-) delete mode 100644 lib/include/regexp.h diff --git a/lib/include/regexp.h b/lib/include/regexp.h deleted file mode 100644 index 7e33c4f..0000000 --- a/lib/include/regexp.h +++ /dev/null @@ -1,11 +0,0 @@ - -#if constant(_Regexp_PCRE._pcre) -#if constant(_Regexp_PCRE.UTF8_SUPPORTED) -#define PCRE_GOT_WIDESTRINGS -#define GOOD _Regexp_PCRE.StudiedWidestring -#define QUICK _Regexp_PCRE.Widestring -#else -#define GOOD _Regexp_PCRE.Studied -#define QUICK _Regexp_PCRE.Plain -#endif -#endif diff --git a/src/modules/Regexp/module.pmod.in b/src/modules/Regexp/module.pmod.in index c3b21dc..89f0e0e 100644 --- a/src/modules/Regexp/module.pmod.in +++ b/src/modules/Regexp/module.pmod.in @@ -1,7 +1,17 @@ // -*- Pike -*- #pike __REAL_VERSION__ -#include <regexp.h> + +#if constant(_Regexp_PCRE._pcre) +#if constant(_Regexp_PCRE.UTF8_SUPPORTED) +#define PCRE_GOT_WIDESTRINGS +#define GOOD _Regexp_PCRE.StudiedWidestring +#define QUICK _Regexp_PCRE.Widestring +#else +#define GOOD _Regexp_PCRE.Studied +#define QUICK _Regexp_PCRE.Plain +#endif +#endif #if constant(_Regexp_PCRE._pcre) final constant PCRE=_Regexp_PCRE; // Regexp.PCRE -- 1.9.4.msysgit.0
0002-Total-hacks-to-get-MinGW-working-DO-NOT-APPLY.patch
(text/x-patch, 1.2 KB)
From 54c890853150894d5c50000e8bf2aa3621836a20 Mon Sep 17 00:00:00 2001 From: Chris Angelico <[email protected]> Date: Mon, 7 Jul 2014 22:44:42 +1000 Subject: [PATCH 2/4] Total hacks to get MinGW working - DO NOT APPLY! --- lib/master.pike.in | 5 +++++ src/modules/system/nt.c | 3 +++ 2 files changed, 8 insertions(+) diff --git a/lib/master.pike.in b/lib/master.pike.in index 29e3bb5..9773b1f 100644 --- a/lib/master.pike.in +++ b/lib/master.pike.in @@ -2415,6 +2415,11 @@ class dirnode (string dirname, object|void compilation_handler, protected void create() { + // MinGW hack by CJA + if (has_prefix(lower_case(dirname), "c:/c/")) { + dirname = "C:" + replace(dirname[4..], "/", "\\"); + } + resolv_debug ("dirnode(%O,%O) created with name %O\n", dirname, compilation_handler, name); fc[dirname]=this; diff --git a/src/modules/system/nt.c b/src/modules/system/nt.c index 4db89c0..13fae90 100644 --- a/src/modules/system/nt.c +++ b/src/modules/system/nt.c @@ -55,6 +55,9 @@ #include <NewAPIs.h> #endif +/* CJA hack: MinGW fix per http://sourceforge.net/p/mingw/bugs/1089/ */ +typedef ITEMIDLIST *PIDLIST_ABSOLUTE; + #include "program.h" #include "stralloc.h" #include "threads.h" -- 1.7.10.4