thoni56 / c-xrefactory

A refactoring tool for C/Yacc and Emacs. The first tool to cross Refactory Rubicon. Initial work, and released under GPL in 2009, by Marián Vittek.
https://thoni56.github.io/c-xrefactory/
GNU General Public License v2.0
23 stars 4 forks source link

MSYS2 Build Fails #42

Closed tajmone closed 3 years ago

tajmone commented 5 years ago

It seems that C Xrefactory won't compile using MYS2/MinGW-64 under Windows 10 x64.

I've tried all the various approaches proposed in INSTALL and none worked:

  1. Via el-get — the problem is that el-get won't work under MSYS2 due to incompatibility problems with MinGW-64 install-info tool (from TextInfo).
  2. Creation of a binary distribution via CreateXrefDistribution fails with numerous warning and errors (see log below),
  3. Simple make failed too, seemingly due to a missing ./c-xref.bs file.
  4. Compiling in src/ via make also failed, again due to missing ./c-xref.bs file.

Any ideas? Is Xref supposed to be compiled as 32-bit only?

Failed Auto Create Xrefactory Distribution

Windows 10 x64 | MSYS2 > MinGW64 

Below is the output log from trying to compile c-xrefactory via

sh ./CreateXrefDistribution

Beside various warnings during make byacc, the BOOTSTRAPPING phase fails

P.K.Dick@RANXEROX MINGW64 /d/GitHub/Xref/c-xrefactory
$ sh ./CreateXrefDistribution
make -C ../byacc-1.9
make[1]: ingresso nella directory "/d/GitHub/Xref/c-xrefactory/byacc-1.9"
cc -O -DNDEBUG -std=c89   -c -o closure.o closure.c
In file included from defs.h:4,
                 from closure.c:1:
defs.h:283:12: warning: '_errno' redeclared without dllimport attribute: previous dllimport ignored [-Wattributes]
  283 | extern int errno;
      |            ^~~~~
cc -O -DNDEBUG -std=c89   -c -o error.o error.c
In file included from defs.h:4,
                 from error.c:3:
defs.h:283:12: warning: '_errno' redeclared without dllimport attribute: previous dllimport ignored [-Wattributes]
  283 | extern int errno;
      |            ^~~~~
cc -O -DNDEBUG -std=c89   -c -o lalr.o lalr.c
In file included from defs.h:4,
                 from lalr.c:1:
defs.h:283:12: warning: '_errno' redeclared without dllimport attribute: previous dllimport ignored [-Wattributes]
  283 | extern int errno;
      |            ^~~~~
cc -O -DNDEBUG -std=c89   -c -o lr0.o lr0.c
In file included from defs.h:4,
                 from lr0.c:1:
defs.h:283:12: warning: '_errno' redeclared without dllimport attribute: previous dllimport ignored [-Wattributes]
  283 | extern int errno;
      |            ^~~~~
cc -O -DNDEBUG -std=c89   -c -o main.o main.c
In file included from defs.h:4,
                 from main.c:3:
defs.h:283:12: warning: '_errno' redeclared without dllimport attribute: previous dllimport ignored [-Wattributes]
  283 | extern int errno;
      |            ^~~~~
cc -O -DNDEBUG -std=c89   -c -o mkpar.o mkpar.c
In file included from defs.h:4,
                 from mkpar.c:1:
defs.h:283:12: warning: '_errno' redeclared without dllimport attribute: previous dllimport ignored [-Wattributes]
  283 | extern int errno;
      |            ^~~~~
cc -O -DNDEBUG -std=c89   -c -o output.o output.c
In file included from defs.h:4,
                 from output.c:1:
defs.h:283:12: warning: '_errno' redeclared without dllimport attribute: previous dllimport ignored [-Wattributes]
  283 | extern int errno;
      |            ^~~~~
cc -O -DNDEBUG -std=c89   -c -o reader.o reader.c
In file included from defs.h:4,
                 from reader.c:1:
defs.h:283:12: warning: '_errno' redeclared without dllimport attribute: previous dllimport ignored [-Wattributes]
  283 | extern int errno;
      |            ^~~~~
