Menu

#419 E2K compilation fix for Linux 7-Zip 23.01

open
nobody
5
2023-10-26
2023-10-23
No

Fixed build linux 7-Zip 23.01 on E2K (MCST Elbrus 2000 architecture).

  • added initial support of e2k arch
  • used compiler built-in functions to get arch and CPU name
  • added temporary workaround for mcst-lcc compiler (don't support #pragma message)
2 Attachments

Discussion

  • Igor Pavlov

    Igor Pavlov - 2023-10-24

    I suppose that

    __builtin_cpu_name
    __builtin_cpu_arch
    

    will not work with clang.
    So we must use also __LCC__ check for these calls.
    I'll fix #pragma message and another problems.
    Thanks.

     
    • Ramil Sattarov

      Ramil Sattarov - 2023-10-25

      Thanks for your comment, I almost forgot about clang (this compiler has recently appeared on the Elbrus platform).

       
  • Igor Pavlov

    Igor Pavlov - 2023-10-25

    What exact possible output strings of __builtin_cpu_arch()?
    Are there any docs for this function?
    Does it read some registers from processor?

     

    Last edit: Igor Pavlov 2023-10-25
    • Ramil Sattarov

      Ramil Sattarov - 2023-10-25

      Possible output strings of const char* __builtin_cpu_arch (void) is:
      elbrus-v1, elbrus-v2, elbrus-v3, elbrus-v4, elbrus-v5 and elbrus-v6.
      The documentation for the mcst-lcc compiler is currently supplied only with the compiler itself.
      This function (as const char* __builtin_cpu_name (void) function) is designed to work in run-time, so it takes data from the processor registers.

       
  • Igor Pavlov

    Igor Pavlov - 2023-10-25

    please check also -m32 modes of clang and lcc:
    lcc doesn't use __ILP32__ by some reason, as another compilers.
    So we need more checks:
    CpuArch.h:

    #if  defined(__e2k__)
      #define MY_CPU_E2K
      #if defined(__ILP32__) || defined(__SIZEOF_POINTER__) && (__SIZEOF_POINTER__ == 4)
        #define MY_CPU_NAME "e2k-32"
        #define MY_CPU_SIZEOF_POINTER 4
      #else
        #define MY_CPU_NAME "e2k"
        #if defined(__LP64__) || defined(__SIZEOF_POINTER__) && (__SIZEOF_POINTER__ == 8)
          #define MY_CPU_SIZEOF_POINTER 8
        #endif
      #endif
      #define MY_CPU_64BIT
    #endif
    
     

    Last edit: Igor Pavlov 2023-10-25
    • Ramil Sattarov

      Ramil Sattarov - 2023-10-26

      Both clang and mcst-lcc use __ptr32__ and __ptr64__ respectively.
      Also clang has standard macros as _ILP32, __ILP32__and _LP64,__LP64__.
      So, __ptr32__ macro will be enough to check.

      A new workaround has also been added in patch for mcst-lcc compiler < 1.26.10 (don't support __attribute__((optimize("no-tree-vectorize"))))

       
      • Igor Pavlov

        Igor Pavlov - 2023-10-26

        __ptr32__ is not good, because gcc doesn't use __ptr32__.
        And I try to get some unification, where the code works same way in both gcc and clang for any platform.
        So __SIZEOF_POINTER__ check looks better for me.

         
        • Ramil Sattarov

          Ramil Sattarov - 2023-10-26

          Yeap, good idea, both compilers use this macro. So we can check only it.

          #if  defined(__e2k__)
            #define MY_CPU_E2K
            #if defined(__SIZEOF_POINTER__) && (__SIZEOF_POINTER__ == 4)
              #define MY_CPU_NAME "e2k-ptr32"
              #define MY_CPU_SIZEOF_POINTER 4
            #else
              #define MY_CPU_NAME "e2k"
              #define MY_CPU_SIZEOF_POINTER 8
            #endif
            #define MY_CPU_64BIT
          #endif
          

          "e2k-32" is not quite the correct name, since -mptr32 is not a 32—bit mode, like i386 or SPARC V8. This is a 64-bit mode with 32-bit pointers, as in x32 ABI for x86-64. Therefore, I suggest calling it "e2k-ptr32" above, so that there is no confusion and misunderstanding.

          There is no such thing as a "32-bit Elbrus". The base registers are always 64-bit, capable of being decomposed into 2 halves or combined into 2 pieces (for v5+).

           

          Last edit: Ramil Sattarov 2023-10-27

Log in to post a comment.