Author Topic: How to compile. Also, update your compiling environment.  (Read 67742 times)

Offline GammaLeak

  • Planewalker
  • *****
  • Posts: 23
Re: How to compile. Also, update your compiling environment.
« Reply #25 on: March 05, 2012, 06:28:48 AM »
That's what I originally said. ;-)

(our executables are PPC only, and shouldn't even run on Mac OS X 10.7 or later, that I know of)

Right you are! Sorry about that!  :)

Offline Wisp

  • Moderator
  • Planewalker
  • *****
  • Posts: 1176
Re: How to compile. Also, update your compiling environment.
« Reply #26 on: December 14, 2012, 09:09:21 AM »
Updated list of packages for building WeiDU on Debian:
Code: [Select]
build-essential hevea ocaml ocaml-native-compilers texlive tcl8.5-dev tk8.5-dev unzip upx-ucl zip

I also tossed together a zip with roy's modified Elkhound source, Bigg's win32 exe and a 32-bit Linux executable, available here.

Offline Wisp

  • Moderator
  • Planewalker
  • *****
  • Posts: 1176
Re: How to compile. Also, update your compiling environment.
« Reply #27 on: June 05, 2013, 02:50:19 PM »
I've updated the instructions for how to compile (in the first post). Interested parties are encouraged to comment and ask questions.

Offline Mike1072

  • Planewalker
  • *****
  • Posts: 298
  • Gender: Male
Re: How to compile. Also, update your compiling environment.
« Reply #28 on: June 05, 2013, 06:51:50 PM »
Thanks!  I had wanted to get my build environment working again.

Right now, it's crapping out partway through the make.

Before starting this, I updated my Cygwin and grabbed fresh installations of OCaml and Elkhound.

These are in my Windows path:
Code: [Select]
C:\elkhound\win32\x86-cygwin;
C:\ocaml\bin;

Normally the make gets this far:
Code: [Select]
Generating dependency information for src/case_ins.ml
Generating dependency information for batteries-lite/batteriesInit.ml
Generating dependency information for batteries-lite/batList.ml
/cygdrive/c/elkhound/win32/x86-cygwin/elkhound -ocaml src/trealparserin.gr
process_begin: CreateProcess(NULL, /cygdrive/c/elkhound/win32/x86-cygwin/elkhound -ocaml src/trealparserin.gr, ...) failed.
make (e=2): The system cannot find the file specified.

And then dies with:
Code: [Select]
Compiling interface batteries-lite/batList.mli
Compiling batteries-lite/batList.ml to native code
/usr/bin/sh: C:ocamlbin/ocamlopt.opt: No such file or directory
cp: cannot stat `batteries-lite/batList.o': No such file or directory
mingw32-make: *** [obj/x86_WIN32/batList.cmx] Error 1

If I switch to forward slashes in the Configuration file (e.g. C:/ocaml/bin), it doesn't die until a little later:
Code: [Select]
Compiling src/tpstate.ml to native code
Compiling src/tphelp.ml to native code
mingw32-make: *** No rule to make target `obj/x86_WIN32/trealparserin.ml', needed by `obj/x86_WIN32/trealparser.ml'.  Stop.
« Last Edit: June 05, 2013, 06:57:28 PM by Mike1072 »

Offline Mike1072

  • Planewalker
  • *****
  • Posts: 298
  • Gender: Male
Re: How to compile. Also, update your compiling environment.
« Reply #29 on: June 05, 2013, 06:55:42 PM »
Even earlier on there is a similar error:
Code: [Select]
C:\\ocaml\\bin/ocamlyacc  src/iwgparser.mly
Generating dependency information for obj/x86_WIN32/iwgparser.mli
C:\\ocaml\\bin/ocamlyacc  src/toldparser.mly
17 shift/reduce conflicts.
Generating dependency information for obj/x86_WIN32/toldparser.mli
ocaml str.cma unix.cma -w p scripts/make_gr.ml
/cygdrive/c/elkhound/win32/x86-cygwin/elkhound -ocaml src/trealparserin.gr
C:\\ocaml\\bin/ocamlyacc  src/dparser.mly
process_begin: CreateProcess(NULL, /cygdrive/c/elkhound/win32/x86-cygwin/elkhound -ocaml src/trealparserin.gr, ...) failed.
make (e=2): The system cannot find the file specified.

Offline Wisp

  • Moderator
  • Planewalker
  • *****
  • Posts: 1176
Re: How to compile. Also, update your compiling environment.
« Reply #30 on: June 06, 2013, 09:44:41 AM »
]Hmm, are you able to invoke Elkhound on the Cygwin terminal manually (no arguments, just to see if it responds)?

Also, you are using mingw32-make, while I use plain make. I suppose it is possible they differ in some relevant way (wrt. how they handle paths and backslashes therein). You may want to try switching.
Edit: Actually, it probably is the different make ports. If the mingw port does not understand Cygwin paths (which seems reasonable), that would account for Elkhound. And if the mingw port does not escape backslashes (like Cygwin's port does), that would account for the behaviour you see with OCaml.
Edit2: You could also try placing Elkhound inside the Cygwin environment (c:\cygwin\bin would not be inappropriate) and go with forward slashes in Configuration and see if that helps. (Before you try altering your Cygwin package selection, I mean.)
« Last Edit: June 06, 2013, 10:39:00 AM by Wisp »

Offline Mike1072

  • Planewalker
  • *****
  • Posts: 298
  • Gender: Male
Re: How to compile. Also, update your compiling environment.
« Reply #31 on: June 06, 2013, 11:57:51 PM »
Also, you are using mingw32-make, while I use plain make.
That was the problem.  I don't remember what possessed me to replace my make.

Offline AL|EN

  • Planewalker
  • *****
  • Posts: 390
  • Gender: Male
Re: How to compile. Also, update your compiling environment.
« Reply #32 on: March 14, 2017, 12:06:55 PM »
1. Cannot download OCaml 4.00.1 Cygwin-based native Win32 port, can I use latest version?
« Last Edit: March 14, 2017, 01:46:26 PM by AL|EN »
Project Infinity public BETA - mod manager for Infinity Engine games
Modder's Guide to Github - you cannot have progress without committing changes

Offline Wisp

  • Moderator
  • Planewalker
  • *****
  • Posts: 1176
Re: How to compile. Also, update your compiling environment.
« Reply #33 on: March 14, 2017, 01:35:08 PM »
I haven't tested it, but this (available from the link "Official OCaml distribution" on ocaml.org) sounds about right. I don't know if it installs mingw itself. If not, you'll have to chase it down within the Cygwin environment. Without porting, WeiDU needs a *nix environment (i.e., Cygwin), Ocaml and Cygwin-hosted mingw-gcc. I'll try to swing an updated description by the weekend.
« Last Edit: March 14, 2017, 04:02:53 PM by Wisp »

Offline AL|EN

  • Planewalker
  • *****
  • Posts: 390
  • Gender: Male
Re: How to compile. Also, update your compiling environment.
« Reply #34 on: March 14, 2017, 01:46:37 PM »
2. After setup, trying to compiling using Windows, I get this error:
Code: [Select]
obj/.depend/idsparser.d:2: *** missing separator. StopGoogle points to http://stackoverflow.com/questions/23927212/makefile2-missing-separator-stop but I can't fix it because there are more than 80 files inside obj/.depend and when I fix one, it's get recreated with nonworking version when I type make weidu again
3. After setup, trying to compiling using debian 32-bit, I get this error when trying to execute weidu.exe at Windows 10 64-bit:
Code: [Select]
Version setup-weidu.exe is not compatible with the version of Windows running. Check the information on the operating system on your computer, then contact the software publisher.
Project Infinity public BETA - mod manager for Infinity Engine games
Modder's Guide to Github - you cannot have progress without committing changes

Offline Wisp

  • Moderator
  • Planewalker
  • *****
  • Posts: 1176
Re: How to compile. Also, update your compiling environment.
« Reply #35 on: March 14, 2017, 03:41:23 PM »
2. After setup, trying to compiling using Windows, I get this error:
Code: [Select]
obj/.depend/idsparser.d:2: *** missing separator. StopGoogle points to http://stackoverflow.com/questions/23927212/makefile2-missing-separator-stop but I can't fix it because there are more than 80 files inside obj/.depend and when I fix one, it's get recreated with nonworking version when I type make weidu again
What's it like originally and what do you do to fix it? What make are you using?

Quote
3. After setup, trying to compiling using debian 32-bit, I get this error when trying to execute weidu.exe at Windows 10 64-bit:
Code: [Select]
Version setup-weidu.exe is not compatible with the version of Windows running. Check the information on the operating system on your computer, then contact the software publisher.
If you are trying to run a WeiDU executable built on Debian on Windows, it won't work. Regardless of the EXE extension, it's an ELF binary built for *nix. OCaml does not do cross-compilation at all.
« Last Edit: March 14, 2017, 04:14:08 PM by Wisp »

Offline AL|EN

  • Planewalker
  • *****
  • Posts: 390
  • Gender: Male
Re: How to compile. Also, update your compiling environment.
« Reply #36 on: March 14, 2017, 04:10:24 PM »
Quote
What's it like originally and what do you do to fix it? What make are you using?
I'm using 'make' from cgwin acording to:
Quote
Install the following Cygwin packages and their dependencies:
Archive: zip
Devel: binutils, git, make
Net: openssh
Utils: upx
The error message is caused by C:\cygwin\home\V3\weidu\obj\.depend\idsparser.d file content:
Code: [Select]
  obj/x86_WIN32/idsparser.cmo :  obj/x86_WIN32/util.cmx  obj/x86_WIN32/parsing.cmx  obj/x86_WIN32/ids.cmx \obj/x86_WIN32/
     obj/x86_WIN32/batteriesInit.cmx   obj/x86_WIN32/idsparser.cmi
  obj/x86_WIN32/idsparser.cmx :  obj/x86_WIN32/util.cmx  obj/x86_WIN32/parsing.cmx  obj/x86_WIN32/ids.cmx \obj/x86_WIN32/
     obj/x86_WIN32/batteriesInit.cmx   obj/x86_WIN32/idsparser.cmi
according to http://stackoverflow.com/questions/23927212/makefile2-missing-separator-stop, make expect real tabs, not spaces: EditorPicAllCharactersVisible
Code: [Select]

obj/x86_WIN32/idsparser.cmo :  obj/x86_WIN32/util.cmx  obj/x86_WIN32/parsing.cmx  obj/x86_WIN32/ids.cmx \obj/x86_WIN32/
   obj/x86_WIN32/batteriesInit.cmx   obj/x86_WIN32/idsparser.cmi
obj/x86_WIN32/idsparser.cmx :  obj/x86_WIN32/util.cmx  obj/x86_WIN32/parsing.cmx  obj/x86_WIN32/ids.cmx \obj/x86_WIN32/
   obj/x86_WIN32/batteriesInit.cmx   obj/x86_WIN32/idsparser.cmi


after replacing spaces to tabs inside idsparser.d file, I no longer getting error message for this file but I get for next one:
Code: [Select]
obj/.depend/bcsparser.d:2: *** missing separator.  Stop
and even if i fix all of those files, after executing 'make weidu' the first file idsparser.d file gets recreated again with spaces and I get the same error.
« Last Edit: March 14, 2017, 04:12:37 PM by AL|EN »
Project Infinity public BETA - mod manager for Infinity Engine games
Modder's Guide to Github - you cannot have progress without committing changes

Offline Wisp

  • Moderator
  • Planewalker
  • *****
  • Posts: 1176
Re: How to compile. Also, update your compiling environment.
« Reply #37 on: March 14, 2017, 05:14:23 PM »
What version of make? I am unable to reproduce this on my machine (but this is with an older version of Cygwin, so not entirely comparable) with the most recent OCaml. Are you using 32-bit or 64-bit OCaml? FWIW, the dependency files are generated with spaces on both my Linux (make 4.1) and Windows (make 4.2.1) systems with no complaints from make.

I'll try with a not-old version of Cygwin some time during the week.
« Last Edit: March 14, 2017, 05:28:28 PM by Wisp »

Offline AL|EN

  • Planewalker
  • *****
  • Posts: 390
  • Gender: Male
Re: How to compile. Also, update your compiling environment.
« Reply #38 on: March 14, 2017, 06:59:40 PM »

Code: [Select]
$ make --version
GNU Make 4.2.1
Ten program został zbudowany dla systemu i686-pc-cygwin
Copyright (C) 1988-2016 Free Software Foundation, Inc.
Licencja GPLv3+: GNU GPL wersja 3 lub nowsza <http://gnu.org/licenses/gpl.html>
To oprogramowanie jest wolnodostępne: można je swobodnie zmieniać i rozpowszechniać.
Nie ma ŻADNEJ GWARANCJI w zakresie dopuszczalnym przez prawo.
I'm using 32-bit OCaml
Project Infinity public BETA - mod manager for Infinity Engine games
Modder's Guide to Github - you cannot have progress without committing changes

Offline Argent77

  • Planewalker
  • *****
  • Posts: 187
Re: How to compile. Also, update your compiling environment.
« Reply #39 on: March 15, 2017, 08:53:07 AM »
I can confirm that latest Cygwin installations fail to compile WeiDU with the above-mentioned error.

If it helps, a comparison between current (working) and latest package versions of my Cygwin installation: http://i.imgur.com/LRDeIkj.png
« Last Edit: March 15, 2017, 10:19:59 AM by Argent77 »

Offline Wisp

  • Moderator
  • Planewalker
  • *****
  • Posts: 1176
Re: How to compile. Also, update your compiling environment.
« Reply #40 on: March 15, 2017, 05:18:11 PM »
Upon closer inspection, the idsparser.d ALIEN posted looks whacked. The less indented lines should end with a backslash, to escape the newline, and the spurious "obj/x86_WIN32/" that comes after the backslash should not be there. So I guess this has something to do with sed, which is among the updated packages (and which is used here).

Can someone make sure they have perl installed and apply this patch and see if it helps?
Code: [Select]
diff --git a/Makefile.ocaml b/Makefile.ocaml
index f13d027..2f4a2ba 100755
--- a/Makefile.ocaml
+++ b/Makefile.ocaml
@@ -324,12 +324,12 @@ cleancaml:
 
 # If you have perl but not sed you can use this line instead. Don't you
 # wish we were using autoconf?
-#FIXDEPEND:=perl -e 'while(<>) { s%[^/\\ :]+[/\\]% %g; s%([^ :\\\n]+)%\$$(OBJDIR)/$$1%g; print $$_;}'
-ifdef WINDIR
-  FIXDEPEND:=sed -e '{ s%[^/\\ :][^/\\ :]*[/\\]% %g; s%\([^ :\\\n][^ :\\\n]*\)%$(OBJDIR)/\1%g; }' # -e 's.obj/x86_WIN32/[^o]*$$..g'
-else
-  FIXDEPEND:=sed -e '{ s%[^/\\ :][^/\\ :]*[/\\]% %g; s%\([^ :\\\n][^ :\\\n]*\)%$(OBJDIR)/\1%g; }'
-endif
+FIXDEPEND:=perl -e 'while(<>) { s%[^/\\ :]+[/\\]% %g; s%([^ :\\\n]+)%\$$(OBJDIR)/$$1%g; print $$_;}'
+#ifdef WINDIR
+#  FIXDEPEND:=sed -e '{ s%[^/\\ :][^/\\ :]*[/\\]% %g; s%\([^ :\\\n][^ :\\\n]*\)%$(OBJDIR)/\1%g; }' # -e 's.obj/x86_WIN32/[^o]*$$..g'
+#else
+#  FIXDEPEND:=sed -e '{ s%[^/\\ :][^/\\ :]*[/\\]% %g; s%\([^ :\\\n][^ :\\\n]*\)%$(OBJDIR)/\1%g; }'
+#endif

You can use the -p1 option to patch to strip the a/b stuff or make the corresponding changes à la main.
« Last Edit: March 15, 2017, 05:34:23 PM by Wisp »

Offline Argent77

  • Planewalker
  • *****
  • Posts: 187
Re: How to compile. Also, update your compiling environment.
« Reply #41 on: March 15, 2017, 06:17:21 PM »
Doesn't work either. Resulting idsparser.d:
Code: [Select]
  $(OBJDIR)/idsparser.cmo :  $(OBJDIR)/util.cmx  $(OBJDIR)/parsing.cmx  $(OBJDIR)/ids.cmx \$(OBJDIR)/
     $(OBJDIR)/batteriesInit.cmx   $(OBJDIR)/idsparser.cmi
  $(OBJDIR)/idsparser.cmx :  $(OBJDIR)/util.cmx  $(OBJDIR)/parsing.cmx  $(OBJDIR)/ids.cmx \$(OBJDIR)/
     $(OBJDIR)/batteriesInit.cmx   $(OBJDIR)/idsparser.cmi

Offline Argent77

  • Planewalker
  • *****
  • Posts: 187
Re: How to compile. Also, update your compiling environment.
« Reply #42 on: March 15, 2017, 06:29:08 PM »
Update: Manually downgrading to sed-4.2.2-3 fixes the issue (for now).

To do this, start Cygwin installer (setup-x86.exe), select "Full" view and make a search for "sed". In the "New" column click on the entry repeatedly until version 4.2.2-3 is selected. Finish the installation.

Offline Wisp

  • Moderator
  • Planewalker
  • *****
  • Posts: 1176
Re: How to compile. Also, update your compiling environment.
« Reply #43 on: March 16, 2017, 01:32:16 PM »
Ok, so this is caused by something all of a sudden starting to use CRLF instead of LF. The perl issue is apparently that for whatever reason, my make and whatever make was used those 15 odd years ago when this build system was written do not escape the $(OBJDIR) variable, but Cygwin make does.

Someone kindly check if current devel works without downgrading sed.

Offline Argent77

  • Planewalker
  • *****
  • Posts: 187
Re: How to compile. Also, update your compiling environment.
« Reply #44 on: March 16, 2017, 02:16:28 PM »
Works fine now (with both sed and perl).

On an unrelated note, I made an attempt to port Windows WeiDU to 64-bit. I was able to make Elkhound 64-bit ready, but failed to compile WeiDU itself because of incomplete 64-bit Windows OCaml support. From what I read on various sites it's unlikely that official OCaml64 packages will ever be fixed for Windows, so I guess we have to make do with 32-bit WeiDU for the time being.

Offline Wisp

  • Moderator
  • Planewalker
  • *****
  • Posts: 1176
Re: How to compile. Also, update your compiling environment.
« Reply #45 on: March 16, 2017, 03:19:00 PM »
Got any patches for the elkhound stuff? No reason that can't be 64-bit even if the rest of it isn't.

Offline Argent77

  • Planewalker
  • *****
  • Posts: 187
Re: How to compile. Also, update your compiling environment.
« Reply #46 on: March 16, 2017, 04:46:46 PM »
Here you go:
Code: [Select]
diff -Naur elkhound-orig/src/ast/exampletest.cc elkhound/src/ast/exampletest.cc
--- elkhound-orig/src/ast/exampletest.cc 2017-01-27 11:23:36.000000000 +0100
+++ elkhound/src/ast/exampletest.cc 2017-03-16 21:54:24.000000000 +0100
@@ -29,15 +29,15 @@
   Super *s4 = new Sub2(4, 104);
 
   // **** render it into xml
-  cout << "**************** first" << endl;
+  std::cout << "**************** first" << std::endl;
   nl0->xmlPrint(cout,0);
-  cout << "**************** second" << endl;
+  std::cout << "**************** second" << std::endl;
   al0->xmlPrint(cout,0);
-  cout << "**************** third" << endl;
+  std::cout << "**************** third" << std::endl;
   s3->xmlPrint(cout,0);
-  cout << "**************** fourth" << endl;
+  std::cout << "**************** fourth" << std::endl;
   s4->xmlPrint(cout,0);
-  cout << "**************** done" << endl;
+  std::cout << "**************** done" << std::endl;
 
   return 0;
 }
diff -Naur elkhound-orig/src/ast/gramlex.cc elkhound/src/ast/gramlex.cc
--- elkhound-orig/src/ast/gramlex.cc 2017-01-27 11:23:36.000000000 +0100
+++ elkhound/src/ast/gramlex.cc 2017-03-16 21:41:24.000000000 +0100
@@ -8,6 +8,10 @@
 
 #include <fstream>       // std::cout, std::ifstream
 
+// might break earlier flex versions
+#ifndef FLEX_STD
+  #define FLEX_STD std::
+#endif // FLEX_STD
 
 // workaround for flex-2.5.31
 #ifdef FLEX_STD    // detect later versions of flex
diff -Naur elkhound-orig/src/elkhound/examples/arith/arith.cc elkhound/src/elkhound/examples/arith/arith.cc
--- elkhound-orig/src/elkhound/examples/arith/arith.cc 2017-01-27 11:23:36.000000000 +0100
+++ elkhound/src/elkhound/examples/arith/arith.cc 2017-03-16 21:46:32.000000000 +0100
@@ -59,7 +59,7 @@
 // --------------------- main ----------------------
 ArithLexer lexer;
 
-int main(int argc)
+int main(int argc, char *argv[])
 {
   // initialize lexer by grabbing first token
   lexer.nextToken(&lexer);
diff -Naur elkhound-orig/src/elkhound/examples/cexp/cexp3mrg.cc elkhound/src/elkhound/examples/cexp/cexp3mrg.cc
--- elkhound-orig/src/elkhound/examples/cexp/cexp3mrg.cc 2017-01-27 11:23:36.000000000 +0100
+++ elkhound/src/elkhound/examples/cexp/cexp3mrg.cc 2017-03-16 21:59:54.000000000 +0100
@@ -9,14 +9,14 @@
 void Exp::incRefCt()
 {
   refCt++;
-  trace("refct") << "incremented refct of " << this << " to " << refCt << endl;
+  trace("refct") << "incremented refct of " << this << " to " << refCt << std::endl;
 }
 
 void Exp::decRefCt()
 {
   xassert(refCt > 0);
   --refCt;
-  trace("refct") << "decremented refct of " << this << " to " << refCt << endl;
+  trace("refct") << "decremented refct of " << this << " to " << refCt << std::endl;
   if (refCt == 0) {
     delete this;
   }
diff -Naur elkhound-orig/src/elkhound/gramanl.cc elkhound/src/elkhound/gramanl.cc
--- elkhound-orig/src/elkhound/gramanl.cc 2017-01-27 11:23:36.000000000 +0100
+++ elkhound/src/elkhound/gramanl.cc 2017-03-16 21:49:14.000000000 +0100
@@ -2231,7 +2231,7 @@
 
 STATICDEF unsigned ItemSet::hash(ItemSet const *key)
 {
-  unsigned crc = key->kernelItemsCRC;
+  uintptr_t crc = key->kernelItemsCRC;
   return HashTable::lcprngHashFn((void*)crc);
 }
 
diff -Naur elkhound-orig/src/elkhound/ssxmain.cc elkhound/src/elkhound/ssxmain.cc
--- elkhound-orig/src/elkhound/ssxmain.cc 2017-01-27 11:23:36.000000000 +0100
+++ elkhound/src/elkhound/ssxmain.cc 2017-03-16 21:54:44.000000000 +0100
@@ -118,14 +118,14 @@
   // count # of parses
   PTreeNode *top = (PTreeNode*)treeTop;
   TreeCount numParses = top->countTrees();
-  cout << "num parses: " << numParses << endl;
+  std::cout << "num parses: " << numParses << std::endl;
 
   // print what it should be
   int n = (inputLen - 1) / 2;
-  cout << "input is x^" << inputLen
-       << "; C(" << n
-       << ") = " << C(n)
-       << endl;
+  std::cout << "input is x^" << inputLen
+            << "; C(" << n
+            << ") = " << C(n)
+            << std::endl;
 
   return 0;
 }
diff -Naur elkhound-orig/src/elkhound/triv/AdB.gr.in elkhound/src/elkhound/triv/AdB.gr.in
--- elkhound-orig/src/elkhound/triv/AdB.gr.in 2017-01-27 11:23:36.000000000 +0100
+++ elkhound/src/elkhound/triv/AdB.gr.in 2017-03-16 22:18:20.000000000 +0100
@@ -9,7 +9,7 @@
 }
 
 nonterm A {
-  fun merge(p1, p2) [ cout << "merging nonterminal A\n"; return p1; ]
+  fun merge(p1, p2) [ std::cout << "merging nonterminal A\n"; return p1; ]
 
   -> d;
   -> B;
diff -Naur elkhound-orig/src/elkhound/triv/CAdB.gr.in elkhound/src/elkhound/triv/CAdB.gr.in
--- elkhound-orig/src/elkhound/triv/CAdB.gr.in 2017-01-27 11:23:36.000000000 +0100
+++ elkhound/src/elkhound/triv/CAdB.gr.in 2017-03-16 22:18:26.000000000 +0100
@@ -20,7 +20,7 @@
 }
 
 nonterm A {
-  fun merge(p1, p2) [ cout << "merging nonterminal A\n"; return p1; ]
+  fun merge(p1, p2) [ std::cout << "merging nonterminal A\n"; return p1; ]
 
   -> d;
   -> B;
diff -Naur elkhound-orig/src/elkhound/triv/DeclExpr.gr.in elkhound/src/elkhound/triv/DeclExpr.gr.in
--- elkhound-orig/src/elkhound/triv/DeclExpr.gr.in 2017-01-27 11:23:36.000000000 +0100
+++ elkhound/src/elkhound/triv/DeclExpr.gr.in 2017-03-16 22:18:30.000000000 +0100
@@ -15,7 +15,7 @@
 }
 
 nonterm Stmt {
-  merge(L,R)  [ cout << "merging Stmt\n"; return L; ]
+  merge(L,R)  [ std::cout << "merging Stmt\n"; return L; ]
   dup(v)      [ return v; ]
   del(v)      []
 
diff -Naur elkhound-orig/src/elkhound/triv/EEb.gr.in elkhound/src/elkhound/triv/EEb.gr.in
--- elkhound-orig/src/elkhound/triv/EEb.gr.in 2017-01-27 11:23:36.000000000 +0100
+++ elkhound/src/elkhound/triv/EEb.gr.in 2017-03-16 22:18:36.000000000 +0100
@@ -9,7 +9,7 @@
 }
 
 nonterm E {
-  fun merge(L,R) [ cout << "merging E\n"; return ++count; ]
+  fun merge(L,R) [ std::cout << "merging E\n"; return ++count; ]
   fun dup(v)     [ return ++count; ]
   fun del(v)     []
 
diff -Naur elkhound-orig/src/elkhound/trivmain.cc elkhound/src/elkhound/trivmain.cc
--- elkhound-orig/src/elkhound/trivmain.cc 2017-01-27 11:23:36.000000000 +0100
+++ elkhound/src/elkhound/trivmain.cc 2017-03-16 22:02:24.000000000 +0100
@@ -156,7 +156,7 @@
   // count # of parses
   if (count) {
     TreeCount numParses = top->countTrees();
-    cout << "num parses: " << numParses << endl;
+    std::cout << "num parses: " << numParses << std::endl;
 
     TreeCount should = 0;    // meaning unknown
     if (0==strcmp(GRAMMAR_NAME, "triv/SSx.tree.bin")) {
@@ -167,17 +167,17 @@
     }
 
     if (should != 0) {
-      cout << "should be: " << should << endl;
+      std::cout << "should be: " << should << std::endl;
       if (should != numParses) {
-        cout << "MISMATCH in number of parse trees\n";
+        std::cout << "MISMATCH in number of parse trees\n";
       }
     }
   }
-  cout << "tree nodes: " << PTreeNode::allocCount
-       << endl;
+  std::cout << "tree nodes: " << PTreeNode::allocCount
+            << std::endl;
 
   if (tracingSys("printTree")) {
-    top->printTree(cout);
+    top->printTree(std::cout);
   }
 }
 
diff -Naur elkhound-orig/src/smbase/bflatten.cc elkhound/src/smbase/bflatten.cc
--- elkhound-orig/src/smbase/bflatten.cc 2017-01-27 11:23:36.000000000 +0100
+++ elkhound/src/smbase/bflatten.cc 2017-03-16 21:34:04.000000000 +0100
@@ -92,7 +92,7 @@
   }
   else /*reading*/ {
     // read the int name
-    int name = readInt();
+    intptr_t name = readInt();
 
     if (name == 0) {      // null
       xassert(nullable);
diff -Naur elkhound-orig/src/smbase/bflatten.h elkhound/src/smbase/bflatten.h
--- elkhound-orig/src/smbase/bflatten.h 2017-01-27 11:23:36.000000000 +0100
+++ elkhound/src/smbase/bflatten.h 2017-03-16 21:34:48.000000000 +0100
@@ -15,7 +15,7 @@
 
   struct OwnerMapping {
     void *ownerPtr;       // a pointer
-    int intName;          // a unique integer name
+    intptr_t intName;     // a unique integer name
   };
   OwnerHashTable<OwnerMapping> ownerTable;      // owner <-> int mapping
   int nextUniqueName;     // counter for making int names
diff -Naur elkhound-orig/src/smbase/bitarray.cc elkhound/src/smbase/bitarray.cc
--- elkhound-orig/src/smbase/bitarray.cc 2017-01-27 11:23:36.000000000 +0100
+++ elkhound/src/smbase/bitarray.cc 2017-03-16 21:55:42.000000000 +0100
@@ -231,9 +231,9 @@
   string s2 = toStringViaIter(b);
   if (s1 != s2 ||
       !s1.equals(str)) {
-    cout << "str: " << str << endl;
-    cout << " s1: " << s1 << endl;
-    cout << " s2: " << s2 << endl;
+    std::cout << "str: " << str << std::endl;
+    std::cout << " s1: " << s1 << std::endl;
+    std::cout << " s2: " << s2 << std::endl;
     xbase("testIter failed");
   }
 
@@ -249,8 +249,8 @@
 
   string cStr = toString(c);
   if (!inv.equals(cStr)) {
-    cout << " inv: " << inv << endl;
-    cout << "cStr: " << cStr << endl;
+    std::cout << " inv: " << inv << std::endl;
+    std::cout << "cStr: " << cStr << std::endl;
     xbase("test inverter failed");
   }
 }
@@ -277,18 +277,18 @@
   string iStr = toString(i);
 
   if (!uStr.equals(expectUnion)) {
-    cout << "         s1: " << s1 << endl;
-    cout << "         s2: " << s2 << endl;
-    cout << "       uStr: " << uStr << endl;
-    cout << "expectUnion: " << expectUnion << endl;
+    std::cout << "         s1: " << s1 << std::endl;
+    std::cout << "         s2: " << s2 << std::endl;
+    std::cout << "       uStr: " << uStr << std::endl;
+    std::cout << "expectUnion: " << expectUnion << std::endl;
     xbase("test union failed");
   }
 
   if (!iStr.equals(expectIntersection)) {
-    cout << "                s1: " << s1 << endl;
-    cout << "                s2: " << s2 << endl;
-    cout << "              iStr: " << iStr << endl;
-    cout << "expectIntersection: " << expectIntersection << endl;
+    std::cout << "                s1: " << s1 << std::endl;
+    std::cout << "                s2: " << s2 << std::endl;
+    std::cout << "              iStr: " << iStr << std::endl;
+    std::cout << "expectIntersection: " << expectIntersection << std::endl;
     xbase("test intersection failed");
   }
 }
@@ -300,9 +300,9 @@
   bool answer = b.anyEvenOddBitPair();
   if (answer != expect) {
     static char const *boolName[] = { "false", "true" };
-    cout << "     s: " << s << endl;
-    cout << "answer: " << boolName[answer] << endl;
-    cout << "expect: " << boolName[expect] << endl;
+    std::cout << "     s: " << s << std::endl;
+    std::cout << "answer: " << boolName[answer] << std::endl;
+    std::cout << "expect: " << boolName[expect] << std::endl;
     xbase("test anyEvenOddBitPair failed");
   }
 }
@@ -365,7 +365,7 @@
   testAnyEvenOddBitPair("11110", true);
   testAnyEvenOddBitPair("01100", false);
 
-  cout << "bitarray is ok\n";
+  std::cout << "bitarray is ok\n";
 }
 
 USUAL_MAIN
diff -Naur elkhound-orig/src/smbase/growbuf.cc elkhound/src/smbase/growbuf.cc
--- elkhound-orig/src/smbase/growbuf.cc 2017-01-27 11:23:36.000000000 +0100
+++ elkhound/src/smbase/growbuf.cc 2017-03-16 21:53:58.000000000 +0100
@@ -43,7 +43,7 @@
       xfailure("buffer contents are wrong");
     }
   }
-  cout << "growbuf ok\n";
+  std::cout << "growbuf ok\n";
 }
 
 USUAL_MAIN
diff -Naur elkhound-orig/src/smbase/srcloc.cc elkhound/src/smbase/srcloc.cc
--- elkhound-orig/src/smbase/srcloc.cc 2017-01-27 11:23:36.000000000 +0100
+++ elkhound/src/smbase/srcloc.cc 2017-03-16 22:00:08.000000000 +0100
@@ -748,7 +748,7 @@
 
     fseek(fp, 0, SEEK_END);
     len = (int)ftell(fp);
-    cout << "length of " << fname << ": " << len << endl;
+    std::cout << "length of " << fname << ": " << len << std::endl;
   }
 
   // get locations for the start and end
@@ -897,23 +897,23 @@
   int ppLine;
   for (ppLine = 1; ppLine < 10; ppLine++) {
     SourceLoc loc = mgr.encodeLineCol("srcloc.tmp", ppLine, 1);
-    cout << "ppLine " << ppLine << ": " << toString(loc) << endl;
+    std::cout << "ppLine " << ppLine << ": " << toString(loc) << std::endl;
   }
 
   // similar for last few lines
   for (ppLine = pp->numLines - 4; ppLine <= pp->numLines; ppLine++) {
     SourceLoc loc = mgr.encodeLineCol("srcloc.tmp", ppLine, 1);
-    cout << "ppLine " << ppLine << ": " << toString(loc) << endl;
+    std::cout << "ppLine " << ppLine << ": " << toString(loc) << std::endl;
   }
 
   // see how the expander line behaves
   if (!expanderLine) {
-    cout << "didn't find expander line!\n";
+    std::cout << "didn't find expander line!\n";
     exit(2);
   }
   else {
     SourceLoc loc = mgr.encodeLineCol("srcloc.tmp", expanderLine, 1);
-    cout << "expander column 1: " << toString(loc) << endl;
+    std::cout << "expander column 1: " << toString(loc) << std::endl;
 
     // in the pp file, I can advance the expander horizontally a long ways;
     // this should truncate to column 9
@@ -922,16 +922,16 @@
     char const *fname;
     int offset;
     mgr.decodeOffset(loc, fname, offset);
-    cout << "expander column 21: " << fname << ", offset " << offset << endl;
+    std::cout << "expander column 21: " << fname << ", offset " << offset << std::endl;
     xassert(0==strcmp(fname, "srcloc.test.cc"));
 
     // map that to line/col, which should show the truncation
     int line, col;
     orig->charToLineCol(offset, line, col);
-    cout << "expander column 21: " << locString(fname, line, col) << endl;
+    std::cout << "expander column 21: " << locString(fname, line, col) << std::endl;
     if (col != 9 && col != 10) {
       // 9 is for LF line endings, 10 for CRLF
-      cout << "expected column 9 or 10!\n";
+      std::cout << "expected column 9 or 10!\n";
       exit(2);
     }
   }
@@ -947,7 +947,7 @@
 
   for (int ppLine = 1; ppLine <= pp->numLines; ppLine++) {
     SourceLoc loc = mgr.encodeLineCol("srcloc.test2.cc", ppLine, 1);
-    cout << "ppLine " << ppLine << ": " << toString(loc) << endl;
+    std::cout << "ppLine " << ppLine << ": " << toString(loc) << std::endl;
   }
 }
 
@@ -956,7 +956,7 @@
 {
   xBase::logExceptions = false;
   traceAddSys("progress");
-  traceProgress() << "begin" << endl;
+  traceProgress() << "begin" << std::endl;
 
   if (argc >= 2) {
     // set maxStaticLocs low to test the warning
@@ -974,22 +974,22 @@
     testFile("srcloc.h");
   }
 
-  traceProgress() << "end" << endl;
+  traceProgress() << "end" << std::endl;
 
   // protect against degeneracy by printing the length of
   // the longest line
-  cout << "\n";
-  cout << "long line len: " << longestLen << endl;
+  std::cout << "\n";
+  std::cout << "long line len: " << longestLen << std::endl;
 
   // test the statics
-  cout << "invalid: " << toString(SL_UNKNOWN) << endl;
-  cout << "here: " << toString(HERE_SOURCELOC) << endl;
+  std::cout << "invalid: " << toString(SL_UNKNOWN) << std::endl;
+  std::cout << "here: " << toString(HERE_SOURCELOC) << std::endl;
 
-  cout << "\n";
+  std::cout << std::endl;
   testHashMap();
   testHashMap2();
 
-  cout << "srcloc is ok\n";
+  std::cout << "srcloc is ok\n";
 }
 
 ARGS_MAIN
diff -Naur elkhound-orig/src/smbase/srcloc.test.cc elkhound/src/smbase/srcloc.test.cc
--- elkhound-orig/src/smbase/srcloc.test.cc 2017-01-27 11:23:36.000000000 +0100
+++ elkhound/src/smbase/srcloc.test.cc 2017-03-16 22:00:22.000000000 +0100
@@ -757,7 +757,7 @@
 
     fseek(fp, 0, SEEK_END);
     len = (int)ftell(fp);
-    cout << "length of " << fname << ": " << len << endl;
+    std::cout << "length of " << fname << ": " << len << std::endl;
   }
 
   // get locations for the start and end
@@ -906,23 +906,23 @@
   int ppLine;
   for (ppLine = 1; ppLine < 10; ppLine++) {
     SourceLoc loc = mgr.encodeLineCol("srcloc.tmp", ppLine, 1);
-    cout << "ppLine " << ppLine << ": " << toString(loc) << endl;
+    std::cout << "ppLine " << ppLine << ": " << toString(loc) << std::endl;
   }
 
   // similar for last few lines
   for (ppLine = pp->numLines - 4; ppLine <= pp->numLines; ppLine++) {
     SourceLoc loc = mgr.encodeLineCol("srcloc.tmp", ppLine, 1);
-    cout << "ppLine " << ppLine << ": " << toString(loc) << endl;
+    std::cout << "ppLine " << ppLine << ": " << toString(loc) << std::endl;
   }
 
   // see how the expander line behaves
   if (!expanderLine) {
-    cout << "didn't find expander line!\n";
+    std::cout << "didn't find expander line!\n";
     exit(2);
   }
   else {
     SourceLoc loc = mgr.encodeLineCol("srcloc.tmp", expanderLine, 1);
-    cout << "expander column 1: " << toString(loc) << endl;
+    std::cout << "expander column 1: " << toString(loc) << std::endl;
 
     // in the pp file, I can advance the expander horizontally a long ways;
     // this should truncate to column 9
@@ -931,16 +931,16 @@
     char const *fname;
     int offset;
     mgr.decodeOffset(loc, fname, offset);
-    cout << "expander column 21: " << fname << ", offset " << offset << endl;
+    std::cout << "expander column 21: " << fname << ", offset " << offset << std::endl;
     xassert(0==strcmp(fname, "srcloc.cc"));
 
     // map that to line/col, which should show the truncation
     int line, col;
     orig->charToLineCol(offset, line, col);
-    cout << "expander column 21: " << locString(fname, line, col) << endl;
+    std::cout << "expander column 21: " << locString(fname, line, col) << std::endl;
     if (col != 9 && col != 10) {
       // 9 is for LF line endings, 10 for CRLF
-      cout << "expected column 9 or 10!\n";
+      std::cout << "expected column 9 or 10!\n";
       exit(2);
     }
   }
@@ -950,7 +950,7 @@
 void entry(int argc, char ** /*argv*/)
 {
   traceAddSys("progress");
-  traceProgress() << "begin" << endl;
+  traceProgress() << "begin" << std::endl;
 
   if (argc >= 2) {
     // set maxStaticLocs low to test the warning
@@ -968,21 +968,21 @@
     testFile("srcloc.h");
   }
 
-  traceProgress() << "end" << endl;
+  traceProgress() << "end" << std::endl;
 
   // protect against degeneracy by printing the length of
   // the longest line
-  cout << "\n";
-  cout << "long line len: " << longestLen << endl;
+  std::cout << std::endl;
+  std::cout << "long line len: " << longestLen << std::endl;
 
   // test the statics
-  cout << "invalid: " << toString(SL_UNKNOWN) << endl;
-  cout << "here: " << toString(HERE_SOURCELOC) << endl;
+  std::cout << "invalid: " << toString(SL_UNKNOWN) << std::endl;
+  std::cout << "here: " << toString(HERE_SOURCELOC) << std::endl;
 
-  cout << "\n";
+  std::cout << std::endl;
   testHashMap();
 
-  cout << "srcloc is ok\n";
+  std::cout << "srcloc is ok\n";
 }
 
 ARGS_MAIN
diff -Naur elkhound-orig/src/smbase/str.cpp elkhound/src/smbase/str.cpp
--- elkhound-orig/src/smbase/str.cpp 2017-01-27 11:23:36.000000000 +0100
+++ elkhound/src/smbase/str.cpp 2017-03-16 22:00:34.000000000 +0100
@@ -468,9 +468,9 @@
 
 void test(unsigned long val)
 {
-  //std::cout << stringb(val << " in hex: 0x" << stringBuilder::Hex(val)) << endl;
+  //std::cout << stringb(val << " in hex: 0x" << stringBuilder::Hex(val)) << std::endl;
 
-  std::cout << stringb(val << " in hex: " << SBHex(val)) << endl;
+  std::cout << stringb(val << " in hex: " << SBHex(val)) << std::endl;
 }
 
 int main()
@@ -483,7 +483,7 @@
   test(1);
 
   std::cout << "stringf: " << stringf("int=%d hex=%X str=%s char=%c float=%f",
-                                 5, 0xAA, "hi", 'f', 3.4) << endl;
+                                 5, 0xAA, "hi", 'f', 3.4) << std::endl;
 
   std::cout << "tests passed\n";
 
diff -Naur elkhound-orig/src/smbase/strhash.cc elkhound/src/smbase/strhash.cc
--- elkhound-orig/src/smbase/strhash.cc 2017-01-27 11:23:36.000000000 +0100
+++ elkhound/src/smbase/strhash.cc 2017-03-16 22:01:28.000000000 +0100
@@ -333,7 +333,7 @@
   dataArray = new StringArray(0);
   char *delim = " \t\n\r\v\f";
   std::filebuf fb;
-  fb.open (inFileName, ios::in);
+  fb.open (inFileName, std::ios::in);
   std::istream in(&fb);
   while(true) {
     stringBuilder s;
@@ -492,7 +492,7 @@
       }
     } else if (strcmp(*argv, "--file")==0) {
       if (numRandStrs) {
-        std::cout << "do not use --random and --file together" << endl;
+        std::cout << "do not use --random and --file together" << std::endl;
         usage();
         exit(1);
       }
diff -Naur elkhound-orig/src/smbase/svdict.cc elkhound/src/smbase/svdict.cc
--- elkhound-orig/src/smbase/svdict.cc 2017-01-27 11:23:36.000000000 +0100
+++ elkhound/src/smbase/svdict.cc 2017-03-16 21:58:54.000000000 +0100
@@ -496,7 +496,7 @@
             dict2.remove(key.c_str());
           }
           else {
-            dict2.modify(key.c_str(), (void*)((int)value + 24));
+            dict2.modify(key.c_str(), (void*)((intptr_t)value + 24));
           }
           xassert(dict2 != dict);
         }
diff -Naur elkhound-orig/src/smbase/typ.h elkhound/src/smbase/typ.h
--- elkhound-orig/src/smbase/typ.h 2017-01-27 11:23:36.000000000 +0100
+++ elkhound/src/smbase/typ.h 2017-03-16 21:32:06.000000000 +0100
@@ -5,6 +5,8 @@
 #ifndef __TYP_H
 #define __TYP_H
 
+#include <stdint.h>
+
 // byte
 typedef unsigned char byte;
 typedef signed char signed_byte;
@@ -30,8 +32,8 @@
 
 // This used when I want to cast a pointer to an integer for something
 // like hashing the address.  It need not be injective.
-inline long pointerToInteger(void const *p)
-  { return (long)p; }
+inline intptr_t pointerToInteger(void const *p)
+  { return (intptr_t)p; }
 
 
 // This can be used to compare two pointers, even when they do not point
@@ -45,7 +47,7 @@
   // existence of this function at least ensures I only have to change
   // one place.
   return p==q?               0 :
-         (long)p < (long)q? -1 :      // would use std::less<> here
+         (intptr_t)p < (intptr_t)q? -1 :      // would use std::less<> here
                             +1 ;
 }
 
diff -Naur elkhound-orig/src/smbase/voidlist.cc elkhound/src/smbase/voidlist.cc
--- elkhound-orig/src/smbase/voidlist.cc 2017-01-27 11:23:36.000000000 +0100
+++ elkhound/src/smbase/voidlist.cc 2017-03-16 21:52:18.000000000 +0100
@@ -749,10 +749,10 @@
 // whereas isSorted would forget that info)
 void verifySorted(VoidList const &list)
 {
-  int prev = 0;
+  intptr_t prev = 0;
   VoidListIter iter(list);
   for (; !iter.isDone(); iter.adv()) {
-    int current = (int)iter.data();
+    intptr_t current = (intptr_t)iter.data();
     xassert(prev <= current);    // numeric address test
     prev = current;
   }
I've tested it on Cygwin (32bit and 64bit) and Debian 7.6 (32bit).

However, "make check" failed with the following error on Cygwin (both 32bit and 64bit):
Code: [Select]
------------ [12] triv/ESb.gr.exe triv/ESb.in1 ------------
reduced by E -> empty
reduced by E -> empty
reduced by S -> a
reduced by S -> a
WARNING: there is no action to deallocate nonterm S
reduced by S -> E S b
reduced by S -> E S b
WARNING: there is no action to deallocate nonterm S
reduced by S -> E S b
reduced by S -> E S b
WARNING: there is no action to deallocate nonterm S
reduced by S -> E S b
reduced by S -> E S b
WARNING: there is no action to deallocate nonterm S
Exception thrown: Assertion failed: referenceCount > 0, file glr.cc line 455
Assertion failed: referenceCount > 0, file glr.cc line 455

[12] A regression test command failed:
  triv/ESb.gr.exe triv/ESb.in1

Offline Wisp

  • Moderator
  • Planewalker
  • *****
  • Posts: 1176
Re: How to compile. Also, update your compiling environment.
« Reply #47 on: March 17, 2017, 03:29:17 PM »
Hah, the check target fails with a compiler error for me (it does this without the patch as well, but with a different error). Well, it might be a while before I can add this to master. I'm not that knowledgeable about elkhound, so I can't say how serious the test failure is. And before I can investigate I have to clean up the code base sufficiently, which is not a high priority at this time. Edit: Additionally, diffing the generated parsers reveals a few differences I can't evaluate (largely because they are numbers with no context).

Thanks for the patch. I've committed it to a branch.
« Last Edit: March 18, 2017, 05:30:02 AM by Wisp »

Offline Argent77

  • Planewalker
  • *****
  • Posts: 187
Re: How to compile. Also, update your compiling environment.
« Reply #48 on: April 14, 2017, 10:07:20 AM »
I'm getting a compiler error when I try to compile WeiDU 240.01 on Mac OSX:
Code: [Select]
Compiling obj/x86_LINUX/idslexer.ml to native code
File "src/idslexer.mll", line 3, characters 0-14:
Error: Unbound module Idsparser
make: *** [obj/x86_LINUX/idslexer.cmx] Error 1

I could track it back to the commit "Fix post-processing of dependency files" which is the first one triggering this error.

Any idea how to fix it?

Offline Wisp

  • Moderator
  • Planewalker
  • *****
  • Posts: 1176
Re: How to compile. Also, update your compiling environment.
« Reply #49 on: April 14, 2017, 12:10:47 PM »
What's the contents of obj/.depend/idslexer.d? Does perl work better than sed?

 

With Quick-Reply you can write a post when viewing a topic without loading a new page. You can still use bulletin board code and smileys as you would in a normal post.

Warning: this topic has not been posted in for at least 120 days.
Unless you're sure you want to reply, please consider starting a new topic.

Name: Email:
Verification:
Type the letters shown in the picture
Listen to the letters / Request another image
Type the letters shown in the picture:
What color is grass?:
What is the seventh word in this sentence?:
What is five minus two (use the full word)?: