Skip to content

Commit

Permalink
[mono] Cleanup unused runtime functions (dotnet#91681)
Browse files Browse the repository at this point in the history
- Removes unused functions
- Removes cmake configure checks for functions/headers that are no longer needed
- Renames HAVE_UWP_WINAPI_SUPPORT to HAVE_APP_WINAPI_SUPPORT
- Move MSVC warning disables into cmake so it is more visible

Co-authored-by: Johan Lorensson <lateralusx.github@gmail.com>
  • Loading branch information
akoeplinger and lateralusX authored Sep 29, 2023
1 parent e81671f commit 38fd485
Show file tree
Hide file tree
Showing 71 changed files with 173 additions and 3,533 deletions.
4 changes: 3 additions & 1 deletion src/coreclr/scripts/genEventPipe.py
Original file line number Diff line number Diff line change
Expand Up @@ -1107,7 +1107,9 @@ def getMonoEventPipeImplFilePrefix():
#if WCHAR_MAX == 0xFFFF
provider_name_utf8 = g_utf16_to_utf8 ((const gunichar2 *)provider_name, -1, NULL, NULL, NULL);
#else
provider_name_utf8 = g_ucs4_to_utf8 ((const gunichar *)provider_name, -1, NULL, NULL, NULL);
gunichar2 *provider_name_utf16 = g_ucs4_to_utf16 ((const gunichar *)provider_name, -1, NULL, NULL, NULL);
provider_name_utf8 = g_utf16_to_utf8 (provider_name_utf16, -1, NULL, NULL, NULL);
g_free (provider_name_utf16);
#endif
ep_return_null_if_nok (provider_name_utf8 != NULL);
Expand Down
16 changes: 12 additions & 4 deletions src/mono/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,18 @@ if (MSVC)
if(EXISTS ${CLR_SOURCELINK_FILE_PATH})
add_link_options("/sourcelink:${CLR_SOURCELINK_FILE_PATH}")
endif()

# FIXME This is all questionable but the logs are flooded and nothing else is fixing them.
add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/wd4090>) # W1: const problem
add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/wd4100>) # W4: unreferenced formal parameter
add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/wd4152>) # W4: nonstandard extension, function/data pointer conversion in expression
add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/wd4201>) # W4: nonstandard extension used: nameless struct/union
add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/wd4210>) # W4: nonstandard extension used: function given file scope
add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/wd4245>) # W4: signed/unsigned mismatch
add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/wd4389>) # W4: signed/unsigned mismatch
add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/wd4505>) # W4: unreferenced function with internal linkage has been removed
add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/wd4702>) # W4: unreachable code
add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/wd4706>) # W4: assignment within conditional expression
endif(MSVC)

set(CROSS_ROOTFS $ENV{ROOTFS_DIR})
Expand Down Expand Up @@ -76,7 +88,6 @@ if(ENABLE_MINIMAL)
endif()

set(DISABLE_COM 1)
set(DISABLE_DLLMAP 1)

# Dependencies between options
if(ENABLE_INTERP_LIB)
Expand All @@ -102,7 +113,6 @@ if(GCC)
set(USE_GCC_ATOMIC_OPS 1)
endif()

set(HAVE_CLASSIC_WINAPI_SUPPORT 1)
set(HAVE_MOVING_COLLECTOR 1)
set(HAVE_CONC_GC_AS_DEFAULT 1)
set(MONO_INSIDE_RUNTIME 1)
Expand Down Expand Up @@ -796,7 +806,6 @@ if(HOST_WIN32)
set(EGLIB_PATHSEP "\\\\")
set(EGLIB_SEARCHSEP ";")
set(EGLIB_OS "WIN32")
set(EGLIB_PIDTYPE "void *")
if(HOST_AMD64 OR HOST_ARM64)
set(EGLIB_GSIZE_FORMAT "\"Iu\"")
else()
Expand All @@ -814,7 +823,6 @@ else()
set(EGLIB_PATHSEP "/")
set(EGLIB_SEARCHSEP ":")
set(EGLIB_OS "UNIX")
set(EGLIB_PIDTYPE "int")
set(EGLIB_GSIZE_FORMAT "\"zu\"")
endif()

Expand Down
137 changes: 4 additions & 133 deletions src/mono/cmake/config.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,6 @@

#ifdef _MSC_VER

// FIXME This is all questionable but the logs are flooded and nothing else is fixing them.
#pragma warning(disable:4090) // W1: const problem
#pragma warning(disable:4100) // W4: unreferenced formal parameter
#pragma warning(disable:4152) // W4: nonstandard extension, function/data pointer conversion in expression
#pragma warning(disable:4201) // W4: nonstandard extension used: nameless struct/union
#pragma warning(disable:4210) // W4: nonstandard extension used: function given file scope
#pragma warning(disable:4245) // W4: signed/unsigned mismatch
#pragma warning(disable:4389) // W4: signed/unsigned mismatch
#pragma warning(disable:4505) // W4: unreferenced function with internal linkage has been removed
#pragma warning(disable:4702) // W4: unreachable code
#pragma warning(disable:4706) // W4: assignment within conditional expression

#include <SDKDDKVer.h>

#if _WIN32_WINNT < 0x0601
Expand All @@ -30,13 +18,13 @@

#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
#define HAVE_CLASSIC_WINAPI_SUPPORT 1
#define HAVE_UWP_WINAPI_SUPPORT 0
#define HAVE_APP_WINAPI_SUPPORT 0
#elif WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP)
#define HAVE_CLASSIC_WINAPI_SUPPORT 0
#define HAVE_UWP_WINAPI_SUPPORT 1
#define HAVE_APP_WINAPI_SUPPORT 1
#else
#define HAVE_CLASSIC_WINAPI_SUPPORT 0
#define HAVE_UWP_WINAPI_SUPPORT 0
#define HAVE_APP_WINAPI_SUPPORT 0
#ifndef HAVE_EXTERN_DEFINED_WINAPI_SUPPORT
#error Unsupported WINAPI family
#endif
Expand Down Expand Up @@ -105,12 +93,6 @@
/* Target Platform is Linux (musl libc)*/
#cmakedefine TARGET_LINUX_MUSL 1

/* Use classic Windows API support */
#cmakedefine HAVE_CLASSIC_WINAPI_SUPPORT 1

/* Don't use UWP Windows API support */
#cmakedefine HAVE_UWP_WINAPI_SUPPORT 1

/* Define to 1 if you have the <sys/types.h> header file. */
#cmakedefine HAVE_SYS_TYPES_H 1

Expand All @@ -135,21 +117,12 @@
/* Define to 1 if you have the <syslog.h> header file. */
#cmakedefine HAVE_SYSLOG_H 1

/* Define to 1 if you have the <sys/filio.h> header file. */
#cmakedefine HAVE_SYS_FILIO_H 1

/* Define to 1 if you have the <sys/sockio.h> header file. */
#cmakedefine HAVE_SYS_SOCKIO_H 1

/* Define to 1 if you have the <netdb.h> header file. */
#cmakedefine HAVE_NETDB_H 1

/* Define to 1 if you have the <utime.h> header file. */
#cmakedefine HAVE_UTIME_H 1

/* Define to 1 if you have the <sys/utime.h> header file. */
#cmakedefine HAVE_SYS_UTIME_H 1

/* Define to 1 if you have the <semaphore.h> header file. */
#cmakedefine HAVE_SEMAPHORE_H 1

Expand Down Expand Up @@ -210,9 +183,6 @@
/* Define to 1 if you have the <unwind.h> header file. */
#cmakedefine HAVE_UNWIND_H 1

/* Define to 1 if you have the <sys/user.h> header file. */
#cmakedefine HAVE_SYS_USER_H 1

