From: Zoltan Varga Date: Tue, 13 Oct 2020 10:19:32 +0000 (-0400) Subject: Add support for the cmake build to mono.proj. (#43317) X-Git-Tag: submit/tizen/20210909.063632~5111 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=4ea002023a2a327473ed2a1cf4173e3d9b7e7895;p=platform%2Fupstream%2Fdotnet%2Fruntime.git Add support for the cmake build to mono.proj. (#43317) * Fix CMake symbol name for HAVE_GNU_LIB_NAMES_H * Fix pthread function checks on linux. * Add support for the cmake build to mono.proj. * Enable the cmake build by default on wasm/osx/android. Co-authored-by: Filip Navara --- diff --git a/src/mono/cmake/configure.cmake b/src/mono/cmake/configure.cmake index fa138ce..f0c0943 100644 --- a/src/mono/cmake/configure.cmake +++ b/src/mono/cmake/configure.cmake @@ -16,8 +16,9 @@ function(ac_check_headers) string(TOUPPER "${arg}" var1) string(REPLACE "/" "_" var2 ${var1}) string(REPLACE "." "_" var3 ${var2}) + string(REPLACE "-" "_" var4 ${var3}) if (FOUND_${arg}) - set(HAVE_${var3} 1 PARENT_SCOPE) + set(HAVE_${var4} 1 PARENT_SCOPE) endif() endforeach(arg) endfunction() @@ -62,8 +63,6 @@ ac_check_funcs ( madvise getrusage getpriority setpriority dladdr sysconf getrlimit prctl nl_langinfo sched_getaffinity sched_setaffinity getpwnam_r getpwuid_r readlink chmod lstat getdtablesize ftruncate msync gethostname getpeername utime utimes openlog closelog atexit popen strerror_r inet_pton inet_aton - pthread_getname_np pthread_setname_np pthread_cond_timedwait_relative_np pthread_kill - pthread_attr_setstacksize pthread_get_stackaddr_np pthread_jit_write_protect_np shm_open poll getfsstat mremap posix_fadvise vsnprintf sendfile statfs statvfs setpgid system fork execv execve waitpid localtime_r mkdtemp getrandom execvp strlcpy stpcpy strtok_r rewinddir vasprintf strndup getpwuid_r getprotobyname getprotobyname_r getaddrinfo mach_absolute_time @@ -74,6 +73,15 @@ if (NOT DARWIN) ac_check_funcs (getentropy) endif() +find_package(Threads) +# Needed to find pthread_ symbols +set(CMAKE_REQUIRED_LIBRARIES "${CMAKE_REQUIRED_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT}") + +ac_check_funcs( + pthread_getname_np pthread_setname_np pthread_cond_timedwait_relative_np pthread_kill + pthread_attr_setstacksize pthread_get_stackaddr_np pthread_jit_write_protect_np +) + check_symbol_exists(pthread_mutexattr_setprotocol "pthread.h" HAVE_DECL_PTHREAD_MUTEXATTR_SETPROTOCOL) check_symbol_exists(CLOCK_MONOTONIC "time.h" HAVE_CLOCK_MONOTONIC) check_symbol_exists(CLOCK_MONOTONIC_COARSE "time.h" HAVE_CLOCK_MONOTONIC_COARSE) diff --git a/src/mono/mono.proj b/src/mono/mono.proj index 66a5ef7..bc22bbf 100644 --- a/src/mono/mono.proj +++ b/src/mono/mono.proj @@ -6,6 +6,7 @@ --> + true $(ROOTFS_DIR) false .cmd @@ -26,7 +27,7 @@ /Applications/Xcode.app/Contents/Developer true true - true + true $(MonoObjDir)cross\config.h true $(Compiler) @@ -41,6 +42,11 @@ + + + + + @@ -854,34 +860,220 @@ make -j$([System.Environment]::ProcessorCount) - - + <_MonoCMakeArgs Condition="'$(MonoBuildTool)' == 'ninja'" Include="-G Ninja"/> + <_MonoCMakeArgs Include="-DCMAKE_INSTALL_PREFIX=$(MonoObjDir)out"/> + <_MonoCMakeArgs Include="-DCMAKE_BUILD_TYPE=$(Configuration)"/> + - + <_MonoCMakeArgs Include="-DCMAKE_OSX_DEPLOYMENT_TARGET=$(macOSVersionMin)" /> + - - - - - - - - + <_MonoCMakeArgs Include="-DENABLE_MINIMAL=ssa,com,jit,reflection_emit_save,portability,assembly_remapping,attach,verifier,full_messages,appdomains,shadowcopy,security,sgen_marksweep_conc,sgen_split_nursery,sgen_gc_bridge,sgen_toggleref,logging,remoting,shared_perfcounters,sgen_debug_helpers,sgen_binary_protocol,soft_debug,interpreter,assert_messages,cleanup,mdb,gac,threads,eventpipe,aot,interpreter"/> + <_MonoCMakeArgs Include="-DENABLE_INTERP_LIB=1"/> + <_MonoCMakeArgs Include="-DDISABLE_ICALL_TABLES=1"/> + <_MonoCMakeArgs Include="-DDISABLE_CRASH_REPORTING=1"/> + <_MonoCMakeArgs Include="-DENABLE_ICALL_EXPORT=1"/> + <_MonoCMakeArgs Include="-DENABLE_LAZY_GC_THREAD_CREATION=1"/> + <_MonoCFLAGS Include="-I$(PkgMicrosoft_NETCore_Runtime_ICU_Transport)/runtimes/browser-wasm/native/include"/> + + + + <_MonoCCOption>CC="$(XcodeDir)/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang" + <_MonoCXXOption>CXX="$(XcodeDir)/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++" + <_MonoRunInitCompiler>false + <_MonoCMakeSysroot Condition="'$(TargetsiOS)' == 'true' and '$(TargetsiOSSimulator)' != 'true'">$(XcodeDir)/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS$(iOSVersion).sdk + <_MonoCMakeSysroot Condition="'$(TargetsiOS)' == 'true' and '$(TargetsiOSSimulator)' == 'true'">$(XcodeDir)/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator$(iOSVersion).sdk + <_MonoCMakeSysroot Condition="'$(TargetstvOS)' == 'true' and '$(TargetstvOSSimulator)' != 'true'">$(XcodeDir)/Platforms/AppleTVOS.platform/Developer/SDKs/AppleTVOS$(tvOSVersion).sdk + <_MonoCMakeSysroot Condition="'$(TargetstvOS)' == 'true' and '$(TargetstvOSSimulator)' == 'true'">$(XcodeDir)/Platforms/AppleTVSimulator.platform/Developer/SDKs/AppleTVSimulator$(tvOSVersion).sdk + <_MonoCMakeSystemName Condition="'$(TargetsiOS)' == 'true'">iOS + <_MonoCMakeSystemName Condition="'$(TargetstvOS)' == 'true'">tvOS + <_MonoCMakeVersionMin Condition="'$(TargetstvOS)' == 'true'">$(tvOSVersionMin) + <_MonoCMakeVersionMin Condition="'$(TargetsiOS)' == 'true'">$(iOSVersionMin) + <_MonoCMakeVersionMin Condition="'$(TargetstvOS)' == 'true'">$(tvOSVersionMin) + + + <_MonoCMakeArgs Include="-DCMAKE_SYSTEM_NAME=$(_MonoCMakeSystemName)"/> + <_MonoCMakeArgs Include="-DCMAKE_OSX_DEPLOYMENT_TARGET=$(_MonoCMakeVersionMin)" /> + <_MonoCMakeArgs Include="-DCMAKE_OSX_SYSROOT='$(_MonoCMakeSysroot)'" /> + <_MonoCMakeArgs Condition="'$(Platform)' == 'x64'" Include="-DCMAKE_OSX_ARCHITECTURES=x86_64"/> + <_MonoCMakeArgs Condition="'$(Platform)' == 'x86'" Include="-DCMAKE_OSX_ARCHITECTURES=i386"/> + <_MonoCMakeArgs Condition="'$(Platform)' == 'arm64'" Include="-DCMAKE_OSX_ARCHITECTURES=arm64"/> + <_MonoCMakeArgs Condition="'$(Platform)' == 'arm'" Include="-DCMAKE_OSX_ARCHITECTURES=armv7s"/> + <_MonoCFLAGS Include="-Wl,-application_extension" /> + <_MonoCXXFLAGS Include="-Wl,-application_extension" /> + + + + <_MonoCMakeArgs Include="-DENABLE_MINIMAL=com,remoting,shared_perfcounters,gac"/> + + + + <_MonoCMakeArgs Include="-DENABLE_MINIMAL=ssa,com,interpreter,jit,portability,assembly_remapping,attach,verifier,full_messages,appdomains,security,sgen_remset,sgen_marksweep_par,sgen_marksweep_fixed,sgen_marksweep_fixed_par,sgen_copying,logging,remoting,shared_perfcounters,gac,eventpipe" /> + <_MonoCMakeArgs Include="-DDISABLE_ICALL_TABLES=1"/> + <_MonoCMakeArgs Include="-DENABLE_ICALL_EXPORT=0"/> + <_MonoCMakeArgs Include="-DENABLE_VISIBILITY_HIDDEN=1"/> + <_MonoCMakeArgs Include="-DENABLE_LAZY_GC_THREAD_CREATION=1"/> + <_MonoCMakeArgs Include="-DENABLE_SIGALTSTACK=0"/> + <_MonoCFLAGS Include="-Werror=partial-availability" /> + <_MonoCFLAGS Include="-fexceptions" /> + <_MonoCPPFLAGS Include="-DSMALL_CONFIG" /> + <_MonoCPPFLAGS Include="-D_XOPEN_SOURCE" /> + <_MonoCPPFLAGS Include="-DHAVE_LARGE_FILE_SUPPORT=1" /> + <_MonoCXXFLAGS Include="-Werror=partial-availability" /> + + + + false + + + <_MonoCMakeArgs Include="-DCMAKE_SYSTEM_NAME=Android"/> + <_MonoCMakeArgs Include="-DCMAKE_ANDROID_NDK=$(ANDROID_NDK_ROOT)"/> + <_MonoCMakeArgs Include="-DCMAKE_SYSTEM_VERSION=$(AndroidApiVersion)"/> + <_MonoCMakeArgs Condition="'$(Platform)' == 'arm64'" Include="-DCMAKE_ANDROID_ARCH_ABI=arm64-v8a" /> + <_MonoCMakeArgs Condition="'$(Platform)' == 'arm'" Include="-DCMAKE_ANDROID_ARCH_ABI=armeabi-v7a" /> + <_MonoCMakeArgs Condition="'$(Platform)' == 'x86'" Include="-DCMAKE_ANDROID_ARCH_ABI=x86" /> + <_MonoCMakeArgs Condition="'$(Platform)' == 'x64'" Include="-DCMAKE_ANDROID_ARCH_ABI=x86_64" /> + <_MonoCMakeArgs Include="-DENABLE_MINIMAL=ssa,portability,attach,verifier,full_messages,sgen_remset,sgen_marksweep_par,sgen_marksweep_fixed,sgen_marksweep_fixed_par,sgen_copying,logging,security,shared_handles,interpreter,gac,cfgdir_config" /> + <_MonoCMakeArgs Include="-DENABLE_SIGALTSTACK=1"/> + <_MonoCMakeArgs Include="-DDISABLE_CRASH_REPORTING=1"/> + <_MonoCMakeArgs Include="-DENABLE_PERFTRACING=0"/> + + <_MonoCFLAGS Condition="'$(Platform)' == 'arm'" Include="-march=armv7-a" /> + <_MonoCFLAGS Condition="'$(Platform)' == 'arm'" Include="-mtune=cortex-a8" /> + <_MonoCFLAGS Condition="'$(Platform)' == 'arm'" Include="-mfpu=vfp" /> + <_MonoCFLAGS Condition="'$(Platform)' == 'arm'" Include="-mfloat-abi=softfp" /> + <_MonoCFLAGS Condition="'$(Platform)' == 'arm64' or '$(Platform)' == 'arm'" Include="-fpic" /> + <_MonoCFLAGS Include="-fstack-protector" /> + <_MonoCFLAGS Condition="'$(Platform)' == 'arm64'" Include="-DANDROID64" /> + <_MonoCFLAGS Condition="'$(Platform)' == 'arm64' or '$(Platform)' == 'x64'" Include="-DL_cuserid=9" /> + <_MonoCFLAGS Condition="'$(Platform)' == 'arm64' or '$(Platform)' == 'arm'" Include="-D__POSIX_VISIBLE=201002" /> + <_MonoCFLAGS Condition="'$(Platform)' == 'arm64' or '$(Platform)' == 'arm'" Include="-DSK_RELEASE" /> + <_MonoCFLAGS Condition="'$(Platform)' == 'arm64' or '$(Platform)' == 'arm'" Include="-DNDEBUG" /> + <_MonoCFLAGS Condition="'$(Platform)' == 'arm64' or '$(Platform)' == 'arm'" Include="-UDEBUG" /> + + <_MonoCXXFLAGS Condition="'$(Platform)' == 'arm'" Include="-march=armv7-a" /> + <_MonoCXXFLAGS Condition="'$(Platform)' == 'arm'" Include="-mtune=cortex-a8" /> + <_MonoCXXFLAGS Condition="'$(Platform)' == 'arm'" Include="-mfpu=vfp" /> + <_MonoCXXFLAGS Condition="'$(Platform)' == 'arm'" Include="-mfloat-abi=softfp" /> + <_MonoCXXFLAGS Condition="'$(Platform)' == 'arm64' or '$(Platform)' == 'arm'" Include="-fpic" /> + <_MonoCXXFLAGS Include="-fstack-protector" /> + <_MonoCXXFLAGS Condition="'$(Platform)' == 'arm64'" Include="-DANDROID64" /> + <_MonoCXXFLAGS Condition="'$(Platform)' == 'arm64' or '$(Platform)' == 'x64'" Include="-DL_cuserid=9" /> + <_MonoCXXFLAGS Condition="'$(Platform)' == 'arm64' or '$(Platform)' == 'arm'" Include="-D__POSIX_VISIBLE=201002" /> + <_MonoCXXFLAGS Condition="'$(Platform)' == 'arm64' or '$(Platform)' == 'arm'" Include="-DSK_RELEASE" /> + <_MonoCXXFLAGS Condition="'$(Platform)' == 'arm64' or '$(Platform)' == 'arm'" Include="-DNDEBUG" /> + <_MonoCXXFLAGS Condition="'$(Platform)' == 'arm64' or '$(Platform)' == 'arm'" Include="-UDEBUG" /> + + <_MonoLDFLAGS Include="-z now" /> + <_MonoLDFLAGS Include="-z relro" /> + <_MonoLDFLAGS Include="-z noexecstack" /> + <_MonoLDFLAGS Include="-ldl" /> + <_MonoLDFLAGS Include="-lm" /> + <_MonoLDFLAGS Include="-llog" /> + <_MonoLDFLAGS Include="-lc" /> + <_MonoLDFLAGS Include="-lgcc" /> + + + + <_MonoCFLAGSOption>-DCMAKE_C_FLAGS="@(_MonoCPPFLAGS, ' ') @(_MonoCFLAGS, ' ')" + <_MonoCXXFLAGSOption>-DCMAKE_CXX_FLAGS="@(_MonoCPPFLAGS, ' ') @(_MonoCXXFLAGS, ' ')" + + + <_MonoCMakeArgs Include="$(_MonoCFLAGSOption)"/> + <_MonoCMakeArgs Include="$(_MonoCXXFLAGSOption)"/> - + - - + + + + + + + + + + ninja + make -j$([System.Environment]::ProcessorCount) + + + + + + true + $(XcodeDir)/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS$(iOSVersion).sdk + $(XcodeDir)/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator$(iOSVersion).sdk + $(XcodeDir)/Platforms/AppleTVOS.platform/Developer/SDKs/AppleTVOS$(tvOSVersion).sdk + $(XcodeDir)/Platforms/AppleTVSimulator.platform/Developer/SDKs/AppleTVSimulator$(tvOSVersion).sdk + $(MonoObjDir)cross/offsets-$(Platform)-darwin.h + aarch64-apple-darwin10 + arm-apple-darwin10 + i386-apple-darwin10 + x86_64-apple-darwin10 + + + + + true + wasm32-unknown-none + $(MonoObjDir)cross/offsets-wasm32-unknown-none.h + $(EMSDK_PATH)/upstream/lib/libclang.dylib + $(EMSDK_PATH)/upstream/lib/libclang.so + + + + $(XcodeDir)/Toolchains/XcodeDefault.xctoolchain/usr/lib/libclang.dylib + + + + + + + + + + + + + + python3 $(MonoProjectRoot)mono/tools/offsets-tool/offsets-tool.py @(MonoAotCrossOffsetsToolParams, ' ') + + + + + + + + + + + + + + + + + + + + + + + + + + + - + <_MonoRuntimeFilePath Condition="'$(TargetsWindows)' == 'true' and '$(Platform)' == 'x64'">$(MonoObjDir)x64\Bin\$(Configuration)\mono-2.0-sgen.dll <_MonoRuntimeFilePath Condition="'$(TargetsWindows)' == 'true' and '$(Platform)' == 'x86'">$(MonoObjDir)Win32\Bin\$(Configuration)\mono-2.0-sgen.dll @@ -894,12 +1086,13 @@ <_MonoRuntimeFilePath Condition="'$(TargetsBrowser)' == 'true' and '$(MonoEnableCMake)' == 'true'">$(MonoObjDir)out\lib\libmonosgen-2.0.a <_MonoRuntimeFilePath Condition="'$(_MonoRuntimeFilePath)' == ''">$(MonoObjDir)mono\mini\.libs\libmonosgen-2.0.so <_MonoRuntimeStaticFilePath Condition="'$(TargetsiOS)' == 'true' or '$(TargetstvOS)' == 'true' or '$(TargetsAndroid)' == 'true'">$(MonoObjDir)out\lib\libmonosgen-2.0.a - <_MonoAotCrossFilePath Condition="'$(TargetsiOS)' == 'true' and '$(Platform)' == 'arm64'">$(MonoObjDir)cross\out\bin\aarch64-apple-darwin10-mono-sgen - <_MonoAotCrossFilePath Condition="'$(TargetsiOS)' == 'true' and '$(Platform)' == 'arm'">$(MonoObjDir)cross\out\bin\arm-apple-darwin10-mono-sgen - <_MonoAotCrossFilePath Condition="'$(TargetsiOS)' == 'true' and '$(Platform)' == 'x86'">$(MonoObjDir)cross\out\bin\i386-apple-darwin10-mono-sgen - <_MonoAotCrossFilePath Condition="'$(TargetsiOS)' == 'true' and '$(Platform)' == 'x64'">$(MonoObjDir)cross\out\bin\mono-sgen - <_MonoAotCrossFilePath Condition="'$(TargetstvOS)' == 'true' and '$(Platform)' == 'arm64'">$(MonoObjDir)cross\out\bin\aarch64-apple-darwin10-mono-sgen - <_MonoAotCrossFilePath Condition="'$(TargetstvOS)' == 'true' and '$(Platform)' == 'x64'">$(MonoObjDir)cross\out\bin\mono-sgen + <_MonoAotCrossFilePath Condition="'$(MonoEnableCMake)' == 'true' and '$(BuildMonoAOTCrossCompiler)' == 'true'">$(MonoObjDir)cross\out\bin\mono-sgen + <_MonoAotCrossFilePath Condition="'$(TargetsiOS)' == 'true' and '$(Platform)' == 'arm64' and '$(MonoEnableCMake)' != 'true'">$(MonoObjDir)cross\out\bin\aarch64-apple-darwin10-mono-sgen + <_MonoAotCrossFilePath Condition="'$(TargetsiOS)' == 'true' and '$(Platform)' == 'arm' and '$(MonoEnableCMake)' != 'true'">$(MonoObjDir)cross\out\bin\arm-apple-darwin10-mono-sgen + <_MonoAotCrossFilePath Condition="'$(TargetsiOS)' == 'true' and '$(Platform)' == 'x86' and '$(MonoEnableCMake)' != 'true'">$(MonoObjDir)cross\out\bin\i386-apple-darwin10-mono-sgen + <_MonoAotCrossFilePath Condition="'$(TargetsiOS)' == 'true' and '$(Platform)' == 'x64' and '$(MonoEnableCMake)' != 'true'">$(MonoObjDir)cross\out\bin\mono-sgen + <_MonoAotCrossFilePath Condition="'$(TargetstvOS)' == 'true' and '$(Platform)' == 'arm64' and '$(MonoEnableCMake)' != 'true'">$(MonoObjDir)cross\out\bin\aarch64-apple-darwin10-mono-sgen + <_MonoAotCrossFilePath Condition="'$(TargetstvOS)' == 'true' and '$(Platform)' == 'x64' and '$(MonoEnableCMake)' != 'true'">$(MonoObjDir)cross\out\bin\mono-sgen <_MonoAotCrossFilePath Condition="'$(TargetsBrowser)' == 'true' and '$(MonoEnableCMake)' != 'true'">$(MonoObjDir)cross\out\bin\wasm32-unknown-none-mono-sgen