Skip to content

Commit aa490b5

Browse files
jkoritzinskymatouskozak
authored andcommitted
Remove remaining CRT PAL wrappers and enable including standard headers in the CoreCLR build (dotnet#98336)
- Remove malloc-family PAL and update callsites that might get passed 0 to bump up to 1. - Move `getenv` usage to use the `PAL` function directly when on non-Windows (to preserve the existing behavior). - Remove other remaining CRT PAL shims - Remove header shims and enable building with the CRT and STL headers across the product, with various build fixes required (mostly around using the standard min/max definitions)
1 parent 43012f1 commit aa490b5

File tree

240 files changed

+559
-5127
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

240 files changed

+559
-5127
lines changed

eng/native/configurecompiler.cmake

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ if (CLR_CMAKE_HOST_UNIX)
2828
add_compile_options(-Wno-null-conversion)
2929
add_compile_options(-glldb)
3030
else()
31-
add_compile_options($<$<COMPILE_LANGUAGE:CXX>:-Werror=conversion-null>)
3231
add_compile_options(-g)
3332
endif()
3433
endif()

eng/native/functions.cmake

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,12 @@ endfunction(convert_to_absolute_path)
220220
function(preprocess_file inputFilename outputFilename)
221221
get_compile_definitions(PREPROCESS_DEFINITIONS)
222222
get_include_directories(PREPROCESS_INCLUDE_DIRECTORIES)
223+
get_source_file_property(SOURCE_FILE_DEFINITIONS ${inputFilename} COMPILE_DEFINITIONS)
224+
225+
foreach(DEFINITION IN LISTS SOURCE_FILE_DEFINITIONS)
226+
list(APPEND PREPROCESS_DEFINITIONS -D${DEFINITION})
227+
endforeach()
228+
223229
if (MSVC)
224230
add_custom_command(
225231
OUTPUT ${outputFilename}

src/coreclr/CMakeLists.txt

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -202,11 +202,12 @@ if(CLR_CMAKE_HOST_UNIX)
202202
add_subdirectory(debug/createdump)
203203
endif(CLR_CMAKE_HOST_OSX OR (CLR_CMAKE_HOST_LINUX AND NOT CLR_CMAKE_HOST_UNIX_X86 AND NOT CLR_CMAKE_HOST_ANDROID))
204204

205-
# Include the dummy c++ include files
206-
include_directories("pal/inc/rt/cpp")
207-
208-
# This prevents inclusion of standard C compiler headers
209-
add_compile_options(-nostdinc)
205+
# The CoreCLR PAL used to redefine NULL, which caused a number of null conversion and arithmetic
206+
# warnings and errors to be suppressed.
207+
# Suppress these warnings here to avoid breaking the build.
208+
add_compile_options($<$<COMPILE_LANG_AND_ID:CXX,Clang,AppleClang>:-Wno-null-arithmetic>)
209+
add_compile_options($<$<COMPILE_LANG_AND_ID:CXX,GNU>:-Wno-conversion-null>)
210+
add_compile_options($<$<COMPILE_LANG_AND_ID:CXX,GNU>:-Wno-pointer-arith>)
210211

211212
set (NATIVE_RESOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/nativeresources)
212213
include_directories(${NATIVE_RESOURCE_DIR})
@@ -218,7 +219,7 @@ if(CLR_CMAKE_HOST_UNIX)
218219
# given Windows .rc file. The target C++ file path is returned in the
219220
# variable specified by the TARGET_FILE parameter.
220221
function(build_resources SOURCE TARGET_NAME TARGET_FILE)
221-
222+
set_property(SOURCE ${SOURCE} APPEND PROPERTY COMPILE_DEFINITIONS "RC_INVOKED")
222223
set(PREPROCESSED_SOURCE ${CMAKE_CURRENT_BINARY_DIR}/${TARGET_NAME}.rc.i)
223224

224225
preprocess_file(${SOURCE} ${PREPROCESSED_SOURCE})

src/coreclr/binder/assemblyname.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@
1111
//
1212
// ============================================================
1313

14+
#include "common.h"
1415
#include "assemblyname.hpp"
1516
#include "assemblybindercommon.hpp"
1617

17-
#include "common.h"
1818
#include "utils.hpp"
1919

2020
#include "textualidentityparser.hpp"

src/coreclr/clrdefinitions.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ if(CLR_CMAKE_HOST_WIN32)
5353
add_definitions(-D_WIN32_WINNT=0x0602)
5454
add_definitions(-DWIN32_LEAN_AND_MEAN)
5555
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
56+
add_compile_definitions(NOMINMAX)
5657
endif(CLR_CMAKE_HOST_WIN32)
5758

5859
if (NOT (CLR_CMAKE_TARGET_ARCH_I386 AND CLR_CMAKE_TARGET_UNIX))

src/coreclr/debug/createdump/CMakeLists.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,6 @@ else(CLR_CMAKE_HOST_WIN32)
5656
endif(CLR_CMAKE_HOST_OSX)
5757
endif (CORECLR_SET_RPATH)
5858

59-
add_definitions(-DPAL_STDCPP_COMPAT)
60-
6159
# This is so we can include "version.c"
6260
include_directories(${CMAKE_BINARY_DIR})
6361

src/coreclr/debug/daccess/daccess.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5793,7 +5793,7 @@ ClrDataAccess::RawGetMethodName(
57935793
SIZE_T maxPrecodeSize = sizeof(StubPrecode);
57945794

57955795
#ifdef HAS_THISPTR_RETBUF_PRECODE
5796-
maxPrecodeSize = max(maxPrecodeSize, sizeof(ThisPtrRetBufPrecode));
5796+
maxPrecodeSize = max((size_t)maxPrecodeSize, sizeof(ThisPtrRetBufPrecode));
57975797
#endif
57985798

57995799
for (SIZE_T i = 0; i < maxPrecodeSize / PRECODE_ALIGNMENT; i++)

src/coreclr/debug/dbgutil/CMakeLists.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@ if(CLR_CMAKE_HOST_WIN32 OR CLR_CMAKE_HOST_OSX)
99
include_directories(${CLR_DIR}/inc/llvm)
1010
endif(CLR_CMAKE_HOST_WIN32 OR CLR_CMAKE_HOST_OSX)
1111

12-
add_definitions(-DPAL_STDCPP_COMPAT)
13-
1412
if(CLR_CMAKE_TARGET_LINUX_MUSL)
1513
add_definitions(-DTARGET_LINUX_MUSL)
1614
endif(CLR_CMAKE_TARGET_LINUX_MUSL)

src/coreclr/debug/debug-pal/CMakeLists.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@ include_directories(../inc)
22
include_directories(../../pal/inc)
33
include_directories(${EP_GENERATED_HEADER_PATH})
44

5-
add_definitions(-DPAL_STDCPP_COMPAT)
6-
75
set(SHARED_EVENTPIPE_SOURCE_PATH ${CLR_SRC_NATIVE_DIR}/eventpipe)
86
add_definitions(-DFEATURE_CORECLR)
97
add_definitions(-DFEATURE_PERFTRACING)

src/coreclr/debug/di/rspriv.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3975,9 +3975,9 @@ class CordbProcess :
39753975

39763976
// CORDB_ADDRESS's are UINT_PTR's (64 bit under HOST_64BIT, 32 bit otherwise)
39773977
#if defined(TARGET_64BIT)
3978-
#define MAX_ADDRESS (_UI64_MAX)
3978+
#define MAX_ADDRESS (UINT64_MAX)
39793979
#else
3980-
#define MAX_ADDRESS (_UI32_MAX)
3980+
#define MAX_ADDRESS (UINT32_MAX)
39813981
#endif
39823982
#define MIN_ADDRESS (0x0)
39833983
CORDB_ADDRESS m_minPatchAddr; //smallest patch in table

0 commit comments

Comments
 (0)