From 484a23df543450491123452d964ad982f85fa588 Mon Sep 17 00:00:00 2001 From: Zoltan Varga Date: Fri, 14 Aug 2020 10:56:22 -0400 Subject: [PATCH] [runtime] Update cmake build. (#40811) * Update cmake build. * . * Auto detect ENABLE_NETCORE. --- src/mono/CMakeLists.txt | 33 ++++++++++++++++--- src/mono/cmake/configure.cmake | 4 ++- src/mono/cmake/defines-todo.cmake | 4 +++ src/mono/cmake/options.cmake | 7 +++++ src/mono/mono/metadata/native-library.c | 7 +++++ src/mono/mono/mini/CMakeLists.txt | 56 +++++++++++++++++++++++++++------ 6 files changed, 95 insertions(+), 16 deletions(-) diff --git a/src/mono/CMakeLists.txt b/src/mono/CMakeLists.txt index 574f039..ba0a291 100644 --- a/src/mono/CMakeLists.txt +++ b/src/mono/CMakeLists.txt @@ -6,6 +6,7 @@ include(GNUInstallDirs) include(CheckIncludeFile) include(CheckFunctionExists) include(TestBigEndian) +include (FindPkgConfig) set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} @@ -32,7 +33,7 @@ include(configure) set(VERSION "") execute_process( - COMMAND grep ^MONO_CORLIB_VERSION= configure.ac + COMMAND grep ^MONO_CORLIB_VERSION= ${CMAKE_SOURCE_DIR}/configure.ac COMMAND cut -d = -f 2 OUTPUT_VARIABLE CORLIB_VERSION_OUT ) @@ -42,6 +43,10 @@ endif() string(STRIP "${CORLIB_VERSION_OUT}" MONO_CORLIB_VERSION_BASE) set(MONO_CORLIB_VERSION "\"${MONO_CORLIB_VERSION_BASE}\"") +if(EXISTS "${CMAKE_SOURCE_DIR}/mono.proj") + set(ENABLE_NETCORE 1) +endif() + if (ENABLE_NETCORE) set(DISABLE_REMOTING 1) set(DISABLE_REFLECTION_EMIT_SAVE 1) @@ -55,6 +60,8 @@ if (ENABLE_NETCORE) set(DISABLE_PERFCOUNTERS 1) set(DISABLE_ATTACH 1) set(DISABLE_DLLMAP 1) + set(DISABLE_CONFIG 1) + set(DISABLE_CFGDIR_CONFIG 1) else() message(FATAL_ERROR "Building without -DENABLE_NETCORE=1 is not supported.") endif() @@ -112,7 +119,7 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Darwin") set(PTHREAD_POINTER_ID 1) set(USE_MACH_SEMA 1) else() - message(FATAL ERROR "") + message(FATAL_ERROR "") endif() ###################################### @@ -129,7 +136,7 @@ if(TARGET_SYSTEM_NAME STREQUAL "Darwin") set(CORETARGETS "-p:TargetsUnix=true -p:TargetsOSX=true") set(NETCORE_HOST_PLATFORM "macos") else() - message(FATAL ERROR "") + message(FATAL_ERROR "") endif() ###################################### @@ -139,7 +146,7 @@ endif() if(CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64") set(HOST_AMD64 1) else() - message(FATAL ERROR "") + message(FATAL_ERROR "") endif() ###################################### @@ -154,7 +161,23 @@ if(TARGET_ARCH STREQUAL "x86_64") set(RID_SUFFIX "x64") set(COREARCH "x64") else() - message(FATAL ERROR "") + message(FATAL_ERROR "") +endif() + +###################################### +# ICU CHECKS +###################################### +set(ICU_SHIM_PATH "../../../libraries/Native/Unix/System.Globalization.Native") +if(TARGET_OSX) + # FIXME: Handle errors + # Defines ICU_INCLUDEDIR/ICU_LIBDIR + set(ENV{PKG_CONFIG_PATH} "{$PKG_CONFIG_PATH}:/usr/local/lib/pkgconfig:/usr/local/opt/icu4c/lib/pkgconfig") + pkg_check_modules(ICU icu-uc) + set(OSX_ICU_LIBRARY_PATH /usr/lib/libicucore.dylib) + set(ICU_FLAGS "-DTARGET_UNIX -DU_DISABLE_RENAMING -Wno-reserved-id-macro -Wno-documentation -Wno-documentation-unknown-command -Wno-switch-enum -Wno-covered-switch-default -Wno-covered-switch-default -Wno-extra-semi-stmt -Wno-unknown-warning-option -Wno-deprecated-declarations") + set(HAVE_SYS_ICU 1) +else() + message(FATAL_ERROR "") endif() ###################################### diff --git a/src/mono/cmake/configure.cmake b/src/mono/cmake/configure.cmake index e8d150c..782f49a 100644 --- a/src/mono/cmake/configure.cmake +++ b/src/mono/cmake/configure.cmake @@ -63,7 +63,7 @@ ac_check_funcs ( 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_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 @@ -81,12 +81,14 @@ check_symbol_exists(IP_PKTINFO "linux/in.h" HAVE_IP_PKTINFO) check_symbol_exists(IPV6_PKTINFO "netdb.h" HAVE_IPV6_PKTINFO) check_symbol_exists(IP_DONTFRAGMENT "Ws2ipdef.h" HAVE_IP_DONTFRAGMENT) check_symbol_exists(IP_MTU_DISCOVER "linux/in.h" HAVE_IP_MTU_DISCOVER) +check_symbol_exists(sys_signame "signal.h" HAVE_SYSSIGNAME) ac_check_type("struct sockaddr_in6" sockaddr_in6 "netinet/in.h") ac_check_type("struct timeval" timeval "sys/time.h;sys/types.h;utime.h") ac_check_type("socklen_t" socklen_t "sys/types.h;sys/socket.h") ac_check_type("struct ip_mreqn" ip_mreqn "netinet/in.h") ac_check_type("struct ip_mreq" ip_mreq "netinet/in.h") +ac_check_type("clockid_t" clockid_t "sys/types.h") check_struct_has_member("struct kinfo_proc" kp_proc "sys/types.h;sys/param.h;sys/sysctl.h;sys/proc.h" HAVE_STRUCT_KINFO_PROC_KP_PROC) check_struct_has_member("struct sockaddr_in" sin_len "netinet/in.h" HAVE_SOCKADDR_IN_SIN_LEN) diff --git a/src/mono/cmake/defines-todo.cmake b/src/mono/cmake/defines-todo.cmake index 0f9e6e4..55c5b6f 100644 --- a/src/mono/cmake/defines-todo.cmake +++ b/src/mono/cmake/defines-todo.cmake @@ -93,3 +93,7 @@ #option (ENABLE_CHECKED_BUILD_PRIVATE_TYPES "Enable private types checked build") #option (ENABLE_CHECKED_BUILD_CRASH_REPORTING "Enable private types checked build") #option (HAVE_BTLS "BoringTls is supported") +#option (ENABLE_JIT_DUMP "Enable jit dump support on Linux") +#option (DISABLE_CRASH_REPORTING) +#option (ENABLE_CXX) +#option (STATIC_ICU) diff --git a/src/mono/cmake/options.cmake b/src/mono/cmake/options.cmake index 9ad182c..0e24b9f 100644 --- a/src/mono/cmake/options.cmake +++ b/src/mono/cmake/options.cmake @@ -39,4 +39,11 @@ option (DISABLE_SOCKETS "Disable sockets") option (DISABLE_GAC "Disable GAC") option (DISABLE_DLLMAP "Disables use of DllMaps in MonoVM") option (DISABLE_THREADS "Disable Threads") +option (DISABLE_CONFIG "Disable .config file support") +option (DISABLE_CFGDIR_CONFIG "Disable config directories") +option (DISABLE_SGEN_TOGGLEREF "Disable toggleref support in SGEN") +option (DISABLE_SGEN_BINARY_PROTOCOL "Disable binary protocol logging in SGEN") +option (DISABLE_PROCESSES "Disable process support") +option (DISABLE_EVENTPIPE "Disable EventPipe support") +option (ENABLE_PERFTRACING "Enables support for eventpipe library") diff --git a/src/mono/mono/metadata/native-library.c b/src/mono/mono/metadata/native-library.c index ff2c6cc..851225d 100644 --- a/src/mono/mono/metadata/native-library.c +++ b/src/mono/mono/metadata/native-library.c @@ -1293,6 +1293,13 @@ lookup_pinvoke_call_impl (MonoMethod *method, MonoLookupPInvokeStatus *status_ou if (strcmp (new_scope, "QCall") == 0) { piinfo->addr = mono_lookup_pinvoke_qcall_internal (method, status_out); + if (!piinfo->addr) { + mono_trace (G_LOG_LEVEL_WARNING, MONO_TRACE_DLLIMPORT, + "Unable to find qcall for '%s'.", + new_import); + status_out->err_code = LOOKUP_PINVOKE_ERR_NO_SYM; + status_out->err_arg = g_strdup (new_import); + } return piinfo->addr; } diff --git a/src/mono/mono/mini/CMakeLists.txt b/src/mono/mono/mini/CMakeLists.txt index d987150..256316c 100644 --- a/src/mono/mono/mini/CMakeLists.txt +++ b/src/mono/mono/mini/CMakeLists.txt @@ -10,6 +10,8 @@ endfunction() include_directories( ${PROJECT_BINARY_DIR}/ ${PROJECT_BINARY_DIR}/../.. + ${PROJECT_BINARY_DIR}/../../mono/eglib + ${CMAKE_SOURCE_DIR}/ ${PROJECT_SOURCE_DIR}/../ ${PROJECT_SOURCE_DIR}/../eglib ${PROJECT_SOURCE_DIR}/../sgen) @@ -188,6 +190,8 @@ set (utils_common_sources lock-free-alloc.h lock-free-array-queue.c lock-free-array-queue.h + lifo-semaphore.c + lifo-semaphore.h mono-linked-list-set.c mono-linked-list-set.h mono-threads.c @@ -205,6 +209,7 @@ set (utils_common_sources mono-threads-haiku.c mono-threads-aix.c mono-threads-wasm.c + mono-threads-sunos.c mono-threads.h mono-threads-debug.h mono-threads-api.h @@ -226,6 +231,7 @@ set (utils_common_sources bsearch.h bsearch.c mono-signal-handler.h + mono-signal-handler.c mono-conc-hashtable.h mono-conc-hashtable.c json.h @@ -328,19 +334,19 @@ set(metadata_common_sources class.c class-getters.h class-init.h + class-init-internals.h class-init.c class-internals.h class-inlines.h class-private-definition.h class-accessors.c + class-setup-vtable.c cominterop.c cominterop.h console-io.h coree.c coree.h coree-internals.h - culture-info.h - culture-info-tables.h debug-helpers.c debug-mono-symfile.h debug-mono-symfile.c @@ -362,12 +368,11 @@ set(metadata_common_sources icall-internals.h icall-def.h icall-table.h + icall-eventpipe.c image.c image-internals.h jit-info.c loader.c - locales.c - locales.h lock-tracer.c lock-tracer.h marshal.c @@ -485,7 +490,7 @@ set(metadata_common_sources native-library.h native-library.c native-library-qcall.c - qcalllist.h + qcall-def.h loaded-images-internals.h loaded-images.c loaded-images-netcore.c @@ -598,6 +603,27 @@ set(sgen_sources_base addprefix (sgen_sources ../sgen/ "${sgen_sources_base}") set_source_files_properties (${sgen_sources} PROPERTIES COMPILE_DEFINITIONS "HAVE_SGEN_GC") +# ICU +if(HAVE_SYS_ICU) +set (icu_shim_sources_base + pal_calendarData.c + pal_casing.c + pal_collation.c + pal_idna.c + pal_locale.c + pal_localeNumberData.c + pal_localeStringData.c + pal_normalization.c + pal_timeZoneInfo.c + entrypoints.c + pal_icushim.c) +addprefix (icu_shim_sources "${ICU_SHIM_PATH}" "${icu_shim_sources_base}") +set_source_files_properties (${icu_shim_sources} PROPERTIES COMPILE_DEFINITIONS OSX_ICU_LIBRARY_PATH="${OSX_ICU_LIBRARY_PATH}") +set_source_files_properties (${icu_shim_sources} PROPERTIES COMPILE_FLAGS "-I${ICU_INCLUDEDIR} -I${CMAKE_SOURCE_DIR}/../libraries/Native/Unix/System.Globalization.Native/ -I${CMAKE_SOURCE_DIR}/../libraries/Native/Unix/Common/ ${ICU_FLAGS}") +set(ICU_LIBS "icucore") +set(ICU_LDFLAGS "-L${ICU_LIBDIR}") +endif() + # # MINI # @@ -667,6 +693,7 @@ set (mini_common_sources mini-cross-helpers.c arch-stubs.c llvm-runtime.h + llvm-intrinsics.h type-checking.c lldb.h lldb.c @@ -727,6 +754,8 @@ set (interp_sources interp/interp.h interp/interp-internals.h interp/interp.c + interp/interp-intrins.h + interp/interp-intrins.c interp/mintops.h interp/mintops.c interp/transform.c) @@ -752,19 +781,25 @@ endif() set (mini_sources "${CMAKE_CURRENT_BINARY_DIR}/buildver-sgen.h;main-core.c;${mini_common_sources};${arch_sources};${os_sources};${interp_sources};${llvm_sources};${debugger_sources};${llvm_runtime_sources}") -add_library(monosgen-objects OBJECT "${eglib_sources};${metadata_sources};${utils_sources};${sgen_sources};${mini_sources}") +add_library(monosgen-objects OBJECT "${eglib_sources};${metadata_sources};${utils_sources};${sgen_sources};${icu_shim_sources};${mini_sources}") add_library (monosgen-static STATIC $) add_library (monosgen SHARED $) set_target_properties(monosgen PROPERTIES OUTPUT_NAME monosgen-2.0) set_target_properties(monosgen PROPERTIES LIBRARY_OUTPUT_DIRECTORY .libs) +# FIXME: Always rebuilds, creates non-deterministic builds # FIXME: Use the previous format -string(TIMESTAMP BUILD_DATE) +#string(TIMESTAMP BUILD_DATE) +#add_custom_command ( +# OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/buildver-sgen.h +# COMMAND echo "const char *build_date = \"${BUILD_DATE}\";" > ${CMAKE_CURRENT_BINARY_DIR}/buildver-sgen.h +# VERBATIM +#) add_custom_command ( OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/buildver-sgen.h - COMMAND echo "const char *build_date = \"${BUILD_DATE}\";" > ${CMAKE_CURRENT_BINARY_DIR}/buildver-sgen.h + COMMAND echo "const char *build_date = \"\";" > ${CMAKE_CURRENT_BINARY_DIR}/buildver-sgen.h VERBATIM ) @@ -781,5 +816,6 @@ add_custom_command ( ) add_executable (mono-sgen "main-sgen.c") -target_link_libraries (mono-sgen monosgen-static "-framework CoreFoundation" "-framework Foundation" "iconv" ${LLVM_LIBS}) -target_link_libraries (monosgen "-framework CoreFoundation" "-framework Foundation" "iconv" ${LLVM_LIBS}) +target_link_libraries (mono-sgen monosgen-static "-framework CoreFoundation" "-framework Foundation" "iconv" ${LLVM_LIBS} ${ICU_LIBS}) +target_link_libraries (monosgen "-framework CoreFoundation" "-framework Foundation" "iconv" ${LLVM_LIBS} ${ICU_LIBS}) +set_target_properties (mono-sgen monosgen PROPERTIES LINK_FLAGS ${ICU_LDFLAGS}) -- 2.7.4