Repository: spack/spack

Issue:
unzip conflict too harsh for Cray
Couldn't really find the right label since it's not really a build error, or a bug but I think that the conflict between unzip and `platform=cray` is a bit too much. I pretty much can't build `vim` on the Cray. I think maybe it should just not be built with `target=be`? @jrood-nrel thoughts?


Discussion:
Sure. Fix it however you want! The only reason I have that conflict is so that people were aware that unzip doesn't build on Cray at the moment. I don't know how I would fix it.
I took an interest in this, mainly for how to build on the Cray FE and
BE (which I have to do for other packages).  And when I say "Cray", I
mostly mean theta at Argonne.

First, @mamelara is right, the conflict for `platform=cray` is
technically too restrictive.  Unzip as is will build on Cray FE but
not BE.  That would be one solution, change the conflict to
`platform=cray os=be`.

But I can do better, I can fix unzip to build on the Cray BE.  It was
actually quite easy and tiny to fix it.  Just unpack the tar file and
build it natively with the BE compiler and you'll see the problem.

There's a stray `-s` linker flag (remove symbol table and relocation
information, ie, strip) that the Cray `cc` wrapper doesn't handle
cleanly.  So, remove the flag and then it builds.  (It already bulds
and runs on FE if you remove the conflict.)

Btw, there's also a spack package for zip which uses the same build
system as unzip.  But it doesn't have the extra `-s` flag, so zip
builds on Cray, both FE and BE.  Odd.

Anyway, I can prepare a PR for this, if you like.  It would be tiny,
safe, very low impact.

But I wanted to warn you of one thing.  I can make unzip build on
Cray, but if you build it for the default BE, then it won't run on the
FE.  (It dies with illegal instruction or some such.)

If you want to run it on the FE, then you need to build it with
`arch=cray-fe-x86_64`.
I merely added `unzip` for one of my projects in https://github.com/spack/spack/pull/7446. I don't have any stake in how it's handled on Cray. Sounds like the PR for this would be shorter than this issue 🙂 
@mwkrentel yeah sure! I was gonna work on it but if you already did it then go for it! Thanks!
@mamelara, @jrood-nrel, and @mwkrentel Can you please take a look at #12199?  I believe that should remove the conflict entirely.

Resolving patch:
diff --git a/var/spack/repos/builtin/packages/unzip/package.py b/var/spack/repos/builtin/packages/unzip/package.py
--- a/var/spack/repos/builtin/packages/unzip/package.py
+++ b/var/spack/repos/builtin/packages/unzip/package.py
@@ -14,9 +14,12 @@ class Unzip(MakefilePackage):
 
     version('6.0', '62b490407489521db863b523a7f86375')
 
-    conflicts('platform=cray', msg='Unzip does not currently build on Cray')
+    # The Cray cc wrapper doesn't handle the '-s' flag (strip) cleanly.
+    @when('platform=cray')
+    def patch(self):
+        filter_file(r'^LFLAGS2=.*', 'LFLAGS2=', join_path('unix', 'configure'))
 
-    make_args = ['-f', 'unix/Makefile']
+    make_args = ['-f', join_path('unix', 'Makefile')]
     build_targets = make_args + ['generic']
 
     def url_for_version(self, version):


Test patch: