Sync eng/native from dotnet/runtime (#3564)
authorAdeel Mujahid <3840695+am11@users.noreply.github.com>
Wed, 21 Dec 2022 00:15:32 +0000 (02:15 +0200)
committerGitHub <noreply@github.com>
Wed, 21 Dec 2022 00:15:32 +0000 (16:15 -0800)
* Sync eng/native from dotnet/runtime
* Sync eng/common/native/init-compiler.sh
* Pass OS name to gen-buildsys.cmd

eng/Build-Native.cmd
eng/common/native/init-compiler.sh
eng/native/build-commons.sh
eng/native/configurecompiler.cmake
eng/native/configureplatform.cmake
eng/native/gen-buildsys.cmd
eng/native/gen-buildsys.sh
eng/native/init-distro-rid.sh
eng/native/init-vs-env.cmd
eng/native/tryrun.cmake

index d72b33f390b9b207777327dd5c04a8e5bccbe63b..bf16c8a02eb891004659368dfd215badfdaff042 100644 (file)
@@ -194,7 +194,7 @@ if /i %__BuildCrossArch% EQU 1 (
     set __ExtraCmakeArgs="-DCLR_MANAGED_BINARY_DIR=!__ManagedBinaryDir!" "-DCLR_BUILD_TYPE=%__BuildType%" "-DCLR_CMAKE_TARGET_ARCH=%__BuildArch%" "-DCMAKE_SYSTEM_VERSION=10.0" "-DNUGET_PACKAGES=%NUGET_PACKAGES:\=/%"
 
     pushd "%__CrossCompIntermediatesDir%"
-    call "%__ProjectDir%\eng\native\gen-buildsys.cmd" "%__ProjectDir%" "%__CrossCompIntermediatesDir%" %__VSVersion% %__CrossArch% !__ExtraCmakeArgs!
+    call "%__ProjectDir%\eng\native\gen-buildsys.cmd" "%__ProjectDir%" "%__CrossCompIntermediatesDir%" %__VSVersion% %__CrossArch% %__BuildOS% !__ExtraCmakeArgs!
     @if defined _echo @echo on
     popd
 
@@ -267,7 +267,7 @@ if %__Build% EQU 1 (
     set __ExtraCmakeArgs="-DCMAKE_SYSTEM_VERSION=10.0" "-DCLR_MANAGED_BINARY_DIR=!__ManagedBinaryDir!" "-DCLR_BUILD_TYPE=%__BuildType%" "-DCLR_CMAKE_TARGET_ARCH=%__BuildArch%" "-DNUGET_PACKAGES=%NUGET_PACKAGES:\=/%"
 
     pushd "%__IntermediatesDir%"
-    call "%__ProjectDir%\eng\native\gen-buildsys.cmd" "%__ProjectDir%" "%__IntermediatesDir%" %__VSVersion% %__BuildArch% !__ExtraCmakeArgs!
+    call "%__ProjectDir%\eng\native\gen-buildsys.cmd" "%__ProjectDir%" "%__IntermediatesDir%" %__VSVersion% %__BuildArch% %__BuildOS% !__ExtraCmakeArgs!
     @if defined _echo @echo on
     popd
 
index 292ebb6535868d62387598dedb8b46ba5b0a99cb..c670cb796892186df1ee79cbdf34364ca100a924 100644 (file)
@@ -1,30 +1,25 @@
-#!/usr/bin/env bash
+#!/bin/sh
 #
 # This file detects the C/C++ compiler and exports it to the CC/CXX environment variables
 #
 # NOTE: some scripts source this file and rely on stdout being empty, make sure to not output anything here!
 
-if [[ "$#" -lt 3 ]]; then
+if [ -z "$build_arch" ] || [ -z "$compiler" ]; then
   echo "Usage..."
-  echo "init-compiler.sh <script directory> <Architecture> <compiler>"
-  echo "Specify the script directory."
+  echo "build_arch=<ARCH> compiler=<NAME> init-compiler.sh"
   echo "Specify the target architecture."
   echo "Specify the name of compiler (clang or gcc)."
   exit 1
 fi
 
-nativescriptroot="$1"
-build_arch="$2"
-compiler="$3"
-
 case "$compiler" in
     clang*|-clang*|--clang*)
         # clangx.y or clang-x.y
         version="$(echo "$compiler" | tr -d '[:alpha:]-=')"
-        parts=(${version//./ })
-        majorVersion="${parts[0]}"
-        minorVersion="${parts[1]}"
-        if [[ -z "$minorVersion" && "$majorVersion" -le 6 ]]; then
+        majorVersion="${version%%.*}"
+        [ -z "${version##*.*}" ] && minorVersion="${version#*.}"
+
+        if [ -z "$minorVersion" ] && [ -n "$majorVersion" ] && [ "$majorVersion" -le 6 ]; then
             minorVersion=0;
         fi
         compiler=clang
@@ -33,23 +28,20 @@ case "$compiler" in
     gcc*|-gcc*|--gcc*)
         # gccx.y or gcc-x.y
         version="$(echo "$compiler" | tr -d '[:alpha:]-=')"
-        parts=(${version//./ })
-        majorVersion="${parts[0]}"
-        minorVersion="${parts[1]}"
+        majorVersion="${version%%.*}"
+        [ -z "${version##*.*}" ] && minorVersion="${version#*.}"
         compiler=gcc
         ;;
 esac
 
 cxxCompiler="$compiler++"
 
-. "$nativescriptroot"/../pipeline-logging-functions.sh
-
 # clear the existing CC and CXX from environment
 CC=
 CXX=
 LDFLAGS=
 
-if [[ "$compiler" == "gcc" ]]; then cxxCompiler="g++"; fi
+if [ "$compiler" = "gcc" ]; then cxxCompiler="g++"; fi
 
 check_version_exists() {
     desired_version=-1
@@ -66,40 +58,41 @@ check_version_exists() {
     echo "$desired_version"
 }
 
-if [[ -z "$CLR_CC" ]]; then
+if [ -z "$CLR_CC" ]; then
 
     # Set default versions
-    if [[ -z "$majorVersion" ]]; then
+    if [ -z "$majorVersion" ]; then
         # note: gcc (all versions) and clang versions higher than 6 do not have minor version in file name, if it is zero.
-        if [[ "$compiler" == "clang" ]]; then versions=( 15 14 13 12 11 10 9 8 7 6.0 5.0 4.0 3.9 3.8 3.7 3.6 3.5 )
-        elif [[ "$compiler" == "gcc" ]]; then versions=( 12 11 10 9 8 7 6 5 4.9 ); fi
-
-        for version in "${versions[@]}"; do
-            parts=(${version//./ })
-            desired_version="$(check_version_exists "${parts[0]}" "${parts[1]}")"
-            if [[ "$desired_version" != "-1" ]]; then majorVersion="${parts[0]}"; break; fi
+        if [ "$compiler" = "clang" ]; then versions="15 14 13 12 11 10 9 8 7 6.0 5.0 4.0 3.9 3.8 3.7 3.6 3.5"
+        elif [ "$compiler" = "gcc" ]; then versions="12 11 10 9 8 7 6 5 4.9"; fi
+
+        for version in $versions; do
+            _major="${version%%.*}"
+            [ -z "${version##*.*}" ] && _minor="${version#*.}"
+            desired_version="$(check_version_exists "$_major" "$_minor")"
+            if [ "$desired_version" != "-1" ]; then majorVersion="$_major"; break; fi
         done
 
-        if [[ -z "$majorVersion" ]]; then
+        if [ -z "$majorVersion" ]; then
             if command -v "$compiler" > /dev/null; then
-                if [[ "$(uname)" != "Darwin" ]]; then
-                    Write-PipelineTelemetryError -category "Build" -type "warning" "Specific version of $compiler not found, falling back to use the one in PATH."
+                if [ "$(uname)" != "Darwin" ]; then
+                    echo "Warning: Specific version of $compiler not found, falling back to use the one in PATH."
                 fi
                 CC="$(command -v "$compiler")"
                 CXX="$(command -v "$cxxCompiler")"
             else
-                Write-PipelineTelemetryError -category "Build" "No usable version of $compiler found."
+                echo "No usable version of $compiler found."
                 exit 1
             fi
         else
-            if [[ "$compiler" == "clang" && "$majorVersion" -lt 5 ]]; then
-                if [[ "$build_arch" == "arm" || "$build_arch" == "armel" ]]; then
+            if [ "$compiler" = "clang" ] && [ "$majorVersion" -lt 5 ]; then
+                if [ "$build_arch" = "arm" ] || [ "$build_arch" = "armel" ]; then
                     if command -v "$compiler" > /dev/null; then
-                        Write-PipelineTelemetryError -category "Build" -type "warning" "Found clang version $majorVersion which is not supported on arm/armel architectures, falling back to use clang from PATH."
+                        echo "Warning: Found clang version $majorVersion which is not supported on arm/armel architectures, falling back to use clang from PATH."
                         CC="$(command -v "$compiler")"
                         CXX="$(command -v "$cxxCompiler")"
                     else
-                        Write-PipelineTelemetryError -category "Build" "Found clang version $majorVersion which is not supported on arm/armel architectures, and there is no clang in PATH."
+                        echo "Found clang version $majorVersion which is not supported on arm/armel architectures, and there is no clang in PATH."
                         exit 1
                     fi
                 fi
@@ -107,33 +100,33 @@ if [[ -z "$CLR_CC" ]]; then
         fi
     else
         desired_version="$(check_version_exists "$majorVersion" "$minorVersion")"
-        if [[ "$desired_version" == "-1" ]]; then
-            Write-PipelineTelemetryError -category "Build" "Could not find specific version of $compiler: $majorVersion $minorVersion."
+        if [ "$desired_version" = "-1" ]; then
+            echo "Could not find specific version of $compiler: $majorVersion $minorVersion."
             exit 1
         fi
     fi
 
-    if [[ -z "$CC" ]]; then
+    if [ -z "$CC" ]; then
         CC="$(command -v "$compiler$desired_version")"
         CXX="$(command -v "$cxxCompiler$desired_version")"
-        if [[ -z "$CXX" ]]; then CXX="$(command -v "$cxxCompiler")"; fi
+        if [ -z "$CXX" ]; then CXX="$(command -v "$cxxCompiler")"; fi
     fi
 else
-    if [[ ! -f "$CLR_CC" ]]; then
-        Write-PipelineTelemetryError -category "Build" "CLR_CC is set but path '$CLR_CC' does not exist"
+    if [ ! -f "$CLR_CC" ]; then
+        echo "CLR_CC is set but path '$CLR_CC' does not exist"
         exit 1
     fi
     CC="$CLR_CC"
     CXX="$CLR_CXX"
 fi
 
-if [[ -z "$CC" ]]; then
-    Write-PipelineTelemetryError -category "Build" "Unable to find $compiler."
+if [ -z "$CC" ]; then
+    echo "Unable to find $compiler."
     exit 1
 fi
 
 # Only lld version >= 9 can be considered stable. lld doesn't support s390x.
-if [[ "$compiler" == "clang" && "$majorVersion" -ge 9 && "$build_arch" != "s390x" ]]; then
+if [ "$compiler" = "clang" ] && [ -n "$majorVersion" ] && [ "$majorVersion" -ge 9 ] && [ "$build_arch" != "s390x" ]; then
     if "$CC" -fuse-ld=lld -Wl,--version >/dev/null 2>&1; then
         LDFLAGS="-fuse-ld=lld"
     fi
index dd0dea81cd61998f923c1bfb8a21406d03fb495b..c9160b1e4b59a13f037a5e5907ed3a841dbbae35 100755 (executable)
@@ -117,7 +117,7 @@ build_native()
             scan_build=scan-build
         fi
 
-        nextCommand="\"$__RepoRootDir/eng/native/gen-buildsys.sh\" \"$cmakeDir\" \"$intermediatesDir\" $hostArch $__Compiler $__BuildType \"$generator\" $scan_build $cmakeArgs"
+        nextCommand="\"$__RepoRootDir/eng/native/gen-buildsys.sh\" \"$cmakeDir\" \"$intermediatesDir\" $hostArch $targetOS $__Compiler $__BuildType \"$generator\" $scan_build $cmakeArgs"
         echo "Invoking $nextCommand"
         eval $nextCommand
 
@@ -163,7 +163,7 @@ build_native()
         popd
     else
         cmake_command=cmake
-        if [[ "$build_arch" == "wasm" ]]; then
+        if [[ "$build_arch" == "wasm" && "$__TargetOS" == "Browser" ]]; then
             cmake_command="emcmake cmake"
             echo "Executing $cmake_command --build \"$intermediatesDir\" --target $target -- -j $__NumProc"
             $cmake_command --build "$intermediatesDir" --target $target -- -j "$__NumProc"
@@ -212,6 +212,7 @@ usage()
     echo "-gccx.y: optional argument to build using gcc version x.y."
     echo "-ninja: target ninja instead of GNU make"
     echo "-numproc: set the number of build processes."
+    echo "-outputrid: optional argument that overrides the target rid name."
     echo "-portablebuild: pass -portablebuild=false to force a non-portable build."
     echo "-skipconfigure: skip build configuration."
     echo "-keepnativesymbols: keep native/unmanaged debug symbols."
@@ -232,6 +233,7 @@ __TargetArch=$arch
 __TargetOS=$os
 __HostOS=$os
 __BuildOS=$os
+__OutputRid=''
 
 # Get the number of processors available to the scheduler
 platform="$(uname)"
@@ -392,6 +394,16 @@ while :; do
             __TargetArch=wasm
             ;;
 
+        outputrid|-outputrid)
+            if [[ -n "$2" ]]; then
+                __OutputRid="$2"
+                shift
+            else
+                echo "ERROR: 'outputrid' requires a non-empty option argument"
+                exit 1
+            fi
+            ;;
+
         ppc64le|-ppc64le)
             __TargetArch=ppc64le
             ;;
@@ -474,3 +486,7 @@ fi
 
 # init the target distro name
 initTargetDistroRid
+
+if [ -z "$__OutputRid" ]; then
+    __OutputRid="$(echo $__DistroRid | tr '[:upper:]' '[:lower:]')"
+fi
index a0163845e63e8c48242e88233c83254b4776125c..d9443ce6ddfc46d4747958c3a672c92a78f050a7 100644 (file)
@@ -160,9 +160,8 @@ elseif (CLR_CMAKE_HOST_UNIX)
       list(JOIN CLR_LINK_SANITIZERS "," CLR_LINK_SANITIZERS_OPTIONS)
       list(APPEND CLR_SANITIZE_LINK_OPTIONS "-fsanitize=${CLR_LINK_SANITIZERS_OPTIONS}")
 
-      # -fdata-sections -ffunction-sections: each function has own section instead of one per .o file (needed for --gc-sections)
       # -O1: optimization level used instead of -O0 to avoid compile error "invalid operand for inline asm constraint"
-      add_compile_options("$<$<OR:$<CONFIG:DEBUG>,$<CONFIG:CHECKED>>:${CLR_SANITIZE_CXX_OPTIONS};-fdata-sections;--ffunction-sections;-O1>")
+      add_compile_options("$<$<OR:$<CONFIG:DEBUG>,$<CONFIG:CHECKED>>:${CLR_SANITIZE_CXX_OPTIONS};-fdata-sections;-O1>")
       add_linker_flag("${CLR_SANITIZE_LINK_OPTIONS}" DEBUG CHECKED)
       # -Wl and --gc-sections: drop unused sections\functions (similar to Windows /Gy function-level-linking)
       add_linker_flag("-Wl,--gc-sections" DEBUG CHECKED)
@@ -220,6 +219,7 @@ elseif (CLR_CMAKE_HOST_ARCH_ARM)
   add_definitions(-DHOST_ARM)
 elseif (CLR_CMAKE_HOST_ARCH_ARMV6)
   set(ARCH_HOST_NAME armv6)
+  add_definitions(-DHOST_ARM)
   add_definitions(-DHOST_ARMV6)
 elseif (CLR_CMAKE_HOST_ARCH_ARM64)
   set(ARCH_HOST_NAME arm64)
@@ -461,6 +461,8 @@ if (CLR_CMAKE_HOST_UNIX)
       # src/coreclr/vm/stackingallocator.h. It is a false-positive, fixed in g++ 12.
       # see: https://github.com/dotnet/runtime/pull/69188#issuecomment-1136764770
       add_compile_options($<$<COMPILE_LANGUAGE:CXX>:-Wno-placement-new>)
+
+      add_compile_options($<$<COMPILE_LANGUAGE:CXX>:-Wno-class-memaccess>)
     endif()
 
     if (CMAKE_CXX_COMPILER_ID)
@@ -477,6 +479,9 @@ if (CLR_CMAKE_HOST_UNIX)
 
   # We mark the function which needs exporting with DLLEXPORT
   add_compile_options(-fvisibility=hidden)
+  
+  # Separate functions so linker can remove them.
+  add_compile_options(-ffunction-sections)
 
   # Specify the minimum supported version of macOS
   # Mac Catalyst needs a special CFLAG, exclusive with mmacosx-version-min
@@ -508,7 +513,7 @@ if (CLR_CMAKE_HOST_UNIX)
       set(CMAKE_OSX_DEPLOYMENT_TARGET "11.0")
       add_compile_options(-arch arm64)
     elseif(CLR_CMAKE_HOST_ARCH_AMD64)
-      set(CMAKE_OSX_DEPLOYMENT_TARGET "10.14")
+      set(CMAKE_OSX_DEPLOYMENT_TARGET "10.15")
       add_compile_options(-arch x86_64)
     else()
       clr_unknown_arch()
@@ -540,6 +545,10 @@ if(CLR_CMAKE_TARGET_UNIX)
       add_compile_definitions($<$<NOT:$<BOOL:$<TARGET_PROPERTY:IGNORE_DEFAULT_TARGET_OS>>>:TARGET_ILLUMOS>)
     endif()
   endif()
+elseif(CLR_CMAKE_TARGET_WASI)
+  add_compile_definitions($<$<NOT:$<BOOL:$<TARGET_PROPERTY:IGNORE_DEFAULT_TARGET_OS>>>:TARGET_WASI>)
+elseif(CLR_CMAKE_TARGET_BROWSER)
+  add_compile_definitions($<$<NOT:$<BOOL:$<TARGET_PROPERTY:IGNORE_DEFAULT_TARGET_OS>>>:TARGET_BROWSER>)
 else(CLR_CMAKE_TARGET_UNIX)
   add_compile_definitions($<$<NOT:$<BOOL:$<TARGET_PROPERTY:IGNORE_DEFAULT_TARGET_OS>>>:TARGET_WINDOWS>)
 endif(CLR_CMAKE_TARGET_UNIX)
index c7a38c3eee829441b389256bb0416dd9b98e6d89..c849c592174af334de5fbfc0894e7816908de3d2 100644 (file)
@@ -214,6 +214,10 @@ if(CLR_CMAKE_HOST_OS STREQUAL Emscripten)
     set(CLR_CMAKE_HOST_BROWSER 1)
 endif(CLR_CMAKE_HOST_OS STREQUAL Emscripten)
 
+if(CLR_CMAKE_TARGET_OS STREQUAL Wasi)
+    set(CLR_CMAKE_HOST_WASI 1)
+endif(CLR_CMAKE_TARGET_OS STREQUAL Wasi)
+
 #--------------------------------------------
 # This repo builds two set of binaries
 # 1. binaries which execute on target arch machine
@@ -263,6 +267,9 @@ elseif(CLR_CMAKE_HOST_UNIX_POWERPC64)
 elseif(CLR_CMAKE_HOST_BROWSER)
     set(CLR_CMAKE_HOST_ARCH_WASM 1)
     set(CLR_CMAKE_HOST_ARCH "wasm")
+elseif(CLR_CMAKE_HOST_WASI)
+    set(CLR_CMAKE_HOST_ARCH_WASM 1)
+    set(CLR_CMAKE_HOST_ARCH "wasm")
 elseif(CLR_CMAKE_HOST_UNIX_MIPS64)
     set(CLR_CMAKE_HOST_ARCH_MIPS64 1)
     set(CLR_CMAKE_HOST_ARCH "mips64")
@@ -410,6 +417,10 @@ if(CLR_CMAKE_TARGET_OS STREQUAL Emscripten)
     set(CLR_CMAKE_TARGET_BROWSER 1)
 endif(CLR_CMAKE_TARGET_OS STREQUAL Emscripten)
 
+if(CLR_CMAKE_TARGET_OS STREQUAL Wasi)
+    set(CLR_CMAKE_TARGET_WASI 1)
+endif(CLR_CMAKE_TARGET_OS STREQUAL Wasi)
+
 if(CLR_CMAKE_TARGET_UNIX)
     if(CLR_CMAKE_TARGET_ARCH STREQUAL x64)
         set(CLR_CMAKE_TARGET_UNIX_AMD64 1)
@@ -443,13 +454,7 @@ else()
 endif(CLR_CMAKE_TARGET_UNIX)
 
 # check if host & target os/arch combination are valid
-if (CLR_CMAKE_TARGET_OS STREQUAL CLR_CMAKE_HOST_OS)
-    if(NOT(CLR_CMAKE_TARGET_ARCH STREQUAL CLR_CMAKE_HOST_ARCH))
-        if(NOT((CLR_CMAKE_HOST_ARCH_AMD64 AND CLR_CMAKE_TARGET_ARCH_ARM64) OR (CLR_CMAKE_HOST_ARCH_I386 AND CLR_CMAKE_TARGET_ARCH_ARM) OR (CLR_CMAKE_HOST_ARCH_AMD64 AND CLR_CMAKE_TARGET_ARCH_ARM) OR (CLR_CMAKE_HOST_ARCH_AMD64 AND CLR_CMAKE_TARGET_ARCH_I386)))
-            message(FATAL_ERROR "Invalid platform and target arch combination TARGET_ARCH=${CLR_CMAKE_TARGET_ARCH} HOST_ARCH=${CLR_CMAKE_HOST_ARCH}")
-        endif()
-    endif()
-else()
+if (NOT (CLR_CMAKE_TARGET_OS STREQUAL CLR_CMAKE_HOST_OS))
     if(NOT (CLR_CMAKE_HOST_OS STREQUAL windows))
         message(FATAL_ERROR "Invalid host and target os/arch combination. Host OS: ${CLR_CMAKE_HOST_OS}")
     endif()
index 3701e639cee983376fcfaebc8bc2f54dfbceab64..b97b8125e0f8c0fc645c5e0b39819fdfb98d046e 100644 (file)
@@ -22,6 +22,7 @@ set __SourceDir=%1
 set __IntermediatesDir=%2
 set __VSVersion=%3
 set __Arch=%4
+set __Os=%5
 set __CmakeGenerator=Visual Studio
 set __UseEmcmake=0
 if /i "%__Ninja%" == "1" (
@@ -41,25 +42,35 @@ if /i "%__Ninja%" == "1" (
 
 if /i "%__Arch%" == "wasm" (
 
-    if "%EMSDK_PATH%" == "" (
-        if not exist "%__repoRoot%src\mono\wasm\emsdk" (
-            echo Error: Should set EMSDK_PATH environment variable pointing to emsdk root.
-            exit /B 1
+    if "%__Os%" == "" (
+        echo Error: Please add target OS parameter
+        exit /B 1
+    )
+    if /i "%__Os%" == "Browser" (
+        if "%EMSDK_PATH%" == "" (
+            if not exist "%__repoRoot%src\mono\wasm\emsdk" (
+                echo Error: Should set EMSDK_PATH environment variable pointing to emsdk root.
+                exit /B 1
+            )
+
+            set EMSDK_PATH=%__repoRoot%src\mono\wasm\emsdk
+            set EMSDK_PATH=!EMSDK_PATH:\=/!
         )
 
-        set EMSDK_PATH=%__repoRoot%src\mono\wasm\emsdk
-        set EMSDK_PATH=!EMSDK_PATH:\=/!
+        set __ExtraCmakeParams=%__ExtraCmakeParams% "-DCMAKE_TOOLCHAIN_FILE=!EMSDK_PATH!/upstream/emscripten/cmake/Modules/Platform/Emscripten.cmake"
+        set __UseEmcmake=1
+    )
+    if /i "%__Os%" == "wasi" (
+        echo Error: WASI build not implemented on Windows yet
+        exit /B 1
     )
-
-    set __ExtraCmakeParams=%__ExtraCmakeParams% "-DCMAKE_TOOLCHAIN_FILE=!EMSDK_PATH!/upstream/emscripten/cmake/Modules/Platform/Emscripten.cmake"
-    set __UseEmcmake=1
 ) else (
     set __ExtraCmakeParams=%__ExtraCmakeParams%  "-DCMAKE_SYSTEM_VERSION=10.0"
 )
 
 :loop
-if [%5] == [] goto end_loop
-set __ExtraCmakeParams=%__ExtraCmakeParams% %5
+if [%6] == [] goto end_loop
+set __ExtraCmakeParams=%__ExtraCmakeParams% %6
 shift
 goto loop
 :end_loop
@@ -98,7 +109,7 @@ exit /B %errorlevel%
 
 :USAGE
   echo "Usage..."
-  echo "gen-buildsys.cmd <path to top level CMakeLists.txt> <path to location for intermediate files> <VSVersion> <arch>"
+  echo "gen-buildsys.cmd <path to top level CMakeLists.txt> <path to location for intermediate files> <VSVersion> <arch> <os>"
   echo "Specify the path to the top level CMake file - <ProjectK>/src/NDP"
   echo "Specify the VSVersion to be used - VS2017 or VS2019"
   EXIT /B 1
index c3bf9adbbef5340bc653672d9dc04998ede6603e..72f90cdf15fcbfc34b7be83ecb16f65406d76244 100755 (executable)
@@ -7,7 +7,7 @@ scriptroot="$( cd -P "$( dirname "$0" )" && pwd )"
 
 if [[ "$#" -lt 4 ]]; then
   echo "Usage..."
-  echo "gen-buildsys.sh <path to top level CMakeLists.txt> <path to intermediate directory> <Architecture> <compiler> [build flavor] [ninja] [scan-build] [cmakeargs]"
+  echo "gen-buildsys.sh <path to top level CMakeLists.txt> <path to intermediate directory> <Architecture> <Os> <compiler> [build flavor] [ninja] [scan-build] [cmakeargs]"
   echo "Specify the path to the top level CMake file."
   echo "Specify the path that the build system files are generated in."
   echo "Specify the host architecture (the architecture the built tools should run on)."
@@ -20,11 +20,12 @@ if [[ "$#" -lt 4 ]]; then
 fi
 
 host_arch="$3"
-compiler="$4"
+target_os="$4"
+compiler="$5"
 
 if [[ "$compiler" != "default" ]]; then
     nativescriptroot="$( cd -P "$scriptroot/../common/native" && pwd )"
-    source "$nativescriptroot/init-compiler.sh" "$nativescriptroot" "$host_arch" "$compiler"
+    build_arch="$host_arch" compiler="$compiler" . "$nativescriptroot/init-compiler.sh"
 
     CCC_CC="$CC"
     CCC_CXX="$CXX"
@@ -39,7 +40,7 @@ scan_build=OFF
 generator="Unix Makefiles"
 __UnprocessedCMakeArgs=""
 
-for i in "${@:5}"; do
+for i in "${@:6}"; do
     upperI="$(echo "$i" | tr "[:lower:]" "[:upper:]")"
     case "$upperI" in
       # Possible build types are DEBUG, CHECKED, RELEASE, RELWITHDEBINFO.
@@ -93,7 +94,14 @@ if [[ "$scan_build" == "ON" && -n "$SCAN_BUILD_COMMAND" ]]; then
 fi
 
 if [[ "$host_arch" == "wasm" ]]; then
-    cmake_command="emcmake $cmake_command"
+    if [[ "$target_os" == "Browser" ]]; then
+        cmake_command="emcmake $cmake_command"
+    elif [[ "$target_os" == "wasi" ]]; then
+        true
+    else
+        echo "target_os was not specified"
+        exit 1
+    fi
 fi
 
 # We have to be able to build with CMake 3.6.2, so we can't use the -S or -B options
index 75012240633da6c52dccd729b2a7a7ca629af70e..309f6970a0f0f42b632cd1ba1d2bfcbd57a9befa 100644 (file)
@@ -148,8 +148,13 @@ initDistroRidGlobal()
     initNonPortableDistroRid "${targetOs}" "${buildArch}" "${isPortable}" "${rootfsDir}"
 
     if [ "$buildArch" = "wasm" ]; then
-        __DistroRid=browser-wasm
-        export __DistroRid
+        if [ "$targetOs" = "Browser" ]; then
+            __DistroRid=browser-wasm
+            export __DistroRid
+        elif [ "$targetOs" = "wasi" ]; then
+            __DistroRid=wasi-wasm
+            export __DistroRid
+        fi
     fi
 
     if [ -z "${__DistroRid}" ]; then
@@ -186,6 +191,8 @@ initDistroRidGlobal()
                 distroRid="android-$buildArch"
             elif [ "$targetOs" = "Browser" ]; then
                 distroRid="browser-$buildArch"
+            elif [ "$targetOs" = "wasi" ]; then
+                distroRid="wasi-$buildArch"
             elif [ "$targetOs" = "FreeBSD" ]; then
                 distroRid="freebsd-$buildArch"
             elif [ "$targetOs" = "illumos" ]; then
index 5f450d0636352aee9ac737cca1f62dc57bc1c43a..403f355eca4811744858114f606dd89dbd7ba0c8 100644 (file)
@@ -52,7 +52,7 @@ if "%VisualStudioVersion%"=="17.0" (
 )
 
 :VSMissing
-echo %__MsgPrefix%Error: Visual Studio 2019 or 2022 with C++ tools required. ^
+echo %__MsgPrefix%Error: Visual Studio 2022 with C++ tools required. ^
 Please see https://github.com/dotnet/runtime/blob/main/docs/workflow/requirements/windows-requirements.md for build requirements.
 exit /b 1
 
index 5c5344bd80161c4d5de20c6385f9f3e070d1d9fe..dc7bffb741a883f36fe3ad85fa220cc9030e18fe 100644 (file)
@@ -20,6 +20,8 @@ elseif(EXISTS ${CROSS_ROOTFS}/usr/platform/i86pc)
   set(CLR_CMAKE_TARGET_OS SunOS)
 elseif(EXISTS /System/Library/CoreServices)
   set(DARWIN 1)
+elseif(EXISTS ${CROSS_ROOTFS}/etc/tizen-release)
+  set(TIZEN 1)
 endif()
 
 if(DARWIN)
@@ -64,11 +66,11 @@ if(DARWIN)
     set_cache_value(SSCANF_CANNOT_HANDLE_MISSING_EXPONENT_EXITCODE 1)
     set_cache_value(SSCANF_SUPPORT_ll_EXITCODE 0)
     set_cache_value(UNGETC_NOT_RETURN_EOF_EXITCODE 1)
-    set_cache_value(HAVE_SHM_OPEN_THAT_WORKS_WELL_ENOUGH_WITH_MMAP_EXITCODE 0)
+    set_cache_value(HAVE_SHM_OPEN_THAT_WORKS_WELL_ENOUGH_WITH_MMAP_EXITCODE 1)
   else()
     message(FATAL_ERROR "Arch is ${TARGET_ARCH_NAME}. Only arm64 or x64 is supported for OSX cross build!")
   endif()
-elseif(TARGET_ARCH_NAME MATCHES "^(armel|arm|armv6|arm64|loongarch64|riscv64|s390x|ppc64le|x86)$" OR FREEBSD OR ILLUMOS)
+elseif(TARGET_ARCH_NAME MATCHES "^(armel|arm|armv6|arm64|loongarch64|riscv64|s390x|ppc64le|x86)$" OR FREEBSD OR ILLUMOS OR TIZEN)
   set_cache_value(FILE_OPS_CHECK_FERROR_OF_PREVIOUS_CALL_EXITCODE 1)
   set_cache_value(GETPWUID_R_SETS_ERRNO_EXITCODE 0)
   set_cache_value(HAS_POSIX_SEMAPHORES_EXITCODE 0)
@@ -144,6 +146,8 @@ elseif(TARGET_ARCH_NAME MATCHES "^(armel|arm|armv6|arm64|loongarch64|riscv64|s39
     set_cache_value(HAVE_SET_MAX_VARIABLE 1)
     set_cache_value(HAVE_FULLY_FEATURED_PTHREAD_MUTEXES 1)
     set_cache_value(HAVE_FUNCTIONAL_PTHREAD_ROBUST_MUTEXES_EXITCODE 0)
+  elseif (TIZEN)
+    set_cache_value(HAVE_FUNCTIONAL_PTHREAD_ROBUST_MUTEXES_EXITCODE 0)
   endif()
 else()
   message(FATAL_ERROR "Arch is ${TARGET_ARCH_NAME}. Only armel, arm, armv6, arm64, loongarch64, s390x, ppc64le and x86 are supported!")