Repository: spack/spack

Issue:
Failure while building NAMD after PR #19452 .
Failure while building NAMD after PR #19452 .
 ```
35     # init_tcl_pointers() declaration and implementation are inconsistent
 36     # "src/colvarproxy_namd.C", line 482: error: inherited member is not
 37     # allowed
 38     patch('inherited-member.patch', when='@:2.13')
 39     patch('inherited-member-2.14.patch', when='@2.14:')
```
If above patch is specific to nvhpc, please use "if-condition" to mention the same. I hope this is not generic patch.

build command: `spack install -v namd@2.12 interface=tcl ^charmpp backend=mpi build-target=charm++ ^openmpi@4.0.3`
output:

> ==> Installing namd
> ==> No binary for namd found: installing from source
> ==> Warning: gcc@8.3.1 cannot build optimized binaries for "zen2". Using best target possible: "zen"
> 1 out of 1 hunk FAILED -- saving rejects to file src/colvarproxy_namd.C.rej
> ==> Using cached archive: spack/var/spack/cache/_source-cache/archive/2a/2a1191909b1ab03bf0205971ad4d8ee9.tar.gz
> ==> Patch spack/var/spack/repos/builtin/packages/namd/inherited-member.patch failed.


_Originally posted by @mohan002 in https://github.com/spack/spack/pull/19452#issuecomment-720013402_


Discussion:
It looks like the only problem is that the patch doesn't apply cleanly to version 2.12. For now, can you make the following change:
```diff
diff --git a/var/spack/repos/builtin/packages/namd/package.py b/var/spack/repos/builtin/packages/namd/package.py
index f7cccc2b59..1ebaca64ae 100644
--- a/var/spack/repos/builtin/packages/namd/package.py
+++ b/var/spack/repos/builtin/packages/namd/package.py
@@ -35,7 +35,7 @@ class Namd(MakefilePackage):
     # init_tcl_pointers() declaration and implementation are inconsistent
     # "src/colvarproxy_namd.C", line 482: error: inherited member is not
     # allowed
-    patch('inherited-member.patch', when='@:2.13')
+    patch('inherited-member.patch', when='@2.13')
     patch('inherited-member-2.14.patch', when='@2.14:')
 
     depends_on('charmpp@6.10.1:', when="@2.14:")
```
@samcmill can you take a look at this and see if it's the right thing to do? Otherwise we may need a different patch for 2.12.
 > @samcmill can you take a look at this and see if it's the right thing to do? Otherwise we may need a different patch for 2.12.

@adamjstewart I concur with your proposed change.  Do you want to commit it, or would you prefer me to submit a PR?

I'll let you submit, ping me and I'll merge.

Resolving patch:
diff --git a/var/spack/repos/builtin/packages/namd/package.py b/var/spack/repos/builtin/packages/namd/package.py
--- a/var/spack/repos/builtin/packages/namd/package.py
+++ b/var/spack/repos/builtin/packages/namd/package.py
@@ -35,8 +35,8 @@ class Namd(MakefilePackage):
     # init_tcl_pointers() declaration and implementation are inconsistent
     # "src/colvarproxy_namd.C", line 482: error: inherited member is not
     # allowed
-    patch('inherited-member.patch', when='@:2.13')
-    patch('inherited-member-2.14.patch', when='@2.14:')
+    patch('inherited-member-2.13.patch', when='@2.13')
+    patch('inherited-member-2.14.patch', when='@2.14')
 
     depends_on('charmpp@6.10.1:', when="@2.14:")
     depends_on('charmpp@6.8.2', when="@2.13")


Test patch: