Skip to content

Commit

Permalink
add linux
Browse files Browse the repository at this point in the history
set IsWIndows

condition the removal of some warnings

Add install-emscripten.sh

add browser_wasm_linux to matrix

install node on linux

update date

" to '

switch on hostedOs

llvm install dir

pwsh option

remove IsWindows

cmake unix make

setup EMSDK

quote vso command

check for IsWindows

typo in testpath

debug

build and run linux naot tests

try removing some changes

remove linux wasm

remove more changes

add checked and release for linux
  • Loading branch information
yowl committed May 4, 2024
1 parent da4ca46 commit 5ca340e
Show file tree
Hide file tree
Showing 13 changed files with 2,829 additions and 27 deletions.
3 changes: 3 additions & 0 deletions eng/native/gen-buildsys.sh
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,9 @@ fi

if [[ "$host_arch" == "wasm" ]]; then
if [[ "$target_os" == "browser" ]]; then
if [[ -n "$NATIVEAOT_CI_WASM_BUILD_EMSDK_PATH" ]]; then
source $NATIVEAOT_CI_WASM_BUILD_EMSDK_PATH/emsdk_env.sh
fi
cmake_command="emcmake $cmake_command"
elif [[ "$target_os" == "wasi" ]]; then
true
Expand Down
14 changes: 12 additions & 2 deletions eng/pipelines/common/global-build-job.yml
Original file line number Diff line number Diff line change
Expand Up @@ -206,15 +206,25 @@ jobs:
df -h
displayName: Disk Usage before Build
# Install Wasm dependencies: emscripten, LLVM, NodeJS
- ${{ if and(eq(parameters.runtimeFlavor, 'coreclr'), eq(parameters.archType, 'wasm')) }}:
# Install Wasm dependencies on Windows: emscripten, LLVM, NodeJS
- ${{ if and(eq(parameters.hostedOs, 'windows'), and(eq(parameters.runtimeFlavor, 'coreclr'), eq(parameters.archType, 'wasm'))) }}:
- script: call $(Build.SourcesDirectory)/eng/pipelines/runtimelab/install-emscripten.cmd $(Build.SourcesDirectory)\wasm-tools
displayName: Install/activate emscripten
- script: call $(Build.SourcesDirectory)/eng/pipelines/runtimelab/install-llvm.cmd $(Build.SourcesDirectory)\wasm-tools $(Build.SourcesDirectory) ${{ parameters.buildConfig }}
displayName: Install/build LLVM
- script: call $(Build.SourcesDirectory)/eng/pipelines/runtimelab/install-nodejs.cmd $(Build.SourcesDirectory)\wasm-tools
displayName: Install NodeJS

# Install Wasm dependencies on Linux: emscripten, LLVM, NodeJS.
- ${{ if and(eq(parameters.hostedOs, 'linux'), and(eq(parameters.runtimeFlavor, 'coreclr'), eq(parameters.archType, 'wasm'))) }}:
- script: $(Build.SourcesDirectory)/eng/pipelines/runtimelab/install-emscripten.sh $(Build.SourcesDirectory)/wasm-tools
displayName: Install/activate emscripten
- script: pwsh $(Build.SourcesDirectory)/eng/pipelines/runtimelab/install-llvm.ps1 -Configs ${{ parameters.buildConfig }} -CI
workingDirectory: $(Build.SourcesDirectory)/wasm-tools
displayName: Install/build LLVM
- script: pwsh $(Build.SourcesDirectory)/eng/pipelines/runtimelab/install-nodejs.ps1 $(Build.SourcesDirectory)/wasm-tools
displayName: Install NodeJS

- ${{ if and(eq(parameters.runtimeFlavor, 'coreclr'), eq(parameters.platform, 'wasi_wasm_win')) }}:
# Install Wasi Wasm dependencies: wasi-sdk, wasmer
- script: call $(Build.SourcesDirectory)/eng/pipelines/runtimelab/install-wasi-sdk.cmd $(Build.SourcesDirectory)\wasm-tools
Expand Down
6 changes: 3 additions & 3 deletions eng/pipelines/runtimelab.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ extends:
helixQueuesTemplate: /eng/pipelines/coreclr/templates/helix-queues-setup.yml
buildConfig: debug
platforms:
# - linux_x64
- linux_x64
- osx_x64
- windows_x64
- Browser_wasm_win
Expand All @@ -81,7 +81,7 @@ extends:
helixQueuesTemplate: /eng/pipelines/coreclr/templates/helix-queues-setup.yml
buildConfig: checked
platforms:
# - linux_x64
- linux_x64
- windows_x64
jobParameters:
timeoutInMinutes: 300
Expand All @@ -101,7 +101,7 @@ extends:
helixQueuesTemplate: /eng/pipelines/libraries/helix-queues-setup.yml
buildConfig: release
platforms:
# - linux_x64
- linux_x64
- osx_x64
- windows_x64
- Browser_wasm_win
Expand Down
16 changes: 16 additions & 0 deletions eng/pipelines/runtimelab/install-emscripten.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/bash

mkdir "$1" 2>/dev/null
cd "$1"

git clone https://github.com/emscripten-core/emsdk.git

cd emsdk
# Checkout a known good version to avoid a random break when emscripten changes the top of tree.
git checkout 37b85e9

python emsdk.py install 3.1.47 || exit 1
./emsdk activate 3.1.47 || exit 1

# We key off of this variable in the common/build.ps1 script.
echo "##vso[task.setvariable variable=NATIVEAOT_CI_WASM_BUILD_EMSDK_PATH]$PWD"
12 changes: 9 additions & 3 deletions eng/pipelines/runtimelab/install-llvm.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ param(
[switch]$NoBuild
)

# Set IsWindows if the version of Powershell does not already have it.
if (!(Test-Path variable:global:IsWindows))
{
$IsWindows=[environment]::OSVersion.Platform -eq [PlatformID]::Win32NT
}

$ErrorActionPreference="Stop"

if (!(gcm git -ErrorAction SilentlyContinue))
Expand Down Expand Up @@ -54,23 +60,23 @@ foreach ($Config in $Configs)
}
else
{
$generator="Ninja"
$generator="Unix Makefiles"
}

$CmakeConfigureCommandLine = "-G", "$generator", "-DLLVM_INCLUDE_BENCHMARKS=OFF"
$CmakeConfigureCommandLine += "-S", $SourceDirName, "-B", $BuildDirPath
if ($Config -eq "Release")
{
$LlvmConfig = "Release"
if ($IsWindows)
if ($IsWindows)
{
$CmakeConfigureCommandLine += "-DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreaded", "-Thost=x64"
}
}
else
{
$LlvmConfig = "Debug"
if ($IsWindows)
if ($IsWindows)
{
$CmakeConfigureCommandLine += "-DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreadedDebug", "-Thost=x64"
}
Expand Down
30 changes: 26 additions & 4 deletions eng/pipelines/runtimelab/install-nodejs.ps1
Original file line number Diff line number Diff line change
@@ -1,7 +1,21 @@
$InstallPath = $Args[0]
$NodeJSVersion = "v20.2.0"
$NodeJSInstallName = "node-$NodeJSVersion-win-x64"
$NodeJSZipName = "$NodeJSInstallName.zip"

if (!(Test-Path variable:global:IsWindows))
{
$IsWindows=[environment]::OSVersion.Platform -eq [PlatformID]::Win32NT
}

if ($IsWIndows)
{
$NodeJSInstallName = "node-$NodeJSVersion-win-x64"
$NodeJSZipName = "$NodeJSInstallName.zip"
}
else
{
$NodeJSInstallName = "node-$NodeJSVersion-linux-x64"
$NodeJSZipName = "$NodeJSInstallName.tar.xz"
}

if (!(Test-Path $InstallPath))
{
Expand Down Expand Up @@ -33,9 +47,17 @@ if ($RetryCount -le 0)
exit 1
}

Expand-Archive -LiteralPath "$InstallPath\$NodeJSInstallName.zip" -DestinationPath $InstallPath -Force
if ($IsWindows)
{
Expand-Archive -LiteralPath "$InstallPath\$NodeJSZipName" -DestinationPath $InstallPath -Force
$NodeJSExePath = "$InstallPath\$NodeJSInstallName\node.exe"
}
else
{
tar xJf $InstallPath/$NodeJSZipName -C $InstallPath
$NodeJSExePath = "$InstallPath/$NodeJSInstallName/bin/node"
}

$NodeJSExePath = "$InstallPath\$NodeJSInstallName\node.exe"
if (!(Test-Path $NodeJSExePath))
{
Write-Error "Did not find NodeJS at: '$NodeJSExePath'"
Expand Down
1 change: 0 additions & 1 deletion src/coreclr/build-runtime.sh
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,6 @@ if [[ -n "$__RequestedBuildComponents" ]]; then
fi

if [[ "$__CMakeTarget" == *"wasmjit"* ]]; then
echo wasmjit
__ExtraCmakeArgs="$__ExtraCmakeArgs -DCLR_CMAKE_BUILD_LLVM_JIT=1"

if [[ "$__BuildType" == "Release" ]]; then
Expand Down
7 changes: 2 additions & 5 deletions src/coreclr/jit/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,10 @@ function(create_standalone_jit)
# We'll be linking against LLVM built without /guard:ehcont, so disable it.
set_target_properties(${TARGETDETAILS_TARGET} PROPERTIES CLR_EH_CONTINUATION OFF)

message("find_package")
message($ENV{LLVM_CMAKE_CONFIG})
# Prefer the version specified in LLVM_CMAKE_CONFIG over the "system" installed version
find_package(LLVM REQUIRED CONFIG PATHS $ENV{LLVM_CMAKE_CONFIG} NO_DEFAULT_PATH)
find_package(LLVM REQUIRED CONFIG)
target_include_directories(${TARGETDETAILS_TARGET} PRIVATE ${LLVM_INCLUDE_DIRS})
message(${LLVM_INCLUDE_DIRS})
separate_arguments(LLVM_DEFINITIONS)
target_compile_definitions(${TARGETDETAILS_TARGET} PRIVATE ${LLVM_DEFINITIONS})
llvm_map_components_to_libnames(llvm_libs core bitwriter)
Expand Down Expand Up @@ -714,8 +713,6 @@ endif (CLR_CMAKE_TARGET_ARCH_RISCV64)
if (CLR_CMAKE_BUILD_LLVM_JIT)
# The LLVM clrjit needs to be the last clrjit to use create_standalone_jit as it modifies some cmake variables.
# LLVM clrjit has an extra export - registerLlvmCallbacks.
add_compile_options(-Wno-switch)
add_compile_options(-Wno-format)
set(CLRJIT_EXPORTS ${CMAKE_CURRENT_LIST_DIR}/ClrJit.Llvm.exports)
set(JIT_EXPORTS_FILE ${CMAKE_CURRENT_BINARY_DIR}/ClrJit.Llvm.exports.def)
preprocess_file (${CLRJIT_EXPORTS} ${JIT_EXPORTS_FILE})
Expand Down
6 changes: 3 additions & 3 deletions src/coreclr/jit/llvm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -784,7 +784,7 @@ CORINFO_GENERIC_HANDLE Llvm::getSymbolHandleForClassToken(mdToken token)
template <EEApiId Func, typename TReturn, typename... TArgs>
TReturn CallEEApi(TArgs... args)
{
return reinterpret_cast<TReturn (*)(TArgs...)>(g_callbacks[static_cast<int>(Func)])(args...);
return static_cast<TReturn (*)(TArgs...)>(g_callbacks[static_cast<int>(Func)])(args...);
}

const char* Llvm::GetMangledMethodName(CORINFO_METHOD_HANDLE methodHandle)
Expand Down Expand Up @@ -885,8 +885,8 @@ extern "C" DLLEXPORT void registerLlvmCallbacks(void** jitImports, void** jitExp
assert(jitExports != nullptr);

memcpy(g_callbacks, jitImports, static_cast<int>(EEApiId::Count) * sizeof(void*));
jitExports[static_cast<int>(JitApiId::StartSingleThreadedCompilation)] = (void*)&Llvm::StartSingleThreadedCompilation;
jitExports[static_cast<int>(JitApiId::FinishSingleThreadedCompilation)] = (void*)&Llvm::FinishSingleThreadedCompilation;
jitExports[static_cast<int>(JitApiId::StartSingleThreadedCompilation)] = &Llvm::StartSingleThreadedCompilation;
jitExports[static_cast<int>(JitApiId::FinishSingleThreadedCompilation)] = &Llvm::FinishSingleThreadedCompilation;
jitExports[static_cast<int>(JitApiId::Count)] = (void*)0x1234;
}

Expand Down
1 change: 0 additions & 1 deletion src/coreclr/jit/llvmcodegen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1100,7 +1100,6 @@ void Llvm::visitNode(GenTree* node)
break;
case GT_JMP:
NYI("LLVM/GT_JMP"); // Requires support for explicit tailcalls.
LLVM_FALLTHROUGH;
default:
unreached();
}
Expand Down
2 changes: 1 addition & 1 deletion src/coreclr/jit/llvmlssa.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1482,7 +1482,7 @@ class ShadowStackAllocator
{
if (block != m_currentBlock)
{
m_actions.Push({AllocationActionKind::Block, {m_currentBlockIndex++}});
m_actions.Push({AllocationActionKind::Block, m_currentBlockIndex++});
m_currentBlock = block;
}
}
Expand Down
Loading

0 comments on commit 5ca340e

Please sign in to comment.