/* Use static ICU */
#cmakedefine STATIC_ICU 1

Expand Down Expand Up @@ -308,9 +278,6 @@
/* Disable sockets */
#cmakedefine DISABLE_SOCKETS 1

/* Disables use of DllMaps in MonoVM */
#cmakedefine DISABLE_DLLMAP 1

/* Disable Threads */
#cmakedefine DISABLE_THREADS 1

Expand All @@ -323,9 +290,6 @@
/* Define to 1 if you have the `sigaction' function. */
#cmakedefine HAVE_SIGACTION 1

/* Define to 1 if you have the `kill' function. */
#cmakedefine HAVE_KILL 1

/* CLOCK_MONOTONIC */
#cmakedefine HAVE_CLOCK_MONOTONIC 1

Expand Down Expand Up @@ -365,9 +329,6 @@
/* Define to 1 if you have the `madvise' function. */
#cmakedefine HAVE_MADVISE 1

/* Define to 1 if you have the `getrusage' function. */
#cmakedefine HAVE_GETRUSAGE 1

/* Define to 1 if you have the `dladdr' function. */
#cmakedefine HAVE_DLADDR 1

Expand All @@ -380,39 +341,18 @@
/* Define to 1 if you have the `prctl' function. */
#cmakedefine HAVE_PRCTL 1

/* Define to 1 if you have the `nl_langinfo' function. */
#cmakedefine HAVE_NL_LANGINFO 1

/* sched_getaffinity */
#cmakedefine HAVE_SCHED_GETAFFINITY 1

/* sched_setaffinity */
#cmakedefine HAVE_SCHED_SETAFFINITY 1

/* Define to 1 if you have the `chmod' function. */
#cmakedefine HAVE_CHMOD 1

/* Define to 1 if you have the `lstat' function. */
#cmakedefine HAVE_LSTAT 1

/* Define to 1 if you have the `getdtablesize' function. */
#cmakedefine HAVE_GETDTABLESIZE 1

/* Define to 1 if you have the `ftruncate' function. */
#cmakedefine HAVE_FTRUNCATE 1

/* Define to 1 if you have the `msync' function. */
#cmakedefine HAVE_MSYNC 1

/* Define to 1 if you have the `getpeername' function. */
#cmakedefine HAVE_GETPEERNAME 1

/* Define to 1 if you have the `utime' function. */
#cmakedefine HAVE_UTIME 1

/* Define to 1 if you have the `utimes' function. */
#cmakedefine HAVE_UTIMES 1

/* Define to 1 if you have the `openlog' function. */
#cmakedefine HAVE_OPENLOG 1

Expand Down Expand Up @@ -443,24 +383,6 @@
/* Have gethostbyname */
#cmakedefine HAVE_GETHOSTBYNAME 1

/* Have getprotobyname */
#cmakedefine HAVE_GETPROTOBYNAME 1

/* Have getprotobyname_r */
#cmakedefine HAVE_GETPROTOBYNAME_R 1

/* Have getnameinfo */
#cmakedefine HAVE_GETNAMEINFO 1

/* Have inet_ntop */
#cmakedefine HAVE_INET_NTOP 1

/* Have inet_pton */
#cmakedefine HAVE_INET_PTON 1

/* Define to 1 if you have the `inet_aton' function. */
#cmakedefine HAVE_INET_ATON 1

/* Define to 1 if you have the <pthread.h> header file. */
#cmakedefine HAVE_PTHREAD_H 1

Expand Down Expand Up @@ -523,54 +445,30 @@
/* sockaddr_in6 has sin6_len */
#cmakedefine HAVE_SOCKADDR_IN6_SIN_LEN 1

/* Have getifaddrs */
#cmakedefine HAVE_GETIFADDRS 1

/* Have access */
#cmakedefine HAVE_ACCESS 1

/* Have getpid */
#cmakedefine HAVE_GETPID 1

/* Have mktemp */
#cmakedefine HAVE_MKTEMP 1

/* Define to 1 if you have the <sys/statvfs.h> header file. */
#cmakedefine HAVE_SYS_STATVFS_H 1

/* Define to 1 if you have the <sys/statfs.h> header file. */
#cmakedefine HAVE_SYS_STATFS_H 1

/* Define to 1 if you have the <sys/mman.h> header file. */
#cmakedefine HAVE_SYS_MMAN_H 1

/* Define to 1 if you have the <sys/mount.h> header file. */
#cmakedefine HAVE_SYS_MOUNT_H 1

/* Define to 1 if you have the `getfsstat' function. */
#cmakedefine HAVE_GETFSSTAT 1

/* Define to 1 if you have the `mremap' function. */
#cmakedefine HAVE_MREMAP 1

/* Define to 1 if you have the `posix_fadvise' function. */
#cmakedefine HAVE_POSIX_FADVISE 1

/* Define to 1 if you have the `vsnprintf' function. */
#cmakedefine HAVE_VSNPRINTF 1

/* struct statfs */
#cmakedefine HAVE_STATFS 1

/* Define to 1 if you have the `statvfs' function. */
#cmakedefine HAVE_STATVFS 1

/* Define to 1 if you have the `setpgid' function. */
#cmakedefine HAVE_SETPGID 1

/* Define to 1 if you have the `system' function. */
#ifdef _MSC_VER
#if HAVE_WINAPI_FAMILY_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT)
#if HAVE_CLASSIC_WINAPI_SUPPORT
#cmakedefine HAVE_SYSTEM 1
#endif
#else
Expand All @@ -580,15 +478,6 @@
/* Define to 1 if you have the `fork' function. */
#cmakedefine HAVE_FORK 1

/* Define to 1 if you have the `execv' function. */
#cmakedefine HAVE_EXECV 1

/* Define to 1 if you have the `execve' function. */
#cmakedefine HAVE_EXECVE 1

/* Define to 1 if you have the `waitpid' function. */
#cmakedefine HAVE_WAITPID 1

/* Define to 1 if you have the `localtime_r' function. */
#cmakedefine HAVE_LOCALTIME_R 1

Expand All @@ -609,18 +498,6 @@
/* Define to 1 if the system has the type `struct sockaddr_in6'. */
#cmakedefine HAVE_STRUCT_SOCKADDR_IN6 1

/* Define to 1 if the system has the type `struct stat'. */
#cmakedefine HAVE_STRUCT_STAT 1

/* Define to 1 if the system has the type `struct timeval'. */
#cmakedefine HAVE_STRUCT_TIMEVAL 1

/* Define to 1 if `st_atim' is a member of `struct stat'. */
#cmakedefine HAVE_STRUCT_STAT_ST_ATIM 1

/* Define to 1 if `st_atimespec' is a member of `struct stat'. */
#cmakedefine HAVE_STRUCT_STAT_ST_ATIMESPEC 1

/* Define to 1 if `super_class' is a member of `struct objc_super'. */
#cmakedefine HAVE_OBJC_SUPER_SUPER_CLASS 1

Expand Down Expand Up @@ -807,15 +684,9 @@
/* Defaults to concurrent GC */
#cmakedefine HAVE_CONC_GC_AS_DEFAULT 1

/* Define to 1 if you have the `stpcpy' function. */
#cmakedefine HAVE_STPCPY 1

/* Define to 1 if you have the `strtok_r' function. */
#cmakedefine HAVE_STRTOK_R 1

/* Define to 1 if you have the `rewinddir' function. */
#cmakedefine HAVE_REWINDDIR 1

/* Define to 1 if you have the `vasprintf' function. */
#cmakedefine HAVE_VASPRINTF 1

Expand Down
Loading

0 comments on commit 38fd485

Please sign in to comment.