Changes between Initial Version and Version 1 of Ticket #67773, comment 8


Ignore:
Timestamp:
Jul 21, 2023, 10:34:03 AM (14 months ago)
Author:
acjones8 (Alex Jones)
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #67773, comment 8

    initial v1  
    2222I'm in a little over my head here, but it seems like GCC redefines vector to `__vector` on non-apple platforms (among other reasons). I tried passing in `__APPLE_ALTIVEC__` like you did earlier with `__ALTIVEC__` using configure-append, but that didn't help any. Then I thought, maybe I'll just try manually redefining vector to `__vector` in the altivec code block in mosh. And that's the trick - GCC has no further complaints after that, the code compiles without any errors. I haven't extensively stress tested it, but after logging into my server and editing for a couple of minutes, everything seems to work fine, it behaves exactly as it did above without altivec. I was a little suspicious, but by disassembling the mosh binary using `otool -tvV`, I can see a few `vsplt` instructions in it, which the altivec manual I found says are vector splat commands. So it doesn't seem like this "fixes" the problem by disabling altivec in a roundabout way, it *does* seem to actually be using altivec now.
    2323
    24 So - with all that said, would it be okay if I offered a patch that fixes this problem? It would only need to add a single line of code, `#define vector __vector` at the top of the AltiVec block in ocb_internal.cc . I figure the potential impact should be minimal, since only G4 and G5 PowerPC users will ever use the AltiVec block anyway. It's very strange that mosh seems to have this issue, since as mentioned, openssh and other programs seem to compile with AltiVec support just fine... which I verified by using otool to disassemble `/opt/local/bin/ssh` and seeing lots of `vsplt` instructions, just like how my own test program has `vaddfp` in it.
     24So - with all that said, would it be okay if I offered a patch that fixes this problem? It would only need to add a single line of code, `#define vector __vector` at the top of the AltiVec block in ocb_internal.cc . I checked GCC 7's source code to look at its version of `altivec.h`, and it seems to lack the checks for ANSI or C++, it just straight up defines vector as `__vector` if `__APPLE_ALTIVEC__` isn't set. It doesn't seem like this would break compatibility, as GCC 7 seems to already be doing that redefinition.
     25
     26It's very strange that mosh seems to have this issue, since as mentioned, openssh and other programs seem to compile with AltiVec support just fine... which I verified by using otool to disassemble `/opt/local/bin/ssh` and seeing lots of `vsplt` and `vperm` instructions, just like how my own test program has `vaddfp` in it...