Skip to content

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

Merged
jkotas merged 1 commit into
dotnet:mainfrom
am11:chore/pal-file-unused
Nov 7, 2026
Merged

jkotas merged 1 commit into
dotnet:mainfrom
am11:chore/pal-file-unused

Conversation

@am11

@am11 am11 commented Nov 2, 2026 •

Copy link
Copy Markdown
Member

Depends on #136939 (the SuperPMI and ilasm/ildasm changes, first commit here); this PR is the PAL cleanup on top of it.

  • 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
    • 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.

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
@am11
am11 requested a review from jkotas November 3, 2026 08:00
Comment thread src/coreclr/md/enc/stgio.cpp Resolved

@jkotas jkotas left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please submit the SuperPMI changes and the ilasm/ildasm changes in separate PR? I would like to merge them separately first.

@am11

am11 commented Nov 3, 2026

Copy link
Copy Markdown
Member Author

@jkotas split the SuperPMI and ilasm/ildasm bits out into #136939; this one is now just the PAL cleanup on top of it.

- Delete pal/src/file (file.cpp, directory.cpp, path.cpp) and pal/src/map
  with their headers and PAL tests.
- Move the remaining Unix callers to stdio/POSIX/minipal: metadata StgIO,
  the memory-mapped stress log, the debugger/diagnostics transport names
  and createdump's default dump path.
- Reduce PAL object types to threads and fold single-use PAL helpers into
  their callers.
- Remove configure checks left without users and their tryrun cache values.

Co-authored-by: Cursor <cursoragent@cursor.com>
@am11
am11 force-pushed the chore/pal-file-unused branch from effdcd7 to f40b149 Compare November 7, 2026 15:55
@jkotas
jkotas requested a balanced review from Copilot November 7, 2026 16:08

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

The PAL file and mapping API removal affects multiple runtime subsystems across platforms, requiring cross-platform build and runtime validation that was unavailable in this source-only review.

No open issues 🎉

What changed in this PR

This PR removes CoreCLR’s PAL file, path, and file-mapping APIs after the tool migrations in #136939, reducing the Unix compatibility layer in favor of stdio, POSIX, and minipal.

Changes:

  • Migrates remaining Unix consumers, including stress-log mapping and temporary-directory handling, while retaining Windows-specific wrappers.
  • Removes obsolete PAL declarations, helpers, initialization, tests, and test registrations.
  • Removes unused configure probes and cached results, and changes GC address-space checks to use RLIMIT_AS.
