PixarAnimationStudios / OpenUSD

Universal Scene Description
http://www.openusd.org
Other
5.48k stars 1.14k forks source link

stackTrace.cpp doesn't compile for AArch64 #3008

Open v-bulle opened 2 months ago

v-bulle commented 2 months ago

When compiling for AArch64 with clang, the following code doesn't compile: usd/v23/pxr/base/arch/stackTrace.cpp

#if defined (ARCH_CPU_ARM)
    {
        long __file_result asm ("x0") = (long)file;
        char* const* __argv asm ("x1") = argv;
        char* const* __envp asm ("x2") = envp;
        long __num_execve asm ("x8") = 221;
        __asm__ __volatile__ (
            "svc 0"
            : "=r" (__file_result)
            : "r"(__num_execve), "r" (__file_result), "r" (__argv), "r" (__envp)
            : "memory"
        );
        result = __file_result;
    }

All the arguments file, argv, envp are already in the correct registers so, one fix could be to replace it with:

#if defined (ARCH_CPU_ARM)
    {
        __asm__ __volatile__ (
            "mov x8, 221\n\t"
            "svc 0"
            : "=r" (result)
            : "r" (file), "r" (argv), "r" (envp)
            : "memory", "x8"
        );
    }
jesschimein commented 2 months ago

Filed as internal issue #USD-9465