Skip to content

IPOPT : Add empty compiler flags for IPOPT build to use spack flags#6714

Merged
scheibelp merged 1 commit intospack:developfrom
junkudo:bugfix/ipopt_flags
Jan 18, 2018
Merged

IPOPT : Add empty compiler flags for IPOPT build to use spack flags#6714
scheibelp merged 1 commit intospack:developfrom
junkudo:bugfix/ipopt_flags

Conversation

@junkudo
Copy link
Copy Markdown
Contributor

@junkudo junkudo commented Dec 18, 2017

This commit changes the IPOPT package file to pass in default empty
flags for CFLAGS, CPPFLAGS, CXXFLAGS, FFLAGS, and LDFLAGS to prevent
IPOPT from using default compiler flags that can override spack
provided flags.

Tries to address part of #6640

@scheibelp
Copy link
Copy Markdown
Member

If this were to extend the AutotoolsPackage would you be interested in using the upcoming logic in #6415? To use that, you would set flag_handler = build_system_flags in the ipopt package and declare the class with class Ipopt(AutotoolsPackage):; this would ensure that configure is invoked with CFLAGS=-g -O0, so you wouldn't have to set CFLAGS= to avoid a conflict with the compiler wrapper flag injection.

@junkudo
Copy link
Copy Markdown
Contributor Author

junkudo commented Dec 19, 2017

I think that sounds like a better solution to me. I can take another shot after #6415 is merged.

@junkudo
Copy link
Copy Markdown
Contributor Author

junkudo commented Dec 19, 2017

It looks like hypre might be another candidate for the flag_handler. It looks to me like default flags are conflicting with the compiler wrapper flag injection.

EDIT:
Scratch that - it looks like only the compilation of the configuration test of hypre has the combination of some default flags and spack flags. I'll go ahead and make issues for the packages I find that have conflicting flags (including this one).

@scheibelp
Copy link
Copy Markdown
Member

@junkudo #6415 has now been merged so you can try out the suggestion at #6714 (comment).

Another possibility is if you don't want to pass the compiler flags as arguments to configure but rather set up environment variables like CPPFLAGS=... before you invoke configure. This can be done by setting flag_handler = env_flags in the Ipopt package.

@junkudo
Copy link
Copy Markdown
Contributor Author

junkudo commented Jan 8, 2018

@scheibelp if you can, could you take a look at my prospective update to this PR at junkudo/spack@2b948b8? I'm running into an issue when I try to actually install ipopt with the same command as before with the new package.py. I'm pretty sure that has nothing to do with flag_handler and everything to do with my conversion to AutotoolsPackage.

For this new package.py, I see in the build output:

==> 'make' 'test'       
...
cd test; make test                                                                                                                                                                                          
make[2]: Entering directory `/g/g14/kudo4/spack/build/spack-stage/spack-stage-j5vFDb/Ipopt-3.12.7/Ipopt/test'                                                                                               
make[2]: stat: hs071_main.cpp: Too many levels of symbolic links                                                                                                                                            
make[2]: *** No rule to make target `hs071_main.cpp', needed by `hs071_main.o'.  Stop. 
...

In the existing package that does not use Autotools:

==> 'make' 'test' 
...

cd test; make test                                                                                                                                                                                          
make[2]: Entering directory `/g/g14/kudo4/spack/build/spack-stage/spack-stage-27zjLT/Ipopt-3.12.7/Ipopt/test'                                                                                               
if /g/g14/kudo4/spack/lib/spack/env/intel/icpc -DHAVE_CONFIG_H -I. -I`echo .` -I../src/Common  -I`echo ./../src/Common` -I`echo ./../src/LinAlg` -I`echo ./../src/LinAlg/TMatrices` -I`echo ./../src/Algori\
thm` -I`echo ./../src/Interfaces`   -O3 -ip -mp1  -DNDEBUG    -DIPOPT_BUILD -MT hs071_main.o -MD -MP -MF ".deps/hs071_main.Tpo" -c -o hs071_main.o hs071_main.cpp; \                                        
then mv -f ".deps/hs071_main.Tpo" ".deps/hs071_main.Po"; else rm -f ".deps/hs071_main.Tpo"; exit 1; fi

@scheibelp
Copy link
Copy Markdown
Member

This appears to be the same issue as #3387 where a self-referential symbolic link is created by configure.

If you set build_directory = 'spack-build' (as in #3388) is the issue resolved for you?

I should admit I'm not sure why this resolves the issue; I'd be interested in figuring that out if it is confirmed that this resolves the current issue in this thread.

@junkudo
Copy link
Copy Markdown
Contributor Author

junkudo commented Jan 9, 2018

Adding `build_directory = 'spack-build' breaks the build much earlier. It now fails right at the start of make:

configure: Main configuration of Ipopt successful                                                                                                                                                           
==> Executing phase: 'build'                                                                                                                                                                                
==> 'make'                                                                                                                                                                                                  
make: *** No targets specified and no makefile found.  Stop.  

Thoughts?

@scheibelp
Copy link
Copy Markdown
Member

You also have to update the definitions of build/install if you implement them and set build_directory (those functions start by default in the source base directory, so you would have to change to spack-build). As it happens, the AutotoolsPackage definition handles calling make install and make test automatically, and if you set parallel = False as a class attribute of ipopt the make invocations will also be serial. So I think all you need to do is remove the build/install definitions.

@junkudo junkudo force-pushed the bugfix/ipopt_flags branch from ea2ecf5 to 7883ce9 Compare January 11, 2018 07:07
@junkudo
Copy link
Copy Markdown
Contributor Author

junkudo commented Jan 11, 2018

@scheibelp - seems like setting the build_directory to spack-build solved the problem with the self-referential link. I updated the PR.

@junkudo
Copy link
Copy Markdown
Contributor Author

junkudo commented Jan 18, 2018

@scheibelp small bump 😄 Any chance you've looked at this?

@scheibelp
Copy link
Copy Markdown
Member

To be clear are all issues resolved (i.e. it's doing what you want like not overriding flags) and you are asking if I can merge it?

@junkudo
Copy link
Copy Markdown
Contributor Author

junkudo commented Jan 18, 2018

Yes to both. The issue is resolved and the flags are being passed in through via the build system flags. Like you previously advised, I did have to set build_directory = spack-build.

@scheibelp scheibelp merged commit 9704369 into spack:develop Jan 18, 2018
@scheibelp
Copy link
Copy Markdown
Member

Thanks!

ch741 pushed a commit to ch741/spack that referenced this pull request Apr 20, 2018
This makes use of the new flag_handler logic from 28d8784 to set
compiler flags for ipopt by passing them as arguments to the build
system rather than injecting them into the compiler wrappers. This
avoids conflicts between flags that are chosen by the build system
and flags that are set by the user.
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