File Description
src/​coreclr/​utilcode/​stresslog.cpp Uses stdio, ftruncate, and mmap on Unix.
src/​coreclr/​utilcode/​longfilepathwrappers.cpp Restricts SearchPathWrapper to Windows.
src/​coreclr/​pal/​tests/​palsuite/​wasm/​index.html Removes exclusions for deleted file tests.
src/​coreclr/​pal/​tests/​palsuite/​threading/​DuplicateHandle/​test12/​test12.cpp Deletes file-handle duplication test.
src/​coreclr/​pal/​tests/​palsuite/​threading/​DuplicateHandle/​test1/​test1.cpp Deletes file-handle duplication tests.
src/​coreclr/​pal/​tests/​palsuite/​paltestlist.txt Removes retired test registrations.
src/​coreclr/​pal/​tests/​palsuite/​paltestlist_to_be_reviewed.txt Removes retired tests from review list.
src/​coreclr/​pal/​tests/​palsuite/​miscellaneous/​CloseHandle/​test1/​test.cpp Deletes file-handle closing test.
src/​coreclr/​pal/​tests/​palsuite/​filemapping_memmgt/​UnmapViewOfFile/​test2/​unmapviewoffile.cpp Deletes null-view unmapping test.
src/​coreclr/​pal/​tests/​palsuite/​filemapping_memmgt/​UnmapViewOfFile/​test1/​UnmapViewOfFile.cpp Deletes file-view unmapping test.
src/​coreclr/​pal/​tests/​palsuite/​filemapping_memmgt/​MapViewOfFile/​test6/​mapviewoffile.cpp Deletes pagefile mapping test.
src/​coreclr/​pal/​tests/​palsuite/​filemapping_memmgt/​MapViewOfFile/​test5/​mapviewoffile.cpp Deletes invalid mapping-handle tests.
src/​coreclr/​pal/​tests/​palsuite/​filemapping_memmgt/​MapViewOfFile/​test4/​mapviewoffile.cpp Deletes mapping access-mode tests.
src/​coreclr/​pal/​tests/​palsuite/​filemapping_memmgt/​CreateFileMappingW/​test9/​createfilemapping.cpp Deletes invalid mapping creation tests.
src/​coreclr/​pal/​tests/​palsuite/​filemapping_memmgt/​CreateFileMappingW/​test8/​createfilemapping.cpp Deletes unnamed pagefile mapping tests.
src/​coreclr/​pal/​tests/​palsuite/​filemapping_memmgt/​CreateFileMappingW/​test7/​createfilemapping.cpp Deletes shared read/write view test.
src/​coreclr/​pal/​tests/​palsuite/​filemapping_memmgt/​CreateFileMappingW/​test6/​CreateFileMappingW.cpp Deletes multiple writable-view test.
src/​coreclr/​pal/​tests/​palsuite/​filemapping_memmgt/​CreateFileMappingW/​test4/​CreateFileMappingW.cpp Deletes copy-on-write mapping test.
src/​coreclr/​pal/​tests/​palsuite/​filemapping_memmgt/​CreateFileMappingW/​test3/​CreateFileMappingW.cpp Deletes writable mapping test.
src/​coreclr/​pal/​tests/​palsuite/​filemapping_memmgt/​CreateFileMappingW/​test2/​CreateFileMappingW.cpp Deletes image mapping test.
src/​coreclr/​pal/​tests/​palsuite/​filemapping_memmgt/​CreateFileMappingW/​test1/​CreateFileMappingW.cpp Deletes read-only mapping test.
src/​coreclr/​pal/​tests/​palsuite/​filemapping_memmgt/​CreateFileMappingW/​CreateFileMapping_neg1/​CreateFileMapping_neg.cpp Deletes zero-length mapping test.
src/​coreclr/​pal/​tests/​palsuite/​file_io/​WriteFile/​test5/​writefile.cpp Deletes large-file writing test.
src/​coreclr/​pal/​tests/​palsuite/​file_io/​WriteFile/​test4/​writefile.cpp Deletes positioned-writing test.
src/​coreclr/​pal/​tests/​palsuite/​file_io/​WriteFile/​test3/​WriteFile.cpp Deletes sequential-writing test.
src/​coreclr/​pal/​tests/​palsuite/​file_io/​WriteFile/​test2/​WriteFile.cpp Deletes write-size tests.
src/​coreclr/​pal/​tests/​palsuite/​file_io/​WriteFile/​test2/​Results.txt Deletes obsolete test data.
src/​coreclr/​pal/​tests/​palsuite/​file_io/​WriteFile/​test1/​WriteFile.cpp Deletes invalid-handle and read-only writing tests.
src/​coreclr/​pal/​tests/​palsuite/​file_io/​SetFilePointer/​test6/​SetFilePointer.cpp Deletes high-word relative-seek tests.
src/​coreclr/​pal/​tests/​palsuite/​file_io/​SetFilePointer/​test5/​SetFilePointer.cpp Deletes high-word absolute-seek tests.
src/​coreclr/​pal/​tests/​palsuite/​file_io/​SetFilePointer/​test1/​SetFilePointer.cpp Deletes invalid seek tests.
src/​coreclr/​pal/​tests/​palsuite/​file_io/​ReadFile/​test4/​readfile.cpp Deletes short-read test.
src/​coreclr/​pal/​tests/​palsuite/​file_io/​ReadFile/​test3/​ReadFile.cpp Deletes sequential-reading tests.
src/​coreclr/​pal/​tests/​palsuite/​file_io/​ReadFile/​test2/​ReadFile.cpp Deletes read-size tests.
src/​coreclr/​pal/​tests/​palsuite/​file_io/​ReadFile/​test1/​ReadFile.cpp Deletes invalid-handle and access tests.
src/​coreclr/​pal/​tests/​palsuite/​file_io/​ReadFile/​test1/​NonReadableFile.txt Deletes obsolete read fixture.
src/​coreclr/​pal/​tests/​palsuite/​file_io/​gettemppatha/​test1/​gettemppatha.cpp Deletes PAL temporary-path tests.
src/​coreclr/​pal/​tests/​palsuite/​file_io/​GetStdHandle/​test2/​GetStdHandle.cpp Deletes standard-handle smoke tests.
src/​coreclr/​pal/​tests/​palsuite/​file_io/​GetStdHandle/​test1/​GetStdHandle.cpp Deletes standard-handle I/O tests.
src/​coreclr/​pal/​tests/​palsuite/​file_io/​GetFullPathNameW/​test2/​test2.cpp Deletes wide-character relative-path test.
src/​coreclr/​pal/​tests/​palsuite/​file_io/​GetFullPathNameW/​test1/​GetFullPathNameW.cpp Deletes wide-character full-path tests.
src/​coreclr/​pal/​tests/​palsuite/​file_io/​GetFullPathNameA/​test2/​test2.cpp Deletes narrow-character relative-path test.
src/​coreclr/​pal/​tests/​palsuite/​file_io/​GetFullPathNameA/​test1/​GetFullPathNameA.cpp Deletes narrow-character full-path tests.
src/​coreclr/​pal/​tests/​palsuite/​file_io/​GetFileSizeEx/​test1/​GetFileSizeEx.cpp Deletes extended file-size tests.
src/​coreclr/​pal/​tests/​palsuite/​file_io/​GetFileSize/​test1/​GetFileSize.cpp Deletes file-size tests.
src/​coreclr/​pal/​tests/​palsuite/​file_io/​FlushFileBuffers/​test1/​FlushFileBuffers.cpp Deletes file-buffer flushing tests.
src/​coreclr/​pal/​tests/​palsuite/​file_io/​FILECanonicalizePath/​FILECanonicalizePath.cpp Deletes path canonicalization tests.
src/​coreclr/​pal/​tests/​palsuite/​file_io/​CreateFileW/​test1/​winoutput Deletes wide-character creation expectations.
src/​coreclr/​pal/​tests/​palsuite/​file_io/​CreateFileW/​test1/​CreateFileW.cpp Deletes wide-character file creation tests.
src/​coreclr/​pal/​tests/​palsuite/​file_io/​CreateFileA/​test1/​winoutput Deletes narrow-character creation expectations.
src/​coreclr/​pal/​tests/​palsuite/​file_io/​CreateFileA/​test1/​CreateFileA.cpp Deletes narrow-character file creation tests.
src/​coreclr/​pal/​tests/​palsuite/​DisabledTests.txt Removes retired mapping-test entry.
src/​coreclr/​pal/​tests/​palsuite/​compileDisabledTests.txt Removes retired image-mapping entry.
src/​coreclr/​pal/​tests/​palsuite/​compilableTests.txt Removes retired tests from compilation list.
src/​coreclr/​pal/​tests/​palsuite/​common/​palsuite.h Removes unused file and pipe declarations.
src/​coreclr/​pal/​tests/​palsuite/​common/​palsuite.cpp Removes wide-character file deletion helper.
src/​coreclr/​pal/​tests/​palsuite/​CMakeLists.txt Removes deleted test sources from build.
src/​coreclr/​pal/​src/​thread/​process.cpp Reads TMPDIR directly for transport names.
src/​coreclr/​pal/​src/​misc/​utils.cpp Reports allocation failure without file-error helper.
src/​coreclr/​pal/​src/​misc/​tracepointprovider.cpp Removes obsolete file header include.
src/​coreclr/​pal/​src/​misc/​dbgmsg.cpp Removes obsolete file header includes.
src/​coreclr/​pal/​src/​locale/​unicode.cpp Removes obsolete file header include.
src/​coreclr/​pal/​src/​loader/​module.cpp Localizes conversion constant and removes obsolete includes.
src/​coreclr/​pal/​src/​init/​pal.cpp Removes file-mapping and standard-handle initialization.
src/​coreclr/​pal/​src/​include/​pal/​utils.h Removes unused StringHolder.
src/​coreclr/​pal/​src/​include/​pal/​stackstring.hpp Removes directory helper declaration.
src/​coreclr/​pal/​src/​include/​pal/​palinternal.h Removes relocated temporary-directory constant.
src/​coreclr/​pal/​src/​include/​pal/​map.hpp Deletes PAL mapping internals header.
src/​coreclr/​pal/​src/​include/​pal/​file.hpp Deletes PAL file internals header.
src/​coreclr/​pal/​src/​include/​pal/​file.h Deletes PAL file utilities header.
src/​coreclr/​pal/​src/​include/​pal/​corunix.hpp Reduces PAL object types to threads.
src/​coreclr/​pal/​src/​exception/​machexception.cpp Removes obsolete mapping header include.
src/​coreclr/​pal/​src/​debug/​debug.cpp Removes obsolete file header include.
src/​coreclr/​pal/​src/​configure.cmake Removes obsolete path and mapping probes.
src/​coreclr/​pal/​src/​config.h.in Removes obsolete configuration macros.
src/​coreclr/​pal/​src/​CMakeLists.txt Removes file and mapping implementation sources.
src/​coreclr/​pal/​inc/​palprivate.h Removes private file and directory declarations.
src/​coreclr/​pal/​inc/​pal.h Removes PAL file, path, and mapping APIs.
src/​coreclr/​minipal/​Windows/​dn-stdio.cpp Removes comment referencing deleted helper.
src/​coreclr/​minipal/​Unix/​dn-stdio.cpp Removes comment referencing deleted helper.
src/​coreclr/​md/​inc/​stgio.h Adds platform-specific file and mapping state.
src/​coreclr/​inc/​winwrap.h Restricts file and search aliases to Windows.
src/​coreclr/​inc/​safewrap.h Restricts file-size wrapper to Windows.
src/​coreclr/​inc/​longfilepathwrappers.h Restricts search wrapper declaration to Windows.
src/​coreclr/​inc/​holder.h Restricts Win32 mapped-view holder to Windows.
src/​coreclr/​gc/​unix/​gcenv.unix.cpp Gates address-space accounting on RLIMIT_AS.
src/​coreclr/​gc/​unix/​configure.cmake Removes /proc/self/statm probe.
src/​coreclr/​gc/​unix/​config.gc.h.in Removes HAVE_PROCFS_STATM macro.
src/​coreclr/​dlls/​mscordac/​mscordac_unixexports.src Removes retired PAL export entries.
src/​coreclr/​debug/​createdump/​createdumppal.cpp Removes local GetTempPathA implementation.
src/​coreclr/​debug/​createdump/​createdumpmain.cpp Reads TMPDIR and ensures trailing separator.
src/​coreclr/​debug/​createdump/​createdump.h Removes Unix temporary-path alias.
src/​coreclr/​CMakeLists.txt Removes obsolete WASI probe cache values.
eng/​native/​tryrun.cmake Removes obsolete cross-compilation probe results.
eng/​native/​tryrun.browser.cmake Removes obsolete browser probe results.
eng/​native/​tryrun_ios_tvos.cmake Removes obsolete Apple mobile probe results.

Review effort: Balanced

@jkotas jkotas left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@jkotas
jkotas merged commit c91a966 into dotnet:main Nov 7, 2026
144 of 146 checks passed
@am11
am11 deleted the chore/pal-file-unused branch November 7, 2026 19:50
@jkotas

jkotas commented Nov 7, 2026

Copy link
Copy Markdown
Member

I have done a cursory look at what PAL tests are remaining. I see a number of tests for APIs that do not exist or that are provided directly by the C-runtime, without going through PAL: IsBadReadPtr, IsBadWritePtr, strcmp, strlen, ... . If you would like to tell your AI to go delete all these unused or unnecessary tests, I will be happy to merge the PR.

@am11

am11 commented Nov 7, 2026

Copy link
Copy Markdown
Member Author

@jkotas, I've pushed CRT passthru tests cleanup in #136973.

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.

4 participants