On Wed, 22 Mar 2023, LIU Hao wrote:

This is the first attempt to allow the CRT to be built with `-masm=intel`. This patch itself may look messy because it contains a lot of inline changes. It should be examined with `git show --color-words='\S'`.

I have only verified that the CRT actually builds with {i686,x86_64}-w64-mingw32-gcc; not sure whether anything goes wrong. Martin, would you please include this patch in your nightly tests? `-masm=intel` requires the latest Clang, though. Older versions do not accept Intel syntax in inline assembly (but they do output Intel syntax).

Out of curiosity, do you have a reference to when it got this new support? (16.0.0 was just released a few days ago.) Anyway, I'll test with the very latest from git.

The patch successfully builds with Clang for x86_64 in the default (AT&T) mode for x86_64, but it breaks compilation for i686, where I get this:

<inline asm>:4:6: error: brackets expression not supported on this target
        jmp [__imp___scprintf]
            ^
1 error generated.

Looking at the change, I see that you're trying to use __REGISTER_PREFIX__ to disambiguate between the two modes - but as far as I can see, __REGISTER_PREFIX__ expands to an empty string in both GCC and Clang, for both i686 and x86_64, when running in the default AT&T mode. So I don't really see how that mode detection is meant to work?

(The same issue also affects the change in __guard_dispatch_icall_dummy, but it's not immediately appear as a build error when building mingw-w64-crt on its own.)


If building with -masm=intel (I configured by adding CFLAGS="-g -O2 -masm=intel" to the configure line), I'm getting lots of build errors though:

x86_64-w64-mingw32/include/psdk_inc/intrin-impl.h:811:1: error: unknown token in expression
__buildreadseg(__readgsbyte, unsigned char, "gs", "b")
^
include/psdk_inc/intrin-impl.h:222:14: note: expanded from macro '__buildreadseg' __asm__ ("mov{" a " %%" z ":%[offset], %[ret] | %[ret], %%" z ":%[offset]}" \
             ^
<inline asm>:2:10: note: instantiated into assembly here
        mov al, %gs:[rax]
                ^

../profile/mcountFunc.S:41:7: error: unknown token in expression
 push %rbp
      ^
../math/llrint.c:13:25: error: ambiguous operand size for instruction 'fistp'
  __asm__ __volatile__ ("fistp{ll} %0"  : "=m" (retval) : "t" (x) : "st");
                        ^
<inline asm>:2:8: note: instantiated into assembly here
        fistp [rsp]
              ^~~~~

../stdio/scanf.S:48:11: error: unknown token in expression
    pushq %rbp
          ^
../math/x86/_chgsignl.S:32:8: error: unknown token in expression
 movq (%rdx), %rax
       ^
../math/x86/acosf.c:20:13: error: unknown token in expression
        "fld    %%st\n\t"
                      ^
<inline asm>:2:6: note: instantiated into assembly here
        fld     %st
                ^
../math/x86/exp.def.h:87:71: error: ambiguous operand size for instruction 'fld' "{ fldt %2 | fld %2 }\n\t" /* 4 c0 */
                                                                      ^
<inline asm>:16:7: note: instantiated into assembly here
         fld [rip + offset c0]
             ^~~~~~~~~~~~~~~~~

(Plus lots, lots more - I just tried to pick up examples of each class of issues that I saw.)

// Martin



_______________________________________________
Mingw-w64-public mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public

Reply via email to