Skip to content

Commit

Permalink
Fix Linux x86 build (#50836)
Browse files Browse the repository at this point in the history
  • Loading branch information
gbalykov authored Jun 18, 2021
1 parent 5221db9 commit f37f0b9
Show file tree
Hide file tree
Showing 22 changed files with 74 additions and 42 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ extern "C"
return TRUE;
}

extern "C" DLLEXPORT void __stdcall jitStartup(ICorJitHost* host)
extern "C" DLLEXPORT void jitStartup(ICorJitHost* host)
{
// crossgen2 doesn't invoke DllMain on Linux/Mac (under PAL), so optionally do initialization work here.
InitializeShim();
Expand All @@ -157,7 +157,7 @@ extern "C" DLLEXPORT void __stdcall jitStartup(ICorJitHost* host)
pnjitStartup(g_ourJitHost);
}

extern "C" DLLEXPORT ICorJitCompiler* __stdcall getJit()
extern "C" DLLEXPORT ICorJitCompiler* getJit()
{
DWORD dwRetVal = 0;
PgetJit pngetJit;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ extern "C"
return TRUE;
}

extern "C" DLLEXPORT void __stdcall jitStartup(ICorJitHost* host)
extern "C" DLLEXPORT void jitStartup(ICorJitHost* host)
{
SetDefaultPaths();
SetLibName();
Expand Down Expand Up @@ -141,7 +141,7 @@ extern "C" DLLEXPORT void __stdcall jitStartup(ICorJitHost* host)
pnjitStartup(g_ourJitHost);
}

extern "C" DLLEXPORT ICorJitCompiler* __stdcall getJit()
extern "C" DLLEXPORT ICorJitCompiler* getJit()
{
DWORD dwRetVal = 0;
PgetJit pngetJit;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ extern "C"
return TRUE;
}

extern "C" DLLEXPORT void __stdcall jitStartup(ICorJitHost* host)
extern "C" DLLEXPORT void jitStartup(ICorJitHost* host)
{
SetDefaultPaths();
SetLibName();
Expand All @@ -117,7 +117,7 @@ extern "C" DLLEXPORT void __stdcall jitStartup(ICorJitHost* host)
pnjitStartup(g_ourJitHost);
}

extern "C" DLLEXPORT ICorJitCompiler* __stdcall getJit()
extern "C" DLLEXPORT ICorJitCompiler* getJit()
{
DWORD dwRetVal = 0;
PgetJit pngetJit;
Expand Down
8 changes: 5 additions & 3 deletions src/coreclr/clrdefinitions.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,14 @@ if(CLR_CMAKE_HOST_WIN32)
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
endif(CLR_CMAKE_HOST_WIN32)

add_compile_definitions($<$<NOT:$<BOOL:$<TARGET_PROPERTY:CROSSGEN_COMPONENT>>>:EnC_SUPPORTED>)
if(CLR_CMAKE_TARGET_ARCH_AMD64 OR CLR_CMAKE_TARGET_ARCH_I386)
if (NOT (CLR_CMAKE_TARGET_ARCH_I386 AND CLR_CMAKE_TARGET_UNIX))
add_compile_definitions($<$<NOT:$<BOOL:$<TARGET_PROPERTY:CROSSGEN_COMPONENT>>>:EnC_SUPPORTED>)
endif()
if(CLR_CMAKE_TARGET_ARCH_AMD64 OR (CLR_CMAKE_TARGET_ARCH_I386 AND CLR_CMAKE_TARGET_WIN32))
if(CLR_CMAKE_TARGET_WIN32)
add_compile_definitions($<$<NOT:$<BOOL:$<TARGET_PROPERTY:CROSSGEN_COMPONENT>>>:FEATURE_ENC_SUPPORTED>)
endif(CLR_CMAKE_TARGET_WIN32)
endif(CLR_CMAKE_TARGET_ARCH_AMD64 OR CLR_CMAKE_TARGET_ARCH_I386)
endif(CLR_CMAKE_TARGET_ARCH_AMD64 OR (CLR_CMAKE_TARGET_ARCH_I386 AND CLR_CMAKE_TARGET_WIN32))

# Features - please keep them alphabetically sorted
if(CLR_CMAKE_TARGET_WIN32)
Expand Down
2 changes: 1 addition & 1 deletion src/coreclr/debug/ee/funceval.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1635,7 +1635,7 @@ static void GCProtectAllPassedArgs(DebuggerEval *pDE,
#endif
}
#endif // TARGET_X86

FALLTHROUGH;
default:
//
// Ignorable - no need to protect
Expand Down
2 changes: 1 addition & 1 deletion src/coreclr/debug/ee/i386/x86walker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,7 @@ void NativeWalker::DecodeInstructionForPatchSkip(const BYTE *address, Instructio
case 2:
case 3:
pInstrAttrib->m_fIsCall = true;
// fall through
FALLTHROUGH;
case 4:
case 5:
pInstrAttrib->m_fIsAbsBranch = true;
Expand Down
2 changes: 1 addition & 1 deletion src/coreclr/gc/unix/gcenv.unix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -884,7 +884,7 @@ static size_t GetLogicalProcessorCacheSizeFromOS()
cacheSize = std::max(cacheSize, ( size_t) sysconf(_SC_LEVEL4_CACHE_SIZE));
#endif

#if defined(TARGET_LINUX) && !defined(HOST_ARM)
#if defined(TARGET_LINUX) && !defined(HOST_ARM) && !defined(HOST_X86)
if (cacheSize == 0)
{
//
Expand Down
4 changes: 4 additions & 0 deletions src/coreclr/gcinfo/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -82,3 +82,7 @@ create_gcinfo_lib(TARGET gcinfo_unix_armel OS unix ARCH armel)
create_gcinfo_lib(TARGET gcinfo_unix_arm OS unix ARCH arm)
create_gcinfo_lib(TARGET gcinfo_win_arm OS win ARCH arm)
create_gcinfo_lib(TARGET gcinfo_win_x86 OS win ARCH x86)

if (CLR_CMAKE_TARGET_ARCH_I386 AND CLR_CMAKE_TARGET_UNIX)
create_gcinfo_lib(TARGET gcinfo_unix_x86 OS unix ARCH x86)
endif (CLR_CMAKE_TARGET_ARCH_I386 AND CLR_CMAKE_TARGET_UNIX)
4 changes: 4 additions & 0 deletions src/coreclr/jit/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -516,6 +516,10 @@ target_compile_definitions(clrjit_unix_arm_${ARCH_HOST_NAME} PRIVATE ARM_SOFTFP
create_standalone_jit(TARGET clrjit_win_arm_${ARCH_HOST_NAME} OS win ARCH arm DESTINATIONS .)
create_standalone_jit(TARGET clrjit_win_x86_${ARCH_HOST_NAME} OS win ARCH x86 DESTINATIONS .)

if (CLR_CMAKE_TARGET_ARCH_I386 AND CLR_CMAKE_TARGET_UNIX)
create_standalone_jit(TARGET clrjit_unix_x86_${ARCH_HOST_NAME} OS unix ARCH x86 DESTINATIONS .)
endif (CLR_CMAKE_TARGET_ARCH_I386 AND CLR_CMAKE_TARGET_UNIX)

if (CLR_CMAKE_TARGET_UNIX)
if (NOT ARCH_TARGET_NAME STREQUAL s390x)
install_clr(TARGETS clrjit_unix_${ARCH_TARGET_NAME}_${ARCH_HOST_NAME} DESTINATIONS . COMPONENT jit)
Expand Down
3 changes: 3 additions & 0 deletions src/coreclr/md/inc/VerifyLayouts.inc
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,9 @@ FIELD(CLiteWeightStgdbRW, m_wszFileName, sizeof(void*))
FIELD(CLiteWeightStgdbRW, m_dwDatabaseLFT, 4)
FIELD(CLiteWeightStgdbRW, m_dwDatabaseLFS, 4)
FIELD(CLiteWeightStgdbRW, m_pStgIO, sizeof(void*))
#ifdef FEATURE_METADATA_EMIT_PORTABLE_PDB
FIELD(CLiteWeightStgdbRW, m_pPdbHeap, sizeof(void*))
#endif
END_TYPE(CLiteWeightStgdbRW, 8)

USING_ALIAS(CLiteWeightStgdb__CMiniMdRW__, CLiteWeightStgdb<CMiniMdRW>)
Expand Down
1 change: 1 addition & 0 deletions src/coreclr/md/inc/metamodel.h
Original file line number Diff line number Diff line change
Expand Up @@ -594,6 +594,7 @@ class CMiniMdBase : public IMetaModelCommonRO


protected:
DAC_ALIGNAS(8)
CMiniMdSchema m_Schema; // data header.
ULONG m_TblCount; // Tables in this database.
BOOL m_fVerifiedByTrustedSource; // whether the data was verified by a trusted source
Expand Down
2 changes: 1 addition & 1 deletion src/coreclr/pal/src/misc/sysinfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -558,7 +558,7 @@ PAL_GetLogicalProcessorCacheSizeFromOS()
cacheSize = std::max(cacheSize, (size_t)sysconf(_SC_LEVEL4_CACHE_SIZE));
#endif

#if defined(TARGET_LINUX) && !defined(HOST_ARM)
#if defined(TARGET_LINUX) && !defined(HOST_ARM) && !defined(HOST_X86)
if (cacheSize == 0)
{
//
Expand Down
9 changes: 5 additions & 4 deletions src/coreclr/vm/callingconvention.h
Original file line number Diff line number Diff line change
Expand Up @@ -423,11 +423,12 @@ class ArgIteratorTemplate : public ARGITERATOR_BASE
//@todo: Is it more apropos to call LookupApproxFieldTypeHandle() here?
TypeHandle fldHnd = pFD->GetApproxFieldTypeHandleThrowing();
CONSISTENCY_CHECK(!fldHnd.IsNull());
pMT = fldHnd.GetMethodTable();
pMT = fldHnd.GetMethodTable();
FALLTHROUGH;
}
case ELEMENT_TYPE_PTR:
case ELEMENT_TYPE_I:
case ELEMENT_TYPE_U:
case ELEMENT_TYPE_PTR:
case ELEMENT_TYPE_I:
case ELEMENT_TYPE_U:
case ELEMENT_TYPE_I4:
case ELEMENT_TYPE_U4:
{
Expand Down
4 changes: 2 additions & 2 deletions src/coreclr/vm/codeman.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1718,8 +1718,8 @@ static void LoadAndInitializeJIT(LPCWSTR pwzJitName, OUT HINSTANCE* phJit, OUT I
}

#ifdef FEATURE_MERGE_JIT_AND_ENGINE
EXTERN_C void __stdcall jitStartup(ICorJitHost* host);
EXTERN_C ICorJitCompiler* __stdcall getJit();
EXTERN_C void jitStartup(ICorJitHost* host);
EXTERN_C ICorJitCompiler* getJit();
#endif // FEATURE_MERGE_JIT_AND_ENGINE

BOOL EEJitManager::LoadJIT()
Expand Down
1 change: 1 addition & 0 deletions src/coreclr/vm/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,7 @@ inline void ClrRestoreNonvolatileContext(PCONTEXT ContextRecord)
#include "pefile.inl"
#include "excep.h"
#include "method.hpp"
#include "field.h"
#include "callingconvention.h"
#include "frames.h"
#include "qcall.h"
Expand Down
5 changes: 5 additions & 0 deletions src/coreclr/vm/crossgencompile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,11 @@ void CrawlFrame::GetExactGenericInstantiations(Instantiation *pClassInst, Instan
UNREACHABLE();
}

void SetObjectReferenceUnchecked(OBJECTREF *dst,OBJECTREF ref)
{
UNREACHABLE();
}

BOOL Object::SupportsInterface(OBJECTREF pObj, MethodTable* pInterfaceMT)
{
UNREACHABLE();
Expand Down
4 changes: 2 additions & 2 deletions src/coreclr/vm/exceptionhandling.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1219,7 +1219,7 @@ lExit: ;
invalidRevPInvoke = gcInfoDecoder.GetReversePInvokeFrameStackSlot() != NO_REVERSE_PINVOKE_FRAME;
#else // USE_GC_INFO_DECODER
hdrInfo gcHdrInfo;
DecodeGCHdrInfo(gcInfoToken, 0, &gcHdrInfo);
DecodeGCHdrInfo(codeInfo.GetGCInfoToken(), 0, &gcHdrInfo);
invalidRevPInvoke = gcHdrInfo.revPInvokeOffset != INVALID_REV_PINVOKE_OFFSET;
#endif // USE_GC_INFO_DECODER

Expand Down Expand Up @@ -4640,7 +4640,7 @@ VOID DECLSPEC_NORETURN UnwindManagedExceptionPass1(PAL_SEHException& ex, CONTEXT
invalidRevPInvoke = gcInfoDecoder.GetReversePInvokeFrameStackSlot() != NO_REVERSE_PINVOKE_FRAME;
#else // USE_GC_INFO_DECODER
hdrInfo gcHdrInfo;
DecodeGCHdrInfo(gcInfoToken, 0, &gcHdrInfo);
DecodeGCHdrInfo(codeInfo.GetGCInfoToken(), 0, &gcHdrInfo);
invalidRevPInvoke = gcHdrInfo.revPInvokeOffset != INVALID_REV_PINVOKE_OFFSET;
#endif // USE_GC_INFO_DECODER

Expand Down
3 changes: 3 additions & 0 deletions src/coreclr/vm/fcall.h
Original file line number Diff line number Diff line change
Expand Up @@ -1145,6 +1145,7 @@ struct FCSigCheck {
#define HCIMPL2_IV(rettype, funcname, a1, a2) rettype F_CALL_CONV funcname(int /* EAX */, int /* EDX */, a1, a2) { HCIMPL_PROLOG(funcname)
#define HCIMPL2VA(rettype, funcname, a1, a2) rettype F_CALL_VA_CONV funcname(a1, a2, ...) { HCIMPL_PROLOG(funcname)
#define HCIMPL3(rettype, funcname, a1, a2, a3) rettype F_CALL_CONV funcname(int /* EAX */, a2, a1, a3) { HCIMPL_PROLOG(funcname)
#define HCIMPL3_RAW(rettype, funcname, a1, a2, a3) rettype F_CALL_CONV funcname(int /* EAX */, a2, a1, a3) {
#define HCIMPL4(rettype, funcname, a1, a2, a3, a4) rettype F_CALL_CONV funcname(int /* EAX */, a2, a1, a4, a3) { HCIMPL_PROLOG(funcname)
#define HCIMPL5(rettype, funcname, a1, a2, a3, a4, a5) rettype F_CALL_CONV funcname(int /* EAX */, a2, a1, a5, a4, a3) { HCIMPL_PROLOG(funcname)

Expand All @@ -1169,6 +1170,7 @@ struct FCSigCheck {
#define HCIMPL2_IV(rettype, funcname, a1, a2) rettype F_CALL_CONV funcname(a1, a2) { HCIMPL_PROLOG(funcname)
#define HCIMPL2VA(rettype, funcname, a1, a2) rettype F_CALL_VA_CONV funcname(a1, a2, ...) { HCIMPL_PROLOG(funcname)
#define HCIMPL3(rettype, funcname, a1, a2, a3) rettype F_CALL_CONV funcname(a1, a2, a3) { HCIMPL_PROLOG(funcname)
#define HCIMPL3_RAW(rettype, funcname, a1, a2, a3) rettype F_CALL_CONV funcname(a1, a2, a3) {
#define HCIMPL4(rettype, funcname, a1, a2, a3, a4) rettype F_CALL_CONV funcname(a1, a2, a4, a3) { HCIMPL_PROLOG(funcname)
#define HCIMPL5(rettype, funcname, a1, a2, a3, a4, a5) rettype F_CALL_CONV funcname(a1, a2, a5, a4, a3) { HCIMPL_PROLOG(funcname)

Expand All @@ -1194,6 +1196,7 @@ struct FCSigCheck {
#define HCIMPL2_IV(rettype, funcname, a1, a2) rettype F_CALL_CONV funcname(a1, a2) { HCIMPL_PROLOG(funcname)
#define HCIMPL2VA(rettype, funcname, a1, a2) rettype F_CALL_VA_CONV funcname(a1, a2, ...) { HCIMPL_PROLOG(funcname)
#define HCIMPL3(rettype, funcname, a1, a2, a3) rettype F_CALL_CONV funcname(a1, a2, a3) { HCIMPL_PROLOG(funcname)
#define HCIMPL3_RAW(rettype, funcname, a1, a2, a3) rettype F_CALL_CONV funcname(a1, a2, a3) {
#define HCIMPL4(rettype, funcname, a1, a2, a3, a4) rettype F_CALL_CONV funcname(a1, a2, a3, a4) { HCIMPL_PROLOG(funcname)
#define HCIMPL5(rettype, funcname, a1, a2, a3, a4, a5) rettype F_CALL_CONV funcname(a1, a2, a3, a4, a5) { HCIMPL_PROLOG(funcname)

Expand Down
19 changes: 19 additions & 0 deletions src/coreclr/vm/field.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,25 @@

#include "peimagelayout.inl"

#ifndef DACCESS_COMPILE
VOID FieldDesc::SetStaticOBJECTREF(OBJECTREF objRef)
{
CONTRACTL
{
THROWS;
GC_TRIGGERS;
MODE_COOPERATIVE;
INJECT_FAULT(COMPlusThrowOM());
}
CONTRACTL_END

GCPROTECT_BEGIN(objRef);
OBJECTREF *pObjRef = (OBJECTREF *)GetCurrentStaticAddress();
SetObjectReference(pObjRef, objRef);
GCPROTECT_END();
}
#endif

// called from code:MethodTableBuilder::InitializeFieldDescs#InitCall
VOID FieldDesc::Init(mdFieldDef mb, CorElementType FieldType, DWORD dwMemberAttrs, BOOL fIsStatic, BOOL fIsRVA, BOOL fIsThreadLocal, LPCSTR pszFieldName)
{
Expand Down
17 changes: 1 addition & 16 deletions src/coreclr/vm/field.h
Original file line number Diff line number Diff line change
Expand Up @@ -483,22 +483,7 @@ class FieldDesc
return *(OBJECTREF *)GetCurrentStaticAddress();
}

VOID SetStaticOBJECTREF(OBJECTREF objRef)
{
CONTRACTL
{
THROWS;
GC_TRIGGERS;
MODE_COOPERATIVE;
INJECT_FAULT(COMPlusThrowOM());
}
CONTRACTL_END

GCPROTECT_BEGIN(objRef);
OBJECTREF *pObjRef = (OBJECTREF *)GetCurrentStaticAddress();
SetObjectReference(pObjRef, objRef);
GCPROTECT_END();
}
VOID SetStaticOBJECTREF(OBJECTREF objRef);

void* GetStaticValuePtr()
{
Expand Down
12 changes: 8 additions & 4 deletions src/coreclr/vm/jithelpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5471,7 +5471,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)
{
_ASSERTE(frame != NULL && handle != NULL);

Expand Down Expand Up @@ -5520,8 +5520,9 @@ void F_CALL_CONV HCCALL3(JIT_ReversePInvokeEnterTrackTransitions, ReversePInvoke
INSTALL_EXCEPTION_HANDLING_RECORD(&frame->record.m_ExReg);
#endif
}
HCIMPLEND_RAW

void F_CALL_CONV HCCALL1(JIT_ReversePInvokeEnter, ReversePInvokeFrame* frame)
HCIMPL1_RAW(void, JIT_ReversePInvokeEnter, ReversePInvokeFrame* frame)
{
_ASSERTE(frame != NULL);

Expand Down Expand Up @@ -5552,8 +5553,9 @@ void F_CALL_CONV HCCALL1(JIT_ReversePInvokeEnter, ReversePInvokeFrame* frame)
INSTALL_EXCEPTION_HANDLING_RECORD(&frame->record.m_ExReg);
#endif
}
HCIMPLEND_RAW

void F_CALL_CONV HCCALL1(JIT_ReversePInvokeExitTrackTransitions, ReversePInvokeFrame* frame)
HCIMPL1_RAW(void, JIT_ReversePInvokeExitTrackTransitions, ReversePInvokeFrame* frame)
{
_ASSERTE(frame != NULL);
_ASSERTE(frame->currentThread == GetThread());
Expand All @@ -5574,8 +5576,9 @@ void F_CALL_CONV HCCALL1(JIT_ReversePInvokeExitTrackTransitions, ReversePInvokeF
}
#endif
}
HCIMPLEND_RAW

void F_CALL_CONV HCCALL1(JIT_ReversePInvokeExit, ReversePInvokeFrame* frame)
HCIMPL1_RAW(void, JIT_ReversePInvokeExit, ReversePInvokeFrame* frame)
{
_ASSERTE(frame != NULL);
_ASSERTE(frame->currentThread == GetThread());
Expand All @@ -5589,6 +5592,7 @@ void F_CALL_CONV HCCALL1(JIT_ReversePInvokeExit, ReversePInvokeFrame* frame)
UNINSTALL_EXCEPTION_HANDLING_RECORD(&frame->record.m_ExReg);
#endif
}
HCIMPLEND_RAW

//========================================================================
//
Expand Down
2 changes: 1 addition & 1 deletion src/coreclr/vm/jitinterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12526,7 +12526,7 @@ void CEEJitInfo::getEHinfo(
#endif // CROSSGEN_COMPILE

#if defined(CROSSGEN_COMPILE)
EXTERN_C ICorJitCompiler* __stdcall getJit();
EXTERN_C ICorJitCompiler* getJit();
#endif // defined(CROSSGEN_COMPILE)

#ifdef FEATURE_INTERPRETER
Expand Down

0 comments on commit f37f0b9

Please sign in to comment.