if_mzscheme does not work.

187 views
Skip to first unread message

Yukihiro Nakadaira

unread,
Jan 6, 2016, 4:06:02 AM1/6/16
to vim...@googlegroups.com
if_mzscheme does not work.  I wrote patch for it.  Please check the attached
patch.

Linux & Windows:
  Fix startup_mzscheme() to initialize collects and config path properly.

Linux:
  Fix configure script for build error.

Windows:
  Fix make_mvc.mak for build error.
  Use scheme_register_tls_space() for 64bit Windows (racket provides it for 64bit from version 6.3).
  Enable DYNAMIC_MZSCHEME with precise GC version of racket which is the binary
distributed by racket-lang.org.

I tested racket-6.3 64bit, racket-6.3 32bit, racket-5.1.2 64bit and racket 5.0 32bit in Windows10 64bit. And racket-6.3, racket-5.3.6 in Ubuntu 15.04 64bit.

--
Yukihiro Nakadaira - yukihiro....@gmail.com
if_mzscheme.diff

tux.

unread,
Jan 6, 2016, 2:03:59 PM1/6/16
to Yukihiro Nakadaira
Still not working on Windows:

> raco.exe: Unrecognized command: ctool
>
> Usage: raco <command> <option> ... <arg> ...

Christian Brabandt

unread,
Jan 6, 2016, 2:08:54 PM1/6/16
to Yukihiro Nakadaira
On Mi, 06 Jan 2016, tux. wrote:

> Still not working on Windows:
>
> > raco.exe: Unrecognized command: ctool

Is this a self-compiled racket?

I noticed that same when trying to install a self-compiled racket (need
to self-compile to enable dynamic linking into vim) and had the same
issue. I believe you needed to do something like
raco pkg install main-distribution
or
raco pkg install racket-lib

(i don't know, what package is exactly needed for ctool, and compiling
main-distribution took a while).

Best,
Christian
--
Wie man sein Kind nicht nennen sollte:
T. Lefon

tux.

unread,
Jan 6, 2016, 2:25:41 PM1/6/16
to Christian Brabandt
Christian Brabandt schrob am Mittwoch, 6. Januar 2016 um 20:08 Zeit:

> Is this a self-compiled racket?

Yes, but that shouldn't matter at all because (as I stated in an
earlier thread on this mailing list that has completely been ignored
by everyone...) "raco ctool" has been removed from Racket 5.2 (!) in
2011 and the official Racket docs recommend to stop using it at all.


Christian Brabandt

unread,
Jan 6, 2016, 2:47:47 PM1/6/16
to Christian Brabandt
Hi tux.!

On Mi, 06 Jan 2016, tux. wrote:

> Christian Brabandt schrob am Mittwoch, 6. Januar 2016 um 20:08 Zeit:
>
> > Is this a self-compiled racket?
>
> Yes, but that shouldn't matter at all because (as I stated in an
> earlier thread on this mailing list that has completely been ignored
> by everyone...)

probably because nobody did know how to fix it?

> "raco ctool" has been removed from Racket 5.2 (!) in
> 2011 and the official Racket docs recommend to stop using it at all.

Where does it say so?

Well, if one uses the binary distribution, it is still available and it
still seems to work. But anyhow, do you happen to know, what should be
used instead?

Best,
Christian
--
Die Natur verstummt auf der Folter; ihre treue Antwort auf
redliche Frage ist: Ja! Ja! Nein! Nein! Alles Übrige ist vom Übel.
-- Goethe, Maximen und Reflektionen, Nr. 992

tux.

unread,
Jan 6, 2016, 2:57:58 PM1/6/16
to Christian Brabandt
Christian Brabandt schrob am Mittwoch, 6. Januar 2016 um 20:47 Zeit:

> Where does it say so?

http://download.racket-lang.org/v5.2.html

"The Racket-to-C compiler (as accessed via `raco ctool' or `mzc') has
been removed; Racket's JIT has long provided better performance, and
the FFI provides better access to C libraries."

> Well, if one uses the binary distribution, it is still available and
> it still seems to work. But anyhow, do you happen to know, what
> should be used instead?

Obviously, Racket's JIT or the FFI. :-)

Bram Moolenaar

unread,
Jan 6, 2016, 3:08:40 PM1/6/16
to Yukihiro Nakadaira, vim...@googlegroups.com
Unfortunately it still doesn't work for me, Ubuntu 15.10 with racket
6.2-2. It didn't work before, thus this change doesn't break it, but it
also doesn't make it work.

Configure output:

|| checking --enable-mzschemeinterp argument... yes
|| checking --with-plthome argument... "no"
|| checking PLTHOME environment var... not set
|| checking for mzscheme... /usr/bin/mzscheme
|| checking MzScheme install prefix... /usr
|| checking for racket include directory... /usr/include/racket
|| checking for racket lib directory... /usr/lib/racket
|| checking if racket requires -pthread... yes
|| checking for racket config directory... /etc/racket
|| checking for racket collects directory... /usr/share/racket/
|| checking for mzscheme_base.c... needed
|| checking for ffi_type_void in -lffi... yes
|| checking if compile and link flags for MzScheme are sane... no: MZSCHEME DISABLED

Log:

configure:5534: checking if compile and link flags for MzScheme are sane
configure:5551: gcc -o conftest -g -Wall -Wextra -Wmissing-prototypes -Wunreachable-code -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1 -pthread -DMZSCHEME_CONFIGDIR='"/etc/racket"' -DINCLUDE_MZSCHEME_BASE -I/usr/include/racket -DMZSCHEME_COLLECTS='"/usr/share/racket/collects"' -L. -Wl,-Bsymbolic-functions -Wl,-z,relro -L/build/ruby2.1-_3OTYb/ruby2.1-2.1.5/debian/lib -fstack-protector -rdynamic -Wl,-export-dynamic -Wl,-E -L/usr/local/lib -Wl,--as-needed conftest.c -L/usr/lib/racket -lmzscheme -lmzgc -Wl,-rpath -Wl,/usr/lib/racket -pthread -lffi >&5
/usr/bin/ld: cannot find -lmzscheme
/usr/bin/ld: cannot find -lmzgc
collect2: error: ld returned 1 exit status

Can this also be made to work?
Or am I missing a package?


--
How do you know when you have run out of invisible ink?

/// Bram Moolenaar -- Br...@Moolenaar.net -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ an exciting new programming language -- http://www.Zimbu.org ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///

James McCoy

unread,
Jan 6, 2016, 8:15:06 PM1/6/16
to vim...@googlegroups.com
This should be looking for -lracket3m, not -lmzscheme & -lmzgc, as
described here: http://docs.racket-lang.org/inside/embedding.html#(part._3m_.Embedding)

That being said, the Debian (and therefore Ubuntu) packaging only
provides a static library. That may be what's tripping up the
detection.

Cheers,
--
James
GPG Key: 4096R/331BA3DB 2011-12-05 James McCoy <jame...@jamessan.com>

Yukihiro Nakadaira

unread,
Jan 7, 2016, 5:36:30 AM1/7/16
to Bram Moolenaar, vim...@googlegroups.com
I used self compiled binary and installer from racket-lang.org.

Ubuntu's racket package does not have library for embedding.  I thought that
/usr/lib/racket/mzdyn3m.o is that.  But it isn't.

I updated patch.

Make_mvc.mak:
  Quote $(MZSCHEME) variable properly.
  Do not use raco when it is not found.

if_mzsch.c:
  Add error handling for scheme_namespace_require() to avoid abort when
  scheme/base module is not found.

if_mzsch.c works without mzscheme_base.c.  So we can remove stuff related to it.

I added error message for when scheme/base module could not be loaded.
if_mzsch.c:1273: "Exxx: Sorry, this command is disabled, the MzScheme's scheme/base module could not be loaded."
Please number it.

--
Yukihiro Nakadaira - yukihiro....@gmail.com
if_mzscheme2.diff

Yukihiro Nakadaira

unread,
Jan 7, 2016, 5:42:38 AM1/7/16
to vim...@googlegroups.com
I updated patch for problem what you described (quote $(MZSCHEME) and don't use
raco when it is not found).  I posted it in the other mail.

I don't know why raco is not exist but I think raco ctool is not removed.  In
the documentation only "9.3 Compiling to Native Code via C" section was removed.

Tux-

unread,
Jan 7, 2016, 6:17:03 AM1/7/16
to vim...@googlegroups.com
raco is still there, but raco ctool was removed in 5.2.

Yukihiro Nakadaira

unread,
Jan 7, 2016, 6:44:15 AM1/7/16
to vim...@googlegroups.com, Bram Moolenaar
On Thu, Jan 7, 2016 at 8:16 PM, Tux- <ze...@tuxproject.de> wrote:
raco is still there, but raco ctool was removed in 5.2.

Sorry, I mistook.  Then, let's remove it simply.

Bram, I updated patch again.

Make_mvc.mak:
  Remove mzscheme_base.c related stuff.

