Skip to content
Closed
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
188 changes: 188 additions & 0 deletions eng/pipelines/collect-obj-files.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,188 @@
# collect-obj-files.ps1
# Collects compiled object files (.obj on Windows, .o on Linux/macOS) for
# the 102 source files modified in PR #127295 ("Remove Unused Includes").
# Usage: pwsh collect-obj-files.ps1 -ArtifactsObjDir <path> -OutputDir <path>

param(
[Parameter(Mandatory)]
[string]$ArtifactsObjDir,

[Parameter(Mandatory)]
[string]$OutputDir
)

Set-StrictMode -Version Latest
$ErrorActionPreference = 'Stop'

# The 102 source file basenames from PR #127295 (dotnet/runtime).
# We search for object files whose name matches "<basename>.obj" or "<basename>.o".
$sourceBasenames = @(
"assembly"
"dacfn"
Comment on lines +19 to +21
"processdescriptor"
"walker"
"dactable"
"debuggermodule"
"funceval"
"ceefilegenwriter"
"arraylist"
"dres"
"windasm"
"interoplib"
"block"
"dllmain"
"ee_il_dll"
"importer"
"loopcloning"
"promotion"
"promotiondecomposition"
"simdcodegenxarch"
"custattr_import"
"regmeta"
"regmeta_compilersupport"
"regmeta_emit"
"regmeta_import"
"regmeta_vm"
"stgtiggerstream"
"mdinternaldisp"
"memory"
"AsmOffsetsVerify"
"Crst"
"DebugHeader"
"EHHelpers"
"FinalizerHelpers"
"GCHelpers"
"GcStressControl"
"HandleTableHelpers"
"MathHelpers"
"MiscHelpers"
"RestrictedCallouts"
"RuntimeInstance"
"SyncClean"
"ThunksMapping"
"TypeManager"
"UniversalTransitionHelpers"
"event"
"ep-rt-aot"
"eventpipeinternal"
"eventtrace"
"eventtrace_gcheap"
"interoplibinterface_java"
"portable"
"rhassert"
"startup"
"stressLog"
"threadstore"
"PalCommon"
"PalMinWin"
"yieldprocessornormalized"
"mcs"
"removedup"
"icorjitinfo_generated"
"jithost"
"superpmi-shim-counter"
"superpmi-shim-simple"
"streamingsuperpmi"
"hostimpl"
"rangelist"
"cgenamd64"
"appdomain"
"callcounting"
"ceeload"
"class"
"classcompat"
"clsload"
"comcallablewrapper"
"cominterfacemarshaler"
"commodule"
"comutilnative"
"corelib"
"dllimport"
"exceptionhandling"
"fieldmarshaler"
"interoplibinterface_comwrappers"
"interoputil"
"jitinterfacegen"
"method"
"methodtable"
"onstackreplacement"
"peassembly"
"prestub"
"qcallentrypoints"
"stdinterfaces"
"stdinterfaces_wrapper"
"stubhelpers"
"stublink"
"threadsuspend"
"tieredcompilation"
"longfile.windows"
)

# Deduplicate basenames (some appear more than once across different source dirs)
$uniqueBasenames = $sourceBasenames | Sort-Object -Unique
Comment on lines +121 to +122

# Build a set for fast lookup
$basenameSet = [System.Collections.Generic.HashSet[string]]::new(
[System.StringComparer]::OrdinalIgnoreCase
)
foreach ($name in $uniqueBasenames) {
[void]$basenameSet.Add($name)
}

if (-not (Test-Path $ArtifactsObjDir)) {
Write-Host "##[warning]Artifacts obj directory not found: $ArtifactsObjDir"
exit 0
}

# Create output directory
New-Item -ItemType Directory -Path $OutputDir -Force | Out-Null

$totalCopied = 0

# Search for .obj and .o files recursively
$extensions = @('*.obj', '*.o')
foreach ($ext in $extensions) {
$files = Get-ChildItem -Path $ArtifactsObjDir -Filter $ext -Recurse -File -ErrorAction SilentlyContinue
foreach ($file in $files) {
# Extract the source basename: e.g., "assembly.cpp.obj" -> "assembly"
# CMake names obj files as <sourcename>.cpp.obj (or .c.obj) on Windows,
# and <sourcename>.cpp.o (or .c.o) on Linux/macOS.
$objName = $file.Name
# Remove the object extension first
$withoutObjExt = $objName
if ($objName.EndsWith('.obj')) {
$withoutObjExt = $objName.Substring(0, $objName.Length - 4)
}
elseif ($objName.EndsWith('.o')) {
$withoutObjExt = $objName.Substring(0, $objName.Length - 2)
}

# Remove the source extension (.cpp, .c)
$baseName = $withoutObjExt
if ($withoutObjExt.EndsWith('.cpp')) {
$baseName = $withoutObjExt.Substring(0, $withoutObjExt.Length - 4)
}
elseif ($withoutObjExt.EndsWith('.c')) {
$baseName = $withoutObjExt.Substring(0, $withoutObjExt.Length - 2)
}
Comment on lines +148 to +167

if ($basenameSet.Contains($baseName)) {
# Preserve relative path from artifacts/obj
$relativePath = $file.FullName.Substring($ArtifactsObjDir.TrimEnd([IO.Path]::DirectorySeparatorChar, '/').Length + 1)
$destPath = Join-Path $OutputDir $relativePath
$destDir = Split-Path $destPath -Parent
if (-not (Test-Path $destDir)) {
New-Item -ItemType Directory -Path $destDir -Force | Out-Null
}
Copy-Item -Path $file.FullName -Destination $destPath -Force
Write-Host "Copied: $relativePath ($($file.Length) bytes)"
$totalCopied++
}
Comment on lines +142 to +180
Comment on lines +142 to +180
}
}

Write-Host ""
Write-Host "Total object files collected: $totalCopied"
if ($totalCopied -eq 0) {
Write-Host "##[warning]No matching object files found. The build may not have compiled these source files on this platform."
}
17 changes: 17 additions & 0 deletions eng/pipelines/common/global-build-job.yml
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,23 @@ jobs:
continueOnError: true
condition: always()

# Collect and publish .obj/.o files for the 102 source files from PR #127295
- pwsh: |
$(Build.SourcesDirectory)/eng/pipelines/collect-obj-files.ps1 `
-ArtifactsObjDir "$(Build.SourcesDirectory)/artifacts/obj" `
-OutputDir "$(Build.StagingDirectory)/obj-artifacts"
displayName: Collect object files for PR #127295
Comment on lines +237 to +242
continueOnError: true
condition: succeededOrFailed()
Comment on lines +242 to +244

- task: PublishBuildArtifacts@1
displayName: Publish object files
inputs:
PathtoPublish: '$(Build.StagingDirectory)/obj-artifacts'
ArtifactName: 'ObjFiles_${{ parameters.osGroup }}${{ parameters.osSubgroup }}_${{ parameters.archType }}_${{ parameters.buildConfig }}'
Comment on lines +246 to +250
continueOnError: true
condition: succeededOrFailed()

- ${{ if in(parameters.osGroup, 'osx', 'ios', 'tvos', 'android') }}:
- script: |
du -sh $(Build.SourcesDirectory)/*
Expand Down
1 change: 0 additions & 1 deletion src/coreclr/binder/assembly.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
// ============================================================
#include "common.h"
#include "assembly.hpp"
#include "utils.hpp"
#include "assemblybindercommon.hpp"

namespace BINDER_SPACE
Expand Down
1 change: 0 additions & 1 deletion src/coreclr/debug/daccess/dacfn.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
#include <virtualcallstub.h>
#include "peimagelayout.inl"

#include "gcinterface.h"
#include "gcinterface.dac.h"
struct DacHostVtPtrs
{
Expand Down
2 changes: 0 additions & 2 deletions src/coreclr/debug/debug-pal/win/processdescriptor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@
// The .NET Foundation licenses this file to you under the MIT license.

#include <windows.h>
#include <stdio.h>
#include <wchar.h>
#include <assert.h>
#include "processdescriptor.h"

ProcessDescriptor ProcessDescriptor::FromCurrentProcess()
Expand Down
1 change: 0 additions & 1 deletion src/coreclr/debug/ee/amd64/walker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
#include "walker.h"

#include "frames.h"
#include "openum.h"
#include "amd64InstrDecode.h"

#ifdef TARGET_AMD64
Expand Down
1 change: 0 additions & 1 deletion src/coreclr/debug/ee/dactable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
#include "../../vm/codeman.h"
#include "../../vm/eedbginterfaceimpl.h"
#include "../../vm/common.h"
#include "../../vm/gcenv.h"
#include "../../vm/ecall.h"
#include "../../vm/cdacplatformmetadata.hpp"

Expand Down
1 change: 0 additions & 1 deletion src/coreclr/debug/ee/debuggermodule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
#include "eeconfig.h" // This is here even for retail & free builds...
#include "vars.hpp"
#include <limits.h>
#include "ilformatter.h"
#include "debuginfostore.h"


Expand Down
1 change: 0 additions & 1 deletion src/coreclr/debug/ee/funceval.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
#include "threads.h"
#include "appdomain.inl"
#include <limits.h>
#include "ilformatter.h"

#ifndef DACCESS_COMPILE

Expand Down
1 change: 0 additions & 1 deletion src/coreclr/dlls/mscorpe/ceefilegenwriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
#include <limits.h>

#include "corerror.h"
#include <posterror.h>

// The following block contains a template for the default entry point stubs of a CLR
// IL only program. One can emit these stubs (with some fix-ups) and make
Expand Down
1 change: 0 additions & 1 deletion src/coreclr/gcinfo/arraylist.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ extern "C" void assertAbort(const char* why, const char* file, unsigned line);
#define _ASSERTE(expr) (void)0
#endif // _DEBUG

#include "gcinfohelpers.h"
#include <stdint.h>
#include "contract.h"
#include "iallocator.h"
Expand Down
1 change: 0 additions & 1 deletion src/coreclr/ildasm/dres.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
#include "dasmenum.hpp"
#include "formattype.h"
#include "dis.h"
#include "resource.h"
#include "ilformatter.h"
#include "outstring.h"

Expand Down
2 changes: 0 additions & 2 deletions src/coreclr/ildasm/windasm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@
************************************************************************************************/
#include "ildasmpch.h"

#include "dynamicarray.h"

#include "dasmenum.hpp"
#include "dis.h"
#include <clrversion.h>
Expand Down
1 change: 0 additions & 1 deletion src/coreclr/interop/interoplib.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
#include "platform.h"
#include <interoplib.h>
#include <interoplibabi.h>
#include <interoplibimports.h>

#ifdef FEATURE_COMWRAPPERS
#include "comwrappers.hpp"
Expand Down
2 changes: 0 additions & 2 deletions src/coreclr/jit/block.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
#pragma hdrstop
#endif

#include "jitstd/algorithm.h"

#if MEASURE_BLOCK_SIZE
/* static */
size_t BasicBlock::s_Size;
Expand Down
1 change: 0 additions & 1 deletion src/coreclr/jit/dllmain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
#pragma hdrstop
#endif
#include "emit.h"
#include "corexcep.h"

#ifndef DLLEXPORT
#define DLLEXPORT
Expand Down
1 change: 0 additions & 1 deletion src/coreclr/jit/ee_il_dll.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
#pragma hdrstop
#endif
#include "emit.h"
#include "corexcep.h"

#if !defined(HOST_UNIX)
#include <io.h> // For _dup, _setmode
Expand Down
2 changes: 0 additions & 2 deletions src/coreclr/jit/importer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
#pragma hdrstop
#endif

#include "corexcep.h"

/*****************************************************************************
*
* Pushes the given tree on the stack.
Expand Down
1 change: 0 additions & 1 deletion src/coreclr/jit/loopcloning.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
*/

#include "jitpch.h"
#include "jitstd/algorithm.h"

#ifdef DEBUG

Expand Down
1 change: 0 additions & 1 deletion src/coreclr/jit/promotion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@

#include "jitpch.h"
#include "promotion.h"
#include "jitstd/algorithm.h"

//------------------------------------------------------------------------
// PhysicalPromotion: Promote structs based on primitive access patterns.
Expand Down
1 change: 0 additions & 1 deletion src/coreclr/jit/promotiondecomposition.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@

#include "jitpch.h"
#include "promotion.h"
#include "jitstd/algorithm.h"

// Represents a list of statements; this is the result of store decomposition.
class DecompositionStatementList
Expand Down
1 change: 0 additions & 1 deletion src/coreclr/jit/simdcodegenxarch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
#include "sideeffects.h"
#include "lower.h"
#include "gcinfo.h"
#include "gcinfoencoder.h"

//-----------------------------------------------------------------------------
// genStoreIndTypeSimd12: store indirect a TYP_SIMD12 (i.e. Vector3) to memory.
Expand Down
2 changes: 0 additions & 2 deletions src/coreclr/md/compiler/custattr_import.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@
#include "rwutil.h"
#include "mdlog.h"
#include "importhelper.h"
#include "posterror.h"
#include "cahlprinternal.h"
#include "custattr.h"
#include "corhdr.h"
#include <metamodelrw.h>
Expand Down
1 change: 0 additions & 1 deletion src/coreclr/md/compiler/regmeta.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
#include "importhelper.h"
#include "filtermanager.h"
#include "switches.h"
#include "posterror.h"
#include "stgio.h"
#include "sstring.h"
#include <minipal/guid.h>
Expand Down
Loading
Loading