Discussion:
Building pcc on Windows
Rich Felker
2014-04-02 20:13:09 UTC
Permalink
Hello!
    263: ..\..\cc\cc\cc.c(438) : error C2065: 'incdir' : undeclared identifier
   264: ..\..\cc\cc\cc.c(438) : error C2065: 'incdir' : undeclared identifier
Based on these error messages, I think you mean "under MSVC" rather
than "on Windows". Since MSVC is not a C compiler, it's not surprising
that it fails to compile C sources...

Rich
r***@q.com
2014-04-02 18:56:49 UTC
Permalink
Hello!



pcc\cc\cc.c does not build on Windows due to undeclared variables. Some of the errors a re:



    263: ..\..\cc\cc\cc.c(438) : error C2065: 'incdir' : undeclared identifier
   264: ..\..\cc\cc\cc.c(438) : error C2065: 'incdir' : undeclared identifier
   268: ..\..\cc\cc\cc.c(439) : error C2065: 'altincdir' : undeclared identifier
   269: ..\..\cc\cc\cc.c(439) : error C2065: 'altincdir' : undeclared identifier
   273: ..\..\cc\cc\cc.c(440) : error C2065: 'libdir' : undeclared identifier
   274: ..\..\cc\cc\cc.c(440) : error C2065: 'libdir' : undeclared identifier
   278: ..\..\cc\cc\cc.c(442) : error C2065: 'pccincdir' : undeclared identifier
   279: ..\..\cc\cc\cc.c(442) : error C2065: 'pccincdir' : undeclared identifier
   283: ..\..\cc\cc\cc.c(443) : error C2065: 'pxxincdir' : undeclared identifier
   284: ..\..\cc\cc\cc.c(443) : error C2065: 'pxxincdir' : undeclared identifier
   288: ..\..\cc\cc\cc.c(451) : error C2065: 'i' : undeclared identifier
   289: ..\..\cc\cc\cc.c(451) : error C2065: 'startfiles' : undeclared identifier
   290: ..\..\cc\cc\cc.c(451) : error C2065: 'i' : undeclared identifier
   291: ..\..\cc\cc\cc.c(451) : error C2109: subscript requires array or pointer type
   292: ..\..\cc\cc\cc.c(451) : error C2065: 'i' : undeclared identifier
   293: ..\..\cc\cc\cc.c(452) : error C2065: 'startfiles' : undeclared identifier
   294: ..\..\cc\cc\cc.c(452) : error C2065: 'i' : undeclared identifier
   295: ..\..\cc\cc\cc.c(452) : error C2109: subscript requires array or pointer type
   296: ..\..\cc\cc\cc.c(452) : error C2065: 'startfiles' : undeclared identifier
   297: ..\..\cc\cc\cc.c(452) : error C2065: 'i' : undeclared identifier
   298: ..\..\cc\cc\cc.c(452) : error C2109: subscript requires array or pointer type
   299: ..\..\cc\cc\cc.c(452) : error C2198: 'win32pathsubst' : too few arguments for call

   ...



Although I have yesterday's (2014 April 01) sources, I'm actually writing about the 20140204 sources. I have verified that t here have been no changes  since that date that have anything to do with the problems I am seeing.



As part of my investigation, I compared the current os\win32\build.bat and pcc\cc\cc.c to the ones that were probably used to build the newest Windows installer package ( pcc-20111206-win32.exe), pcc-20111206.tgz. There are numerous obvious differences in the  code, including the fact that  changes were made but not to the code contained within the #ifdef os_win32 blocks. So the surrounding code was updated but the code in the #ifdef os_win32 blocks was not.



Also, it is clear that the supplied pcc\os\win32\build.bat has not been usable for a long time. I am in the process of learning my way around the project, so I care about whether or not I can build it in its entirety. Since I prefer to use a makefile  instead of  batch files, I am writing new native makefiles to build the various pieces of pcc. These makefiles will be Microsoft nmake-specific (the compiler toolchain  from Visual Studio 2010 SP1, which contains  compiler version 16.00.30319.01). To be clear, I use the Microsoft tools via the command line and have no interest in using their IDEs or creating IDE-based 'projects'.



Thus far I have built and run successfully mkext.exe and cpp.exe. Today, I'll try building ccom.exe. I'm keeping a journal on all of this from which I plan to base written build instructions, a replacement for the current batch-based build system, and maybe a few suggestions and fixes. Speaking of fixes...



Since I have  older code that 'worked' on Windows and  newer code which doesn't, I could work out the changes to 'fix' pcc.exe. I'm  thinking that the owner of that code could do it with a lot less time and effort, s o I'm hoping that person will feel sorry enough for the (apparently) only developer using Windows to help me avoid spending a lot of time on that ;-)



Once I become familiar with the project, I intend to actively contribute to it. I've been looking over the list of outstanding bugs for stuff I could do sooner rather than later...



Kind Regards ,



Rick Spates
Anders Magnusson
2014-04-06 09:08:59 UTC
Permalink
The layout of cc was changed some while ago, and the Windows port has
not been fixed after that change.

I have no windows development environment myself, but I think it is
simple for someone that has to fix it.

I do not have any opinion whether to use bat files, makefiler or so on
windows.

-- Ragge
Hello!
pcc\cc\cc.c does not build on Windows due to undeclared variables.
263: ..\..\cc\cc\cc.c(438) : error C2065: 'incdir' : undeclared
identifier
264: ..\..\cc\cc\cc.c(438) : error C2065: 'incdir' : undeclared
identifier
268: ..\..\cc\cc\cc.c(439) : error C2065: 'altincdir' : undeclared
identifier
269: ..\..\cc\cc\cc.c(439) : error C2065: 'altincdir' : undeclared
identifier
273: ..\..\cc\cc\cc.c(440) : error C2065: 'libdir' : undeclared
identifier
274: ..\..\cc\cc\cc.c(440) : error C2065: 'libdir' : undeclared
identifier
278: ..\..\cc\cc\cc.c(442) : error C2065: 'pccincdir' : undeclared
identifier
279: ..\..\cc\cc\cc.c(442) : error C2065: 'pccincdir' : undeclared
identifier
283: ..\..\cc\cc\cc.c(443) : error C2065: 'pxxincdir' : undeclared
identifier
284: ..\..\cc\cc\cc.c(443) : error C2065: 'pxxincdir' : undeclared
identifier
288: ..\..\cc\cc\cc.c(451) : error C2065: 'i' : undeclared identifier
289: ..\..\cc\cc\cc.c(451) : error C2065: 'startfiles' : undeclared
identifier
290: ..\..\cc\cc\cc.c(451) : error C2065: 'i' : undeclared identifier
291: ..\..\cc\cc\cc.c(451) : error C2109: subscript requires array
or pointer type
292: ..\..\cc\cc\cc.c(451) : error C2065: 'i' : undeclared identifier
293: ..\..\cc\cc\cc.c(452) : error C2065: 'startfiles' : undeclared
identifier
294: ..\..\cc\cc\cc.c(452) : error C2065: 'i' : undeclared identifier
295: ..\..\cc\cc\cc.c(452) : error C2109: subscript requires array
or pointer type
296: ..\..\cc\cc\cc.c(452) : error C2065: 'startfiles' : undeclared
identifier
297: ..\..\cc\cc\cc.c(452) : error C2065: 'i' : undeclared identifier
298: ..\..\cc\cc\cc.c(452) : error C2109: subscript requires array
or pointer type
299: ..\..\cc\cc\cc.c(452) : error C2198: 'win32pathsubst' : too
few arguments for call
...
Although I have yesterday's (2014 April 01) sources, I'm actually
writing about the 20140204 sources. I have verified that there have
been no changes since that date that have anything to do with the
problems I am seeing.
As part of my investigation, I compared the current os\win32\build.bat
and pcc\cc\cc.c to the ones that were probably used to build the
newest Windows installer package (pcc-20111206-win32.exe),
pcc-20111206.tgz. There are numerous obvious differences in the code,
including the fact that changes were made but not to the code
contained within the #ifdef os_win32 blocks. So the surrounding code
was updated but the code in the #ifdef os_win32 blocks was not.
Also, it is clear that the supplied pcc\os\win32\build.bat has not
been usable for a long time. I am in the process of learning my way
around the project, so I care about whether or not I can build it in
its entirety. Since I prefer to use a makefile instead of batch files,
I am writing new native makefiles to build the various pieces of pcc.
These makefiles will be Microsoft nmake-specific (the compiler
toolchain from Visual Studio 2010 SP1, which contains compiler version
16.00.30319.01). To be clear, I use the Microsoft tools via the
command line and have no interest in using their IDEs or creating
IDE-based 'projects'.
Thus far I have built and run successfully mkext.exe and cpp.exe.
Today, I'll try building ccom.exe. I'm keeping a journal on all of
this from which I plan to base written build instructions, a
replacement for the current batch-based build system, and maybe a few
suggestions and fixes. Speaking of fixes...
Since I have older code that 'worked' on Windows and newer code which
doesn't, I could work out the changes to 'fix' pcc.exe. I'm thinking
that the owner of that code could do it with a lot less time and
effort, so I'm hoping that person will feel sorry enough for the
(apparently) only developer using Windows to help me avoid spending a
lot of time on that ;-)
Once I become familiar with the project, I intend to actively
contribute to it. I've been looking over the list of outstanding bugs
for stuff I could do sooner rather than later...
Kind Regards,
Rick Spates
_______________________________________________
Pcc mailing list
http://lists.ludd.ltu.se/cgi-bin/mailman/listinfo/pcc
r***@q.com
2014-04-07 01:51:52 UTC
Permalink
Hello, Mr. Magnusson. ----- Original Message -----
Post by Anders Magnusson
The layout of cc was changed some while ago, and the Windows port has
not been fixed after that change.
I understand completely. I have no windows development environment myself, but I think it is simple for someone that has to fix it. Agreed. I do not have any opinion whether to use bat files, makefiler or so on windows. Thank you. I've  compiled a list of  Windows compilers that could  be used for the initial build of pcc. Once I starting thinking about that, I am now considering using the version of GNU make (v3.7 8.1) that accompanies UnxUtils. Thank you for your time. Regards, Rick
Antoine Leca
2014-04-06 10:31:18 UTC
Permalink
I did improve the building on Windows some time ago, but I did not
finished all the tests so it was not submitted here before last year's
shutdown (and then priorities changed.)

Perhaps you can start from where I leaved things:
https://github.com/antoineL/pcc/commit/fb891d9
Patch at
https://github.com/antoineL/pcc/commit/fb891d9f0256ce0372b8236b00341d24e738f297.patch


Antoine
r***@q.com
2014-04-07 01:53:52 UTC
Permalink
Hello, Mr. Leca.
Post by Antoine Leca
I did improve the building on Windows some time ago, but I did not
finished all the tests so it was not submitted here before last year's
shutdown (and then priorities changed.)
I understand.
Post by Antoine Leca
https://github.com/antoineL/pcc/commit/fb891d9
Patch at
https://github.com/antoineL/pcc/commit/fb891d9f0256ce0372b8236b00341d24e738f297.patch
Thanks! I really appreciate this very much.

Thanks again,

Rick
Iain Hibbert
2014-04-07 07:26:47 UTC
Permalink
Post by r***@q.com
Also, it is clear that the supplied pcc\os\win32\build.bat has not been
usable for a long time. I am in the process of learning my way around
the project, so I care about whether or not I can build it in its
entirety. Since I prefer to use a makefile instead of batch files, I am
writing new native makefiles to build the various pieces of pcc. These
makefiles will be Microsoft nmake-specific (the compiler toolchain  from
Visual Studio 2010 SP1, which contains compiler version 16.00.30319.01).
To be clear, I use the Microsoft tools via the command line and have no
interest in using their IDEs or creating IDE-based 'projects'.
is this nmake compatible with POSIX make? It always helps to prevent
bit-rot if the same tools can be used across the board..

personally, i think that pcc is a C99 compiler and this should be
buildable with a C99 compiler. I don't know how much Windows environment
would be necessary to build, but at the least a binary download of pcc
(and possibly pcc-libs) should be able to build its own (and future :)
sources.. this would probably be the best target to aim for, rather than
relying on a pre-installed compiler/development system?

iain
Martin Husemann
2014-04-07 07:32:19 UTC
Permalink
Post by Iain Hibbert
sources.. this would probably be the best target to aim for, rather than
relying on a pre-installed compiler/development system?
I agree - especially since a typical windows developement machine does
not have any C99 compilers installed, and it makes no sense to me to
download a binary install of mingw/gcc just to build pcc - instead of
just downloading a pcc binary and using that to compile the latest pcc
sources.

Martin
Antoine Leca
2014-04-08 08:02:59 UTC
Permalink
Post by Iain Hibbert
is this nmake compatible with POSIX make?
At the strict tool level, yes, nmake is pretty compatible with POSIX,
while not being strictly compatible: a couple of features are missing,
most of small use, like the -S option (inverse of -k), the .DEFAULT and
.POSIX pseudo targets, support for dealing with archive members
(library(member.o) target and $% macro), the predefined YACC, LEX, AR,
and FC macros and the accompanying xFLAGS, and single-suffix inferences
rules (like .c: ${CC} ${CFLAGS} ${LDFLAGS} -o $* $<)
More worrying are lacking the use of brackets in ${} macro invocation
(only $() is supported), and the + operator for commands.
But as a general rule, compatibility is pretty good.

Besides strict POSIX, most often-assumed *nix extensions are not
available either; and on the other hand, nmake has its own set of
extensions, which (of course!) uses a different (incompatible) syntax;
the most obvious is the use !if/!include/etc. where BSD uses
.if/.include/etc. and GNU uses if/include/etc. (and not compatible
between them); there is some form of VPATH feature as well, but it does
NOT work the same way as with BSD or GNU (it is attached to each target)

Having said all that, there is a fundamental difference between Windows
and Posix which pervades Makefile's: the commands are to be executed by
the shell (through system(3)), and in this area there are much bigger
differences, both in syntax --for example, the escape character is ^ in
Windows, in commands --no rm(1), mv(1), install(1) in Windows-- or in
built-ins --no export, the syntax of for is different, etc.

Also, if we nail down to the PCC project, there is no sed(1) either
(although I guess PowerShell experts can now help in this area if they
really wanted to), so the current Makefile.in with all their @foobar@
are pretty unwelcome on Windows.
Post by Iain Hibbert
personally, i think that pcc is a C99 compiler and this should be
buildable with a C99 compiler.
There is an evident chicken-and-egg problem here, but I won't digress.

However, a real limit of C99 code when it comes to Windows, is the lack
of support for some C99 features in the C runtime library, and most
notably the %zu printf modifier. And of course, having a C99 compiler is
of no help if the library is still at C89 level.
Post by Iain Hibbert
I don't know how much Windows environment
would be necessary to build, but at the least a binary download of pcc
(and possibly pcc-libs) should be able to build its own (and future :)
sources.. this would probably be the best target to aim for, rather than
relying on a pre-installed compiler/development system?
You really need yacc and (f)lex too. Berkeley yacc is pretty easy to use
on Windows, but lex is quite another game; I do not know how tested is
the legacy lex(1) from V7 or System V or similar sources; about flex,
there is a 2.5.4 version compiled for Windows which is floating around
since 1999, and is quite possible to use for PCC; but more recent
releases (current is 2.5.40) are much more *nix oriented, or even GNU
oriented, up to going as far as forking m4 with a non-POSIX -P parameter
under the hood... not easy to handle quietly on Windows. :-(


Antoine
Iain Hibbert
2014-04-08 09:43:09 UTC
Permalink
Post by Antoine Leca
But as a general rule, compatibility is pretty good.
we should try to keep the pcc Makefile.in files compatible where possible.
I simplified them somewhat a while ago to explicitly list files, changed
most ${} to $() for example and I don't think VPATH is required anymore,
though no doubt there would be more to do. It might be easier to find a
make that has compatible syntax which can be built (by pcc) on windows
rather than using one that comes with a commercial development system?

I don't know what to do with the configure scripts though, if that is not
able to be processed without loading a POSIX environment
Post by Antoine Leca
Post by Iain Hibbert
personally, i think that pcc is a C99 compiler and this should be
buildable with a C99 compiler.
There is an evident chicken-and-egg problem here, but I won't digress.
For development of course.. but if a user can download a pcc binary, then
use that to build the pcc sources, that should be enough. I do not recall
the last time I ran something on my machines that was not compiled by me,
but I started many years ago with a binary download of NetBSD.
Post by Antoine Leca
However, a real limit of C99 code when it comes to Windows, is the lack
of support for some C99 features in the C runtime library, and most
notably the %zu printf modifier. And of course, having a C99 compiler is
of no help if the library is still at C89 level.
which is the C runtime library? I didn't think windows came with anything
like that in any case.. If I recall, mip/compat.c provides a basic
printf() that should be sufficient to compile pcc itself (if not, then
lets fix it up :)
Post by Antoine Leca
Post by Iain Hibbert
I don't know how much Windows environment
would be necessary to build, but at the least a binary download of pcc
(and possibly pcc-libs) should be able to build its own (and future :)
sources.. this would probably be the best target to aim for, rather than
relying on a pre-installed compiler/development system?
You really need yacc and (f)lex too. Berkeley yacc is pretty easy to use
on Windows, but lex is quite another game; I do not know how tested is
the legacy lex(1) from V7 or System V or similar sources; about flex,
there is a 2.5.4 version compiled for Windows which is floating around
since 1999, and is quite possible to use for PCC; but more recent
releases (current is 2.5.40) are much more *nix oriented, or even GNU
oriented, up to going as far as forking m4 with a non-POSIX -P parameter
under the hood... not easy to handle quietly on Windows. :-(
I think ultimately that although eg Cygwin is available and this can be
used to bootstrap pcc on windows, the point of Cygwin is to provide a
POSIX environment, and just because somebody wants a compiler on Windows,
they don't necessarily want a POSIX environment.. (also, it already
provides a compiler)

iain
Antoine Leca
2014-04-08 11:14:51 UTC
Permalink
Post by Iain Hibbert
Post by Antoine Leca
But as a general rule, compatibility is pretty good.
we should try to keep the pcc Makefile.in files compatible where possible.
I agree with the goal (of course).
I also believe that, for what matters to (n)make, there is no problem.
Post by Iain Hibbert
I simplified them somewhat a while ago to explicitly list files, changed
most ${} to $() for example and I don't think VPATH is required anymore,
I also think VPATH is not required (recently built pcc with a bare-bones
make, no problem noticed.) Thanks to standardize at $(), I did not
notice but from what I saw this morning, it was a good move!

On the other hand, I do not see how to save the basic problems related
to shell differences and the lack of sed...
Post by Iain Hibbert
It might be easier to find a
make that has compatible syntax which can be built (by pcc) on windows
rather than using one that comes with a commercial development system?
In my experience, developers on Windows do not argue when asked to use
GNU make if there are deficiencies with their native tool: it is pretty
easy to get, and works pretty well on Windows (which is not that usual
with GNU tools on Windows, so kudos to that team.)

On the other hand, I do not believe this is required for PCC when nmake
is already available: it won't bring anything not already available, and
won't solve any of the remaining problem. AFAIK, that is.
Post by Iain Hibbert
Post by Antoine Leca
However, a real limit of C99 code when it comes to Windows, is the lack
of support for some C99 features in the C runtime library, and most
notably the %zu printf modifier. And of course, having a C99 compiler is
of no help if the library is still at C89 level.
which is the C runtime library?
(If I wasn't clear enough: I meant libc.)

For many Win32 compilers, it is provided (as a DLL) by the operating
system; it is called MSVCRT.DLL (a hint it is developed by Microsoft
Visual C++ team, known to NOT be very concerned by C99 compatibility).

In fact, the very point of MinGW was to provide the necessary lib*.a and
crt*.o to be able to use (and build) GCC on Win32 using that DLL.
Post by Iain Hibbert
I didn't think windows came with anything
like that in any case.. If I recall, mip/compat.c provides a basic
printf() that should be sufficient to compile pcc itself (if not, then
lets fix it up :)
Well, if you believe this is a goal, I can investigate a patch to drop
the few remaining places where C99 library features are required; I saw
recently they are mainly in mkext.c, which is anyway a problem in
itself, since when you are building a cross-compiler, the autoconf
HAVE_C99_PRINTF test is by-passed; IMHO, mkext.c (or any locally-run
helper program) should not depend on any feature-test, there are too
much possibilities for confusion between host-available and
build-available features anyway.

Besides long long (which is of course required, but OTOH is present in
all half-decent compilers for more than 13 years now), I do not believe
there are other C99 features required for PCC. Perhaps stdint.h, but
this is so easy to solve at developer's side that it should not matter.
Post by Iain Hibbert
I think ultimately that although eg Cygwin is available and this can be
used to bootstrap pcc on windows, the point of Cygwin is to provide a
POSIX environment, and just because somebody wants a compiler on Windows,
they don't necessarily want a POSIX environment.. (also, it already
provides a compiler)
Yes.
And while I usually use Cygwin or Interix, I ended considering that the
build.bat approach, with the paths for yacc/bison and flex to be
provided externally, was a very acceptable way to deal with the problem
particularly for a small package such as pcc. (If he still reads,
perhaps Rick can comment on this, I would welcome his point of view.)

On the other hand, the idea to use nmake is very seducing, and when one
tries to actually make use of the Makefile, I believe they are pretty
much usable as they stand... once the @foobar@ stuff is replaced!
Particularly for the building phase, since the installing phase could be
a bit more complex, due to install not existing (we would need some
install.cmd, certainly not impossible), or differences in the directory
structure, even differences between the way to just install programs
(comparing sudo with required-elevation-because-of-UAC.)
However, as you said above, about configure things are very different.


Antoine
Iain Hibbert
2014-04-09 11:09:58 UTC
Permalink
Post by Antoine Leca
On the other hand, I do not see how to save the basic problems related
to shell differences and the lack of sed...
does win-bash work?

http://win-bash.sourceforge.net/

also, how about the unxutils package?

http://unxutils.sourceforge.net/

this seems to provide m4, make, sed, flex and bison in a native format (ie
no cygwin) also the archive contains zsh.exe though I can't evaluate these
here
Post by Antoine Leca
On the other hand, the idea to use nmake is very seducing, and when one
tries to actually make use of the Makefile, I believe they are pretty
but how?
Post by Antoine Leca
Particularly for the building phase, since the installing phase could be
a bit more complex, due to install not existing (we would need some
install.cmd, certainly not impossible)
can install-sh (provided) fill this capability? I guess it requires a
bourne shell (which may be available for windows?) otherwise, surely
somebody has written an msdos install script..
Post by Antoine Leca
or differences in the directory
structure, even differences between the way to just install programs
(comparing sudo with required-elevation-because-of-UAC.)
However, as you said above, about configure things are very different.
I recall somebody previously (Thorsten?) suggesting that use of autoconf
was better curtailed, but it is very useful.. it could be replaced no
doubt by expanding the os dependent system, perhaps with more than just C
headers

regards,
iain

Continue reading on narkive:
Loading...