Skip to content

Spec Header Dirs: Only first include/#13991

Merged
ax3l merged 3 commits intospack:developfrom
ax3l:fix-includeMathDouble
Dec 7, 2019
Merged

Spec Header Dirs: Only first include/#13991
ax3l merged 3 commits intospack:developfrom
ax3l:fix-includeMathDouble

Conversation

@ax3l
Copy link
Copy Markdown
Member

@ax3l ax3l commented Dec 5, 2019

Avoid matching recurringly nested include paths that most certainly refer to internally shipped libraries in packages.
Example in CUDA Toolkit #13819 #13983, shipping a libc++ fork internally with libcu++ since 10.2.89: <prefix>/include/cuda/std/detail/libcxx/include.

Quick fix #13969

A more thorough solution is not to recursively search for headers anymore since this is against the idea of C/C++ facade headers: #13969 (comment) Unfortunately, it's not that easy for us to find which headers are facade and which ones are detail, but I am not sure we have to know anything besides the include dir locations.

Generally, just searching for any include/ in the overall path (instead of just taking the <prefix>/include) is dangerous as well. For example, spack could be installed in /my/large/software/include/here/is/axels/home/src/spack/ ;-)

General policy suggestion: just add <prefix>/include to the build environment by default. Packages that break this unix-wide default should provide the

@property
def headers(self):

@adamjstewart mentioned on Slack that some Python packages might need special treatment, let's see if we can find examples again to double check.

@adamjstewart
Copy link
Copy Markdown
Member

For the record, boost was the package I needed a way to locate the Python headers for. The following packages use the same logic:

$ grep 'spec.*python.*headers' */package.py
boost/package.py:            spec['python'].headers.directories[0],
dealii/package.py:                python_include = spec['python'].headers.directories[0]
neuron/package.py:            py_inc = spec['python'].headers.directories[0]
opencv/package.py:            python_include_dir = spec['python'].headers.directories[0]
openspeedshop-utils/package.py:        python_include = spec['python'].headers.directories[0]
openspeedshop/package.py:        python_include = spec['python'].headers.directories[0]
precice/package.py:            python_include = spec['python'].headers.directories[0]
psi4/package.py:                os.path.join(spec['python'].headers.directories[0]),
py-gpaw/package.py:        python_include = spec['python'].headers.directories[0]

I agree that the default should not be recursively searching for headers, we should just use prefix.include unless someone overrides headers.

@ax3l
Copy link
Copy Markdown
Member Author

ax3l commented Dec 5, 2019

So it's actually the CPython headers you are searching for in those packages. We then should just overwrite the python package's headers property :)

Side note: As far as I am aware, many C++ projects that build python bindings with Boost.Python or pybind11 can derive the corresponding python public headers by just passing the spec's python executable as an argument to CMake (if they use CMake). Not sure what autotools projects do.

@ax3l
Copy link
Copy Markdown
Member Author

ax3l commented Dec 5, 2019

Hm, CI says no. Have to go back to regex school.

@alalazo
Copy link
Copy Markdown
Member

alalazo commented Dec 5, 2019

@ax3l https://regex101.com/ 🙂

@ax3l ax3l force-pushed the fix-includeMathDouble branch from f45e5fc to d87fe9b Compare December 5, 2019 18:36
@ax3l
Copy link
Copy Markdown
Member Author

ax3l commented Dec 5, 2019

Pew the regex was fine, just forgot to update the group number below :D

@ax3l ax3l force-pushed the fix-includeMathDouble branch from d87fe9b to c19fd8c Compare December 6, 2019 07:50
@ax3l
Copy link
Copy Markdown
Member Author

ax3l commented Dec 6, 2019

Ha, what am I saying. TIL: non-capture groups.
Update: and now I also learned greediness.

@nazavode
Copy link
Copy Markdown
Contributor

nazavode commented Dec 6, 2019

Just tried this patch on top of f84ad57 and it looks like it is working fine, I was able to build stuff that was previously broken like openmpi+cuda ^hwloc+cuda ^cuda@10.2.89. Thanks!

Copy link
Copy Markdown
Member

@alalazo alalazo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wonder if we can do it changing only one character in the regex

@ax3l ax3l force-pushed the fix-includeMathDouble branch from aed496b to 05ed756 Compare December 6, 2019 18:44
@ax3l
Copy link
Copy Markdown
Member Author

ax3l commented Dec 6, 2019

Just adding a unit test as well before pushing the fix.

@ax3l ax3l force-pushed the fix-includeMathDouble branch 3 times, most recently from 3cc73b2 to 0ecfff8 Compare December 6, 2019 19:26
@ax3l ax3l force-pushed the fix-includeMathDouble branch from 0ecfff8 to 9a5b09f Compare December 6, 2019 21:02
ax3l and others added 2 commits December 6, 2019 13:02
Avoid matching recurringly nested include paths that usually
refer to internally shipped libraries in packages.
Example in CUDA Toolkit, shipping a libc++ fork internally
with libcu++ since 10.2.89:
`<prefix>/include/cuda/some/more/details/include/` or
`<prefix>/include/cuda/std/detail/libcxx/include`

regex: non-greedy first match of include

Co-Authored-By: Massimiliano Culpo <massimiliano.culpo@gmail.com>
@ax3l ax3l merged commit d705e96 into spack:develop Dec 7, 2019
@ax3l ax3l deleted the fix-includeMathDouble branch December 7, 2019 07:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

cuda: g++ finds C++ std headers shipped by cuda sdk instead of its own libstdc++

5 participants