ncurses: fix pic and opt flags (#12272)

Resolves #11932.

Move the PIC flags from CFLAGS on the configure line to the spack
compiler wrapper for ncurses.  The problem with the configure line for
autotools is that specifying CFLAGS sets the entire flags, thus
deleting the flags that configure would add itself.

By default, if CFLAGS is unspecified, then configure picks a sensible
default of `-g -O2`.  But adding `-fPIC` erases these and it ends up
building unoptimized.
This commit is contained in:
Mark W. Krentel 2019-08-06 22:21:25 -05:00 committed by Adam J. Stewart
parent e077532baf
commit 2f84db881b

View File

@ -36,10 +36,14 @@ class Ncurses(AutotoolsPackage):
def setup_environment(self, spack_env, run_env):
spack_env.unset('TERMINFO')
def flag_handler(self, name, flags):
if name == 'cflags' or name == 'cxxflags':
flags.append(self.compiler.pic_flag)
return (flags, None, None)
def configure(self, spec, prefix):
opts = [
'CFLAGS={0}'.format(self.compiler.pic_flag),
'CXXFLAGS={0}'.format(self.compiler.pic_flag),
'--with-shared',
'--with-cxx-shared',
'--enable-overwrite',