As my understanding, x86_64-unknown-none target should be ok with sse2 enabled manually through -Ctarget-feature=+sse2. However, while enabled, my program crashed with stack alignment issue.
My program is likely a mini OS, loaded to a KVM machine (created by KVM API), trying to setup GDT/IDT. With sse2 enabled, the generated code as below make use of sse2 registers (0x8f). And I checked the rsp register, it is aligned with 8 bytes, but not 16 bytes.
With only sse enabled, it works just fine. However, I am trying to use hard-float by deleted +soft-float in a self x86_64-unknown-none.json, and this will cause compiler_builtin compiled failed, because it need float number, so I enabled sse2, and got this alignment issue.
By googling, chat-gpt, what all I want is that how to ensure stack alignment is 16 bytes. And +strict-align, preferred-stack-boudnary etc. flags are not working.
Any suggestion?
And more background:
I am try to porting newlib to my little os wirtten in rust, every things works fine, except when invoking printf("%f", 3.14) like statement, it always print out zero. By printed out float number representation in c and rust, they do differs. In c, it is big-endian, in rust it is little endian. I do not find a way to change to little endian in c which it should be default to be little endian.
So I try to enable sse in rust os, and get errors above.
These may be two different issue.