pure-gen make should exit non-zero on error

3 views
Skip to first unread message

Ryan Schmidt

unread,
Jun 11, 2009, 10:39:51 PM6/11/09
to pure...@googlegroups.com
I don't have programs named "llvm-gcc" or "llvm-g++", and when
running make for pure-gen 0.5 I get this output:


sed -e 's?@version@?0.5?' -e 's?./dump-ast?/mp/lib/pure-gen/dump-
ast?' < pure-gen.pure > xxpure-gen.pure
ghc --make dump-ast.hs -o dump-ast
pure -c xxpure-gen.pure -o pure-gen
[1 of 1] Compiling Main ( dump-ast.hs, dump-ast.o )
Linking dump-ast ...
llvmc: Can't find program 'llvm-gcc'
sh: llvm-g++: command not found
rm -f xxpure-gen.pure


But "make" still exits with a zero status code. It should exit non-
zero if an error occurred, as it did here.

This is on Mac OS X 10.4.11.

Ryan Schmidt

unread,
Jun 11, 2009, 10:51:24 PM6/11/09
to pure...@googlegroups.com
On Jun 11, 2009, at 21:39, Ryan Schmidt wrote:

> I don't have programs named "llvm-gcc" or "llvm-g++", and when
> running make for pure-gen 0.5 I get this output:
>
>
> sed -e 's?@version@?0.5?' -e 's?./dump-ast?/mp/lib/pure-gen/dump-
> ast?' < pure-gen.pure > xxpure-gen.pure
> ghc --make dump-ast.hs -o dump-ast
> pure -c xxpure-gen.pure -o pure-gen
> [1 of 1] Compiling Main ( dump-ast.hs, dump-ast.o )
> Linking dump-ast ...
> llvmc: Can't find program 'llvm-gcc'
> sh: llvm-g++: command not found
> rm -f xxpure-gen.pure


In MacPorts, the llvm-gcc port provides executables called llvm-
gcc-4.2 and llvm-g++-4.2. I can't find any calls to llvm-gcc or llvm-g
++ or llvmc within the pure-gen code. How can I figure out who is
calling these programs and from where, so that I can tell it the
correct names of these executables on my system?


Albert Graef

unread,
Jun 13, 2009, 10:40:05 AM6/13/09
to pure...@googlegroups.com
Ryan Schmidt wrote:
> But "make" still exits with a zero status code. It should exit non-
> zero if an error occurred, as it did here.

Hmm yes, pure -c should probably return an exit code if llvmc and
llvm-g++ can't be executed. These are run through system(3), though
(i.e., through the shell), and I'm not sure how to interpret the return
value from that in a portable way. I put it on my TODO list, thanks for
reporting.

Albert

--
Dr. Albert Gr"af
Dept. of Music-Informatics, University of Mainz, Germany
Email: Dr.G...@t-online.de, a...@muwiinfa.geschichte.uni-mainz.de
WWW: http://www.musikinformatik.uni-mainz.de/ag

Albert Graef

unread,
Jun 13, 2009, 10:56:19 AM6/13/09
to pure...@googlegroups.com
Ryan Schmidt wrote:
> In MacPorts, the llvm-gcc port provides executables called llvm-
> gcc-4.2 and llvm-g++-4.2.

That's probably a bad idea, since llvmc also assumes that the llvm-gcc
executable is called just llvm-gcc. In any case, the command to invoke
the C++ linker is hardcoded as llvm-g++ in the Pure interpreter right
now. I could make this configurable (e.g., with a configure option, or
an environment variable interpreted at runtime), but then you'd still
have to deal with llvmc (which is part of LLVM, not Pure).

> I can't find any calls to llvm-gcc or llvm-g ++ or llvmc within the pure-gen code.

No, pure-gen itself never calls these programs, that happens when
pure-gen is compiled to a native executable using 'pure -c'.

The calls are in the Pure batch compiler, near the end of the
interpreter::compiler() method in interpreter.cc. Just search for the
two calls to system() in that module.

John Cowan

unread,
Jun 13, 2009, 9:14:13 PM6/13/09
to pure...@googlegroups.com
Albert Graef scripsit:

>
> Ryan Schmidt wrote:
> > But "make" still exits with a zero status code. It should exit non-
> > zero if an error occurred, as it did here.
>
> Hmm yes, pure -c should probably return an exit code if llvmc and
> llvm-g++ can't be executed. These are run through system(3), though
> (i.e., through the shell), and I'm not sure how to interpret the return
> value from that in a portable way.

system() returns the same values as waitpid(), so WIFEXITED(result) &&
(WEXITSTATUS(result) == 0) means success. However, you need to make the
shell return the same exit value as the command it executed, so append
"; exit $?" to the command to do so.

--
John Cowan co...@ccil.org http://ccil.org/~cowan
The penguin geeks is happy / As under the waves they lark
The closed-source geeks ain't happy / They sad cause they in the dark
But geeks in the dark is lucky / They in for a worser treat
One day when the Borg go belly-up / Guess who wind up on the street.

Albert Graef

unread,
Jun 14, 2009, 1:33:50 AM6/14/09
to pure...@googlegroups.com
John Cowan wrote:
> system() returns the same values as waitpid(), so WIFEXITED(result) &&
> (WEXITSTATUS(result) == 0) means success. However, you need to make the
> shell return the same exit value as the command it executed, so append
> "; exit $?" to the command to do so.

Unfortunately, that's not portable. Not all systems have a Un*x shell.

John Cowan

unread,
Jun 14, 2009, 2:08:06 AM6/14/09
to pure...@googlegroups.com
Albert Graef scripsit:

> Unfortunately, that's not portable. Not all systems have a Un*x shell.

Well, yes, not portable to Windows. But when it comes to executing
things, Windows is inherently broken. You can at least make things work
correctly in Posix systems even if Windows cranks along blindly.

--
John Cowan http://www.ccil.org/~cowan co...@ccil.org
Uneasy lies the head that wears the Editor's hat! --Eddie Foirbeis Climo

Reply all
Reply to author
Forward
0 new messages