--
Yukihiro Nakadaira - yukihiro....@gmail.com
if_mzscheme3.diff

Yukihiro Nakadaira

unread,
Jan 7, 2016, 7:55:25 AM1/7/16
to vim...@googlegroups.com
On Thu, Jan 7, 2016 at 7:36 PM, Yukihiro Nakadaira <yukihiro....@gmail.com> wrote:
Ubuntu's racket package does not have library for embedding.  I thought that
/usr/lib/racket/mzdyn3m.o is that.  But it isn't.

I searched Ubuntu package

14.04 trusty racket have /usr/lib/libracket3m.a
15.04 vivid racket don't have it
15.10 wily racket don't have it
16.04 xenial racket have it

So if_mzscheme will work in the next release of Ubuntu.

Yukihiro Nakadaira

unread,
Jan 7, 2016, 8:31:20 AM1/7/16
to vim...@googlegroups.com
I tried Minimal Racket installer and actually its raco.exe doesn't have ctool
subcommand.  So it seems related to build option.

With Minimal Racket, if_mzscheme doesn't work because Minimal Racket doesn't
have "scheme/base" module.  Replacing it with "racket/base" module will work.
I'm not sure if it doesn't have side effect.

With this change, test70 still fails because test70 uses r5rs module and Minimal
Racket doesn't have it.

for if_mzscheme3.diff
diff --git a/src/if_mzsch.c b/src/if_mzsch.c
index da23353..1cc6807 100644
--- a/src/if_mzsch.c
+++ b/src/if_mzsch.c
@@ -1021,7 +1021,7 @@ mzscheme_env_main(Scheme_Env *env, int argc, char **argv)
     static Scheme_Object*
 load_base_module(void *data)
 {
-    scheme_namespace_require(scheme_intern_symbol("scheme/base"));
+    scheme_namespace_require(scheme_intern_symbol("racket/base"));
     return scheme_null;
 }
 
@@ -1270,7 +1270,7 @@ mzscheme_init(void)
 #endif
  if (load_base_module_failed || startup_mzscheme())
  {
-     EMSG(_("Exxx: Sorry, this command is disabled, the MzScheme's scheme/base module could not be loaded."));
+     EMSG(_("Exxx: Sorry, this command is disabled, the MzScheme's racket/base module could not be loaded."));
      return -1;
  }
  initialized = TRUE;

--
Yukihiro Nakadaira - yukihiro....@gmail.com

Yukihiro Nakadaira

unread,
Jan 7, 2016, 9:02:36 AM1/7/16
to vim...@googlegroups.com
On Thu, Jan 7, 2016 at 10:31 PM, Yukihiro Nakadaira <yukihiro....@gmail.com> wrote:
I tried Minimal Racket installer and actually its raco.exe doesn't have ctool
subcommand.  So it seems related to build option.

With Minimal Racket, if_mzscheme doesn't work because Minimal Racket doesn't
have "scheme/base" module.  Replacing it with "racket/base" module will work.
I'm not sure if it doesn't have side effect.

With this change, test70 still fails because test70 uses r5rs module and Minimal
Racket doesn't have it.

This was solved by
raco.exe pkg install scheme-lib
raco.exe pkg install r5rs-lib

Sergey Khorev

unread,
Jan 9, 2016, 1:32:09 PM1/9/16
to vim...@googlegroups.com
Yukihiro-san,

I gave up on catching up Racket updates in if_mzscheme so the interface has been broken for some time now. Your patch seems to finally fix the issues I encounterred (tested on Arch successfully), many thanks for that.


With this change, test70 still fails because test70 uses r5rs module and Minimal
Racket doesn't have it.

This was solved by
raco.exe pkg install scheme-lib
raco.exe pkg install r5rs-lib


Don't you think this should be included in the documentation?



Yukihiro Nakadaira

unread,
Jan 10, 2016, 3:51:27 AM1/10/16
to vim...@googlegroups.com, Bram Moolenaar
Thank you for your suggestion.  I have added documentation for it.

```
8. MzScheme setup        *mzscheme-setup*

Vim requires "scheme/base" module for if_mzsch core, "r5rs" module for test
and "raco ctool" command for building Vim.  If MzScheme did not have them, you
can install them with MzScheme's raco command:

  raco pkg install scheme-lib       # scheme/base module
  raco pkg install r5rs-lib         # r5rs module
  raco pkg install cext-lib         # raco ctool command
```
if_mzscheme4.diff

Christian Brabandt

unread,
Jan 11, 2016, 6:52:05 AM1/11/16
to vim...@googlegroups.com
Hi Yukihiro!
Thanks for that. Is it possible, to build scheme with DYNAMIC_SCHEME=yes
on Windows? I tried it, but it failed for me. Not sure if it still
possible at all.


Best,
Christian
--
Lieber hochschwanger, als niederträchtig.

Yukihiro Nakadaira

unread,
Jan 11, 2016, 7:24:37 AM1/11/16
to vim...@googlegroups.com
Yes, DYNAMIC_MZSCHEME should work.  If Racket is installed in C:\Racket63,
build command is

nmake -f Make_mvc.mak MZSCHEME=C:\Racket63 MZSCHEME_VER=3m_9z0ds0 DYNAMIC_MZSCHEME=yes

MZSCHEME is install path.
MZSCHEME_VER is version number of C:\Racket63\lib\libracketXXXXXX.dll.

--
Yukihiro Nakadaira - yukihiro....@gmail.com

Christian Brabandt

unread,
Jan 11, 2016, 7:37:07 AM1/11/16
to vim...@googlegroups.com
Hi Yukihiro!
Tried that. I see those errors:
cl -c /W3 /nologo -I. -Iproto -DHAVE_PATHDEF -DWIN32 -DFEAT_CSCOPE -DFEAT_NETBEANS_INTG -DFEAT_XPM_W32 -DWINVER=0x0400 -D_WIN32_WINNT=0x0400 /Fo.\ObjGXZi386/ /Ox /GL -DNDEBUG /Zl /MT -DFEAT_GUI_W32 -DFEAT_DIRECTX -DDYNAMIC_DIRECTX -DDYNAMIC_ICONV -DDYNAMIC_GETTEXT -DFEAT_MZSCHEME -I C:\racket63\\include -DINCLUDE_MZSCHEME_BASE -DDYNAMIC_MZSCHEME -DDYNAMIC_MZSCH_DLL=\"libracket3m_9z0ds0.dll\" -DDYNAMIC_MZGC_DLL=\"libmzgc3m_9z0ds0.dll\" -DFEAT_huge /Fd.\ObjGXZi386/ /Zi if_mzsch.c -DMZSCHEME_COLLECTS=\"C:\\racket63\\\\collects\"
if_mzsch.c
if_mzsch.c(371) : warning C4005: 'scheme_current_thread' : macro redefinition
c:\racket63\include\schthread.h(645) : see previous definition of 'scheme_current_thread'
if_mzsch.c(871) : fatal error C1189: #error : Precise GC v.4+ or Racket with futures/places do not support dynamic MzScheme
NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\BIN\cl.EXE"' : return code '0x2'
Stop.

And even after uncommenting the Precise GC error I see link errors:
if_mzsch.obj : error LNK2001: unresolved external symbol __imp__scheme_register_embedded_load
if_mzsch.obj : error LNK2001: unresolved external symbol __imp__scheme_register_tls_space
if_mzsch.obj : error LNK2001: unresolved external symbol __imp__scheme_embedded_load
if_mzsch.obj : error LNK2001: unresolved external symbol __imp__scheme_main_setup
gvim.exe : fatal error LNK1120: 4 unresolved externals
NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\BIN\link.EXE"' : return code '0x460'
Stop.



Best,
Christian
--
Die Mutter von Max hat drei Söhne:
Bim, Bam und ...
und? ...
Max.

Yukihiro Nakadaira

unread,
Jan 11, 2016, 7:46:31 AM1/11/16
to vim...@googlegroups.com
It seems that my patch is not applied correctly.
Please try latest patch if_mzscheme4.diff in this post
Yukihiro Nakadaira - yukihiro....@gmail.com

Christian Brabandt

unread,
Jan 11, 2016, 8:01:55 AM1/11/16
to vim...@googlegroups.com
Hi Yukihiro!

Thanks. I missed that patch. After applying, it worked as expected.
Thanks!

Best,
Christian
Mit freundlichen Grüßen
Christian
--
Tote Hühner in den Ställen, im Sommer gibt es Salmonellen.

Ken Takata

unread,
Jan 13, 2016, 7:39:56 AM1/13/16
to vim_dev, Br...@moolenaar.net
Hi Yukihiro,
I wrote an additional patch for your if_mzscheme4.diff:
https://bitbucket.org/k_takata/vim-ktakata-mq/src/5b5a73a34c71df5e0ecf5234d698570dae3f40e8/mzscheme_collects_and_mingw.patch?fileviewer=file-view-default

This adds a new setting MZSCHEME_COLLECTS so that the collects directory (used
at runtime) can be set separately form the MZSCHEME directory (used at compile
time).
This also adds changes for MinGW/Cygwin.

I think it's also better to update src/INSTALLpc.txt. I'm preparing it.

Regards,
Ken Takata

Yukihiro Nakadaira

unread,
Jan 13, 2016, 11:01:28 PM1/13/16
to vim...@googlegroups.com
Yukihiro Nakadaira - yukihiro....@gmail.com
if_mzscheme5.diff

Ken Takata

unread,
Jan 14, 2016, 10:10:27 AM1/14/16
to vim_dev
Hi,

2016/1/14 Thu 13:01:28 UTC+9 Yukihiro Nakadaira wrote:
> Thank you.  I merged
> https://bitbucket.org/k_takata/vim-ktakata-mq/raw/d2b34c2918f89b9fb6caf6043ea2ab6622632d11/mzscheme_collects_and_mingw.patch
> https://bitbucket.org/k_takata/vim-ktakata-mq/raw/d2b34c2918f89b9fb6caf6043ea2ab6622632d11/mzscheme_base_module.patch
> and created merged patch if_mzscheme5.diff.
>
> if_mzscheme now uses racket/base module and falls back to scheme/base if it doesn't exist.

I wrote a patch for src/INSTALLpc.txt:
https://bitbucket.org/k_takata/vim-ktakata-mq/src/23061ff5facacdf82768e6516bd75c42c4917a37/mzscheme_installpc.patch?fileviewer=file-view-default

Please review.


Regards,
Ken Takata

Yukihiro Nakadaira

unread,
Jan 16, 2016, 2:01:35 AM1/16/16
to vim...@googlegroups.com, Bram Moolenaar
Thank you.  I merged it in my patch.

And I updated patch for crash in appveyor test.  I guess Racket is using
thread internally and it is broken by unloading the dll when exiting.  So I
changed if_zscheme to not unload the dll.

The latest patch if_mzscheme6.diff is attached.

--
Yukihiro Nakadaira - yukihiro....@gmail.com
if_mzscheme6.diff

Bram Moolenaar

unread,
Jan 16, 2016, 7:42:13 AM1/16/16
to Yukihiro Nakadaira, vim...@googlegroups.com
Thanks. Is this ready to be included now?

--
CRONE: Who sent you?
ARTHUR: The Knights Who Say GNU!
CRONE: Aaaagh! (she looks around in rear) No! We have no licenses here.
"Monty Python and the Holy editor wars" PYTHON (MONTY) SOFTWARE LTD

Yukihiro Nakadaira

unread,
Jan 16, 2016, 8:02:21 AM1/16/16
to Bram Moolenaar, vim...@googlegroups.com
On Sat, Jan 16, 2016 at 9:42 PM, Bram Moolenaar <Br...@moolenaar.net> wrote:

Yukihiro Nakadaira wrote:

> On Fri, Jan 15, 2016 at 12:10 AM, Ken Takata <ktakat...@gmail.com> wrote:
>
> > Hi,
> >
> > 2016/1/14 Thu 13:01:28 UTC+9 Yukihiro Nakadaira wrote:
> > > Thank you.  I merged
> > >
> > https://bitbucket.org/k_takata/vim-ktakata-mq/raw/d2b34c2918f89b9fb6caf6043ea2ab6622632d11/mzscheme_collects_and_mingw.patch
> > >
> > https://bitbucket.org/k_takata/vim-ktakata-mq/raw/d2b34c2918f89b9fb6caf6043ea2ab6622632d11/mzscheme_base_module.patch
> > > and created merged patch if_mzscheme5.diff.
> > >
> > > if_mzscheme now uses racket/base module and falls back to scheme/base if
> > it doesn't exist.
> >
> > I wrote a patch for src/INSTALLpc.txt:
> >
> > https://bitbucket.org/k_takata/vim-ktakata-mq/src/23061ff5facacdf82768e6516bd75c42c4917a37/mzscheme_installpc.patch?fileviewer=file-view-default
> >
> > Please review.
> >
>
> Thank you.  I merged it in my patch.
>
> And I updated patch for crash in appveyor test.  I guess Racket is using
> thread internally and it is broken by unloading the dll when exiting.  So I
> changed if_zscheme to not unload the dll.
>
> The latest patch if_mzscheme6.diff is attached.

Thanks.  Is this ready to be included now?

Yes, it is. 

--
Yukihiro Nakadaira - yukihiro....@gmail.com
Reply all
Reply to author
Forward
0 new messages