Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use getexepath in mono to deduplicate related code #60449

Merged
merged 3 commits into from
Oct 21, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/coreclr/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)

Expand Down
8 changes: 3 additions & 5 deletions src/coreclr/debug/debug-pal/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
Expand All @@ -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++)
Expand Down
1 change: 0 additions & 1 deletion src/coreclr/hosts/corerun/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
4 changes: 2 additions & 2 deletions src/coreclr/hosts/corerun/corerun.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ class platform_specific_actions final

// CMake generated
#include <config.h>
#include <getexepath.h>
#include <common/getexepath.h>

#define MAIN main
#define W(str) str
Expand Down Expand Up @@ -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)
{
Expand Down
2 changes: 0 additions & 2 deletions src/coreclr/pal/src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/coreclr/pal/src/init/pal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 <getexepath.h>
#include <common/getexepath.h>

#if HAVE_MACH_EXCEPTIONS
#include "../exception/machexception.h"
Expand Down Expand Up @@ -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" );
Expand Down
5 changes: 0 additions & 5 deletions src/coreclr/vm/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
2 changes: 1 addition & 1 deletion src/coreclr/vm/diagnosticserveradapter.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

#if defined(FEATURE_PERFTRACING)

#include "ds-server.h"
#include <eventpipe/ds-server.h>

class DiagnosticServerAdapter final
{
Expand Down
2 changes: 1 addition & 1 deletion src/coreclr/vm/eventing/eventpipe/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
10 changes: 5 additions & 5 deletions src/coreclr/vm/eventing/eventpipe/ds-rt-coreclr.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
#ifndef __DIAGNOSTICS_RT_MONO_H__
#define __DIAGNOSTICS_RT_MONO_H__

#include "ds-rt-config.h"
#include <eventpipe/ds-rt-config.h>

#ifdef ENABLE_PERFTRACING
#include "ep-rt-coreclr.h"
#include "ds-process-protocol.h"
#include "ds-profiler-protocol.h"
#include "ds-dump-protocol.h"
#include <eventpipe/ds-process-protocol.h>
#include <eventpipe/ds-profiler-protocol.h>
#include <eventpipe/ds-dump-protocol.h>

#undef DS_LOG_ALWAYS_0
#define DS_LOG_ALWAYS_0(msg) STRESS_LOG0(LF_DIAGNOSTICS_PORT, LL_ALWAYS, msg "\n")
Expand Down Expand Up @@ -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<const CLSID *>(ds_startup_profiler_command_payload_get_profiler_guid_cref (payload)));
profilerData->path.Set(reinterpret_cast<LPCWSTR>(ds_startup_profiler_command_payload_get_profiler_path (payload)));
Expand Down
2 changes: 1 addition & 1 deletion src/coreclr/vm/eventing/eventpipe/ds-rt-types-coreclr.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#ifndef __DIAGNOSTICS_RT_TYPES_CORECLR_H__
#define __DIAGNOSTICS_RT_TYPES_CORECLR_H__

#include "ds-rt-config.h"
#include <eventpipe/ds-rt-config.h>

#ifdef ENABLE_PERFTRACING
#include "ep-rt-types-coreclr.h"
Expand Down
10 changes: 5 additions & 5 deletions src/coreclr/vm/eventing/eventpipe/ep-rt-coreclr.cpp
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#include "ep-rt-config.h"
#include <eventpipe/ep-rt-config.h>

#ifdef ENABLE_PERFTRACING
#include "ep-types.h"
#include "ep.h"
#include "ep-stack-contents.h"
#include "ep-rt.h"
#include <eventpipe/ep-types.h>
#include <eventpipe/ep.h>
#include <eventpipe/ep-stack-contents.h>
#include <eventpipe/ep-rt.h>
#include "threadsuspend.h"

ep_rt_lock_handle_t _ep_rt_coreclr_config_lock_handle;
Expand Down
12 changes: 6 additions & 6 deletions src/coreclr/vm/eventing/eventpipe/ep-rt-coreclr.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
#ifndef __EVENTPIPE_RT_CORECLR_H__
#define __EVENTPIPE_RT_CORECLR_H__

#include "ep-rt-config.h"
#include <eventpipe/ep-rt-config.h>

#ifdef ENABLE_PERFTRACING
#include "ep-thread.h"
#include "ep-types.h"
#include "ep-provider.h"
#include "ep-session-provider.h"
#include <eventpipe/ep-thread.h>
#include <eventpipe/ep-types.h>
#include <eventpipe/ep-provider.h>
#include <eventpipe/ep-session-provider.h>
#include "fstream.h"
#include "typestring.h"
#include "win32threadpool.h"
Expand Down Expand Up @@ -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<ep_char8_t *>(malloc(newStrSize));
if (newStr == NULL)
{
Expand Down
2 changes: 1 addition & 1 deletion src/coreclr/vm/eventing/eventpipe/ep-rt-types-coreclr.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#ifndef __EVENTPIPE_RT_TYPES_CORECLR_H__
#define __EVENTPIPE_RT_TYPES_CORECLR_H__

#include "ep-rt-config.h"
#include <eventpipe/ep-rt-config.h>

#ifdef ENABLE_PERFTRACING
#include "slist.h"
Expand Down
20 changes: 10 additions & 10 deletions src/coreclr/vm/eventpipeadapter.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 <eventpipe/ep.h>
#include <eventpipe/ep-provider.h>
#include <eventpipe/ep-config.h>
#include <eventpipe/ep-event.h>
#include <eventpipe/ep-event-instance.h>
#include <eventpipe/ep-session.h>
#include <eventpipe/ep-session-provider.h>
#include <eventpipe/ep-metadata-generator.h>
#include <eventpipe/ep-event-payload.h>
#include <eventpipe/ep-buffer-manager.h>


class EventPipeProviderConfigurationAdapter final
Expand Down
2 changes: 1 addition & 1 deletion src/libraries/Native/Unix/System.Native/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/libraries/Native/Unix/System.Native/pal_process.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
#include <sys/sysctl.h>
#endif

#include <getexepath.h>
#include <common/getexepath.h>

// Validate that our SysLogPriority values are correct for the platform
c_static_assert(PAL_LOG_EMERG == LOG_EMERG);
Expand Down Expand Up @@ -886,5 +886,5 @@ int32_t SystemNative_SchedGetAffinity(int32_t pid, intptr_t* mask)

char* SystemNative_GetProcessPath()
{
return getexepath();
return minipal_getexepath();
}
5 changes: 4 additions & 1 deletion src/mono/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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 "")
Expand Down Expand Up @@ -586,7 +588,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)
Expand Down Expand Up @@ -809,6 +811,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)
Expand Down
2 changes: 2 additions & 0 deletions src/mono/cmake/config.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions src/mono/cmake/configure.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
6 changes: 1 addition & 5 deletions src/mono/dlls/dbgshim/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
5 changes: 1 addition & 4 deletions src/mono/dlls/mscordbi/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
am11 marked this conversation as resolved.
Show resolved Hide resolved

if (CLR_CMAKE_HOST_UNIX)
# Add custom targets that the pal build expects.
Expand Down
4 changes: 1 addition & 3 deletions src/mono/mono/component/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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")

Expand Down Expand Up @@ -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}
)
Expand Down
Loading