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

Define dirent d_type for Solaris based OS #34263

Merged
merged 1 commit into from
Apr 4, 2020
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
10 changes: 7 additions & 3 deletions eng/native/configurecompiler.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -179,11 +179,15 @@ endif(CLR_CMAKE_HOST_UNIX)
if(CLR_CMAKE_HOST_LINUX)
add_compile_options($<$<COMPILE_LANGUAGE:ASM>:-Wa,--noexecstack>)
add_link_options(-Wl,--build-id=sha1 -Wl,-z,relro,-z,now)
endif(CLR_CMAKE_HOST_LINUX)
if(CLR_CMAKE_HOST_FREEBSD)
elseif(CLR_CMAKE_HOST_FREEBSD)
add_compile_options($<$<COMPILE_LANGUAGE:ASM>:-Wa,--noexecstack>)
add_link_options(LINKER:--build-id=sha1)
endif(CLR_CMAKE_HOST_FREEBSD)
elseif(CLR_CMAKE_HOST_SUNOS)
set(CMAKE_INCLUDE_PATH ${CMAKE_INCLUDE_PATH} /opt/local/include)
set(CMAKE_LIBRARY_PATH ${CMAKE_LIBRARY_PATH} /opt/local/lib)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fstack-protector")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fstack-protector")
endif()

#------------------------------------
# Definitions (for platform)
Expand Down
4 changes: 1 addition & 3 deletions src/installer/corehost/cli/common.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,7 @@ function(set_common_libs TargetType)
target_link_libraries (${DOTNET_PROJECT_NAME} "pthread")
endif()

if(CLR_CMAKE_TARGET_LINUX)
target_link_libraries (${DOTNET_PROJECT_NAME} "dl")
endif()
target_link_libraries (${DOTNET_PROJECT_NAME} ${CMAKE_DL_LIBS})
endif()

if (NOT ${TargetType} STREQUAL "lib-static")
Expand Down
3 changes: 3 additions & 0 deletions src/installer/corehost/cli/hostmisc/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ project(hostmisc)

set(DOTNET_PROJECT_NAME "hostmisc")

include(configure.cmake)
include_directories(${CMAKE_CURRENT_BINARY_DIR})

# CMake does not recommend using globbing since it messes with the freshness checks
set(SOURCES
trace.cpp
Expand Down
6 changes: 6 additions & 0 deletions src/installer/corehost/cli/hostmisc/config.h.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#ifndef _PAL_CONFIG_H_INCLUDED
#define _PAL_CONFIG_H_INCLUDED 1

#cmakedefine01 HAVE_DIRENT_D_TYPE

#endif
5 changes: 5 additions & 0 deletions src/installer/corehost/cli/hostmisc/configure.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
include(CheckStructHasMember)

check_struct_has_member("struct dirent" d_type dirent.h HAVE_DIRENT_D_TYPE)

configure_file(${CMAKE_CURRENT_SOURCE_DIR}/config.h.in ${CMAKE_CURRENT_BINARY_DIR}/config.h)
1 change: 1 addition & 0 deletions src/installer/corehost/cli/hostmisc/pal.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
#define xout std::cout
#define DIR_SEPARATOR '/'
#define PATH_SEPARATOR ':'
#undef _X
#define _X(s) s

#define S_OK 0x00000000
Expand Down
16 changes: 15 additions & 1 deletion src/installer/corehost/cli/hostmisc/pal.unix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include <fnmatch.h>
#include <ctime>
#include <pwd.h>
#include "config.h"

#if defined(TARGET_OSX)
#include <mach-o/dyld.h>
Expand All @@ -27,6 +28,13 @@
#define symlinkEntrypointExecutable "/proc/curproc/exe"
#endif

#if !HAVE_DIRENT_D_TYPE
#define DT_UNKNOWN 0
#define DT_DIR 4
#define DT_REG 8
#define DT_LNK 10
#endif

pal::string_t pal::to_string(int value) { return std::to_string(value); }

pal::string_t pal::to_lower(const pal::string_t& in)
Expand Down Expand Up @@ -821,8 +829,14 @@ static void readdir(const pal::string_t& path, const pal::string_t& pattern, boo
continue;
}

#if HAVE_DIRENT_D_TYPE
int dirEntryType = entry->d_type;
#else
int dirEntryType = DT_UNKNOWN;
#endif

// We are interested in files only
switch (entry->d_type)
switch (dirEntryType)
{
case DT_DIR:
break;
Expand Down