Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/corert.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorChristian Scheuer <info@creatix.dk>2018-02-04 03:47:18 +0300
committerMorgan Brown <morganbr@users.noreply.github.com>2018-02-04 03:47:18 +0300
commitf19daaae780f2b0b2675792a8b0ef071dc1e58ff (patch)
tree638ec60b9f3f2c538b9288a1f8ab32f8dc8f0048 /src
parent2aaccdfc08dc2217bbc1777d4c98dda2a4867fb7 (diff)
Add support for building wasm on OSX and Ubuntu 16 (#5297)
* Enable wasm building on OSX. Upgrade libLLVM to 4.0.0 and LLVMSharp to 5.0.0 LLVM upgrade: Fix 'Use still stuck around after Def is destroyed' of the deleted basic blocks Add wasm support in runtest.sh Remove HelloWasm.csproj reference to .ilproj on non-windows OS because of dependency on ilasm Fix LinkNative target to execute correct commands for Unix wasm builds. Added support for building on Ubuntu 16.04.3 Update documentation on how to build WebAssembly.
Diffstat (limited to 'src')
-rw-r--r--src/BuildIntegration/Microsoft.NETCore.Native.Unix.props25
-rw-r--r--src/BuildIntegration/Microsoft.NETCore.Native.targets9
-rw-r--r--src/ILCompiler.WebAssembly/src/CodeGen/ILToWebAssemblyImporter.cs5
-rw-r--r--src/ILCompiler.WebAssembly/src/CodeGen/WebAssemblyObjectWriter.cs4
-rw-r--r--src/ILCompiler.WebAssembly/src/Compiler/WebAssemblyCodegenCompilation.cs1
-rw-r--r--src/ILCompiler.WebAssembly/src/ILCompiler.WebAssembly.csproj23
-rw-r--r--src/ILCompiler.WebAssembly/src/libLLVMdep.depproj22
-rwxr-xr-xsrc/Native/gen-buildsys-clang.sh1
8 files changed, 65 insertions, 25 deletions
diff --git a/src/BuildIntegration/Microsoft.NETCore.Native.Unix.props b/src/BuildIntegration/Microsoft.NETCore.Native.Unix.props
index 03be5996b..441f4754c 100644
--- a/src/BuildIntegration/Microsoft.NETCore.Native.Unix.props
+++ b/src/BuildIntegration/Microsoft.NETCore.Native.Unix.props
@@ -33,6 +33,11 @@ See the LICENSE file in the project root for more information.
</PropertyGroup>
<Target Name="SetupOSSpecificProps" DependsOnTargets="$(IlcDynamicBuildPropertyDependencies)">
+ <PropertyGroup>
+ <NativeLibraryExtension Condition="'$(NativeCodeGen)' != 'wasm'">.a</NativeLibraryExtension>
+ <NativeLibraryExtension Condition="'$(NativeCodeGen)' == 'wasm'">.bc</NativeLibraryExtension>
+ </PropertyGroup>
+
<ItemGroup>
<CppCompilerAndLinkerArg Include="-I $(IlcPath)/inc" />
<CppCompilerAndLinkerArg Condition="'$(Configuration)' == 'Debug'" Include="-g -O0" />
@@ -48,19 +53,19 @@ See the LICENSE file in the project root for more information.
<NativeLibrary Condition="$(NativeCodeGen) == ''" Include="$(IlcPath)/sdk/libRuntime.a" />
<NativeLibrary Condition="$(NativeCodeGen) == 'cpp'" Include="$(IlcPath)/sdk/libbootstrappercpp.a" />
<NativeLibrary Condition="$(NativeCodeGen) == 'cpp'" Include="$(IlcPath)/sdk/libPortableRuntime.a" />
- <NativeLibrary Condition="$(NativeCodeGen) == 'wasm'" Include="$(IlcPath)/sdk/libbootstrappercpp.a" />
- <NativeLibrary Condition="$(NativeCodeGen) == 'wasm'" Include="$(IlcPath)/sdk/libPortableRuntime.a" />
+ <NativeLibrary Condition="$(NativeCodeGen) == 'wasm'" Include="$(IlcPath)/sdk/libbootstrappercpp.bc" />
+ <NativeLibrary Condition="$(NativeCodeGen) == 'wasm'" Include="$(IlcPath)/sdk/libPortableRuntime.bc" />
</ItemGroup>
<ItemGroup>
- <NativeLibrary Include="$(IlcPath)/sdk/libSystem.Private.CoreLib.Native.a" />
- <NativeLibrary Include="$(IlcPath)/framework/System.Native.a" />
- <NativeLibrary Include="$(IlcPath)/framework/System.Globalization.Native.a" />
- <NativeLibrary Include="$(IlcPath)/framework/System.IO.Compression.Native.a" />
- <NativeLibrary Include="$(IlcPath)/framework/System.Net.Http.Native.a" />
- <NativeLibrary Include="$(IlcPath)/framework/System.Net.Security.Native.a" />
- <NativeLibrary Include="$(IlcPath)/framework/System.Security.Cryptography.Native.Apple.a" Condition="'$(TargetOS)' == 'OSX'"/>
- <NativeLibrary Include="$(IlcPath)/framework/System.Security.Cryptography.Native.OpenSsl.a" Condition="'$(TargetOS)' != 'OSX'"/>
+ <NativeLibrary Include="$(IlcPath)/sdk/libSystem.Private.CoreLib.Native$(NativeLibraryExtension)" />
+ <NativeLibrary Include="$(IlcPath)/framework/System.Native$(NativeLibraryExtension)" />
+ <NativeLibrary Include="$(IlcPath)/framework/System.Globalization.Native$(NativeLibraryExtension)" />
+ <NativeLibrary Include="$(IlcPath)/framework/System.IO.Compression.Native$(NativeLibraryExtension)" />
+ <NativeLibrary Include="$(IlcPath)/framework/System.Net.Http.Native$(NativeLibraryExtension)" />
+ <NativeLibrary Include="$(IlcPath)/framework/System.Net.Security.Native$(NativeLibraryExtension)" />
+ <NativeLibrary Include="$(IlcPath)/framework/System.Security.Cryptography.Native.Apple$(NativeLibraryExtension)" Condition="'$(TargetOS)' == 'OSX'"/>
+ <NativeLibrary Include="$(IlcPath)/framework/System.Security.Cryptography.Native.OpenSsl$(NativeLibraryExtension)" Condition="'$(TargetOS)' != 'OSX'"/>
</ItemGroup>
<ItemGroup Condition="'$(TargetOS)' == 'OSX'">
diff --git a/src/BuildIntegration/Microsoft.NETCore.Native.targets b/src/BuildIntegration/Microsoft.NETCore.Native.targets
index 1e70f4aa4..e93c1d4de 100644
--- a/src/BuildIntegration/Microsoft.NETCore.Native.targets
+++ b/src/BuildIntegration/Microsoft.NETCore.Native.targets
@@ -214,8 +214,8 @@ See the LICENSE file in the project root for more information.
<MakeDir Directories="$([System.IO.Path]::GetDirectoryName($(NativeBinary)))" />
- <Exec Command="$(CppLinker) @(CustomLinkerArg, ' ')" Condition="'$(OS)' != 'Windows_NT' and '$(NativeLib)' != 'Static'" />
- <Exec Command="$(CppLibCreator) @(CustomLibArg, ' ')" Condition="'$(OS)' != 'Windows_NT' and '$(NativeLib)' == 'Static'" />
+ <Exec Command="$(CppLinker) @(CustomLinkerArg, ' ')" Condition="'$(OS)' != 'Windows_NT' and '$(NativeLib)' != 'Static' and '$(NativeCodeGen)' != 'wasm'" />
+ <Exec Command="$(CppLibCreator) @(CustomLibArg, ' ')" Condition="'$(OS)' != 'Windows_NT' and '$(NativeLib)' == 'Static' and '$(NativeCodeGen)' != 'wasm'" />
<WriteLinesToFile File="$(NativeIntermediateOutputPath)link.rsp" Lines="@(CustomLinkerArg)" Overwrite="true" Condition="'$(OS)' == 'Windows_NT' and '$(NativeLib)' != 'Static'" />
<Exec Command="$(CppLinker) @&quot;$(NativeIntermediateOutputPath)link.rsp&quot;" Condition="'$(OS)' == 'Windows_NT' and '$(NativeLib)' != 'Static' and '$(NativeCodeGen)' != 'wasm'" />
@@ -224,12 +224,13 @@ See the LICENSE file in the project root for more information.
<PropertyGroup>
<EmccArgs>&quot;$(NativeObject)&quot; -o &quot;$(NativeBinary)&quot; -s WASM=1 -s ALLOW_MEMORY_GROWTH=1 </EmccArgs>
- <EmccArgs Condition="'$(Platform)'=='wasm'">$(EmccArgs) &quot;$(IlcPath)\sdk\libPortableRuntime.bc&quot; &quot;$(IlcPath)\sdk\libbootstrappercpp.bc&quot; </EmccArgs>
+ <EmccArgs Condition="'$(Platform)'=='wasm'">$(EmccArgs) &quot;$(IlcPath)/sdk/libPortableRuntime.bc&quot; &quot;$(IlcPath)/sdk/libbootstrappercpp.bc&quot; </EmccArgs>
<EmccArgs Condition="'$(Configuration)'=='Release'">$(EmccArgs) -O2 --llvm-lto 2</EmccArgs>
<EmccArgs Condition="'$(Configuration)'=='Debug'">$(EmccArgs) -g3</EmccArgs>
</PropertyGroup>
- <Exec Command="&quot;$(EMSCRIPTEN)\emcc.bat&quot; $(EmccArgs)" Condition="'$(NativeCodeGen)' == 'wasm' and '$(EMSCRIPTEN)' != ''" />
+ <Exec Command="&quot;$(EMSCRIPTEN)\emcc.bat&quot; $(EmccArgs)" Condition="'$(NativeCodeGen)' == 'wasm' and '$(EMSCRIPTEN)' != '' and '$(OS)' == 'Windows_NT'" />
+ <Exec Command="&quot;$(EMSCRIPTEN)/emcc&quot; $(EmccArgs)" Condition="'$(NativeCodeGen)' == 'wasm' and '$(EMSCRIPTEN)' != '' and '$(OS)' != 'Windows_NT'" />
<Message Text="Emscripten not found, not linking WebAssembly. To enable WebAssembly linking, install Emscripten and ensure the EMSCRIPTEN environment variable points to the directory containing emcc.bat"
Condition="'$(NativeCodeGen)' == 'wasm' and '$(EMSCRIPTEN)' == ''" />
</Target>
diff --git a/src/ILCompiler.WebAssembly/src/CodeGen/ILToWebAssemblyImporter.cs b/src/ILCompiler.WebAssembly/src/CodeGen/ILToWebAssemblyImporter.cs
index a24c1efe9..1ac1869c3 100644
--- a/src/ILCompiler.WebAssembly/src/CodeGen/ILToWebAssemblyImporter.cs
+++ b/src/ILCompiler.WebAssembly/src/CodeGen/ILToWebAssemblyImporter.cs
@@ -116,15 +116,18 @@ namespace Internal.IL
}
catch
{
+ LLVMBasicBlockRef trapBlock = LLVM.AppendBasicBlock(_llvmFunction, "Trap");
+
// Change the function body to trap
foreach (BasicBlock block in _basicBlocks)
{
if (block != null && block.Block.Pointer != IntPtr.Zero)
{
+ LLVM.ReplaceAllUsesWith(block.Block, trapBlock);
LLVM.DeleteBasicBlock(block.Block);
}
}
- LLVMBasicBlockRef trapBlock = LLVM.AppendBasicBlock(_llvmFunction, "Trap");
+
LLVM.PositionBuilderAtEnd(_builder, trapBlock);
EmitTrapCall();
LLVM.BuildRetVoid(_builder);
diff --git a/src/ILCompiler.WebAssembly/src/CodeGen/WebAssemblyObjectWriter.cs b/src/ILCompiler.WebAssembly/src/CodeGen/WebAssemblyObjectWriter.cs
index 9cb9b26d5..8808a2e02 100644
--- a/src/ILCompiler.WebAssembly/src/CodeGen/WebAssemblyObjectWriter.cs
+++ b/src/ILCompiler.WebAssembly/src/CodeGen/WebAssemblyObjectWriter.cs
@@ -183,9 +183,9 @@ namespace ILCompiler.DependencyAnalysis
EmitNativeMain();
LLVM.WriteBitcodeToFile(Module, _objectFilePath);
#if DEBUG
- LLVM.PrintModuleToFile(Module, Path.ChangeExtension(_objectFilePath, ".txt"), out IntPtr unused2);
+ LLVM.PrintModuleToFile(Module, Path.ChangeExtension(_objectFilePath, ".txt"), out string unused2);
#endif //DEBUG
- LLVM.VerifyModule(Module, LLVMVerifierFailureAction.LLVMAbortProcessAction, out IntPtr unused);
+ LLVM.VerifyModule(Module, LLVMVerifierFailureAction.LLVMAbortProcessAction, out string unused);
//throw new NotImplementedException(); // This function isn't complete
}
diff --git a/src/ILCompiler.WebAssembly/src/Compiler/WebAssemblyCodegenCompilation.cs b/src/ILCompiler.WebAssembly/src/Compiler/WebAssemblyCodegenCompilation.cs
index 94b35a3f4..5a32248a7 100644
--- a/src/ILCompiler.WebAssembly/src/Compiler/WebAssemblyCodegenCompilation.cs
+++ b/src/ILCompiler.WebAssembly/src/Compiler/WebAssemblyCodegenCompilation.cs
@@ -26,7 +26,6 @@ namespace ILCompiler
: base(dependencyGraph, nodeFactory, GetCompilationRoots(roots, nodeFactory), null, null, logger)
{
NodeFactory = nodeFactory;
- LLVM.LoadLibrary_libLLVM("./libLLVM-x64.dll");
Module = LLVM.ModuleCreateWithName("netscripten");
LLVM.SetTarget(Module, "asmjs-unknown-emscripten");
Options = options;
diff --git a/src/ILCompiler.WebAssembly/src/ILCompiler.WebAssembly.csproj b/src/ILCompiler.WebAssembly/src/ILCompiler.WebAssembly.csproj
index cd88923c7..2eb7e3eeb 100644
--- a/src/ILCompiler.WebAssembly/src/ILCompiler.WebAssembly.csproj
+++ b/src/ILCompiler.WebAssembly/src/ILCompiler.WebAssembly.csproj
@@ -10,15 +10,18 @@
<NoWarn>8002</NoWarn>
<OutputPath>$(BaseOutputPath)$(OSPlatformConfig)/tools</OutputPath>
</PropertyGroup>
+
<ItemGroup>
<PackageReference Include="LLVMSharp">
- <Version>3.9.1-rc3</Version>
- </PackageReference>
- <PackageReference Include="libLLVM">
- <Version>3.9.1</Version>
- </PackageReference>
+ <Version>5.0.0</Version>
+ </PackageReference>
</ItemGroup>
+
<ItemGroup Condition="'$(IsProjectNLibrary)' != 'true'">
+ <ProjectReference Include="libLLVMdep.depproj">
+ <ReferenceOutputAssembly>false</ReferenceOutputAssembly>
+ <SkipGetTargetFrameworkProperties>true</SkipGetTargetFrameworkProperties>
+ </ProjectReference>
<ProjectReference Include="..\..\ILCompiler.DependencyAnalysisFramework\src\ILCompiler.DependencyAnalysisFramework.csproj" />
<ProjectReference Include="..\..\ILCompiler.MetadataTransform\src\ILCompiler.MetadataTransform.csproj" />
<ProjectReference Include="..\..\ILCompiler.MetadataWriter\src\ILCompiler.MetadataWriter.csproj" />
@@ -53,10 +56,16 @@
<Compile Include="CodeGen\ILToWebAssemblyImporter.cs" />
</ItemGroup>
<ItemGroup>
- <Content Include="..\..\..\packages\llvmsharp\3.9.1-rc3\lib\netstandard1.1\LLVMSharp.dll">
+ <Content Include="..\..\..\packages\llvmsharp\5.0.0\lib\netstandard1.1\LLVMSharp.dll">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
- <Content Include="..\..\..\packages\libllvm\3.9.1\content\libLLVM-x64.dll">
+ <Content Include="..\..\..\packages\libllvm\4.0.0\runtimes\osx\native\libLLVM.dylib" Condition="'$(HostOS)' == 'OSX'">
+ <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+ </Content>
+ <Content Include="..\..\..\packages\libllvm\4.0.0\runtimes\linux-x64\native\libLLVM.so" Condition="'$(HostOS)' == 'Linux'">
+ <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+ </Content>
+ <Content Include="..\..\..\packages\libllvm\4.0.0\runtimes\win-x64\native\libLLVM.dll" Condition="'$(HostOS)' == 'Windows_NT'">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
diff --git a/src/ILCompiler.WebAssembly/src/libLLVMdep.depproj b/src/ILCompiler.WebAssembly/src/libLLVMdep.depproj
new file mode 100644
index 000000000..5e0a14f61
--- /dev/null
+++ b/src/ILCompiler.WebAssembly/src/libLLVMdep.depproj
@@ -0,0 +1,22 @@
+<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003" DefaultTargets="Build">
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+
+ <PropertyGroup>
+ <OutputPath>$(BaseOutputPath)$(OSPlatformConfig)/tools</OutputPath>
+ </PropertyGroup>
+
+ <PropertyGroup>
+ <TargetFramework>netstandard1.3</TargetFramework>
+ <RuntimeIdentifiers>$(NuPkgRid)</RuntimeIdentifiers>
+ <RuntimeIdentifiers Condition="$(NuPkgRid.StartsWith('ubuntu.'))">ubuntu.14.04-x64</RuntimeIdentifiers>
+ <RidSpecificAssets>true</RidSpecificAssets>
+ </PropertyGroup>
+
+ <ItemGroup>
+ <PackageReference Include="libLLVM">
+ <Version>4.0.0</Version>
+ </PackageReference>
+ </ItemGroup>
+
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+</Project>
diff --git a/src/Native/gen-buildsys-clang.sh b/src/Native/gen-buildsys-clang.sh
index 0c2441f77..fed57d122 100755
--- a/src/Native/gen-buildsys-clang.sh
+++ b/src/Native/gen-buildsys-clang.sh
@@ -117,6 +117,7 @@ if [ $build_arch == "wasm" ]; then
emcmake cmake \
"-DEMSCRIPTEN_GENERATE_BITCODE_STATIC_LIBRARIES=1" \
"-DCMAKE_TOOLCHAIN_FILE=$EMSCRIPTEN/cmake/Modules/Platform/Emscripten.cmake" \
+ "-DCLR_CMAKE_TARGET_ARCH=$build_arch" \
"-DCMAKE_BUILD_TYPE=$build_type" \
"$1/src/Native"
else