Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Moving boost to a system include #1137

Closed
bathmatt opened this issue Mar 14, 2017 · 14 comments
Closed

Moving boost to a system include #1137

bathmatt opened this issue Mar 14, 2017 · 14 comments
Assignees
Labels

Comments

@bathmatt
Copy link
Contributor

bathmatt commented Mar 14, 2017

I've been trying to move boost to a system include, however, when I run cmake and build it doesn't look right.

I applied these changes I think everywhere

./packages/stk/stk_classic/stk_usecases/io/CMakeLists.txt:INCLUDE_DIRECTORIES(SYSTEM ${Boost_INCLUDE_DIRS})

I make sure I didn't miss any, here is my silly script

dir-Trilinos (gcc) 31 $ grep INCLUDE_DIR `find . -name C\*txt -exec grep -l Boost {} \;`|grep Boost|grep -v SYSTEM

and it's clean. but I see

-I/projects/sems/install/rhel6-x86_64/sems/tpl/boost/1.59.0/gcc/5.3.0/base/include

and not the -Isystem

where's my mistake?

cd /home/mbetten/builds/panzer/cuda/debug/packages/stk/stk_topology/stk_topology && /projects/sems/install/rhel6-x86_64/sems/compiler/gcc/5.3.0/openmpi/1.10.1/bin/mpicxx -I/home/mbetten/builds/panzer/cuda/debug -I/home/mbetten/Trilinos/Trilinos/packages/stk/stk_topology -I/home/mbetten/builds/panzer/cuda/debug/packages/stk/stk_util/stk_util/use_cases -I/home/mbetten/Trilinos/Trilinos/packages/stk/stk_util/stk_util/use_cases -I/home/mbetten/builds/panzer/cuda/debug/packages/stk/stk_util/stk_util/registry -I/home/mbetten/Trilinos/Trilinos/packages/stk/stk_util/stk_util/registry -I/home/mbetten/builds/panzer/cuda/debug/packages/stk/stk_util/stk_util/parallel -I/home/mbetten/Trilinos/Trilinos/packages/stk/stk_util/stk_util/parallel -I/home/mbetten/builds/panzer/cuda/debug/packages/stk/stk_util/stk_util/diag -I/home/mbetten/Trilinos/Trilinos/packages/stk/stk_util/stk_util/diag -I/home/mbetten/Trilinos/Trilinos/packages/stk/stk_util/stk_util/environment -I/home/mbetten/builds/panzer/cuda/debug/packages/stk/stk_util/stk_util/util -I/home/mbetten/Trilinos/Trilinos/packages/stk/stk_util -I/home/mbetten/builds/panzer/cuda/debug/packages/stk/stk_util -I/home/mbetten/Trilinos/Trilinos/packages/stk/stk_util/stk_util/util -I/home/mbetten/Trilinos/Trilinos/packages/seacas/libraries/aprepro_lib -I/projects/sems/install/rhel6-x86_64/sems/tpl/boost/1.59.0/gcc/5.3.0/base/include -std=c++11 -g -O0   -o CMakeFiles/stk_topology.dir/topology.cpp.o -c /home/mbetten/Trilinos/Trilinos/packages/stk/stk_topology/stk_topology/topology.cpp
@bathmatt
Copy link
Contributor Author

boost_as_system_lib has been added @bartlettroscoe can you look at this one?
Thanks

@bartlettroscoe
Copy link
Member

@bathmatt, there should not be any statements like INCLUDE_DIRECTORIES(SYSTEM ${Boost_INCLUDE_DIRS}) in STK CMakeLists.txt files. That is not how you pull in a TPL. See:

I will rip all of these out and put in optional dependencies on the Boost and BoostTpl TPLs in the STK cmake/Dependencies.cmake files that will result in -isystem being added to all Boost includes by STK.

I should be able to verify this on my local machine by just doing a make VERBOSE=1 with STK and then grepping the output to make sure that Boost is always included with -isystem instead of -I. I will then push this to a branch for you to try.

@bartlettroscoe
Copy link
Member

@bathmatt, you don't build STKClassic anymore right? So I don't need to worry about fixing up files under that subpakage?

bartlettroscoe added a commit that referenced this issue Mar 15, 2017
This has taken care of 173 comile lines but there are another 199 compile
lines in STK that are getting included with -I.  I am not sure I understand
why.  It may be that I will need to refactor TriBITS to hanlde the TPL paths
separately.
@bartlettroscoe
Copy link
Member

I made some progress on this and pushed a trial commit to the branch:

However, there are still many compile lines that have the -I form of Boost include instead of the -isystem form. I am currently digging into why this might be the case and how to address this.

@bathmatt, one easy hack to remove get boost include dirs to use -isystem instead of -I is the post-process the CMake-generated flags.cmake files and replace -I<boost_include_dir> with -system <boost_include_dir>. Is that something that would help you in debugging in the short term? If so, I can likely provide a single script that will make these replacements pretty fast. If not, I will keep digging trying to figure out how to get CMake to pu in -isystem <boost_include_dir> instead of -I<boost_include_dir>.

@bathmatt
Copy link
Contributor Author

bathmatt commented Mar 15, 2017 via email

bartlettroscoe added a commit that referenced this issue Mar 15, 2017
)

This commit adds the direct TPL dependencies for the 'Boost' and 'BoostLibs'
TPLs to all of the STK subpackages.  This has been confirmed to result in
'-isystem' being used instead of '-I' for the Boost include directory for all
object files compiled for Boost libraries (except STKClassic which I did not
bother updating since no-one is using anymore).

Note that this does *not* currently result in '-isystem' getting used for
Boost includes for most of the object files related to test executbles in the
STK subpackages under:

* stk/stk_doc_tests/
* stk/stk_unit_tests/

This appears to be because this approach only works for exectuables that have
upstream libraries in the same SE package.  However, I don't think this is
worthwile to fix because the driving use case in #1137 should
only need the STK libraries built, not the STK tests and executables.  The
major TriBITS refactoring in TriBITSPub/TriBITS#63 will likely fix this
automatically.
@bartlettroscoe
Copy link
Member

@Bathmat, if you merge in the branch:

(which is only the commit is 644c9dc) and configure Trilinos with -DTrilinos_TPL_SYSTEM_INCLUDE_DIRS=ON, then all of the STK object files for STK libraries should build with boost include dir being passed in with -isystem instead of -I so they should not generate any warnings (see details below).

Note that this does not result in -isystem getting used for the boost include dir for most of the tests in the STK packages under:

  • stk/stk_doc_tests/
  • stk/stk_unit_tests/

But if you don't need to build STK tests and examples, then this should be a problem to you. However, if you need to build the STK tests, please let me know and I will see about getting -isystem used for boost includes for these as well.

@bmpersc, can you please work with the STK developers to see if they can accept the path in the commit 644c9dc back in the native STK source repo?

@bathmatt, are there other Trilinos packages that are emitting Boost warnings as well? If so, we can make the same changes in their Dependencies.cmake files as well and make them go away.

I am putting this Story in review. Please let me know if there is anything more I need to do with this. Otherwise, I will move on to #1140 (part of #1133).


DETAILED NOTES:

(2017/03/15)

I made some progress on this yesterday. I pushed the branch:

To [email protected]:trilinos/Trilinos.git
 * [new branch]      stk-boost-isystem-1137 -> stk-boost-isystem-1137

that has the commit:

21bee2a "WIP: Getting boost included with -isystem (#1137)"
Author: Roscoe A. Bartlett <[email protected]>
Date:   Wed Mar 15 08:35:35 2017 -0600 (4 hours ago)

M       packages/stk/stk_doc_tests/cmake/Dependencies.cmake
M       packages/stk/stk_exp/cmake/Dependencies.cmake
M       packages/stk/stk_expreval/cmake/Dependencies.cmake
M       packages/stk/stk_io/cmake/Dependencies.cmake
M       packages/stk/stk_mesh/cmake/Dependencies.cmake
M       packages/stk/stk_search/cmake/Dependencies.cmake
M       packages/stk/stk_search_util/cmake/Dependencies.cmake
M       packages/stk/stk_topology/cmake/Dependencies.cmake
M       packages/stk/stk_transfer/cmake/Dependencies.cmake
M       packages/stk/stk_unit_test_utils/cmake/Dependencies.cmake
M       packages/stk/stk_unit_tests/cmake/Dependencies.cmake
M       packages/stk/stk_usecases/cmake/Dependencies.cmake
M       packages/stk/stk_usecases/mesh/CMakeLists.txt
M       packages/stk/stk_usecases/util/CMakeLists.txt
M       packages/stk/stk_util/cmake/Dependencies.cmake

What that commit actually does is to just add the Boost and BoostLib TPLs to the Dependencies.cmake files. Then configuring Trilinos with:

./do-configure -DTrilinos_ENABLE_STK=ON -DTrilinos_TPL_SYSTEM_INCLUDE_DIRS=ON

this casues TriBITS to call INCLUDE_DIRECTORIES(SYSTEM ...) for all of the libraries and executables created in STK. To isolate the build lines for just the STK source files, I did:

$ make -j16
$ cd packages/stk/
$ rm `find . -name "*.o"`
$ make -j16 VERBOSE=1 &> make.out

However, this only resulted in 173 compile lines including the Boost headers using:

-isystem /projects/sems/install/rhel6-x86_64/sems/tpl/boost/1.55.0/gcc/4.8.4/base/include

as shown by:

$ grep \
  "system /projects/sems/install/rhel6-x86_64/sems/tpl/boost/1.55.0/gcc/4.8.4/base/include" make.out \
   | sort | wc -l
173

But there are still 199 compile lines that show that Boost is getting included using:

-I/projects/sems/install/rhel6-x86_64/sems/tpl/boost/1.55.0/gcc/4.8.4/base/include

as shown by:

$ grep \
  "I/projects/sems/install/rhel6-x86_64/sems/tpl/boost/1.55.0/gcc/4.8.4/base/include" make.out \
  | sort | wc -l
199

Given that 173 + 199 adds up nicely to 372 which is the number object files in stk:

$ find . -name "*.o" | wc -l
372

That is consistent that there are compile lines that have both forms of Boost includes as shown by:

$ grep \
  "system /projects/sems/install/rhel6-x86_64/sems/tpl/boost/1.55.0/gcc/4.8.4/base/include" make.out \
  | grep \
    "I/projects/sems/install/rhel6-x86_64/sems/tpl/boost/1.55.0/gcc/4.8.4/base/include" \
  | sort | wc -l
0

$ grep \
  "I/projects/sems/install/rhel6-x86_64/sems/tpl/boost/1.55.0/gcc/4.8.4/base/include" make.out \
  | grep "system /projects/sems/install/rhel6-x86_64/sems/tpl/boost/1.55.0/gcc/4.8.4/base/include" \
  | sort | wc -l
0

Also note that there are some object files built in the same STK subpackage that have either the -I or the -isystem form of the includes. Why is this?

It seems that many STK subpackages only have one form or the other of Boost include. Why is this?

So I spent about 40 minutes trying to figure out how to get grep and sed to extract out the build directory output from make and could not figure it out. It then spent 5 minutes writing a simple python program extract_2nd_column.py to do what I needed. Just shows you that it pays to just write a simple script some times intead of trying to figure out regexs and sed.

Here are all of the directories that use the -I<boost_include_dir> form:

$ grep \
  "I/projects/sems/install/rhel6-x86_64/sems/tpl/boost/1.55.0/gcc/4.8.4/base/include" make.out \
  | ~/Trilinos.base/extract_2nd_column.py | sort | uniq | less

/ascldap/users/rabartl/Trilinos.base/BUILDS/GCC-4.8.4/MPI_RELEASE_DEBUG_SHARED_PT/packages/stk/stk_doc_tests/stk_io
/ascldap/users/rabartl/Trilinos.base/BUILDS/GCC-4.8.4/MPI_RELEASE_DEBUG_SHARED_PT/packages/stk/stk_doc_tests/stk_topology
/ascldap/users/rabartl/Trilinos.base/BUILDS/GCC-4.8.4/MPI_RELEASE_DEBUG_SHARED_PT/packages/stk/stk_doc_tests/stk_util
/ascldap/users/rabartl/Trilinos.base/BUILDS/GCC-4.8.4/MPI_RELEASE_DEBUG_SHARED_PT/packages/stk/stk_unit_tests/stk_io
/ascldap/users/rabartl/Trilinos.base/BUILDS/GCC-4.8.4/MPI_RELEASE_DEBUG_SHARED_PT/packages/stk/stk_unit_tests/stk_mesh
/ascldap/users/rabartl/Trilinos.base/BUILDS/GCC-4.8.4/MPI_RELEASE_DEBUG_SHARED_PT/packages/stk/stk_unit_tests/stk_topology
/ascldap/users/rabartl/Trilinos.base/BUILDS/GCC-4.8.4/MPI_RELEASE_DEBUG_SHARED_PT/packages/stk/stk_unit_tests/stk_transfer
/ascldap/users/rabartl/Trilinos.base/BUILDS/GCC-4.8.4/MPI_RELEASE_DEBUG_SHARED_PT/packages/stk/stk_unit_tests/stk_util
/ascldap/users/rabartl/Trilinos.base/BUILDS/GCC-4.8.4/MPI_RELEASE_DEBUG_SHARED_PT/packages/stk/stk_unit_tests/stk_util/parallel

Here are all of the directories that use the -isystem <boost_include_dir> form:

$ grep \
  "system /projects/sems/install/rhel6-x86_64/sems/tpl/boost/1.55.0/gcc/4.8.4/base/include" make.out \
  | ~/Trilinos.base/extract_2nd_column.py | sort | uniq | less

/ascldap/users/rabartl/Trilinos.base/BUILDS/GCC-4.8.4/MPI_RELEASE_DEBUG_SHARED_PT/packages/stk/stk_expreval/stk_expreval
/ascldap/users/rabartl/Trilinos.base/BUILDS/GCC-4.8.4/MPI_RELEASE_DEBUG_SHARED_PT/packages/stk/stk_io/stk_io
/ascldap/users/rabartl/Trilinos.base/BUILDS/GCC-4.8.4/MPI_RELEASE_DEBUG_SHARED_PT/packages/stk/stk_io/stk_io/util
/ascldap/users/rabartl/Trilinos.base/BUILDS/GCC-4.8.4/MPI_RELEASE_DEBUG_SHARED_PT/packages/stk/stk_mesh/stk_mesh/base
/ascldap/users/rabartl/Trilinos.base/BUILDS/GCC-4.8.4/MPI_RELEASE_DEBUG_SHARED_PT/packages/stk/stk_search/integrationtest
/ascldap/users/rabartl/Trilinos.base/BUILDS/GCC-4.8.4/MPI_RELEASE_DEBUG_SHARED_PT/packages/stk/stk_search/stk_search
/ascldap/users/rabartl/Trilinos.base/BUILDS/GCC-4.8.4/MPI_RELEASE_DEBUG_SHARED_PT/packages/stk/stk_search/unit_tests
/ascldap/users/rabartl/Trilinos.base/BUILDS/GCC-4.8.4/MPI_RELEASE_DEBUG_SHARED_PT/packages/stk/stk_search_util/stk_search_util
/ascldap/users/rabartl/Trilinos.base/BUILDS/GCC-4.8.4/MPI_RELEASE_DEBUG_SHARED_PT/packages/stk/stk_search_util/unit_tests
/ascldap/users/rabartl/Trilinos.base/BUILDS/GCC-4.8.4/MPI_RELEASE_DEBUG_SHARED_PT/packages/stk/stk_topology/stk_topology
/ascldap/users/rabartl/Trilinos.base/BUILDS/GCC-4.8.4/MPI_RELEASE_DEBUG_SHARED_PT/packages/stk/stk_unit_tests/stk_mesh_fixtures
/ascldap/users/rabartl/Trilinos.base/BUILDS/GCC-4.8.4/MPI_RELEASE_DEBUG_SHARED_PT/packages/stk/stk_unit_test_utils
/ascldap/users/rabartl/Trilinos.base/BUILDS/GCC-4.8.4/MPI_RELEASE_DEBUG_SHARED_PT/packages/stk/stk_util/stk_util/diag
/ascldap/users/rabartl/Trilinos.base/BUILDS/GCC-4.8.4/MPI_RELEASE_DEBUG_SHARED_PT/packages/stk/stk_util/stk_util/environment
/ascldap/users/rabartl/Trilinos.base/BUILDS/GCC-4.8.4/MPI_RELEASE_DEBUG_SHARED_PT/packages/stk/stk_util/stk_util/parallel
/ascldap/users/rabartl/Trilinos.base/BUILDS/GCC-4.8.4/MPI_RELEASE_DEBUG_SHARED_PT/packages/stk/stk_util/stk_util/registry
/ascldap/users/rabartl/Trilinos.base/BUILDS/GCC-4.8.4/MPI_RELEASE_DEBUG_SHARED_PT/packages/stk/stk_util/stk_util/use_cases
/ascldap/users/rabartl/Trilinos.base/BUILDS/GCC-4.8.4/MPI_RELEASE_DEBUG_SHARED_PT/packages/stk/stk_util/stk_util/util

Hum, I wonder if this only impacts test executables? Do the STK subpakages in stk/stk_doc_tests/ and stk/stk_unit_tests/ have any libraries of their own or just test executables?

Look at:

$ find stk_doc_tests -name CMakeLists.txt -exec grep -nHi add_library {} \;
$ find stk_unit_tests -name CMakeLists.txt -exec grep -nHi add_library {} \;
stk_unit_tests/stk_mesh_fixtures/CMakeLists.txt:66:TRIBITS_ADD_LIBRARY(

I think that answers the question. It looks like in order for this appraoch to work with TriBITS currently a TriBITS exectuable must have a TriBITS library added before it. That is why we see the object files built in the directory stk/stk_unit_tests/stk_mesh_fixtures/ getting the -isystem <boost_include_dir> but not the other directories stk/stk_unit_tests/.

So is this a TriBITS defect? Perhaps, is it worth fixing? Likely not since the way that TriBITS handles TPLs and TPL include dirs is going to dramatically change as part of TriBITSPub/TriBITS#63. Therefore, for now, I think the solution is to just not built the STK tests and things should be good to go.

Going back and configuing STK with no tests enabled, and just building its libraries:

$ cd $HOME/Trilinos.base/BUILDS/GCC-4.8.4/MPI_RELEASE_DEBUG_SHARED_PT/
$ rm -r CMake*
$ ./do-configure -DTrilinos_ENABLE_STK=ON -DTrilinos_TPL_SYSTEM_INCLUDE_DIRS=ON -DTrilinos_ENABLE_TESTS=OFF
$ make -j16
$ cd packages/stk/
$ rm `find . -name "*.o"`
$ make -j16 VERBOSE=1 &> make.out

Looking for compiles using the -isystem <boost_include_dir> form shows:

$ grep \
  "system /projects/sems/install/rhel6-x86_64/sems/tpl/boost/1.55.0/gcc/4.8.4/base/include" make.out \
  | sort | wc -l
166

Looking for compiles using the -I<boost_include_dir> form shows:

$ grep \
  "I/projects/sems/install/rhel6-x86_64/sems/tpl/boost/1.55.0/gcc/4.8.4/base/include" make.out \
  | sort | wc -l
0

So it looks like if you are just building libraries, then the changes made to the STK Dependencies.cmake files in this commit should remove all of the warnings from Boost when building STK libraries.

Therefore, I amended this commit log and forced pushed it as:

To [email protected]:trilinos/Trilinos.git
 + 21bee2a...644c9dc stk-boost-isystem-1137 -> stk-boost-isystem-1137 (forced update)

@bartlettroscoe bartlettroscoe added the stage: in review Primary work is completed and now is just waiting for human review and/or test feedback label Mar 15, 2017
@bathmatt
Copy link
Contributor Author

@bartlettroscoe this is a huge huge improvement :)... @mwglass can we look at getting this through the chain of commits to get it into the trilinos build? Who takes care of this? Is it @bmpersc

@mwglass
Copy link
Contributor

mwglass commented Mar 16, 2017

Sure, if someone can send me a patch file with all the necessary changes we can get these pushed to the main STK repo.

@bathmatt
Copy link
Contributor Author

bathmatt commented Mar 16, 2017 via email

@bartlettroscoe
Copy link
Member

If someone can send me a patch file with all the necessary changes we can get these pushed to the main STK repo.

The patch can be created by simply doing:

$ cd Trilinos/
$ git remote add github [email protected]:trilinos/Trilinos.git
$ git fetch github
$ git format-patch -1 -o ../patches 644c9dc

The you just apply the patch to the STK native git repo using git am -p<num> <name-of-git-patch>.patch. That way, my commit message is preserved and I get credit for the fix :-)

@bartlettroscoe
Copy link
Member

Once this is committed to the STK repo and then STK is snapshotted back to Trilinos, then we can delete the branch stk-boost-isystem-1137 and close this issue.

@mwglass
Copy link
Contributor

mwglass commented Mar 17, 2017

The patch was pushed to the Sierra repo today so it will be available in the next STK snapshot.

@bathmatt
Copy link
Contributor Author

bathmatt commented Mar 17, 2017 via email

@bartlettroscoe
Copy link
Member

I believe this was resolved a long time ago. Closing as complete.

@bartlettroscoe bartlettroscoe removed the stage: in review Primary work is completed and now is just waiting for human review and/or test feedback label Aug 7, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants