Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2002-12

Exit status of compiler on errors

5 messages · 3 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Tom Verhoeff

We use FreePascal in our education, and I am working on some scripts that help teachers to develop programming assignments for students. These assignments are then entered in PEACH (Programming Education And Contest Hosting system: peach.win.tue.nl), which automatically evaluates submitted programs and archives all results.

It turns out that the FreePascal compiler also generates a 0 exit status when there are (syntax) errors. Is there any way in which this can be changed? My scripts would be considerably simpler if the compiler generated a non-zero exit status when the compile is not successful.

Any suggestions? Have I overlooked the obvious? The Linux man page for fpc does not mention an exit status.

Tom

E-MAIL: T.Verhoeff @ TUE.NL | Fac. of Math. & Computing Science PHONE: +31 40 247 41 25 | Eindhoven University of Technology FAX: +31 40 245 17 33 | PO Box 513, NL-5600 MB Eindhoven http://www.win.tue.nl/~wstomv/ | The Netherlands

Reply by email

Michael Van Canneyt
to Tom Verhoeff
Tom Verhoeff wrote 14 lines
We use FreePascal in our education, and I am working on some scripts that help teachers to develop programming assignments for students. These assignments are then entered in PEACH (Programming Education And Contest Hosting system: peach.win.tue.nl), which automatically evaluates submitted programs and archives all results. It turns out that the FreePascal compiler also generates a 0 exit status when there are (syntax) errors. Is there any way in which this can be changed? My scripts would be considerably simpler if the compiler generated a non-zero exit status when the compile is not successful. Any suggestions? Have I overlooked the obvious? The Linux man page for fpc does not mention an exit status.

Do you use the fpc executable or the ppc386 executable ? The ppc386 executable should always generate a nonzero exit code if an error occurs. Our own automated testing system relies on this as well.

For the fpc executable this may be different, though. If you use this one, I suggest you use ppc386 instead; fpc offers no additional functionality yet except choosing the right cross-compiler if needed.

Michael.

Reply by email

Tom Verhoeff
Tom Verhoeff wrote 11 lines
We use FreePascal in our education, and I am working on some scripts that help teachers to develop programming assignments for students. These assignments are then entered in PEACH (Programming Education And Contest Hosting system: peach.win.tue.nl), which automatically evaluates submitted programs and archives all results. It turns out that the FreePascal compiler also generates a 0 exit status when there are (syntax) errors. Is there any way in which this can be changed? My scripts would be considerably simpler if the compiler generated a non-zero exit status when the compile is not successful.

I just discovered that invoking the compiler as ppc386 does give a proper exit status, but when invoking it as fpc it does not. (Still under Linux.)

Why is that?

By the way, this is also relevant when calling the compiler from within make files.

The gcc man page clearly explains the policy for its exit status. Maybe an idea for fpc (doc/manpage) as well.

Tom

Reply by email

Michael Van Canneyt
to Tom Verhoeff
Tom Verhoeff wrote 20 lines
Tom Verhoeff wrote: >We use FreePascal in our education, and I am working on some scripts >that help teachers to develop programming assignments for students. >These assignments are then entered in PEACH (Programming Education >And Contest Hosting system: peach.win.tue.nl), which automatically >evaluates submitted programs and archives all results. > >It turns out that the FreePascal compiler also generates a 0 exit >status when there are (syntax) errors. Is there any way in which >this can be changed? My scripts would be considerably simpler if >the compiler generated a non-zero exit status when the compile is >not successful. I just discovered that invoking the compiler as ppc386 does give a proper exit status, but when invoking it as fpc it does not. (Still under Linux.) Why is that?

'fpc' was later added. It does some checking of options, and then calls ppc386 or ppcm68k or the powerpc version. Normally it should exit with the same exit code as the executed binary, obviously, does doesn't always happen.

By the way, this is also relevant when calling the compiler from within make files.

The core developers never use fpc as far as I know. It's definitely a bug.

I would not recommend using FPC in any case. It has been introduced since it will replace the binary eventually when cross-compiling is more fully supported.

The gcc man page clearly explains the policy for its exit status. Maybe an idea for fpc (doc/manpage) as well.

I don't know whether there IS a clear 'policy' for the exit status other than that the exit status is nonzero for an error. :-)

Michael.

Reply by email

Florian Klaempfl
to Michael Van Canneyt
Michael Van Canneyt wrote 51 lines
On Fri, 6 Dec 2002, Tom Verhoeff wrote: >Tom Verhoeff wrote: > > >>We use FreePascal in our education, and I am working on some scripts >>that help teachers to develop programming assignments for students. >>These assignments are then entered in PEACH (Programming Education >>And Contest Hosting system: peach.win.tue.nl), which automatically >>evaluates submitted programs and archives all results. >> >>It turns out that the FreePascal compiler also generates a 0 exit >>status when there are (syntax) errors. Is there any way in which >>this can be changed? My scripts would be considerably simpler if >>the compiler generated a non-zero exit status when the compile is >>not successful. > >I just discovered that invoking the compiler as ppc386 does give >a proper exit status, but when invoking it as fpc it does not. >(Still under Linux.) > >Why is that? 'fpc' was later added. It does some checking of options, and then calls ppc386 or ppcm68k or the powerpc version. Normally it should exit with the same exit code as the executed binary, obviously, does doesn't always happen. >By the way, this is also relevant when calling the compiler from >within make files. The core developers never use fpc as far as I know. It's definitely a bug. I would not recommend using FPC in any case. It has been introduced since it will replace the binary eventually when cross-compiling is more fully supported. >The gcc man page clearly explains the policy for its exit status. >Maybe an idea for fpc (doc/manpage) as well. I don't know whether there IS a clear 'policy' for the exit status other than that the exit status is nonzero for an error. :-)

This is the important code of fpc.pp.

      { call ppcXXX }
      swapvectors;
      exec(ppcbin,ppccommandline);
      swapvectors;
      if doserror0 then
        error(ppcbin+' can''t be executed');
      halt(dosexitcode);

It should work correctly. So the error must be somewhere else...

Reply by email