Best way to pass environment variable to the build

388 views
Skip to first unread message

Martin Cuma

unread,
Nov 28, 2017, 1:19:45 PM11/28/17
to Spack
I am building a plugin to Quantum Espresso called Yambo, as a part of the whole QE build. QE plugins build with the make command, which in turn runs configure/make of the plugin. So, being a newbie, I simply add :make('yambo') to the install function of the QE's package.py.

Now, Yambo requires to redefine some environment variables, which I also do in the packages.py:
        env['F90']=spack_fc
        env['FCFLAGS']='-assume bscc -g -O3 -ip'

Those variables seem to pass to the Yambo's configure fine.

The tricky thing is CPP, which I set as:
        env['CPP']='gcc -E'
but, inside the build CPP='cpp'.

So, my first question is - does Spack define a CPP that may be overwriting my CPP, or, if not, how to change Spack's default CPP?

Second, I figure one could also set these environment variables from the command line like
CPP="gcc -E" spack install ....
would that be something you'd suggest instead? What makes me wary of this is that I'd prefer to use whatever CPP is default for the main QE build (since it works), and only redefine CPP for the Yambo build that's done after the main QE.

Thanks,
MC

Gamblin, Todd

unread,
Nov 28, 2017, 1:34:14 PM11/28/17
to Martin Cuma, Spack
On Nov 28, 2017, at 10:19 AM, Martin Cuma <mart...@gmail.com> wrote:

I am building a plugin to Quantum Espresso called Yambo, as a part of the whole QE build. QE plugins build with the make command, which in turn runs configure/make of the plugin. So, being a newbie, I simply add :make('yambo') to the install function of the QE's package.py.

Now, Yambo requires to redefine some environment variables, which I also do in the packages.py:
        env['F90']=spack_fc
        env['FCFLAGS']='-assume bscc -g -O3 -ip'

Those variables seem to pass to the Yambo's configure fine.

The tricky thing is CPP, which I set as:
        env['CPP']='gcc -E'
but, inside the build CPP='cpp'.

So, my first question is - does Spack define a CPP that may be overwriting my CPP, or, if not, how to change Spack's default CPP?

It doesn’t currently:

$ spack env libelf|grep CPP
CPPFLAGS=

only cppflags, which is empty here.

(note: spack env will be moved to spack build-env at some point to make way for virtual environment support)

So it should be fine to just set CPP as you do.  I might set it to:

 ‘%s -E’ % spack_cc

The compilers I can think of support -E — but I can’t say whether it’s completely universal.

Second, I figure one could also set these environment variables from the command line like
CPP="gcc -E" spack install ....
would that be something you'd suggest instead?

We actually don’t currently support setting this stuff on the command line, though you could make a variant that takes a string value, set *that* on the command line, and pass it to the build.  Generally if it’s a relevant build option, you want to expose it as a variant, but in this particular case I think it’s something the build should just handle — I don’t think people typically want/need a parameterized CPP.

What makes me wary of this is that I'd prefer to use whatever CPP is default for the main QE build (since it works), and only redefine CPP for the Yambo build that's done after the main QE.

In this case I would definitely do it in the yambo package.

-Todd



Thanks,
MC

--
You received this message because you are subscribed to the Google Groups "Spack" group.
To unsubscribe from this group and stop receiving emails from it, send an email to spack+un...@googlegroups.com.
To post to this group, send email to sp...@googlegroups.com.
Visit this group at https://groups.google.com/group/spack.
For more options, visit https://groups.google.com/d/optout.

Martin Cuma

unread,
Nov 28, 2017, 5:24:35 PM11/28/17
to Spack
Thanks Todd, good to know.

I have a follow up question, when I run:
$ spack env hpl %intel
==> Error: [Errno 2] No such file or directory

I am scratching my head how to debug this error - I recall at the SC17 tutorial a debug mode was mentioned but I can't find a note on this. How can I get more verbose/debug output in this case to see what's going on?

Thanks,
MC

Gamblin, Todd

unread,
Nov 28, 2017, 5:30:48 PM11/28/17
to Martin Cuma, Spack
that’s odd.  spack -d <command> will print debug output and the full stack trace. What happens when you run that?
--

Martin Cuma

unread,
Nov 28, 2017, 5:39:58 PM11/28/17
to Spack
Ah, the -d is the magic flag - sorry for missing the obvious - though spack -h or spack env -h does not show that as an option so I went under a premise that it does not exist.

Thanks,
MC

Gamblin, Todd

unread,
Nov 28, 2017, 5:43:56 PM11/28/17
to Martin Cuma, Spack
Perhaps we should promote it to the basic help, since it’s useful for debugging.  It should show up in spack help -a.
--

Martin Cuma

unread,
Nov 28, 2017, 7:03:52 PM11/28/17
to Spack
Yeah, the commands complexity can get daunting so the more command line help the better.

BTW, the reason for the failures turned out to be that I was running the "spack env" with variants that were space separated. That works with "spack spec" or "spack install", but not with "spack env" as whatever is behind the space is considered to be the next command. So, instead of "spack env hpl %intel", I had to do "spack env hpl%intel". Another thing to put to my cheat sheet ;-)

This is shown but not explicitly noted in the "spack env" help webpage, so, if I had checked that first I would probably get it right away.

Thanks,
MC
Reply all
Reply to author
Forward
0 new messages