Skip to content

Remove PAL file, path and file-mapping APIs - #136821

Open
am11 wants to merge 5 commits into
dotnet:mainfrom
am11:chore/pal-file-unused
Open

am11 wants to merge 5 commits into
dotnet:mainfrom
am11:chore/pal-file-unused

Conversation

@am11

@am11 am11 commented Nov 2, 2026 •

Copy link
Copy Markdown
Member
  • Delete pal/src/file (file.cpp, directory.cpp, path.cpp) and pal/src/map with their headers and PAL tests. This removes the PAL's Win32 file, path and mapping APIs (CreateFile, ReadFile/WriteFile, SetFilePointer, GetFileSize, FlushFileBuffers, GetStdHandle, CreateFileMapping/MapViewOfFile, GetFullPathName, SearchPathW, GetTempPathA, CreatePipe, ...).
  • Move the remaining Unix callers to stdio/POSIX/minipal:
    • metadata StgIO: FILE* and VMToOSInterface mappings
    • superpmi, its shim collector and mcs: FILE*; the JIT path is resolved with realpath
    • ilasm, ildasm and metainfo: VMToOSInterface mappings and minimal path handling
    • memory-mapped stress log: mmap
    • debugger/diagnostics transport names and createdump's default dump path: read TMPDIR inline (createdump now adds the missing trailing /)
  • Reduce PAL object types to threads and fold single-use PAL helpers into their callers.
  • Remove configure checks left without users (HAVE_PROCFS_STATM, ONE_SHARED_MAPPING_PER_FILEREGION_PER_PROCESS, REALPATH_SUPPORTS_NONEXISTENT_FILES, OPEN64_IS_USED_INSTEAD_OF_OPEN, WRITE_0_BYTES_HANGS_TTY) and their tryrun cache values.

@github-actions github-actions Bot added the area-PAL-coreclr only for closed issues label Nov 2, 2026
@am11
am11 requested review from janvorli and jkotas November 2, 2026 04:24
@dotnet-policy-service dotnet-policy-service Bot added the community-contribution Indicates that the PR has been added by a community member label Nov 2, 2026
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 3 pipeline(s).
12 pipeline(s) were filtered out due to trigger conditions.
There may be pipelines that require an authorized user to comment /azp run to run.

- Remove CreatePipe/InternalCreatePipe, which have no callers.
- Move DeleteFileA, CreateDirectoryA/W, RemoveDirectoryW and
  SetCurrentDirectoryA/W out of the PAL into palsuite helpers, matching
  DeleteFileW; they were only used by PAL tests.
- Delete directory.cpp: the two internal GetCurrentDirectoryA callers now
  use RealPathHelper("."), and DIRGetLastErrorFromErrno is gone with it.
- Delete pal/file.h, which duplicated file.hpp declarations and held the
  unused find_obj struct, and fold the three MaxWCharToAcpLength*
  constants into one.
- Remove the unused PROCINFO_ID enum and MAPProtectionToFileOpenFlags.
- Remove code guarded by OPEN64_IS_USED_INSTEAD_OF_OPEN and
  WRITE_0_BYTES_HANGS_TTY, which are hardcoded to 0.
- Remove #ifndef CORECLR code in map.cpp (the PAL is always built with
  CORECLR), along with the temp file handling it left unreachable.
- Remove the ONE_SHARED_MAPPING_PER_FILEREGION_PER_PROCESS fallback; the
  configure check and all tryrun caches resolve it to 0.
- Remove an unreachable branch in InternalCanonicalizeRealPath and a
  stale comment on InternalSetFilePointerForUnixFd.
- Drop errorpathnotfound checks that only exercised the test-side
  DeleteFileA/DeleteFileW helpers.

Co-authored-by: Cursor <cursoragent@cursor.com>
@am11
am11 force-pushed the chore/pal-file-unused branch from 3dcd413 to 7b506fc Compare November 2, 2026 12:16
- Remove REALPATH_SUPPORTS_NONEXISTENT_FILES; the configure check, all
  tryrun caches and the WASI override resolve it to 0.
- Fold InternalCreateFile, InternalWriteFile, InternalReadFile,
  InternalGetFileSize, InternalFlushFileBuffers, InternalCreateFileMapping,
  InternalMapViewOfFile and InternalUnmapViewOfFile into their public
  APIs, and inline InternalOpen.
- Implement CreateFileW, GetFileSize and MapViewOfFile on top of
  CreateFileA, GetFileSizeEx and MapViewOfFileEx.
- Make the remaining file.cpp and map.cpp helpers static and move the
  file mapping types from map.hpp into map.cpp.

Co-authored-by: Cursor <cursoragent@cursor.com>
Comment thread src/coreclr/pal/src/map/map.cpp Resolved
@am11 am11 changed the title Remove unused and test-only code from PAL file and map Remove PAL file, path and file-mapping APIs Nov 3, 2026
Revert palsuite.cpp/.h to main and drop DeleteFileW and the CreatePipe declaration; nothing uses them after the file_io tests were removed.

Co-authored-by: Cursor <cursoragent@cursor.com>
@am11
am11 requested a review from jkotas November 3, 2026 08:00

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-PAL-coreclr only for closed issues community-contribution Indicates that the PR has been added by a community member

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants