indent_size = 2
# Generated code
-[*{_AssemblyInfo.cs,.notsupported.cs}]
+[*{_AssemblyInfo.cs,.notsupported.cs,AsmOffsets.cs}]
generated_code = true
# C# files
<add key="dotnet6-transport" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet6-transport/nuget/v3/index.json" />
<!-- Used for the Rich Navigation indexing task -->
<add key="richnav" value="https://pkgs.dev.azure.com/azure-public/vside/_packaging/vs-buildservices/nuget/v3/index.json" />
+ <!-- Used for NativeAOT ObjWriter. TODO: Delete once we publish the package from here. -->
+ <add key="dotnet-experimental" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-experimental/nuget/v3/index.json" />
</packageSources>
<disabledPackageSources>
<clear />
<RuntimeFlavor Condition="'$(RuntimeFlavor)' == ''">$(PrimaryRuntimeFlavor)</RuntimeFlavor>
</PropertyGroup>
+ <!-- CLR NativeAot only builds in a subset of the matrix -->
<PropertyGroup>
- <DefaultCoreClrSubsets>clr.native+linuxdac+clr.corelib+clr.tools+clr.nativecorelib+clr.packages</DefaultCoreClrSubsets>
+ <NativeAotSupported Condition="('$(TargetOS)' == 'windows' or '$(TargetOS)' == 'linux' or '$(TargetOS)' == 'OSX') and ('$(TargetArchitecture)' == 'x64' or '$(TargetArchitecture)' == 'arm64') and ('$(TargetOS)' != 'OSX' or '$(TargetArchitecture)' != 'arm64') and ('$(__DistroRid)' != 'linux-musl-arm64')">true</NativeAotSupported>
+ </PropertyGroup>
+
+ <PropertyGroup>
+ <DefaultCoreClrSubsets>clr.native+linuxdac+clr.corelib+clr.tools+clr.nativecorelib+clr.packages+clr.nativeaotlibs</DefaultCoreClrSubsets>
<!-- Even on platforms that do not support the CoreCLR runtime, we still want to build ilasm/ildasm. -->
<DefaultCoreClrSubsets Condition="'$(PrimaryRuntimeFlavor)' != 'CoreCLR'">clr.iltools+clr.packages</DefaultCoreClrSubsets>
<SubsetName Include="Clr.ILTools" Description="The CoreCLR IL tools." />
<SubsetName Include="Clr.Runtime" Description="The CoreCLR .NET runtime." />
<SubsetName Include="Clr.Native" Description="All CoreCLR native non-test components, including the runtime, jits, and other native tools." />
+ <SubsetName Include="Clr.NativeAotLibs" Description="The CoreCLR native AOT CoreLib, runtime, and other low level class libraries." />
+ <SubsetName Include="Clr.ObjWriter" Description="Object writer for the CoreCLR Native AOT compiler." />
<SubsetName Include="Clr.PalTests" OnDemand="true" Description="The CoreCLR PAL tests." />
<SubsetName Include="Clr.PalTestList" OnDemand="true" Description="Generate the list of the CoreCLR PAL tests. When using the command line, use Clr.PalTests instead." />
<SubsetName Include="Clr.Hosts" Description="The CoreCLR corerun test host." />
<ClrRuntimeBuildSubsets>$(ClrRuntimeBuildSubsets);ClrILToolsSubset=true</ClrRuntimeBuildSubsets>
</PropertyGroup>
+ <PropertyGroup Condition="$(_subset.Contains('+clr.nativeaotlibs+')) and '$(NativeAotSupported)' == 'true'">
+ <ClrRuntimeBuildSubsets>$(ClrRuntimeBuildSubsets);ClrNativeAotSubset=true</ClrRuntimeBuildSubsets>
+ </PropertyGroup>
+
<ItemGroup Condition="'$(ClrRuntimeBuildSubsets)' != '' or $(_subset.Contains('+clr.nativeprereqs+'))">
<ProjectToBuild Include="$(CoreClrProjectRoot)runtime-prereqs.proj" Category="clr" />
</ItemGroup>
$(CoreClrProjectRoot)tools\tieringtest\tieringtest.csproj;
$(CoreClrProjectRoot)tools\r2rdump\R2RDump.csproj;
$(CoreClrProjectRoot)tools\dotnet-pgo\dotnet-pgo.csproj;
+ $(CoreClrProjectRoot)tools\aot\ILCompiler\repro\repro.csproj;
$(CoreClrProjectRoot)tools\r2rtest\R2RTest.csproj" Category="clr" Condition="'$(DotNetBuildFromSource)' != 'true'"/>
<ProjectToBuild Include="$(CoreClrProjectRoot)tools\aot\crossgen2\crossgen2.csproj" Category="clr" />
+ <ProjectToBuild Include="$(CoreClrProjectRoot)tools\aot\ILCompiler.Build.Tasks\ILCompiler.Build.Tasks.csproj" Category="clr" Condition="'$(NativeAotSupported)' == 'true'" />
+ <ProjectToBuild Include="$(CoreClrProjectRoot)tools\aot\ILCompiler\ILCompiler.csproj" Category="clr" Condition="'$(NativeAotSupported)' == 'true'" />
+ <ProjectToBuild Include="$(CoreClrProjectRoot)nativeaot\BuildIntegration\BuildIntegration.proj" Category="clr" Condition="'$(NativeAotSupported)' == 'true'" />
<ProjectToBuild Condition="'$(TargetArchitecture)' != 'x64' and '$(BuildArchitecture)' == 'x64'" Include="$(CoreClrProjectRoot)tools\aot\crossgen2\crossgen2_crossarch.csproj" Category="clr" />
<ProjectToBuild Include="$(CoreClrProjectRoot)tools\aot\ILCompiler.TypeSystem.ReadyToRun.Tests\ILCompiler.TypeSystem.ReadyToRun.Tests.csproj"
<ProjectToBuild Include="$(CoreClrProjectRoot)tools\dotnet-pgo\dotnet-pgo-pack.proj" Pack="true" BuildInParallel="false" Category="clr" Condition="'$(DotNetBuildFromSource)' != 'true' and '$(RuntimeFlavor)' != 'Mono'"/>
</ItemGroup>
+ <ItemGroup Condition="$(_subset.Contains('+clr.nativeaotlibs+')) and '$(NativeAotSupported)' == 'true'">
+ <ProjectToBuild Include="$(CoreClrProjectRoot)nativeaot\System.Private.CoreLib\src\System.Private.CoreLib.csproj" Category="clr" />
+ <ProjectToBuild Include="$(CoreClrProjectRoot)nativeaot\System.Private.Reflection.Metadata\src\System.Private.Reflection.Metadata.csproj" Category="clr" />
+ <ProjectToBuild Include="$(CoreClrProjectRoot)nativeaot\System.Private.TypeLoader\src\System.Private.TypeLoader.csproj" Category="clr" />
+ <ProjectToBuild Include="$(CoreClrProjectRoot)nativeaot\System.Private.Interop\src\System.Private.Interop.csproj" Category="clr" />
+ <ProjectToBuild Include="$(CoreClrProjectRoot)nativeaot\System.Private.Reflection.Core\src\System.Private.Reflection.Core.csproj" Category="clr" />
+ <ProjectToBuild Include="$(CoreClrProjectRoot)nativeaot\System.Private.Reflection.Execution\src\System.Private.Reflection.Execution.csproj" Category="clr" />
+ <ProjectToBuild Include="$(CoreClrProjectRoot)nativeaot\System.Private.DisabledReflection\src\System.Private.DisabledReflection.csproj" Category="clr" />
+ <ProjectToBuild Include="$(CoreClrProjectRoot)nativeaot\System.Private.StackTraceMetadata\src\System.Private.StackTraceMetadata.csproj" Category="clr" />
+ <ProjectToBuild Include="$(CoreClrProjectRoot)nativeaot\Test.CoreLib\src\Test.CoreLib.csproj" Category="clr" />
+ </ItemGroup>
+
+ <ItemGroup Condition="$(_subset.Contains('+clr.objwriter+'))">
+ <ProjectToBuild Include="$(CoreClrProjectRoot)tools\aot\ObjWriter\objwriter.proj" Category="clr" />
+ </ItemGroup>
+
<!-- Mono sets -->
<ItemGroup Condition="$(_subset.Contains('+mono.llvm+')) or $(_subset.Contains('+mono.aotcross+')) or '$(TargetOS)' == 'iOS' or '$(TargetOS)' == 'iOSSimulator' or '$(TargetOS)' == 'tvOS' or '$(TargetOS)' == 'tvOSSimulator' or '$(TargetOS)' == 'MacCatalyst' or '$(TargetOS)' == 'Android' or '$(TargetOS)' == 'Browser'">
<ProjectToBuild Include="$(MonoProjectRoot)llvm\llvm-init.proj" Category="mono" />
endif()
endfunction()
+function(install_static_library targetName destination component)
+ if (NOT "${component}" STREQUAL "${targetName}")
+ get_property(definedComponents GLOBAL PROPERTY CLR_CMAKE_COMPONENTS)
+ list(FIND definedComponents "${component}" componentIdx)
+ if (${componentIdx} EQUAL -1)
+ message(FATAL_ERROR "The ${component} component is not defined. Add a call to `add_component(${component})` to define the component in the build.")
+ endif()
+ add_dependencies(${component} ${targetName})
+ endif()
+ install (TARGETS ${targetName} DESTINATION ${destination} COMPONENT ${component})
+ if (WIN32)
+ set_target_properties(${targetName} PROPERTIES
+ COMPILE_PDB_NAME "${targetName}"
+ COMPILE_PDB_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}"
+ )
+ install (FILES "$<TARGET_FILE_DIR:${targetName}>/${targetName}.pdb" DESTINATION ${destination} COMPONENT ${component})
+ endif()
+endfunction()
+
# install_clr(TARGETS targetName [targetName2 ...] [DESTINATIONS destination [destination2 ...]] [COMPONENT componentName])
function(install_clr)
set(multiValueArgs TARGETS DESTINATIONS)
add_subdirectory(tools/aot/jitinterface)
+if(NOT CLR_CROSS_COMPONENTS_BUILD)
+ # NativeAOT only buildable for a subset of CoreCLR-supported configurations
+ if((CLR_CMAKE_HOST_LINUX OR CLR_CMAKE_HOST_OSX OR CLR_CMAKE_HOST_WIN32) AND (CLR_CMAKE_HOST_ARCH_ARM64 OR CLR_CMAKE_HOST_ARCH_AMD64) AND NOT (CLR_CMAKE_HOST_OSX AND CLR_CMAKE_HOST_ARCH_ARM64))
+ add_subdirectory(nativeaot)
+ endif()
+endif(NOT CLR_CROSS_COMPONENTS_BUILD)
+
# Above projects do not build with these compile options
# All of the compiler options are specified in file compileoptions.cmake
# Do not add any new options here. They should be added in compileoptions.cmake
<Import Project="..\..\Directory.Build.props" />
<PropertyGroup>
- <BaseIntermediateOutputPath>$([MSBuild]::NormalizeDirectory('$(ArtifactsObjDir)', 'coreclr', '$(MSBuildProjectName)'))</BaseIntermediateOutputPath>
+ <IsNativeAotProject Condition="$(MSBuildProjectDirectory.Contains('nativeaot'))">true</IsNativeAotProject>
+ <BaseIntermediateOutputPath Condition="'$(IsNativeAotProject)' != 'true'">$([MSBuild]::NormalizeDirectory('$(ArtifactsObjDir)', 'coreclr', '$(MSBuildProjectName)'))</BaseIntermediateOutputPath>
+ <BaseIntermediateOutputPath Condition="'$(IsNativeAotProject)' == 'true'">$([MSBuild]::NormalizeDirectory('$(ArtifactsObjDir)', 'coreclr', 'nativeaot', '$(MSBuildProjectName)'))</BaseIntermediateOutputPath>
<IntermediateOutputPath Condition="'$(PlatformName)' == 'AnyCPU'">$(BaseIntermediateOutputPath)$(Configuration)\</IntermediateOutputPath>
<IntermediateOutputPath Condition="'$(PlatformName)' != 'AnyCPU'">$(BaseIntermediateOutputPath)$(PlatformName)\$(Configuration)\</IntermediateOutputPath>
<ProjectDir>$(MSBuildThisFileDirectory)</ProjectDir>
</Target>
<!-- Import targets here to have TargetPath and other macros defined. Limit to CoreLib. -->
- <Import Condition="'$(MSBuildProjectName)' == 'System.Private.CoreLib'" Project="$(RepositoryEngineeringDir)illink.targets" />
+ <Import Condition="'$(MSBuildProjectName)' == 'System.Private.CoreLib' or '$(IsNativeAotProject)' == 'true'" Project="$(RepositoryEngineeringDir)illink.targets" />
</Project>
if not "!string:-iltools-=!"=="!string!" (
set __CMakeTarget=!__CMakeTarget! iltools
)
+ if not "!string:-nativeaot-=!"=="!string!" (
+ set __CMakeTarget=!__CMakeTarget! nativeaot
+ )
)
if [!__CMakeTarget!] == [] (
set __CMakeTarget=install
usage_list+=("-pgoinstrument: generate instrumented code for profile guided optimization enabled binaries.")
usage_list+=("-skipcrossarchnative: Skip building cross-architecture native binaries.")
usage_list+=("-staticanalyzer: use scan_build static analyzer.")
-usage_list+=("-component: Build individual components instead of the full project. Available options are 'hosts', 'jit', 'runtime', 'paltests', 'alljits', and 'iltools'. Can be specified multiple times.")
+usage_list+=("-component: Build individual components instead of the full project. Available options are 'hosts', 'jit', 'runtime', 'paltests', 'alljits', 'iltools', and 'nativeaot'. Can be specified multiple times.")
setup_dirs_local()
{
add_component(runtime)
add_component(paltests paltests_install)
add_component(iltools)
+add_component(nativeaot)
# Define coreclr_all as the fallback component and make every component depend on this component.
# iltools and paltests should be minimal subsets, so don't add a dependency on coreclr_misc
endif (MSVC)
if(CLR_CMAKE_HOST_UNIX)
+ # Up for grabs to clean these warnings up
+ if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
+ add_compile_options(-Wno-error)
+ endif()
+
add_compile_options(-fno-rtti) # Native AOT runtime doesn't use RTTI
add_compile_options(-fno-exceptions) # Native AOT runtime doesn't use C++ exception handling
if(NOT CLR_CMAKE_TARGET_ARCH_WASM)
add_subdirectory(Full)
+else()
+ add_subdirectory(Portable)
endif()
-
-add_subdirectory(Portable)
(sizeof(InterfaceDispatchCacheEntry) * cCacheEntries),
sizeof(void*) * 2);
if (pCache == NULL)
- return NULL;
+ return (uintptr_t)NULL;
CID_COUNTER_INC(CacheAllocates);
#ifdef FEATURE_CID_STATS
#define offsetof(s,m) (uintptr_t)( (intptr_t)&reinterpret_cast<const volatile char&>((((s *)0)->m)) )
#endif // offsetof
+#ifdef __GNUC__
+#ifdef HOST_64BIT
+#define __int64 long
+#else // HOST_64BIT
+#define __int64 long long
+#endif // HOST_64BIT
+#endif // __GNUC__
+
#ifndef FORCEINLINE
#define FORCEINLINE __forceinline
#endif
+#ifdef __GNUC__
+#define __forceinline __attribute__((always_inline)) inline
+#endif // __GNUC__
+
#ifndef NOINLINE
#ifdef _MSC_VER
#define NOINLINE __declspec(noinline)
#define C_ASSERT(e) static_assert(e, #e)
#endif // C_ASSERT
-#ifdef __llvm__
-#define DECLSPEC_THREAD __thread
-#else // __llvm__
+#ifdef _MSC_VER
#define DECLSPEC_THREAD __declspec(thread)
-#endif // !__llvm__
+#else // _MSC_VER
+#define DECLSPEC_THREAD __thread
+#endif // !_MSC_VER
#ifndef __GCENV_BASE_INCLUDED__
#if !defined(_INC_WINDOWS)
// The MethodTable for the last allocation. This value is used inside of the GC allocator
// to emit allocation ETW events with type information. We set this value unconditionally to avoid
// race conditions where ETW is enabled after the value is set.
- DECLSPEC_THREAD static MethodTable * tls_pLastAllocationEEType;
+ static DECLSPEC_THREAD MethodTable * tls_pLastAllocationEEType;
// Tracks the amount of bytes that were reserved for threads in their gc_alloc_context and went unused when they died.
// Used for GC.GetTotalAllocatedBytes
#ifndef StressLog_h
#define StressLog_h 1
+#ifdef _MSC_VER
#define SUPPRESS_WARNING_4127 \
__pragma(warning(push)) \
__pragma(warning(disable:4127)) /* conditional expression is constant*/
#define POP_WARNING_STATE \
__pragma(warning(pop))
+#else // _MSC_VER
+#define SUPPRESS_WARNING_4127
+#define POP_WARNING_STATE
+#endif // _MSC_VER
#define WHILE_0 \
SUPPRESS_WARNING_4127 \
static uint8_t s_shiftTab[16];
};
+#ifndef __GNUC__
__declspec(selectany)
-int8_t VarInt::s_negLengthTab[16] =
+#endif
+int8_t
+#ifdef __GNUC__
+__attribute__((weak))
+#endif
+VarInt::s_negLengthTab[16] =
{
-1, // 0
-2, // 1
-5, // 15
};
+#ifndef __GNUC__
__declspec(selectany)
-uint8_t VarInt::s_shiftTab[16] =
+#endif
+uint8_t
+#ifdef __GNUC__
+__attribute__((weak))
+#endif
+VarInt::s_shiftTab[16] =
{
32-7*1, // 0
32-7*2, // 1
COOP_PINVOKE_HELPER(int, RhpGetThunkBlockSize, ())
{
ASSERT_UNCONDITIONALLY("NYI");
- return NULL;
+ return 0;
}
COOP_PINVOKE_HELPER(void, RhCallDescrWorker, (void * callDescr))
FORCEINLINE int32_t PalInterlockedExchange(_Inout_ int32_t volatile *pDst, int32_t iValue)
{
+#ifdef __clang__
return __sync_swap(pDst, iValue);
+#else
+ return __atomic_exchange_n(pDst, iValue, __ATOMIC_ACQ_REL);
+#endif
}
FORCEINLINE int64_t PalInterlockedExchange64(_Inout_ int64_t volatile *pDst, int64_t iValue)
{
+#ifdef __clang__
return __sync_swap(pDst, iValue);
+#else
+ return __atomic_exchange_n(pDst, iValue, __ATOMIC_ACQ_REL);
+#endif
}
FORCEINLINE int32_t PalInterlockedCompareExchange(_Inout_ int32_t volatile *pDst, int32_t iValue, int32_t iComparand)
REDHAWK_PALEXPORT _Ret_maybenull_ void* REDHAWK_PALAPI PalSetWerDataBuffer(_In_ void* pNewBuffer)
{
static void* pBuffer;
- return _InterlockedExchangePointer(&pBuffer, pNewBuffer);
+ return PalInterlockedExchangePointer(&pBuffer, pNewBuffer);
}
extern "C" HANDLE GetCurrentProcess()
INT32 slot = decoder.GetReversePInvokeFrameStackSlot();
assert(slot != NO_REVERSE_PINVOKE_FRAME);
- TADDR basePointer = NULL;
+ TADDR basePointer = (TADDR)NULL;
UINT32 stackBasedRegister = decoder.GetStackBaseRegister();
if (stackBasedRegister == NO_STACK_BASE_REGISTER)
{
INT32 slot = decoder.GetReversePInvokeFrameStackSlot();
assert(slot != NO_REVERSE_PINVOKE_FRAME);
- TADDR basePointer = NULL;
+ TADDR basePointer = (TADDR)NULL;
UINT32 stackBasedRegister = decoder.GetStackBaseRegister();
if (stackBasedRegister == NO_STACK_BASE_REGISTER)
{
<_CoreClrBuildArg Condition="'$(ClrPalTestsSubset)' == 'true'" Include="-component paltests" />
<_CoreClrBuildArg Condition="'$(ClrAllJitsSubset)' == 'true'" Include="-component alljits" />
<_CoreClrBuildArg Condition="'$(ClrILToolsSubset)' == 'true'" Include="-component iltools" />
+ <_CoreClrBuildArg Condition="'$(ClrNativeAotSubset)' == 'true'" Include="-component nativeaot" />
</ItemGroup>
<PropertyGroup>
}
_infinitelyRecursingCount++;
+#if SYSTEM_PRIVATE_CORELIB
// Note: our infrastructure for reporting this exception will again cause resource lookup.
// This is the most direct way of dealing with that problem.
string message = $"Infinite recursion during resource lookup within {System.CoreLib.Name}. This may be a bug in {System.CoreLib.Name}, or potentially in certain extensibility points such as assembly resolve events or CultureInfo names. Resource name: {key}";
Environment.FailFast(message);
+#endif
}
_currentlyLoading ??= new List<string>();