[Radiance-dev] Radiance compiled with mingw gcc (windows)

Georg Mischler schorsch at schorsch.com
Mon Sep 19 13:48:15 CEST 2005


pisuke at blueyonder.co.uk wrote:

> diff -r ray/platform/mingw.cfg ray_dev/platform/mingw.cfg
> 13c13
> < CPPDEFINES: _WIN32 NDEBUG _CONSOLE _MBCS HDSUF=.exe
> ---
> > CPPDEFINES: _WIN32 NDEBUG _CONSOLE _MBCS HDSUF=.exe NON_POSIX

NON_POSIX is set in common/platform.h based on _WIN32, so there
is no need to set it here. If you still get errors, then you
probably need to #include platform.h somewhere.



> 25c25
> < RAD_ARGSCOMPAT: fixargv0.c
> ---
> > RAD_ARGSCOMPAT: getpath.c fixargv0.c
> 28c28

getpath.c is always included in librtargs.a. If a program needs it,
then you should link it to that library.



> < RAD_PROCESS: win_process.c win_popen.c
> ---
> > RAD_PROCESS: gethomedir.c eputs.c getpath.c win_process.c win_popen.c

For gethomedir.c and getpath.c, link to librtpath.a.
For eputs.c, link to librterror.a.
For win_process.c and win_popen.c, link to librtproc.a.

With all those libraries, note that some linkers may require them
to be added in a certain order. So if a specific function isn't
found, it may be just necessary to reorder the list appropriately.



> 29a30
> > RAD_MLIB:   m

This was indeed an omission.



> diff -r ray/src/common/rtprocess.h ray_dev/src/common/rtprocess.h
> 24c24
> <   int win_kill(RT_PID pid, int sig /* ignored */);
> ---
> >   int win_kill(RT_PID pid, RT_PID sig /* ignored */);

Ahem, no. The signal number doesn't have the same type as a PID.
It's rather the "pid" variable in rtcontrib.c:killpersist() that we
need to change.
What kind of problem were you trying to fix with this?



> diff -r ray/src/common/SConscript ray_dev/src/common/SConscript
> 17c17
> <               font.c mesh.c readmesh.c tmesh.c sceneio.c xf.c''')
> ---
> >               font.c mesh.c readmesh.c tmesh.c sceneio.c xf.c win_popen.c
> win_process.c''')

Never add platform specific files directly to the argument list.
That's what the compat variables are there for.
And those two files clearly have nothing at all to do with scene
file parsing, so it would be the wrong place to add them anyway.
Link to librtproc.a instead.



> diff -r ray/src/common/win_process.c ray_dev/src/common/win_process.c
> 284c284
> <       cmdstr = quoted_cmdline(cmdpath, av);
> ---
> >       cmdstr = quoted_cmdline(cmdpath, av+1);

Correct as discussed.



> 290c290
> < int win_kill(RT_PID pid, int sig) /* we ignore sig... */
> ---
> > int win_kill(RT_PID pid, RT_PID sig) /* we ignore sig... */

Again: A signal number doesn't have the same type as a PID.



> 328c328
> <                       int win_kill(pid, 0);
> ---
> >                       win_kill(pid, 0);

Yeah, that did indeed look strange...



> diff -r ray/src/gen/SConscript ray_dev/src/gen/SConscript
> 6a7
> > socketlib = env['RAD_SOCKETLIB']
> 35c36
> <             source=p[1], LIBS=p[2] + mlib)
> ---
> >             source=p[1], LIBS=p[2] + mlib + socketlib)

Which programs asked for this?
You can instead add '$RAD_SOCKETLIB' to those that really need it
(and tell me which ones those are, so I can put it into CVS).



> diff -r ray/src/rt/rtrace.c ray_dev/src/rt/rtrace.c
> 31a32
> > #include  "random.h"

Looks like Windows does indeed need this.



> diff -r ray/src/util/ranimate.c ray_dev/src/util/ranimate.c
> 338c338,339
> <               if (errno == ENOENT && mkdir(vval(DIRECTORY), 0777) == 0)
> ---
> > /*            if (errno == ENOENT && mkdir(vval(DIRECTORY), 0777) == 0)*/
> >               if (errno == ENOENT && mkdir(vval(DIRECTORY)) == 0)

I added a macro to common/paths.h which should take care of this.



> diff -r ray/src/gen/mkillum.c ray_dev/src/gen/mkillum.c
> 168c168
> <       if (fscanf(fp, "%*s %d", &pid) != 1 || kill(pid, SIGALRM) < 0)
> ---
> >       if (fscanf(fp, "%*s %d", &pid) != 1 || kill(pid, SIGTERM) < 0)

> diff -r ray/src/util/rtcontrib.c ray_dev/src/util/rtcontrib.c
> 342c342
> <       if (fscanf(fp, "%*s %d", &pid) != 1 || kill(pid, SIGALRM) < 0)
> ---
> >       if (fscanf(fp, "%*s %d", &pid) != 1 || kill(pid, SIGTERM) < 0)

For the moment, I added macros that redefines SIGALRM as SIGTERM
if the former is not known, which is a portable workaround.

There are two things to consider here (for Greg, primarily):
First, both mkillum and rtcontrib define an identical(!) function
named killpersist(). This is bad design, because redundant code
multiplies potential errors.

Second: kill() on Windows is currently equivalent to the brute
force kill(pid, SIGKILL) on unix, where the actual signal number
is completely ignored. This means that rtrace can't do the
cleanup that it otherwise would do.

I think that all this persistence magic should be moved to our
process management library, so that it can be handled in a
platform independent manner with all functionality preserved.



> 979c979,980
> <       if (fseeko((FILE *)e->data, *(off_t *)p, SEEK_CUR) < 0) {
> ---
> > /*    if (fseeko((FILE *)e->data, *(off_t *)p, SEEK_CUR) < 0) {*/
> >       if (fseek((FILE *)e->data, (long)*(off_t *)p, SEEK_CUR) < 0) {

We better solve this temporarily via -Dfseeko=fseek in mingw.cfg,
until the actual replacement for fseeko() is ready.



> diff -r ray/src/util/SConscript ray_dev/src/util/SConscript
> 24a25,27
> > ('rtcontrib',    Split('rtcontrib.c') + [Version],
> >       ['rttrace', 'rtscene', 'rtpic', 'rtfunc', 'rtproc', 'rtio', 'rtmath',
> >       'rtargs', 'rtpath', 'rtcont', 'rtmem', 'rterror','ws2_32'])
> 34c37
> <       ['rtpic','rtargs','rtio','rtcont','rtmem','rtpath','rtmath',
> ---
> >       ['rtproc','rtpic','rtargs','rtio','rtcont','rtmem','rtpath','rtmath',

I changed the sequence here a little, which may or may not matter.
More importantly, I changed 'ws2_32' to '$RAD_SOCKETLIB'.

I also modified the build procedure for ranimate, so that the
decision between util/netproc.c and util/win_netproc.c is made
in the *.cfg file through the RAD_NETCOMPAT variable. This has
moved one more platform specific detail away from the local
SConscript files.



I commited all the changes to CVS and checked that it still
compiles on Linux.  There may be two or three small things that
you still need to look at more closely for mingw.  I assume that
all of those changes are also beneficial for compiling with VC,
so this is a very valueble contribution!


-schorsch

-- 
Georg Mischler  --  simulations developer  --  schorsch at schorsch com
+schorsch.com+  --  lighting design tools  --  http://www.schorsch.com/



More information about the Radiance-dev mailing list