Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Coreclr has missing FPREG entries causing the build to fail on FreeBSD #4086

Closed
josteink opened this issue Mar 29, 2015 · 12 comments · Fixed by dotnet/coreclr#734
Closed

Coreclr has missing FPREG entries causing the build to fail on FreeBSD #4086

josteink opened this issue Mar 29, 2015 · 12 comments · Fixed by dotnet/coreclr#734
Labels
os-freebsd FreeBSD OS

Comments

@josteink
Copy link
Member

I'm creating a separate issue/bug for this, because I'd like it to get some scrutiny.

I did hack a little bit at this myself, but I literally have zero experience doing direct FPU-programming. While I've fixed the related compiler-warnings and errors, I can in no way guarantee that the following code is correct:

// from x86/fpu.h: struct __envxmm64
#define FPREG_ControlWord(uc)   (((savefpu*)((uc)->uc_mcontext.mc_fpstate))->sv_env.en_cw)
#define FPREG_StatusWord(uc)    (((savefpu*)((uc)->uc_mcontext.mc_fpstate))->sv_env.en_sw)
#define FPREG_TagWord(uc)       (((savefpu*)((uc)->uc_mcontext.mc_fpstate))->sv_env.en_tw)
#define FPREG_ErrorOffset(uc)   (((savefpu*)((uc)->uc_mcontext.mc_fpstate))->sv_env.en_rip)                 // *(DWORD*)&((uc)->__fpregs_mem.rdp)
#define FPREG_ErrorSelector(uc) *((WORD*) &(((savefpu*)((uc)->uc_mcontext.mc_fpstate))->sv_env.en_rip) + 2) // *(((WORD*)&((uc)->__fpregs_mem.rip)) + 2)
#define FPREG_DataOffset(uc)    (((savefpu*)((uc)->uc_mcontext.mc_fpstate))->sv_env.en_rdp)                 // *(DWORD*)&((uc)->__fpregs_mem.rdp)
#define FPREG_DataSelector(uc)  *((WORD*) &(((savefpu*)((uc)->uc_mcontext.mc_fpstate))->sv_env.en_rdp) + 2) // *(((WORD*)&((uc)->__fpregs_mem.rdp)) + 2)
#define FPREG_MxCsr(uc)         (((savefpu*)((uc)->uc_mcontext.mc_fpstate))->sv_env.en_mxcsr)
#define FPREG_MxCsr_Mask(uc)    (((savefpu*)((uc)->uc_mcontext.mc_fpstate))->sv_env.en_mxcsr_mask)

(From josteink/coreclr@3dab47d )

Especially these lines where the original code I based it on had lots of pointer-magic going on, I have no idea if are translated correctly.

Any feedback or assistance on this issue would be appreciated.

@josteink
Copy link
Member Author

With that PR merged, we have 10 out of 11 registers worked out. Only 1 left to go. I've given it a try, but I don't really feel like I'm making any headway.

Anyone else care to have a look at this? @ajensenwaud ? @kangaroo ? @janhenke ?

@janhenke
Copy link
Member

I will try to take a look later. No promise on a solution though.

@janhenke
Copy link
Member

I did not come any further on this issue yet, if anybody else has an idea, be my guest. FPU/SSE/AVX state handling is also something new for me.

@josteink
Copy link
Member Author

Anyone else willing to take a cursory look at this one?

@emaste : You're already involved with FreeBSD and the LLVM-projects. Any chance you could contribute here, or find other suitable candidates?

Any help is appreciated. This is literally the last compilation bug to get coreclr into the linking-phase on FreeBSD.

@ajensenwaud
Copy link
Contributor

I already had a look over the last week but am not familiar enough with FPREG to fix it.

Anders Jensen-Waud

On 17 Apr 2015, at 17:20, Jostein Kjønigsen notifications@github.com wrote:

Anyone else willing to take a cursory look at this one?

@edmaste : You're already involved with FreeBSD and the LLVM-projects. Any chance you could contribute here, or find other suitable candidates?

Any help is appreciated. This is literally the last compilation bug to get coreclr into the linking-phase on FreeBSD.


Reply to this email directly or view it on GitHub.

@emaste
Copy link

emaste commented Apr 17, 2015

Which one is still missing? I'll try to take a look but haven't set up a build environment for this so can't easily check the remaining error.

@josteink
Copy link
Member Author

This is the part where we're literally missing one line of code:

https://github.com/dotnet/coreclr/blob/master/src/pal/src/include/pal/context.h#L128-L144

If you can't find a fix yourself, maybe you know someone else in the FreeBSD community who can take a look?

@emaste
Copy link

emaste commented Apr 17, 2015

I think you want sv_fp[index].fp_acc

@josteink
Copy link
Member Author

That seems to build! That's awesome! Thanks for the help!

I'll prepare a PR to close this issue now :)

josteink referenced this issue in josteink/coreclr Apr 17, 2015
FreeBSD now builds without compilation errors. For FreeBSD and glory!

                ,        ,
               /(        )`
               \ \___   / |
               /- _  `-/  '
              (/\/ \ \   /\
              / /   | `    \
              O O   ) /    |
              `-^--'`<     '
             (_.)  _  )   /
              `.___/`    /
                `-----' /
   <----.     __ / __   \
   <----|====O)))==) \) /====
   <----'    `--' `.__,' \
                |        |
                 \       /       /\
            ______( (_  / \______/
          ,'  ,-----'   |
          `--{__________)

This closes https://github.com/dotnet/coreclr/issues/594#issuecomment-93995183
@janvorli
Copy link
Member

LGTM, it is great to see to have the compilation issues behind us :-)

@josteink
Copy link
Member Author

@janvorli Did you mean to comment on PR? :)

@janvorli
Copy link
Member

@josteink I am sorry, I keep mixing PRs with issues.

@msftgits msftgits transferred this issue from dotnet/coreclr Jan 30, 2020
@ghost ghost locked as resolved and limited conversation to collaborators Jan 6, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
os-freebsd FreeBSD OS
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants