adelshokhy112 / linux-syscall-support

Automatically exported from code.google.com/p/linux-syscall-support
24 stars 24 forks source link

MIPS compilation fails with Clang: invalid input constraint '0' in asm #9

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?

Build for MIPS using clang 3.5 (-target mipsel-linux-uclibc -march=mips32)

What is the expected output? What do you see instead?

./linux_syscall_support.h:2977:14: error: invalid input constraint '0' in asm
  LSS_INLINE _syscall1(void *,  brk,             void *,      e)
             ^
./linux_syscall_support.h:2596:27: note: expanded from macro '_syscall1'
        LSS_REG(4, arg1); LSS_BODY(type, name, "=r", "r"(__r4));              \
                          ^
./linux_syscall_support.h:2583:35: note: expanded from macro 'LSS_BODY'
                                : "0"(__v0), ##__VA_ARGS__                    \
                                  ^
./linux_syscall_support.h:2978:14: error: invalid input constraint '0' in asm
  LSS_INLINE _syscall1(int,     chdir,           const char *,p)
             ^
./linux_syscall_support.h:2596:27: note: expanded from macro '_syscall1'
        LSS_REG(4, arg1); LSS_BODY(type, name, "=r", "r"(__r4));              \
                          ^
./linux_syscall_support.h:2583:35: note: expanded from macro 'LSS_BODY'
                                : "0"(__v0), ##__VA_ARGS__                    \
                                  ^

(many more of the same follow)

What version of the product are you using? On what operating system?

r31.

Please provide any additional information below.

Clang bug: http://llvm.org/bugs/show_bug.cgi?id=21613
The following patch is suggested as a workaround:

Index: linux_syscall_support.h
===================================================================
--- linux_syscall_support.h (revision 31)
+++ linux_syscall_support.h (working copy)
@@ -2579,7 +2579,7 @@
     #define LSS_BODY(type,name,r7,...)                                        \
           register unsigned long __v0 __asm__("$2") = __NR_##name;            \
           __asm__ __volatile__ ("syscall\n"                                   \
-                                : "+r"(__v0), r7 (__r7)                       \
+                                : "=r"(__v0), r7 (__r7)                       \
                                 : "0"(__v0), ##__VA_ARGS__                    \
                                 : LSS_SYSCALL_CLOBBERS);                      \
           LSS_RETURN(type, __v0, __r7)
@@ -3742,7 +3742,7 @@
       register unsigned long __v1 __asm__("$3");
       register unsigned long __r7 __asm__("$7");
       __asm__ __volatile__ ("syscall\n"
-                            : "+r"(__v0), "=r"(__v1), "=r" (__r7)
+                            : "=r"(__v0), "=r"(__v1), "=r" (__r7)
                             : "0"(__v0)
                             : "$8", "$9", "$10", "$11", "$12",
                               "$13", "$14", "$15", "$24", "$25", "memory"); 

Original issue reported on code.google.com by npenn...@cisco.com on 16 Jan 2015 at 11:29

GoogleCodeExporter commented 8 years ago
thanks ... posted https://codereview.chromium.org/836473006

Original comment by vapier@chromium.org on 16 Jan 2015 at 12:05

GoogleCodeExporter commented 8 years ago

Original comment by vapier@chromium.org on 16 Jan 2015 at 1:53

GoogleCodeExporter commented 8 years ago
committed!

Original comment by vapier@chromium.org on 22 Jan 2015 at 4:48