cc -O -DNDEBUG -std=c89   -c -o skeleton.o skeleton.c
In file included from defs.h:4,
                 from skeleton.c:1:
defs.h:283:12: warning: '_errno' redeclared without dllimport attribute: previous dllimport ignored [-Wattributes]
  283 | extern int errno;
      |            ^~~~~
cc -O -DNDEBUG -std=c89   -c -o symtab.o symtab.c
In file included from defs.h:4,
                 from symtab.c:1:
defs.h:283:12: warning: '_errno' redeclared without dllimport attribute: previous dllimport ignored [-Wattributes]
  283 | extern int errno;
      |            ^~~~~
cc -O -DNDEBUG -std=c89   -c -o verbose.o verbose.c
In file included from defs.h:4,
                 from verbose.c:1:
defs.h:283:12: warning: '_errno' redeclared without dllimport attribute: previous dllimport ignored [-Wattributes]
  283 | extern int errno;
      |            ^~~~~
cc -O -DNDEBUG -std=c89   -c -o warshall.o warshall.c
In file included from defs.h:4,
                 from warshall.c:1:
defs.h:283:12: warning: '_errno' redeclared without dllimport attribute: previous dllimport ignored [-Wattributes]
  283 | extern int errno;
      |            ^~~~~
Loading yacc ... done
make[1]: uscita dalla directory "/d/GitHub/Xref/c-xrefactory/byacc-1.9"
BOOTSTRAPPING...
make ROOTDIR=.. -f Makefile.bs
make[1]: ingresso nella directory "/d/GitHub/Xref/c-xrefactory/src"
cc  -DBOOTSTRAP -o .objects/cgram.o -MMD -c cgram.c
cgram.c:159: warning: "CONST" redefined
  159 | #define CONST 295
      |
In file included from C:/tools/msys64/mingw64/x86_64-w64-mingw32/include/windef.h:8,
                 from C:/tools/msys64/mingw64/x86_64-w64-mingw32/include/windows.h:69,
                 from stdinc.h:17,
                 from proto.h:23,
                 from cgram.x:12,
                 from cgram.y:36:
C:/tools/msys64/mingw64/x86_64-w64-mingw32/include/minwindef.h:122: note: this is the location of the previous definition
  122 | #define CONST const
      |
cgram.c:174: warning: "VOID" redefined
  174 | #define VOID 310
      |
In file included from C:/tools/msys64/mingw64/x86_64-w64-mingw32/include/minwindef.h:163,
                 from C:/tools/msys64/mingw64/x86_64-w64-mingw32/include/windef.h:8,
                 from C:/tools/msys64/mingw64/x86_64-w64-mingw32/include/windows.h:69,
                 from stdinc.h:17,
                 from proto.h:23,
                 from cgram.x:12,
                 from cgram.y:36:
C:/tools/msys64/mingw64/x86_64-w64-mingw32/include/winnt.h:284: note: this is the location of the previous definition
  284 | #define VOID void
      |
cgram.c:204: warning: "INTERFACE" redefined
  204 | #define INTERFACE 340
      |
In file included from C:/tools/msys64/mingw64/x86_64-w64-mingw32/include/windows.h:108,
                 from stdinc.h:17,
                 from proto.h:23,
                 from cgram.x:12,
                 from cgram.y:36:
C:/tools/msys64/mingw64/x86_64-w64-mingw32/include/commdlg.h:587: note: this is the location of the previous definition
  587 | #define INTERFACE IPrintDialogServices
      |
cgram.c:213: warning: "THIS" redefined
  213 | #define THIS 349
      |
In file included from C:/tools/msys64/mingw64/x86_64-w64-mingw32/include/objbase.h:14,
                 from C:/tools/msys64/mingw64/x86_64-w64-mingw32/include/ole2.h:17,
                 from C:/tools/msys64/mingw64/x86_64-w64-mingw32/include/wtypes.h:12,
                 from C:/tools/msys64/mingw64/x86_64-w64-mingw32/include/winscard.h:10,
                 from C:/tools/msys64/mingw64/x86_64-w64-mingw32/include/windows.h:97,
                 from stdinc.h:17,
                 from proto.h:23,
                 from cgram.x:12,
                 from cgram.y:36:
C:/tools/msys64/mingw64/x86_64-w64-mingw32/include/combaseapi.h:106: note: this is the location of the previous definition
  106 | #define THIS INTERFACE *This
      |
cgram.c:227: warning: "DELETE" redefined
  227 | #define DELETE 363
      |
In file included from C:/tools/msys64/mingw64/x86_64-w64-mingw32/include/minwindef.h:163,
                 from C:/tools/msys64/mingw64/x86_64-w64-mingw32/include/windef.h:8,
                 from C:/tools/msys64/mingw64/x86_64-w64-mingw32/include/windows.h:69,
                 from stdinc.h:17,
                 from proto.h:23,
                 from cgram.x:12,
                 from cgram.y:36:
C:/tools/msys64/mingw64/x86_64-w64-mingw32/include/winnt.h:2878: note: this is the location of the previous definition
 2878 | #define DELETE (__MSABI_LONG(0x00010000))
      |
cc  -DBOOTSTRAP -o .objects/main.o -MMD -c main.c
In file included from unigram.h:24,
                 from main.c:20:
cgram.h:84: warning: "INTERFACE" redefined
   84 | #define INTERFACE 340
      |
In file included from C:/tools/msys64/mingw64/x86_64-w64-mingw32/include/windows.h:108,
                 from stdinc.h:17,
                 from proto.h:23,
                 from main.h:4,
                 from main.c:1:
C:/tools/msys64/mingw64/x86_64-w64-mingw32/include/commdlg.h:587: note: this is the location of the previous definition
  587 | #define INTERFACE IPrintDialogServices
      |
cc  -DBOOTSTRAP -o .objects/globals.o -MMD -c globals.c
In file included from unigram.h:24,
                 from globals.c:6:
cgram.h:84: warning: "INTERFACE" redefined
   84 | #define INTERFACE 340
      |
In file included from C:/tools/msys64/mingw64/x86_64-w64-mingw32/include/windows.h:108,
                 from stdinc.h:17,
                 from proto.h:23,
                 from globals.h:5,
                 from globals.c:1:
C:/tools/msys64/mingw64/x86_64-w64-mingw32/include/commdlg.h:587: note: this is the location of the previous definition
  587 | #define INTERFACE IPrintDialogServices
      |
cc  -DBOOTSTRAP -o .objects/misc.o -MMD -c misc.c
misc.c: In function 'concatFNameInTmpMemory':
misc.c:1504:13: error: 's' undeclared (first use in this function)
 1504 |         for(s=tt+1; *s; s++) if (*s=='/') *s=SLASH;
      |             ^
misc.c:1504:13: note: each undeclared identifier is reported only once for each function it appears in
make[1]: *** [Makefile.bs:15: .objects/misc.o] Error 1
make[1]: uscita dalla directory "/d/GitHub/Xref/c-xrefactory/src"
make: *** [Makefile.common:80: c-xref.bs] Error 2
cp: impossibile eseguire stat di 'src/c-xref': No such file or directory
cp: impossibile eseguire stat di 'emacs/c-xrefactory.el'$'\r': No such file or directory
cp: impossibile eseguire stat di 'emacs/c-xref.el'$'\r': No such file or directory
cp: impossibile eseguire stat di 'emacs/c-xrefprotocol.el'$'\r': No such file or directory

Failed Make in Root Folder

Below is the output log from trying to compile c-xrefactory via make inside root folder.

The problem seems to be a missing ./c-xref.bs file.

P.K.Dick@RANXEROX MINGW64 /d/GitHub/Xref/c-xrefactory
$ make
make -C src
BOOTSTRAPPING...
make ROOTDIR=.. -f Makefile.bs
make[2]: ".objects/main.o" è aggiornato.
/bin/sh: ./c-xref.bs: No such file or directory
make[1]: *** [Makefile.common:104: strFill.g.h] Error 127
make: *** [Makefile:6: all] Error 2

Failed Make in src/ Folder

Below is the output log from trying to compile c-xrefactory via make inside src/ folder.

Again, the problem seems to be a missing ./c-xref.bs file.

P.K.Dick@RANXEROX MINGW64 /d/GitHub/Xref/c-xrefactory/src
$ make
BOOTSTRAPPING...
make ROOTDIR=.. -f Makefile.bs
make[1]: ingresso nella directory "/d/GitHub/Xref/c-xrefactory/src"
make[1]: ".objects/main.o" è aggiornato.
make[1]: uscita dalla directory "/d/GitHub/Xref/c-xrefactory/src"
/bin/sh: ./c-xref.bs: No such file or directory
make: *** [Makefile.common:104: strFill.g.h] Error 127
thoni56 commented 5 years ago

A few points on this matter:

(The c-xref.bs is a binary built by the initial build using default sources for some things which is then used to generate target specific sources for those things, so that a target specific c-xref can be built. This is a small part of all the magic that is built into the design of c-xrefactory...)

I'll try MSYS2 as soon as I'm at an MSYS2-prompt.

tajmone commented 5 years ago

Thanks Thoni. I tried, but still no lack.

Anyways, slightly older versions (1.6.7 vs 1.6.10) are available as precompiled Windows binaries directly from Xref website:

file for editor
xref-1.6.7-i86pcWindows.zip Emacs, XEmacs
xref-1.6.7-jedit-i86pcWindows.zip jEdit
xref-1.6.7-any.tar.gz Emacs, XEmacs, jEdit

If these work they should be fine as a starting point, at least to start getting a feel of the tool.

NOTE — I had to fiddle manually with the links, for they still pointed at the old mirro domain, which is mostly down (just had to change www.xref.sk to www.xrefactory.com, for they are mirrors of each other).

If this repository were to exploit Travis CI or Circle CI to actually build precompiled binary releases for Windows (via cross-compilation) it would be great!

thoni56 commented 5 years ago

Just some quick findings and a few comments:

I continuously use Emacs with c-xrefactory on WSL for many of my projects, so even MSYS Posix would be low on my prio if it didn't work.

tajmone commented 5 years ago

WSL is definitely something that came to my mind, I'll try and set it up and, if I manage, I'll add a script that can be used to do all the automagick setup from a fresh WSL Ubuntu install.

thoni56 commented 5 years ago

I think that will be no problem. c-xrefactory actually has very few special requirements, it uses the file system and pipes, so there are not any extra libraries that you need, AFAICR.

thoni56 commented 5 years ago

I continuously use Emacs with c-xrefactory on WSL for many of my projects,

I've set up an Xming X11 server on the Windows side so my Emacs will open a window on the desktop. And it successfully loads c-xrefactory via el-get.

tajmone commented 3 years ago

@thoni56, could you add to the Wiki some guidelines on how to setup c-xrefactory under Win10 using WSL/WSL2, possibly with some links/tips for Emacs too.

I've set up an Xming X11 server on the Windows side so my Emacs will open a window on the desktop.

Isn't it possible to install Emacs for Windows and interface it with c-xrefactory running under WSL?

thoni56 commented 3 years ago

The recommended way to install c-xrefactory is using el-get as is explained in the Readme. That will automatically compile it in the environment Emacs is running.

That works in Linux, Cygwin and MacOS. I haven't tried any other environment for a while. But if it has "normal" unix-like features,(make, bash, cc, ...) it might work.

I don't think it is posssible to have Emacs and c-xref communicate over a network, which is what WSL/Windows would be.

There are some remnants of a "user" concept to the "server-mode" but I don't know if and how that was working as a true server.

Anyway, if possible that would be a lot of work in an area that is mostly unknown to me.

I'll add something about setting up Emacs on WSL.

thoni56 commented 3 years ago

I've successfully compiled c-xrefactory as part of the recommended installation from within Emacs using el-get. You currently have to have zlib-devel installed to make that build succeed (pacman -S zlib-devel) .

I also have added some tips for setup in the readme.

NOTE: only Msys2-MSYS, which uses the Cygwin layer to emulate Linux/Unix, is supported, not Msys2-MingW* (the "Windows native" 32- and 64-bit versions).