diff --git a/src/coreclr/CMakeLists.txt b/src/coreclr/CMakeLists.txt index 6f8897c20c796..c56fc969bf9fd 100644 --- a/src/coreclr/CMakeLists.txt +++ b/src/coreclr/CMakeLists.txt @@ -18,6 +18,8 @@ project(CoreCLR) include(../../eng/native/configurepaths.cmake) include(${CLR_ENG_NATIVE_DIR}/configurecompiler.cmake) +include_directories("${CLR_SRC_NATIVE_DIR}") + if(MSVC) set(CMAKE_CXX_STANDARD_LIBRARIES "") # do not link against standard win32 libs i.e. kernel32, uuid, user32, etc. endif (MSVC) @@ -133,7 +135,7 @@ endif() #------------------------------------- # Include the basic prebuilt headers - required for getting fileversion resource details. include_directories("pal/prebuilt/inc") -include_directories("../../artifacts/obj/coreclr") +include_directories("${CLR_REPO_ROOT_DIR}/artifacts/obj/coreclr") add_subdirectory(tools/aot/jitinterface) diff --git a/src/coreclr/debug/debug-pal/CMakeLists.txt b/src/coreclr/debug/debug-pal/CMakeLists.txt index d2846f93b13f9..2cd2f7d18594f 100644 --- a/src/coreclr/debug/debug-pal/CMakeLists.txt +++ b/src/coreclr/debug/debug-pal/CMakeLists.txt @@ -4,9 +4,7 @@ include_directories(../../pal/inc) add_definitions(-DPAL_STDCPP_COMPAT) - -set(SHARED_EVENTPIPE_DIR ${CLR_SRC_NATIVE_DIR}/eventpipe) -include_directories(${SHARED_EVENTPIPE_DIR}) +set(SHARED_EVENTPIPE_SOURCE_PATH ${CLR_SRC_NATIVE_DIR}/eventpipe) add_definitions(-DFEATURE_CORECLR) add_definitions(-DFEATURE_PERFTRACING) add_definitions(-DFEATURE_PERFTRACING_STANDALONE_PAL) @@ -16,7 +14,7 @@ if(CLR_CMAKE_HOST_WIN32) include_directories(../../inc) #needed for warning control if(CLR_CMAKE_TARGET_WIN32) - set (EVENTPIPE_PAL_SOURCES "${SHARED_EVENTPIPE_DIR}/ds-ipc-pal-namedpipe.c") + set (EVENTPIPE_PAL_SOURCES "${SHARED_EVENTPIPE_SOURCE_PATH}/ds-ipc-pal-namedpipe.c") set_source_files_properties(${EVENTPIPE_PAL_SOURCES} PROPERTIES LANGUAGE CXX) set(TWO_WAY_PIPE_SOURCES @@ -36,7 +34,7 @@ if(CLR_CMAKE_HOST_UNIX) add_definitions(-DPAL_IMPLEMENTATION) add_definitions(-D_POSIX_C_SOURCE=200809L) - set (EVENTPIPE_PAL_SOURCES "${SHARED_EVENTPIPE_DIR}/ds-ipc-pal-socket.c") + set (EVENTPIPE_PAL_SOURCES "${SHARED_EVENTPIPE_SOURCE_PATH}/ds-ipc-pal-socket.c") set_source_files_properties(${EVENTPIPE_PAL_SOURCES} PROPERTIES LANGUAGE CXX) if (CMAKE_VERSION VERSION_GREATER 3.11 OR CMAKE_VERSION VERSION_EQUAL 3.11) set_source_files_properties(${EVENTPIPE_PAL_SOURCES} PROPERTIES COMPILE_OPTIONS -xc++) diff --git a/src/coreclr/hosts/corerun/CMakeLists.txt b/src/coreclr/hosts/corerun/CMakeLists.txt index 0991f16dc83c9..ef20f57e0bb8d 100644 --- a/src/coreclr/hosts/corerun/CMakeLists.txt +++ b/src/coreclr/hosts/corerun/CMakeLists.txt @@ -5,7 +5,6 @@ set(CMAKE_INCLUDE_CURRENT_DIR ON) if(CLR_CMAKE_HOST_WIN32) add_definitions(-DFX_VER_INTERNALNAME_STR=corerun.exe) else(CLR_CMAKE_HOST_WIN32) - include_directories("${CLR_SRC_NATIVE_DIR}/common") include(configure.cmake) endif(CLR_CMAKE_HOST_WIN32) diff --git a/src/coreclr/hosts/corerun/corerun.hpp b/src/coreclr/hosts/corerun/corerun.hpp index a1fce670adc80..c453f9e5daf12 100644 --- a/src/coreclr/hosts/corerun/corerun.hpp +++ b/src/coreclr/hosts/corerun/corerun.hpp @@ -310,7 +310,7 @@ class platform_specific_actions final // CMake generated #include -#include +#include #define MAIN main #define W(str) str @@ -365,7 +365,7 @@ namespace pal assert(error == 0); } - inline string_t get_exe_path() { return { getexepath() }; } + inline string_t get_exe_path() { return minipal_getexepath(); } inline string_t get_absolute_path(const string_t& path) { diff --git a/src/coreclr/pal/src/CMakeLists.txt b/src/coreclr/pal/src/CMakeLists.txt index 2068b295285fd..4f071b21046b0 100644 --- a/src/coreclr/pal/src/CMakeLists.txt +++ b/src/coreclr/pal/src/CMakeLists.txt @@ -117,8 +117,6 @@ if (CMAKE_CXX_COMPILER_ID MATCHES "GNU" AND (CLR_CMAKE_HOST_ARCH_AMD64 OR CLR_CM add_compile_options(-Wa,--divide) endif() -include_directories("${CLR_SRC_NATIVE_DIR}/common") - set(SOURCES cruntime/file.cpp cruntime/filecrt.cpp diff --git a/src/coreclr/pal/src/init/pal.cpp b/src/coreclr/pal/src/init/pal.cpp index 93c5c15ea7aec..e9dffec3dbb2a 100644 --- a/src/coreclr/pal/src/init/pal.cpp +++ b/src/coreclr/pal/src/init/pal.cpp @@ -39,7 +39,7 @@ SET_DEFAULT_DEBUG_CHANNEL(PAL); // some headers have code with asserts, so do th #include "pal/numa.h" #include "pal/stackstring.hpp" #include "pal/cgroup.h" -#include +#include #if HAVE_MACH_EXCEPTIONS #include "../exception/machexception.h" @@ -1272,7 +1272,7 @@ static LPWSTR INIT_GetCurrentEXEPath() LPWSTR return_value; INT return_size; - char* path = getexepath(); + char* path = minipal_getexepath(); if (!path) { ERROR( "Cannot get current exe path\n" ); diff --git a/src/coreclr/vm/CMakeLists.txt b/src/coreclr/vm/CMakeLists.txt index a1b164a0af65d..1e961638b8c06 100644 --- a/src/coreclr/vm/CMakeLists.txt +++ b/src/coreclr/vm/CMakeLists.txt @@ -36,12 +36,7 @@ if(FEATURE_JIT_PITCHING) endif(FEATURE_JIT_PITCHING) if(FEATURE_PERFTRACING) - set(SHARED_EVENTPIPE_DIR ${CLR_SRC_NATIVE_DIR}/eventpipe) set(CORECLR_EVENTPIPE_SHIM_DIR ${CMAKE_CURRENT_SOURCE_DIR}/eventing/eventpipe) -endif(FEATURE_PERFTRACING) - -if(FEATURE_PERFTRACING) - include_directories(${SHARED_EVENTPIPE_DIR}) include_directories(${CORECLR_EVENTPIPE_SHIM_DIR}) endif(FEATURE_PERFTRACING) diff --git a/src/coreclr/vm/diagnosticserveradapter.h b/src/coreclr/vm/diagnosticserveradapter.h index 6c2c12467a093..89383a3c98200 100644 --- a/src/coreclr/vm/diagnosticserveradapter.h +++ b/src/coreclr/vm/diagnosticserveradapter.h @@ -6,7 +6,7 @@ #if defined(FEATURE_PERFTRACING) -#include "ds-server.h" +#include class DiagnosticServerAdapter final { diff --git a/src/coreclr/vm/eventing/eventpipe/CMakeLists.txt b/src/coreclr/vm/eventing/eventpipe/CMakeLists.txt index 3b03605aece06..46a11ee8602ba 100644 --- a/src/coreclr/vm/eventing/eventpipe/CMakeLists.txt +++ b/src/coreclr/vm/eventing/eventpipe/CMakeLists.txt @@ -41,7 +41,7 @@ set (EVENTPIPE_HEADERS "") set (CORECLR_EVENTPIPE_SHIM_SOURCES "") set (CORECLR_EVENTPIPE_SHIM_HEADERS "") -set (SHARED_EVENTPIPE_SOURCE_PATH "${SHARED_EVENTPIPE_DIR}") +set (SHARED_EVENTPIPE_SOURCE_PATH "${CLR_SRC_NATIVE_DIR}/eventpipe") set (CORECLR_EVENTPIPE_SHIM_SOURCE_PATH "${CORECLR_EVENTPIPE_SHIM_DIR}") include (${SHARED_EVENTPIPE_SOURCE_PATH}/CMakeLists.txt) diff --git a/src/coreclr/vm/eventing/eventpipe/ds-rt-coreclr.h b/src/coreclr/vm/eventing/eventpipe/ds-rt-coreclr.h index 646b8f9bd8f19..904727b52dd6e 100644 --- a/src/coreclr/vm/eventing/eventpipe/ds-rt-coreclr.h +++ b/src/coreclr/vm/eventing/eventpipe/ds-rt-coreclr.h @@ -2,13 +2,13 @@ #ifndef __DIAGNOSTICS_RT_MONO_H__ #define __DIAGNOSTICS_RT_MONO_H__ -#include "ds-rt-config.h" +#include #ifdef ENABLE_PERFTRACING #include "ep-rt-coreclr.h" -#include "ds-process-protocol.h" -#include "ds-profiler-protocol.h" -#include "ds-dump-protocol.h" +#include +#include +#include #undef DS_LOG_ALWAYS_0 #define DS_LOG_ALWAYS_0(msg) STRESS_LOG0(LF_DIAGNOSTICS_PORT, LL_ALWAYS, msg "\n") @@ -300,7 +300,7 @@ ds_rt_profiler_startup (DiagnosticsStartupProfilerCommandPayload *payload) STATIC_CONTRACT_NOTHROW; HRESULT hr = S_OK; - EX_TRY { + EX_TRY { StoredProfilerNode *profilerData = new StoredProfilerNode(); profilerData->guid = *(reinterpret_cast(ds_startup_profiler_command_payload_get_profiler_guid_cref (payload))); profilerData->path.Set(reinterpret_cast(ds_startup_profiler_command_payload_get_profiler_path (payload))); diff --git a/src/coreclr/vm/eventing/eventpipe/ds-rt-types-coreclr.h b/src/coreclr/vm/eventing/eventpipe/ds-rt-types-coreclr.h index 99e235628dc64..529590fb22cbc 100644 --- a/src/coreclr/vm/eventing/eventpipe/ds-rt-types-coreclr.h +++ b/src/coreclr/vm/eventing/eventpipe/ds-rt-types-coreclr.h @@ -2,7 +2,7 @@ #ifndef __DIAGNOSTICS_RT_TYPES_CORECLR_H__ #define __DIAGNOSTICS_RT_TYPES_CORECLR_H__ -#include "ds-rt-config.h" +#include #ifdef ENABLE_PERFTRACING #include "ep-rt-types-coreclr.h" diff --git a/src/coreclr/vm/eventing/eventpipe/ep-rt-coreclr.cpp b/src/coreclr/vm/eventing/eventpipe/ep-rt-coreclr.cpp index 481cc505c43bc..e09b6b1600745 100644 --- a/src/coreclr/vm/eventing/eventpipe/ep-rt-coreclr.cpp +++ b/src/coreclr/vm/eventing/eventpipe/ep-rt-coreclr.cpp @@ -1,10 +1,10 @@ -#include "ep-rt-config.h" +#include #ifdef ENABLE_PERFTRACING -#include "ep-types.h" -#include "ep.h" -#include "ep-stack-contents.h" -#include "ep-rt.h" +#include +#include +#include +#include #include "threadsuspend.h" ep_rt_lock_handle_t _ep_rt_coreclr_config_lock_handle; diff --git a/src/coreclr/vm/eventing/eventpipe/ep-rt-coreclr.h b/src/coreclr/vm/eventing/eventpipe/ep-rt-coreclr.h index 7ee83ae8c5f84..2c1d483e21526 100644 --- a/src/coreclr/vm/eventing/eventpipe/ep-rt-coreclr.h +++ b/src/coreclr/vm/eventing/eventpipe/ep-rt-coreclr.h @@ -2,13 +2,13 @@ #ifndef __EVENTPIPE_RT_CORECLR_H__ #define __EVENTPIPE_RT_CORECLR_H__ -#include "ep-rt-config.h" +#include #ifdef ENABLE_PERFTRACING -#include "ep-thread.h" -#include "ep-types.h" -#include "ep-provider.h" -#include "ep-session-provider.h" +#include +#include +#include +#include #include "fstream.h" #include "typestring.h" #include "win32threadpool.h" @@ -2565,7 +2565,7 @@ ep_rt_utf8_string_replace ( if (strFound != NULL) { size_t strSearchLen = strlen(strSearch); - size_t newStrSize = strlen(*str) + strlen(strReplacement) - strSearchLen + 1; + size_t newStrSize = strlen(*str) + strlen(strReplacement) - strSearchLen + 1; ep_char8_t *newStr = reinterpret_cast(malloc(newStrSize)); if (newStr == NULL) { diff --git a/src/coreclr/vm/eventing/eventpipe/ep-rt-types-coreclr.h b/src/coreclr/vm/eventing/eventpipe/ep-rt-types-coreclr.h index 5fd1ba2fa8cc0..a4434fedb43cd 100644 --- a/src/coreclr/vm/eventing/eventpipe/ep-rt-types-coreclr.h +++ b/src/coreclr/vm/eventing/eventpipe/ep-rt-types-coreclr.h @@ -2,7 +2,7 @@ #ifndef __EVENTPIPE_RT_TYPES_CORECLR_H__ #define __EVENTPIPE_RT_TYPES_CORECLR_H__ -#include "ep-rt-config.h" +#include #ifdef ENABLE_PERFTRACING #include "slist.h" diff --git a/src/coreclr/vm/eventpipeadapter.h b/src/coreclr/vm/eventpipeadapter.h index fa10d94699ac7..6bde11ccc0ed3 100644 --- a/src/coreclr/vm/eventpipeadapter.h +++ b/src/coreclr/vm/eventpipeadapter.h @@ -6,16 +6,16 @@ #if defined(FEATURE_PERFTRACING) -#include "ep.h" -#include "ep-provider.h" -#include "ep-config.h" -#include "ep-event.h" -#include "ep-event-instance.h" -#include "ep-session.h" -#include "ep-session-provider.h" -#include "ep-metadata-generator.h" -#include "ep-event-payload.h" -#include "ep-buffer-manager.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include class EventPipeProviderConfigurationAdapter final diff --git a/src/libraries/Native/Unix/System.Native/CMakeLists.txt b/src/libraries/Native/Unix/System.Native/CMakeLists.txt index 188ca5fc6bde8..0adbefe8c1c0e 100644 --- a/src/libraries/Native/Unix/System.Native/CMakeLists.txt +++ b/src/libraries/Native/Unix/System.Native/CMakeLists.txt @@ -8,7 +8,7 @@ if (CLR_CMAKE_TARGET_OSX) add_definitions(-D_DARWIN_C_SOURCE) endif () -include_directories("${CLR_SRC_NATIVE_DIR}/common") +include_directories("${CLR_SRC_NATIVE_DIR}") set(NATIVE_SOURCES pal_errno.c diff --git a/src/libraries/Native/Unix/System.Native/pal_process.c b/src/libraries/Native/Unix/System.Native/pal_process.c index fabdfae76187c..cb8bdf319eb10 100644 --- a/src/libraries/Native/Unix/System.Native/pal_process.c +++ b/src/libraries/Native/Unix/System.Native/pal_process.c @@ -39,7 +39,7 @@ #include #endif -#include +#include // Validate that our SysLogPriority values are correct for the platform c_static_assert(PAL_LOG_EMERG == LOG_EMERG); @@ -886,5 +886,5 @@ int32_t SystemNative_SchedGetAffinity(int32_t pid, intptr_t* mask) char* SystemNative_GetProcessPath() { - return getexepath(); + return minipal_getexepath(); } diff --git a/src/mono/CMakeLists.txt b/src/mono/CMakeLists.txt index 58a0a18e80bdf..fb302b7a368c0 100644 --- a/src/mono/CMakeLists.txt +++ b/src/mono/CMakeLists.txt @@ -6,6 +6,8 @@ endif() project(mono) +include(../../eng/native/configurepaths.cmake) + set(CMAKE_C_FLAGS_CHECKED "") set(CMAKE_CXX_FLAGS_CHECKED "") set(CMAKE_EXE_LINKER_FLAGS_CHECKED "") @@ -587,7 +589,7 @@ endif() ###################################### # ICU CHECKS ###################################### -set(ICU_SHIM_PATH "../../../libraries/Native/Unix/System.Globalization.Native") +set(ICU_SHIM_PATH "${CLR_SRC_LIBS_NATIVE_DIR}/Unix/System.Globalization.Native") if(MONO_CROSS_COMPILE) elseif(HOST_OSX AND NOT HOST_MACCAT) include(FindPkgConfig) @@ -810,6 +812,7 @@ if (TARGET_BROWSER) endif() ### End of OS specific checks +include_directories("${CLR_SRC_NATIVE_DIR}") add_subdirectory(mono) if (ENABLE_MSCORDBI AND NOT TARGET_ARCH STREQUAL "arm64" AND NOT CMAKE_CROSSCOMPILING AND NOT TARGET_IOS AND NOT TARGET_ANDROID AND NOT TARGET_BROWSER AND NOT HOST_MACCAT) add_subdirectory(dlls/mscordbi) diff --git a/src/mono/cmake/config.h.in b/src/mono/cmake/config.h.in index 136a22bbe1dd5..48a82ec6db8c4 100644 --- a/src/mono/cmake/config.h.in +++ b/src/mono/cmake/config.h.in @@ -595,6 +595,8 @@ /* Define to 1 if you have the `pthread_jit_write_protect_np' function. */ #cmakedefine HAVE_PTHREAD_JIT_WRITE_PROTECT_NP 1 +#cmakedefine01 HAVE_GETAUXVAL + /* Define to 1 if you have the declaration of `pthread_mutexattr_setprotocol', and to 0 if you don't. */ #cmakedefine HAVE_DECL_PTHREAD_MUTEXATTR_SETPROTOCOL 1 diff --git a/src/mono/cmake/configure.cmake b/src/mono/cmake/configure.cmake index 5bad48a719b85..7bee1c6b98553 100644 --- a/src/mono/cmake/configure.cmake +++ b/src/mono/cmake/configure.cmake @@ -103,6 +103,7 @@ check_symbol_exists(CLOCK_MONOTONIC "time.h" HAVE_CLOCK_MONOTONIC) check_symbol_exists(CLOCK_MONOTONIC_COARSE "time.h" HAVE_CLOCK_MONOTONIC_COARSE) check_symbol_exists(sys_signame "signal.h" HAVE_SYSSIGNAME) check_symbol_exists(pthread_jit_write_protect_np "pthread.h" HAVE_PTHREAD_JIT_WRITE_PROTECT_NP) +check_symbol_exists(getauxval sys/auxv.h HAVE_GETAUXVAL) 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") diff --git a/src/mono/dlls/dbgshim/CMakeLists.txt b/src/mono/dlls/dbgshim/CMakeLists.txt index 40c36fc1af196..f19ff0e7dc51e 100644 --- a/src/mono/dlls/dbgshim/CMakeLists.txt +++ b/src/mono/dlls/dbgshim/CMakeLists.txt @@ -27,11 +27,7 @@ if(HOST_WIN32) endif() endif() -include(${PROJECT_SOURCE_DIR}/../../../../eng/native/configuretools.cmake) -include(${PROJECT_SOURCE_DIR}/../../../../eng/native/configurepaths.cmake) -include(${PROJECT_SOURCE_DIR}/../../../../eng/native/configureplatform.cmake) -include(${PROJECT_SOURCE_DIR}/../../../../eng/native/configurecompiler.cmake) - +include(${CLR_ENG_NATIVE_DIR}/configurecompiler.cmake) add_definitions(-D_WIN32_WINNT=0x0602) diff --git a/src/mono/dlls/mscordbi/CMakeLists.txt b/src/mono/dlls/mscordbi/CMakeLists.txt index ea667c3e2b2f6..2f8ba379561e1 100644 --- a/src/mono/dlls/mscordbi/CMakeLists.txt +++ b/src/mono/dlls/mscordbi/CMakeLists.txt @@ -94,10 +94,7 @@ endif() add_subdirectory(${PROJECT_SOURCE_DIR}/socket-dbi) -include(${PROJECT_SOURCE_DIR}/../../../../eng/native/configuretools.cmake) -include(${PROJECT_SOURCE_DIR}/../../../../eng/native/configurepaths.cmake) -include(${PROJECT_SOURCE_DIR}/../../../../eng/native/configureplatform.cmake) -include(${PROJECT_SOURCE_DIR}/../../../../eng/native/configurecompiler.cmake) +include(${CLR_ENG_NATIVE_DIR}/configurecompiler.cmake) if (CLR_CMAKE_HOST_UNIX) # Add custom targets that the pal build expects. diff --git a/src/mono/mono/component/CMakeLists.txt b/src/mono/mono/component/CMakeLists.txt index 1bc4eadb67291..595f6d889442b 100644 --- a/src/mono/mono/component/CMakeLists.txt +++ b/src/mono/mono/component/CMakeLists.txt @@ -1,6 +1,5 @@ set(MONO_COMPONENT_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../component") -set(SHARED_EVENTPIPE_INCLUDE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../../native/") -set(SHARED_EVENTPIPE_SOURCE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../../native/eventpipe/") +set(SHARED_EVENTPIPE_SOURCE_PATH "${CLR_SRC_NATIVE_DIR}/eventpipe/") set(MONO_EVENTPIPE_SHIM_SOURCE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../eventpipe/") set(MONO_EVENTPIPE_GEN_INCLUDE_PATH "${CMAKE_CURRENT_BINARY_DIR}/eventpipe") @@ -56,7 +55,6 @@ list(APPEND components include(${MONO_EVENTPIPE_SHIM_SOURCE_PATH}/CMakeLists.txt) include_directories( - ${SHARED_EVENTPIPE_INCLUDE_PATH} ${MONO_EVENTPIPE_SHIM_SOURCE_PATH} ${MONO_EVENTPIPE_GEN_INCLUDE_PATH} ) diff --git a/src/mono/mono/metadata/assembly.c b/src/mono/mono/metadata/assembly.c index 6f14674683a86..2228a3ed47aba 100644 --- a/src/mono/mono/metadata/assembly.c +++ b/src/mono/mono/metadata/assembly.c @@ -1,7 +1,7 @@ /** * \file * Routines for loading assemblies. - * + * * Author: * Miguel de Icaza (miguel@ximian.com) * @@ -46,6 +46,7 @@ #include #include #include +#include #ifndef HOST_WIN32 #include @@ -146,7 +147,7 @@ mono_public_tokens_are_equal (const unsigned char *pubt1, const unsigned char *p * Notice that \c MONO_PATH and this method are really a very bad idea as * it prevents the GAC from working and it prevents the standard * resolution mechanisms from working. Nonetheless, for some debugging - * situations and bootstrapping setups, this is useful to have. + * situations and bootstrapping setups, this is useful to have. */ void mono_set_assemblies_path (const char* path) @@ -389,7 +390,7 @@ mono_assembly_setrootdir (const char *root_dir) /** * mono_assembly_getrootdir: - * + * * Obtains the root directory used for looking up assemblies. * * Returns: a string with the directory, this string should not be freed. @@ -402,7 +403,7 @@ mono_assembly_getrootdir (void) /** * mono_native_getrootdir: - * + * * Obtains the root directory used for looking up native libs (.so, .dylib). * * Returns: a string with the directory, this string should be freed by @@ -463,12 +464,12 @@ compute_base (char *path) /* Not a well known Mono executable, we are embedded, cant guess the base */ if (strcmp (p, "/mono") && strcmp (p, "/mono-boehm") && strcmp (p, "/mono-sgen") && strcmp (p, "/pedump") && strcmp (p, "/monodis")) return NULL; - + *p = 0; p = strrchr (path, '/'); if (p == NULL) return NULL; - + if (strcmp (p, "/bin") != 0) return NULL; *p = 0; @@ -488,7 +489,7 @@ set_dirs (char *exe) char *config, *lib, *mono; struct stat buf; const char *bindir; - + /* * Only /usr prefix is treated specially */ @@ -507,7 +508,7 @@ set_dirs (char *exe) else { mono_set_dirs (lib, config); } - + g_free (config); g_free (lib); g_free (mono); @@ -519,42 +520,23 @@ set_dirs (char *exe) * mono_set_rootdir: * * Registers the root directory for the Mono runtime, for Linux and Solaris 10, - * this auto-detects the prefix where Mono was installed. + * this auto-detects the prefix where Mono was installed. */ void mono_set_rootdir (void) { -#if defined(HOST_WIN32) || (defined(HOST_DARWIN) && !defined(TARGET_ARM)) - gchar *bindir, *installdir, *root, *name, *resolvedname, *config; - -#ifdef HOST_WIN32 - name = mono_get_module_file_name ((HMODULE) &__ImageBase); -#else - { - /* - * _NSGetExecutablePath may return -1 to indicate buf is not large - * enough, but we ignore that case to avoid having to do extra dynamic - * allocation for the path and hope that 4096 is enough - this is - * ok in the Linux/Solaris case below at least... - */ - - gchar buf[4096]; - guint buf_size = sizeof (buf); - - name = NULL; - if (_NSGetExecutablePath (buf, &buf_size) == 0) - name = g_strdup (buf); - - if (name == NULL) { - fallback (); - return; - } - } + char *path = minipal_getexepath(); + if (path == NULL) { +#ifndef HOST_WIN32 + fallback (); #endif + return; + } - resolvedname = mono_path_resolve_symlinks (name); +#if defined(HOST_WIN32) || (defined(HOST_DARWIN) && !defined(TARGET_ARM)) + gchar *bindir, *installdir, *root, *config; - bindir = g_path_get_dirname (resolvedname); + bindir = g_path_get_dirname (path); installdir = g_path_get_dirname (bindir); root = g_build_path (G_DIR_SEPARATOR_S, installdir, "lib", (const char*)NULL); @@ -572,44 +554,12 @@ mono_set_rootdir (void) g_free (root); g_free (installdir); g_free (bindir); - g_free (name); - g_free (resolvedname); + g_free (path); #elif defined(DISABLE_MONO_AUTODETECTION) fallback (); #else - char buf [4096]; - int s; - char *str; - -#if defined(HAVE_READLINK) - /* Linux style */ - s = readlink ("/proc/self/exe", buf, sizeof (buf)-1); -#else - s = -1; -#endif - - if (s != -1){ - buf [s] = 0; - set_dirs (buf); - return; - } - - /* Solaris 10 style */ - str = g_strdup_printf ("/proc/%d/path/a.out", mono_process_current_pid ()); - -#if defined(HAVE_READLINK) - s = readlink (str, buf, sizeof (buf)-1); -#else - s = -1; -#endif - - g_free (str); - if (s != -1){ - buf [s] = 0; - set_dirs (buf); - return; - } - fallback (); + set_dirs (path); + return; #endif } @@ -895,7 +845,7 @@ remap_keys (MonoAssemblyName *aname) continue; memcpy (aname->public_key_token, entry->to, MONO_PUBLIC_KEY_TOKEN_LENGTH); - + mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_ASSEMBLY, "Remapped public key token of retargetable assembly %s from %s to %s", aname->name, entry->from, entry->to); @@ -928,7 +878,7 @@ mono_assembly_remap_version (MonoAssemblyName *aname, MonoAssemblyName *dest_ana /* Remap assembly name */ if (!strcmp (aname->name, "System.Net")) dest_aname->name = g_strdup ("System"); - + remap_keys (dest_aname); mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_ASSEMBLY, @@ -1233,7 +1183,7 @@ mono_assembly_load_reference (MonoImage *image, int index) mono_image_lock (image); if (!image->references) { MonoTableInfo *t = &image->tables [MONO_TABLE_ASSEMBLYREF]; - + int n = table_info_get_rows (t); image->references = g_new0 (MonoAssembly *, n + 1); image->nreferences = n; @@ -1285,7 +1235,7 @@ mono_assembly_load_reference (MonoImage *image, int index) } else { extra_msg = g_strdup (""); } - + mono_trace (G_LOG_LEVEL_WARNING, MONO_TRACE_ASSEMBLY, "The following assembly referenced from %s could not be loaded:\n" " Assembly: %s (assemblyref_index=%d)\n" " Version: %d.%d.%d.%d\n" @@ -1302,7 +1252,7 @@ mono_assembly_load_reference (MonoImage *image, int index) if (reference == NULL) { /* Flag as not found */ reference = (MonoAssembly *)REFERENCE_MISSING; - } + } if (!image->references [index]) { if (reference != REFERENCE_MISSING){ @@ -1315,7 +1265,7 @@ mono_assembly_load_reference (MonoImage *image, int index) mono_trace (G_LOG_LEVEL_INFO, MONO_TRACE_ASSEMBLY, "Failed to load assembly %s[%p].", image->assembly->aname.name, image->assembly); } - + image->references [index] = reference; } mono_image_unlock (image); @@ -1385,7 +1335,7 @@ static void mono_install_assembly_load_hook_v1 (MonoAssemblyLoadFunc func, gpointer user_data) { AssemblyLoadHook *hook; - + g_return_if_fail (func != NULL); hook = g_new0 (AssemblyLoadHook, 1); @@ -1477,7 +1427,7 @@ static void mono_install_assembly_search_hook_internal_v1 (MonoAssemblySearchFunc func, gpointer user_data, gboolean postload) { AssemblySearchHook *hook; - + g_return_if_fail (func != NULL); hook = g_new0 (AssemblySearchHook, 1); @@ -1519,7 +1469,7 @@ void mono_install_assembly_search_hook (MonoAssemblySearchFunc func, gpointer user_data) { mono_install_assembly_search_hook_internal_v1 (func, user_data, FALSE); -} +} /** * mono_install_assembly_refonly_search_hook: @@ -1537,7 +1487,7 @@ void mono_install_assembly_postload_search_hook (MonoAssemblySearchFunc func, gpointer user_data) { mono_install_assembly_search_hook_internal_v1 (func, user_data, TRUE); -} +} void mono_install_assembly_postload_refonly_search_hook (MonoAssemblySearchFunc func, gpointer user_data) @@ -1608,7 +1558,7 @@ void mono_install_assembly_preload_hook (MonoAssemblyPreLoadFunc func, gpointer user_data) { AssemblyPreLoadHook *hook; - + g_return_if_fail (func != NULL); hook = g_new0 (AssemblyPreLoadHook, 1); @@ -1778,7 +1728,7 @@ open_from_satellite_bundle (MonoAssemblyLoadContext *alc, const char *filename, return image; } -/** +/** * mono_assembly_open_from_bundle: * \param filename Filename requested * \param status return status code @@ -1812,7 +1762,7 @@ mono_assembly_open_from_bundle (MonoAssemblyLoadContext *alc, const char *filena /** * mono_assembly_open_full: * \param filename the file to load - * \param status return status code + * \param status return status code * \param refonly Whether this assembly is being opened in "reflection-only" mode. * * This loads an assembly from the specified \p filename. The \p filename allows @@ -1861,7 +1811,7 @@ mono_assembly_request_open (const char *filename, const MonoAssemblyOpenRequest MonoAssemblyLoadRequest load_req; /* we will be overwriting the load request's asmctx.*/ memcpy (&load_req, &open_req->request, sizeof (load_req)); - + g_return_val_if_fail (filename != NULL, NULL); if (!status) @@ -1924,7 +1874,7 @@ mono_assembly_request_open (const char *filename, const MonoAssemblyOpenRequest /* Clear the reference added by mono_image_open */ mono_image_close (image); - + g_free (fname); return ass; @@ -1947,7 +1897,7 @@ free_assembly_name_item (gpointer val, gpointer user_data) * * This is an internal method, we need this because when we load mscorlib * we do not have the internals visible cattr loaded yet, - * so we need to load these after we initialize the runtime. + * so we need to load these after we initialize the runtime. * * LOCKING: Acquires the assemblies lock plus the loader lock. */ @@ -1980,7 +1930,7 @@ mono_assembly_load_friends (MonoAssembly* ass) GSList *visible_list = NULL; GSList *ignores_list = NULL; - /* + /* * We build the list outside the assemblies lock, the worse that can happen * is that we'll need to free the allocated list. */ @@ -2142,7 +2092,7 @@ mono_assembly_open (const char *filename, MonoImageOpenStatus *status) * image did not contain an assembly reference table. */ MonoAssembly * -mono_assembly_load_from_full (MonoImage *image, const char*fname, +mono_assembly_load_from_full (MonoImage *image, const char*fname, MonoImageOpenStatus *status, gboolean refonly) { if (refonly) { @@ -2228,7 +2178,7 @@ mono_assembly_request_load_from (MonoImage *image, const char *fname, mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_ASSEMBLY, "Image addref %s[%p] (%s) -> %s[%p]: %d", ass->aname.name, ass, mono_alc_is_default (mono_image_get_alc (image)) ? "default ALC" : "custom ALC", image->name, image, image->ref_count); - /* + /* * The load hooks might take locks so we can't call them while holding the * assemblies lock. */ @@ -2313,7 +2263,7 @@ mono_assembly_request_load_from (MonoImage *image, const char *fname, mono_assembly_invoke_load_hook_internal (req->alc, ass); MONO_PROFILER_RAISE (assembly_loaded, (ass)); - + return ass; } @@ -2336,7 +2286,7 @@ mono_assembly_request_load_from (MonoImage *image, const char *fname, * If there is an error loading the assembly the \p status will indicate the * reason with \p status being set to \c MONO_IMAGE_INVALID if the * image did not contain an assembly reference table. - + */ MonoAssembly * mono_assembly_load_from (MonoImage *image, const char *fname, @@ -2357,7 +2307,7 @@ mono_assembly_load_from (MonoImage *image, const char *fname, /** * mono_assembly_name_free_internal: * \param aname assembly name to free - * + * * Frees the provided assembly name object. * (it does not frees the object itself, only the name members). */ @@ -2414,13 +2364,13 @@ parse_public_key (const gchar *key, gchar** pubkey, gboolean *is_ecma) default: return FALSE; } - + /* We need the first 16 bytes * to check whether this key is valid or not */ pkeylen = strlen (pkey) >> 1; if (pkeylen < 16) return FALSE; - + for (i = 0, j = 0; i < 16; i++) { header [i] = g_ascii_xdigit_value (pkey [j++]) << 4; header [i] |= g_ascii_xdigit_value (pkey [j++]); @@ -2437,12 +2387,12 @@ parse_public_key (const gchar *key, gchar** pubkey, gboolean *is_ecma) bitlen = read32 (header + 12) >> 3; if ((bitlen + 16 + 4) != pkeylen) return FALSE; - + arr = (gchar *)g_malloc (keylen + 4); /* Encode the size of the blob */ mono_metadata_encode_value (keylen, &arr[0], &endp); offset = (gint)(endp-arr); - + for (i = offset, j = 0; i < keylen + offset; i++) { arr [i] = g_ascii_xdigit_value (key [j++]) << 4; arr [i] |= g_ascii_xdigit_value (key [j++]); @@ -2504,18 +2454,18 @@ build_assembly_name (const char *name, const char *version, const char *culture, else aname->revision = -1; } - + aname->flags = flags; aname->arch = arch; aname->name = g_strdup (name); - + if (culture) { if (g_ascii_strcasecmp (culture, "neutral") == 0) aname->culture = g_strdup (""); else aname->culture = g_strdup (culture); } - + if (token && strncmp (token, "null", 4) != 0) { char *lower; @@ -2543,7 +2493,7 @@ build_assembly_name (const char *name, const char *version, const char *culture, g_strlcpy ((gchar*)aname->public_key_token, "b77a5c561934e089", MONO_PUBLIC_KEY_TOKEN_LENGTH); return TRUE; } - + len = mono_metadata_decode_blob_size ((const gchar *) pkey, (const gchar **) &pkeyptr); // We also need to generate the key token mono_digest_get_public_token ((guchar*) tok, (guint8*) pkeyptr, len); @@ -2612,7 +2562,7 @@ mono_assembly_name_parse_full (const char *name, MonoAssemblyName *aname, gboole if (!is_token_defined) is_token_defined = &token_defined; *is_token_defined = FALSE; - + parts = tmp = g_strsplit (name, ",", 6); if (!tmp || !*tmp) { goto cleanup_and_fail; @@ -2631,7 +2581,7 @@ mono_assembly_name_parse_full (const char *name, MonoAssemblyName *aname, gboole dllname++; } dllname = *tmp; - + tmp++; while (*tmp) { @@ -2785,7 +2735,7 @@ unquote (const char *str) * mono_assembly_name_parse: * \param name name to parse * \param aname the destination assembly name - * + * * Parses an assembly qualified type name and assigns the name, * version, culture and token to the provided assembly name object. * @@ -2926,13 +2876,13 @@ mono_assembly_load_with_partial_name_internal (const char *name, MonoAssemblyLoa if (!mono_assembly_name_parse (name, aname)) return NULL; - /* + /* * If no specific version has been requested, make sure we load the * correct version for system assemblies. - */ + */ if ((aname->major | aname->minor | aname->build | aname->revision) == 0) aname = mono_assembly_remap_version (aname, &mapped_aname); - + res = mono_assembly_loaded_internal (alc, aname); if (res) { mono_assembly_name_free_internal (aname); @@ -2987,7 +2937,7 @@ mono_assembly_load_corlib (MonoImageOpenStatus *status) corlib = mono_assembly_request_open (corlib_name, &req, status); } g_assert (corlib); - + return corlib; } @@ -3062,7 +3012,7 @@ mono_assembly_load_full_alc (MonoGCHandle alc_gchandle, MonoAssemblyName *aname, * Loads the assembly referenced by \p aname, if the value of \p basedir is not NULL, it * attempts to load the assembly from that directory before probing the standard locations. * - * If the assembly is being opened in reflection-only mode (\p refonly set to TRUE) then no + * If the assembly is being opened in reflection-only mode (\p refonly set to TRUE) then no * assembly binding takes place. * * \returns the assembly referenced by \p aname loaded or NULL on error. On error the @@ -3145,7 +3095,7 @@ mono_assembly_loaded_internal (MonoAssemblyLoadContext *alc, MonoAssemblyName *a * \param aname an assembly to look for. * * This is used to determine if the specified assembly has been loaded - + * \returns NULL If the given \p aname assembly has not been loaded, or a pointer to * a \c MonoAssembly that matches the \c MonoAssemblyName specified. */ @@ -3283,7 +3233,7 @@ mono_assembly_foreach (GFunc func, gpointer user_data) GList *copy; /* - * We make a copy of the list to avoid calling the callback inside the + * We make a copy of the list to avoid calling the callback inside the * lock, which could lead to deadlocks. */ mono_assemblies_lock (); @@ -3440,7 +3390,7 @@ mono_assembly_try_decode_skip_verification_param (const char *p, const char **re *abort_decoding = TRUE; return FALSE; } - + /* property name length */ len = mono_metadata_decode_value (p, &p); @@ -3490,10 +3440,10 @@ mono_assembly_try_decode_skip_verification (const char *p, const char *endn) params_len = mono_metadata_decode_value (p, &p); if (is_valid) { const char *params_end = p + params_len; - + /* number of parameters */ len = mono_metadata_decode_value (p, &p); - + for (j = 0; j < len; ++j) { if (mono_assembly_try_decode_skip_verification_param (p, &p, &abort_decoding)) return TRUE; @@ -3505,7 +3455,7 @@ mono_assembly_try_decode_skip_verification (const char *p, const char *endn) p += params_len; } } - + return FALSE; } @@ -3513,7 +3463,7 @@ mono_assembly_try_decode_skip_verification (const char *p, const char *endn) gboolean mono_assembly_has_skip_verification (MonoAssembly *assembly) { - MonoTableInfo *t; + MonoTableInfo *t; guint32 cols [MONO_DECL_SECURITY_SIZE]; const char *blob; int i, len; diff --git a/src/mono/mono/utils/mono-dl-darwin.c b/src/mono/mono/utils/mono-dl-darwin.c index 1242b1981b4f0..217125542cee0 100644 --- a/src/mono/mono/utils/mono-dl-darwin.c +++ b/src/mono/mono/utils/mono-dl-darwin.c @@ -43,15 +43,6 @@ mono_dl_get_so_suffixes (void) return suffixes; } -int -mono_dl_get_executable_path (char *buf, int buflen) -{ - uint32_t bsize = buflen; - if (_NSGetExecutablePath (buf, &bsize) == 0) - return strlen (buf); - return -1; -} - const char* mono_dl_get_system_dir (void) { diff --git a/src/mono/mono/utils/mono-dl-posix.c b/src/mono/mono/utils/mono-dl-posix.c index b716b83bce1f1..16a653997865a 100644 --- a/src/mono/mono/utils/mono-dl-posix.c +++ b/src/mono/mono/utils/mono-dl-posix.c @@ -65,16 +65,6 @@ mono_dl_get_so_suffixes (void) return suffixes; } -int -mono_dl_get_executable_path (char *buf, int buflen) -{ -#if defined(HAVE_READLINK) - return readlink ("/proc/self/exe", buf, buflen - 1); -#else - return -1; -#endif -} - const char* mono_dl_get_system_dir (void) { @@ -104,11 +94,11 @@ mono_dl_open_file (const char *file, int flags) #endif #if defined(_AIX) /* - * dlopen is /weird/ on AIX + * dlopen is /weird/ on AIX * shared libraries (really, all oobjects are, since PPC is PIC) * can cohabitate with not just SOs of the other arch, but also * with regular objects in an archive used for static linking - * + * * we have to pass RTLD_MEMBER, otherwise lib.a(lib.o) doesn't work */ return dlopen (file, flags | RTLD_MEMBER); @@ -137,7 +127,7 @@ mono_dl_convert_flags (int mono_flags, int native_flags) // Specifying both will default to LOCAL if (mono_flags & MONO_DL_GLOBAL && !(mono_flags & MONO_DL_LOCAL)) lflags |= RTLD_GLOBAL; - else + else lflags |= RTLD_LOCAL; if (mono_flags & MONO_DL_LAZY) diff --git a/src/mono/mono/utils/mono-dl-wasm.c b/src/mono/mono/utils/mono-dl-wasm.c index df7d60756965c..3827dcea49584 100644 --- a/src/mono/mono/utils/mono-dl-wasm.c +++ b/src/mono/mono/utils/mono-dl-wasm.c @@ -30,13 +30,6 @@ mono_dl_get_so_suffixes (void) return suffixes; } -int -mono_dl_get_executable_path (char *buf, int buflen) -{ - strncpy (buf, "/managed", buflen); //This is a packaging convertion that our tooling should enforce - return 0; -} - const char* mono_dl_get_system_dir (void) { @@ -65,7 +58,7 @@ mono_dl_convert_flags (int mono_flags, int native_flags) // Specifying both will default to LOCAL if (mono_flags & MONO_DL_GLOBAL && !(mono_flags & MONO_DL_LOCAL)) lflags |= RTLD_GLOBAL; - else + else lflags |= RTLD_LOCAL; if (mono_flags & MONO_DL_LAZY) diff --git a/src/mono/mono/utils/mono-dl-windows.c b/src/mono/mono/utils/mono-dl-windows.c index 487fe83188da0..e2c6d2dfc64ca 100644 --- a/src/mono/mono/utils/mono-dl-windows.c +++ b/src/mono/mono/utils/mono-dl-windows.c @@ -220,12 +220,6 @@ mono_dl_current_error_string (void) } #endif /* HAVE_API_SUPPORT_WIN32_FORMAT_MESSAGE */ -int -mono_dl_get_executable_path (char *buf, int buflen) -{ - return -1; //TODO -} - const char* mono_dl_get_system_dir (void) { diff --git a/src/mono/mono/utils/mono-dl.c b/src/mono/mono/utils/mono-dl.c index 166cd5d602a8f..137999e208346 100644 --- a/src/mono/mono/utils/mono-dl.c +++ b/src/mono/mono/utils/mono-dl.c @@ -21,6 +21,7 @@ #include #include #include +#include #if defined(TARGET_ANDROID) && !defined(WIN32) #include @@ -174,7 +175,7 @@ fix_libc_name (const char *name) * mono_dl_open_self: * \param error_msg pointer for error message on failure * - * Returns a handle to the main program, on android x86 it's not possible to + * Returns a handle to the main program, on android x86 it's not possible to * call dl_open(null), it returns a null handle, so this function returns RTLD_DEFAULT * handle in this platform. */ @@ -197,9 +198,9 @@ mono_dl_open_self (char **error_msg) module->dl_fallback = NULL; module->full_name = NULL; return module; -#else +#else return mono_dl_open (NULL, MONO_DL_LAZY, error_msg); -#endif +#endif } /** @@ -257,11 +258,11 @@ mono_dl_open_full (const char *name, int mono_flags, int native_flags, char **er MonoDlFallbackHandler *handler = (MonoDlFallbackHandler *) node->data; if (error_msg) *error_msg = NULL; - + lib = handler->load_func (name, lflags, error_msg, handler->user_data); if (error_msg && *error_msg != NULL) g_free (*error_msg); - + if (lib != NULL){ dl_fallback = handler; found_name = g_strdup (name); @@ -279,7 +280,7 @@ mono_dl_open_full (const char *name, int mono_flags, int native_flags, char **er g_free (module); return NULL; } - + suff = ".la"; ext = strrchr (name, '.'); if (ext && strcmp (ext, ".la") == 0) @@ -379,13 +380,13 @@ void mono_dl_close (MonoDl *module) { MonoDlFallbackHandler *dl_fallback = module->dl_fallback; - + if (dl_fallback){ if (dl_fallback->close_func != NULL) dl_fallback->close_func (module->handle, dl_fallback->user_data); } else mono_dl_close_handle (module); - + g_free (module->full_name); g_free (module); } @@ -573,7 +574,7 @@ mono_dl_fallback_register (MonoDlFallbackLoad load_func, MonoDlFallbackSymbol sy handler->user_data = user_data; fallback_handlers = g_slist_prepend (fallback_handlers, handler); - + leave: return handler; } @@ -613,18 +614,14 @@ MonoDl* mono_dl_open_runtime_lib (const char* lib_name, int flags, char **error_msg) { MonoDl *runtime_lib = NULL; - char buf [4096]; - int binl; *error_msg = NULL; - binl = mono_dl_get_executable_path (buf, sizeof (buf)); + char *resolvedname = minipal_getexepath(); - if (binl != -1) { + if (!resolvedname) { char *base; - char *resolvedname, *name; + char *name; char *baseparent = NULL; - buf [binl] = 0; - resolvedname = mono_path_resolve_symlinks (buf); base = g_path_get_dirname (resolvedname); name = g_strdup_printf ("%s/.libs", base); runtime_lib = try_load (lib_name, name, flags, error_msg); diff --git a/src/mono/mono/utils/mono-dl.h b/src/mono/mono/utils/mono-dl.h index 5a810f8c295da..a0a2c4ec7e4c2 100644 --- a/src/mono/mono/utils/mono-dl.h +++ b/src/mono/mono/utils/mono-dl.h @@ -55,7 +55,6 @@ void mono_dl_close_handle (MonoDl *module); void* mono_dl_lookup_symbol (MonoDl *module, const char *name); int mono_dl_convert_flags (int mono_flags, int native_flags); char* mono_dl_current_error_string (void); -int mono_dl_get_executable_path (char *buf, int buflen); const char* mono_dl_get_system_dir (void); #endif /* __MONO_UTILS_DL_H__ */ diff --git a/src/native/common/getexepath.h b/src/native/common/getexepath.h index e918dadcb8e55..01c6b01e249a1 100644 --- a/src/native/common/getexepath.h +++ b/src/native/common/getexepath.h @@ -15,6 +15,8 @@ #include #include #include +#elif defined(_WIN32) +#include #endif #ifdef __cplusplus @@ -23,7 +25,7 @@ extern "C" { // Returns the full path to the executable for the current process, resolving symbolic links. // The caller is responsible for releasing the buffer. Returns null on error. -extern inline char* getexepath(void) +static inline char* minipal_getexepath(void) { #if defined(__APPLE__) uint32_t path_length = 0; @@ -59,6 +61,17 @@ extern inline char* getexepath(void) } return realpath(path, NULL); +#elif defined(_WIN32) + char path[MAX_PATH]; + if (GetModuleFileNameA(NULL, path, MAX_PATH) == 0) + { + return NULL; + } + + return strdup(path); +#elif defined(TARGET_WASM) + // This is a packaging convention that our tooling should enforce. + return strdup("/managed"); #else #if HAVE_GETAUXVAL && defined(AT_EXECFN) const char* path = (const char *)getauxval(AT_EXECFN); diff --git a/src/native/corehost/hostmisc/hostmisc.cmake b/src/native/corehost/hostmisc/hostmisc.cmake index 2560446a92f7e..a6237b0526c74 100644 --- a/src/native/corehost/hostmisc/hostmisc.cmake +++ b/src/native/corehost/hostmisc/hostmisc.cmake @@ -3,7 +3,7 @@ include(${CMAKE_CURRENT_LIST_DIR}/configure.cmake) include_directories(${CMAKE_CURRENT_BINARY_DIR}) -include_directories("${CLR_SRC_NATIVE_DIR}/common") +include_directories("${CLR_SRC_NATIVE_DIR}") if(CLR_CMAKE_TARGET_OS_ILLUMOS) add_definitions(-DTARGET_ILLUMOS) diff --git a/src/native/corehost/hostmisc/pal.unix.cpp b/src/native/corehost/hostmisc/pal.unix.cpp index 3a0602710bf6e..0657041541af4 100644 --- a/src/native/corehost/hostmisc/pal.unix.cpp +++ b/src/native/corehost/hostmisc/pal.unix.cpp @@ -5,7 +5,6 @@ #define _WITH_GETLINE #endif -#include #include "pal.h" #include "utils.h" #include "trace.h" @@ -20,6 +19,7 @@ #include #include #include "config.h" +#include #if defined(TARGET_OSX) #include @@ -837,7 +837,7 @@ pal::string_t pal::get_current_os_rid_platform() bool pal::get_own_executable_path(pal::string_t* recv) { - char* path = getexepath(); + char* path = minipal_getexepath(); if (!path) { return false;