Skip to content

ncurses: fix pic and opt flags#12272

Merged
adamjstewart merged 1 commit intospack:developfrom
mwkrentel:krentel/ncurses-flags
Aug 7, 2019
Merged

ncurses: fix pic and opt flags#12272
adamjstewart merged 1 commit intospack:developfrom
mwkrentel:krentel/ncurses-flags

Conversation

@mwkrentel
Copy link
Copy Markdown
Member

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 patch is a simple and safe way of fixing the problem of building
ncurses unoptimized. But this brings up two larger issues that affect
autotools in general.

(1) Autotools was designed to pass compiler flags via CFLAGS and
CXXFLAGS on the configure line. You can either set these yourself, or
else leave them unspecified and then configure selects sensible
defaults, normally -g -O2.

The problem is that if you specify any flag, then configure uses
those as the entire flags. This erases the -O2 flag and builds the
package unoptimized, unless you add it yourself. You have to do
things like setting CFLAGS='-fPIC -g -O2' to keep -O2.

Cmake has an easier time of this because every cmake package has a
build_type variant which is orthogonal to the opt flags.

(2) The --with-shared and --with-cxx-shared options tell configure
to build shared libraries and libtool already adds the PIC flag.
(Run spack -d install and you see that -fPIC is added twice.)

So, adding -fPIC should not be necessary at all, and certainly
that's true for the latest ncurses and GNU. But there are reports
#3135 that libtool has trouble with the PGI compiler, at least for
older libtool.

I suspect that whatever problems there were have long since been
fixed. Either that or libtool is fundamentally broken for PGI, which
I find hard to believe.

This deserves further study, but we'll keep the -fPIC for now. The
last thing I want to do is break someone else's use case.

Resolves spack#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.
@adamjstewart adamjstewart merged commit 2f84db8 into spack:develop Aug 7, 2019
likask added a commit to likask/spack that referenced this pull request Aug 7, 2019
…upsream_develop

* commit 'f7026a058b63f5a3109691e2c3871ee77c08f756': (1881 commits)
  Version 19.8.1 of PLASMA  (spack#12299)
  new package: py-exodus (spack#12291)
  ncurses: fix pic and opt flags (spack#12272)
  pumi: new version 2.2.1 (spack#12282)
  tests: explain and test dependency flattening routines (spack#11993)
  graphviz package: add MacOS fixes and quartz support (spack#11128)
  Overhaul numpy package (spack#12170)
  mirrors: mirror config should use spack variable expansions (spack#9027)
  stacks: fix reference handling in env.write() (spack#12096)
  fltk: fix about variable types (spack#12292)
  Avoid sending empty reports to codecov (spack#12293)
  Packages/musl (spack#12288)
  c-blosc package: Add -std=gnu99 flag for gcc (spack#11959)
  Move new packages from tutorial to builtin (spack#12289)
  Balay/amrex 19.08 (spack#12287)
  openPMD-api: pre-load depend libs (spack#12279)
  Add version 19.8.0 of PLASMA (spack#12275)
  Add version 2.5.1 of MAGMA released today (spack#12274)
  ginkgo: add maintainers (spack#12273)
  new package: py-backports-tempfile (spack#12261)
  ...

# Conflicts:
#	.travis.yml
#	var/spack/repos/builtin/packages/moab/package.py
#	var/spack/repos/builtin/packages/mofem-cephas/package.py
#	var/spack/repos/builtin/packages/mofem-fracture-module/package.py
#	var/spack/repos/builtin/packages/mofem-users-modules/package.py
#	var/spack/repos/builtin/packages/petsc/package.py
dev-zero pushed a commit to dev-zero/spack that referenced this pull request Aug 13, 2019
Resolves spack#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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants