From da4ca465b80ffa1fbc6d14f5ecb93315d8eb6235 Mon Sep 17 00:00:00 2001 From: yowl Date: Tue, 30 Apr 2024 01:32:57 -0500 Subject: [PATCH] test commit to see if pre-c11-compat happens in CI --- eng/pipelines/runtimelab/install-llvm.ps1 | 30 ++++++++++++++++--- src/coreclr/build-runtime.sh | 23 +++++++++++++- src/coreclr/jit/CMakeLists.txt | 7 ++++- src/coreclr/jit/llvm.cpp | 6 ++-- src/coreclr/jit/llvmcodegen.cpp | 1 + src/coreclr/jit/llvmlssa.cpp | 2 +- .../nativeaot/Runtime/unix/UnixContext.h | 2 ++ src/native/libs/build-native.sh | 6 ++-- 8 files changed, 64 insertions(+), 13 deletions(-) diff --git a/eng/pipelines/runtimelab/install-llvm.ps1 b/eng/pipelines/runtimelab/install-llvm.ps1 index bccc9d980e5c..7d797bfe9ec3 100644 --- a/eng/pipelines/runtimelab/install-llvm.ps1 +++ b/eng/pipelines/runtimelab/install-llvm.ps1 @@ -35,23 +35,45 @@ foreach ($Config in $Configs) { pushd llvm-project $BuildDirName = "build-$($Config.ToLower())" - mkdir $BuildDirName -Force + if ($IsWindows) + { + mkdir $BuildDirName -Force + } + else + { + mkdir $BuildDirName --parents + } $BuildDirPath = "$pwd/$BuildDirName" $SourceDirName = "$pwd/llvm" popd - $CmakeConfigureCommandLine = "-G", "Visual Studio 17 2022", "-DLLVM_INCLUDE_BENCHMARKS=OFF", "-Thost=x64" + if ($IsWindows) + { + $generator="Visual Studio 17 2022" + } + else + { + $generator="Ninja" + } + + $CmakeConfigureCommandLine = "-G", "$generator", "-DLLVM_INCLUDE_BENCHMARKS=OFF" $CmakeConfigureCommandLine += "-S", $SourceDirName, "-B", $BuildDirPath if ($Config -eq "Release") { $LlvmConfig = "Release" - $CmakeConfigureCommandLine += "-DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreaded" + if ($IsWindows) + { + $CmakeConfigureCommandLine += "-DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreaded", "-Thost=x64" + } } else { $LlvmConfig = "Debug" - $CmakeConfigureCommandLine += "-DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreadedDebug" + if ($IsWindows) + { + $CmakeConfigureCommandLine += "-DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreadedDebug", "-Thost=x64" + } } $CmakeConfigureCommandLine += "-DCMAKE_BUILD_TYPE=$LlvmConfig" diff --git a/src/coreclr/build-runtime.sh b/src/coreclr/build-runtime.sh index 58d1d2eb00ab..b5071cb8b8a1 100755 --- a/src/coreclr/build-runtime.sh +++ b/src/coreclr/build-runtime.sh @@ -171,6 +171,27 @@ if [[ -n "$__RequestedBuildComponents" ]]; then __CMakeTarget=" $__RequestedBuildComponents " __CMakeTarget="${__CMakeTarget// paltests / paltests_install }" fi + +if [[ "$__CMakeTarget" == *"wasmjit"* ]]; then + echo wasmjit + __ExtraCmakeArgs="$__ExtraCmakeArgs -DCLR_CMAKE_BUILD_LLVM_JIT=1" + + if [[ "$__BuildType" == "Release" ]]; then + if [[ -n $LLVM_CMAKE_CONFIG_RELEASE ]]; then + LLVM_CMAKE_CONFIG="$LLVM_CMAKE_CONFIG_RELEASE" + fi + else + if [[ -n $LLVM_CMAKE_CONFIG_DEBUG ]]; then + LLVM_CMAKE_CONFIG="$LLVM_CMAKE_CONFIG_DEBUG" + fi + fi + + if [[ -z "$LLVM_CMAKE_CONFIG" ]]; then + echo The LLVM_CMAKE_CONFIG environment variable pointing to llvm-build-dir/lib/cmake/llvm must be set. 1>&2 + exit 1 + fi +fi + if [[ -z "$__CMakeTarget" ]]; then __CMakeTarget="install" fi @@ -185,7 +206,7 @@ fi eval "$__RepoRootDir/eng/native/version/copy_version_files.sh" -build_native "$__HostOS" "$__HostArch" "$__ProjectRoot" "$__IntermediatesDir" "$__CMakeTarget" "$__CMakeArgs" "CoreCLR component" +build_native "$__HostOS" "$__HostArch" "$__ProjectRoot" "$__IntermediatesDir" "$__CMakeTarget" "$__CMakeArgs $__ExtraCmakeArgs" "CoreCLR component" # Build complete diff --git a/src/coreclr/jit/CMakeLists.txt b/src/coreclr/jit/CMakeLists.txt index efb3e4dd46b7..4ddddae252e1 100644 --- a/src/coreclr/jit/CMakeLists.txt +++ b/src/coreclr/jit/CMakeLists.txt @@ -91,8 +91,11 @@ 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) - find_package(LLVM REQUIRED CONFIG PATHS $ENV{LLVM_CMAKE_CONFIG}) + message("find_package") + message($ENV{LLVM_CMAKE_CONFIG}) + find_package(LLVM REQUIRED CONFIG PATHS $ENV{LLVM_CMAKE_CONFIG} NO_DEFAULT_PATH) 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) @@ -711,6 +714,8 @@ 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}) diff --git a/src/coreclr/jit/llvm.cpp b/src/coreclr/jit/llvm.cpp index 1c52f253ac77..3a2bd87558a1 100644 --- a/src/coreclr/jit/llvm.cpp +++ b/src/coreclr/jit/llvm.cpp @@ -784,7 +784,7 @@ CORINFO_GENERIC_HANDLE Llvm::getSymbolHandleForClassToken(mdToken token) template TReturn CallEEApi(TArgs... args) { - return static_cast(g_callbacks[static_cast(Func)])(args...); + return reinterpret_cast(g_callbacks[static_cast(Func)])(args...); } const char* Llvm::GetMangledMethodName(CORINFO_METHOD_HANDLE methodHandle) @@ -885,8 +885,8 @@ extern "C" DLLEXPORT void registerLlvmCallbacks(void** jitImports, void** jitExp assert(jitExports != nullptr); memcpy(g_callbacks, jitImports, static_cast(EEApiId::Count) * sizeof(void*)); - jitExports[static_cast(JitApiId::StartSingleThreadedCompilation)] = &Llvm::StartSingleThreadedCompilation; - jitExports[static_cast(JitApiId::FinishSingleThreadedCompilation)] = &Llvm::FinishSingleThreadedCompilation; + jitExports[static_cast(JitApiId::StartSingleThreadedCompilation)] = (void*)&Llvm::StartSingleThreadedCompilation; + jitExports[static_cast(JitApiId::FinishSingleThreadedCompilation)] = (void*)&Llvm::FinishSingleThreadedCompilation; jitExports[static_cast(JitApiId::Count)] = (void*)0x1234; } diff --git a/src/coreclr/jit/llvmcodegen.cpp b/src/coreclr/jit/llvmcodegen.cpp index 644fd739746a..65b9e19ae8cf 100644 --- a/src/coreclr/jit/llvmcodegen.cpp +++ b/src/coreclr/jit/llvmcodegen.cpp @@ -1100,6 +1100,7 @@ void Llvm::visitNode(GenTree* node) break; case GT_JMP: NYI("LLVM/GT_JMP"); // Requires support for explicit tailcalls. + LLVM_FALLTHROUGH; default: unreached(); } diff --git a/src/coreclr/jit/llvmlssa.cpp b/src/coreclr/jit/llvmlssa.cpp index e5d6f4a1aa10..1d5f1a72704b 100644 --- a/src/coreclr/jit/llvmlssa.cpp +++ b/src/coreclr/jit/llvmlssa.cpp @@ -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; } } diff --git a/src/coreclr/nativeaot/Runtime/unix/UnixContext.h b/src/coreclr/nativeaot/Runtime/unix/UnixContext.h index 49839e80d693..17080bb8be53 100644 --- a/src/coreclr/nativeaot/Runtime/unix/UnixContext.h +++ b/src/coreclr/nativeaot/Runtime/unix/UnixContext.h @@ -7,6 +7,8 @@ // WASM has no thread state contexts. #ifndef HOST_WASM +#include + // Convert Unix native context to PAL_LIMITED_CONTEXT void NativeContextToPalContext(const void* context, PAL_LIMITED_CONTEXT* palContext); // Redirect Unix native context to the PAL_LIMITED_CONTEXT and also set the first two argument registers diff --git a/src/native/libs/build-native.sh b/src/native/libs/build-native.sh index 9cb656b4fcd6..f354352b6184 100755 --- a/src/native/libs/build-native.sh +++ b/src/native/libs/build-native.sh @@ -60,15 +60,15 @@ source "$__RepoRootDir"/eng/native/build-commons.sh # Set cross build if [[ "$__TargetOS" == browser ]]; then - if [[ -z "$EMSDK_PATH" ]]; then + if [[ -z "$EMSDK" ]]; then if [[ -d "$__RepoRootDir"/src/mono/browser/emsdk/ ]]; then - export EMSDK_PATH="$__RepoRootDir"/src/mono/browser/emsdk/ + export EMSDK="$__RepoRootDir"/src/mono/browser/emsdk/ else echo "Error: You need to set the EMSDK_PATH environment variable pointing to the emscripten SDK root." exit 1 fi fi - source "$EMSDK_PATH"/emsdk_env.sh + source "$EMSDK"/emsdk_env.sh export CLR_CC=$(which emcc) elif [[ "$__TargetOS" == wasi ]]; then if [[ -z "$WASI_SDK_PATH" ]]; then