Skip to content

Fix Linux x86 build #50836

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

Merged
merged 1 commit into from
Jun 18, 2021
Merged

Fix Linux x86 build #50836

merged 1 commit into from
Jun 18, 2021

Conversation

gbalykov
Copy link
Member

@gbalykov gbalykov commented Apr 7, 2021

After this change next subsets can be built: clr.runtime+clr.corelib+clr.iltools+clr.dactools+clr.jit

Related issue: #40003

cc @alpencolt

@ghost
Copy link

ghost commented Apr 7, 2021

Tagging subscribers to this area: @hoyosjs
See info in area-owners.md if you want to be subscribed.

Issue Details

After this change next subsets can be built: clr.runtime+clr.corelib+clr.iltools+clr.dactools+clr.jit

Related issue: #40003

cc @alpencolt

Author: gbalykov
Assignees: -
Labels:

area-Infrastructure-coreclr

Milestone: -

@gbalykov gbalykov force-pushed the fix-linux-x86-build branch from 255716d to 70ae805 Compare April 7, 2021 19:35
@jkoritzinsky jkoritzinsky dismissed their stale review April 7, 2021 19:42

Changes have been made.

@@ -594,6 +594,7 @@ class CMiniMdBase : public IMetaModelCommonRO


protected:
DAC_ALIGNAS(8)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cc: @sdmaclea

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure why alignment to 8 is needed. I would rather expect DAC_ALIGNAS(IMetaModelCommonRO).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In src/coreclr/md/inc/VerifyLayouts.inc there's a 8byte alignment check for m_Schema:

BEGIN_TYPE(CMiniMdBase, 8)                                           //vtable ptr and first field 8-byte alignment
ALIGN_FIELD(CMiniMdBase, m_Schema, sizeof(CMiniMdSchema), 8)

This check started to fail after recent changes to CMiniMdBase and CMiniMdSchema, where new class fields were added. So, I've added explicit 8 byte alignment

@trylek
Copy link
Member

trylek commented May 10, 2021

In general this looks reasonable to me. Adding @janvorli as one of the few people familiar with our pre-existing runtime support for Linux x86. Once this PR has been resolved against the current runtime main and demonstrated passing PR testing, I believe it to be ready to be merged in.

@gbalykov gbalykov force-pushed the fix-linux-x86-build branch 2 times, most recently from 2c60c01 to 2f475ef Compare May 11, 2021 11:13
@gbalykov
Copy link
Member Author

Rebased with some additional changes after #49906

}
case ELEMENT_TYPE_PTR:
case ELEMENT_TYPE_PTR:
FALLTHROUGH;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think these need the FALLTHROUGH, call you please remove them here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, I'll remove this

SetObjectReference(pObjRef, objRef);
GCPROTECT_END();
}
VOID SetStaticOBJECTREF(OBJECTREF objRef);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the reason for moving this method out of the header?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is also related to access to FieldDesc on linux x86 in IsArgumentInRegister. Otherwise, there are build errors with SetStaticOBJECTREF defined in header, since now "field.h" is included in "common.h"

@@ -5415,7 +5415,7 @@ NOINLINE static void JIT_ReversePInvokeEnterRare2(ReversePInvokeFrame* frame, vo
// As a result, we specially decorate this method to have the correct calling convention
// and argument ordering for an HCALL, but we don't use the HCALL macros and contracts
// since this method doesn't follow the contracts.
void F_CALL_CONV HCCALL3(JIT_ReversePInvokeEnterTrackTransitions, ReversePInvokeFrame* frame, CORINFO_METHOD_HANDLE handle, void* secretArg)
HCIMPL3_RAW(void, JIT_ReversePInvokeEnterTrackTransitions, ReversePInvokeFrame* frame, CORINFO_METHOD_HANDLE handle, void* secretArg)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand the reason for switching some of the helpers calling convention. Can you please explain the purpose of these changes?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Calling convention doesn't change here. Actual problem is incorrect usage of HCCALL3 macro: it should be used to call function. HCIMPL3_RAW should be used for declaration instead.

@@ -367,6 +367,7 @@ inline void ClrRestoreNonvolatileContext(PCONTEXT ContextRecord)
#include "pefile.inl"
#include "excep.h"
#include "method.hpp"
#include "field.h"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Which part of the change needs to have the field.h include here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is required on linux x86, because IsArgumentInRegister accesses FieldDesc. Otherwise:

  /home/z/Dev/runtime3/src/coreclr/binder/../vm/callingconvention.h:416:46: error: member access into incomplete type 'FieldDesc'
                      CorElementType type = pFD->GetFieldType();

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please instead move the #include "frames.h" above the #include "field.h" and revert the change in field.h and field.cpp? I've verified it compiles fine on x86 Linux that way.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I still get the original build error this way, because "frames.h" itself includes "callingconvention.h", which requires "field.h" on x86. So, if "frames.h" is above "field.h" there still is error: member access into incomplete type 'FieldDesc'

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, I am sorry, I've found I've forgotten to add "cross" to my command line when trying to build for x86. Please keep it as you had it.

@@ -153,7 +153,7 @@ extern "C"
return TRUE;
}

extern "C" DLLEXPORT void __stdcall jitStartup(ICorJitHost* host)
extern "C" DLLEXPORT void jitStartup(ICorJitHost* host)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@BruceForstall is the __stdcall removal ok?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it is ok. We preffer to just use default calling convention whenever possible.

@gbalykov gbalykov force-pushed the fix-linux-x86-build branch from 2f475ef to 5fac123 Compare May 11, 2021 13:53
@gbalykov gbalykov force-pushed the fix-linux-x86-build branch from 5fac123 to 37717f6 Compare May 19, 2021 10:52
Copy link
Member

@janvorli janvorli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thank you!

@janvorli janvorli closed this May 21, 2021
@janvorli janvorli reopened this May 21, 2021
@gbalykov
Copy link
Member Author

Can this be merged?

@janvorli
Copy link
Member

@gbalykov the libraries tests are failing on Windows x86 in this PR, it might be related. Let me re-run them to see.

@gbalykov gbalykov force-pushed the fix-linux-x86-build branch from 37717f6 to 218272b Compare June 17, 2021 19:26
@gbalykov gbalykov force-pushed the fix-linux-x86-build branch from 218272b to 6c63f03 Compare June 18, 2021 08:44
@gbalykov
Copy link
Member Author

@janvorli I've rebased on latest master, test fails don't seem to be related, am I right?

@janvorli
Copy link
Member

@gbalykov right, they are in unrelated.

@janvorli janvorli merged commit f37f0b9 into dotnet:main Jun 18, 2021
@gbalykov
Copy link
Member Author

Thanks!

@ghost ghost locked as resolved and limited conversation to collaborators Jul 18, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants