From d17f1c4c4fd2e545673a411f46e3781f17a26b0b Mon Sep 17 00:00:00 2001
From: Adeel Mujahid <3840695+am11@users.noreply.github.com>
Date: Tue, 3 Dec 2024 17:27:08 +0200
Subject: [PATCH 01/12] Fix zlib-ng build with cmake 3.31.0

---
 src/native/external/zlib-ng/CMakeLists.txt | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/src/native/external/zlib-ng/CMakeLists.txt b/src/native/external/zlib-ng/CMakeLists.txt
index 719673fbf34a1a..052675b3850335 100644
--- a/src/native/external/zlib-ng/CMakeLists.txt
+++ b/src/native/external/zlib-ng/CMakeLists.txt
@@ -1,8 +1,6 @@
-cmake_minimum_required(VERSION 3.5.1)
+cmake_minimum_required(VERSION 3.5.1...3.31.0)
 if(CMAKE_VERSION VERSION_LESS 3.12)
     cmake_policy(VERSION ${CMAKE_VERSION})
-else()
-    cmake_policy(VERSION 3.5.1...3.29.0)
 endif()
 message(STATUS "Using CMake version ${CMAKE_VERSION}")
 

From 5d3d4cc116aeb30e0f2499476b987a9a4a598db5 Mon Sep 17 00:00:00 2001
From: Adeel Mujahid <3840695+am11@users.noreply.github.com>
Date: Tue, 3 Dec 2024 17:34:20 +0200
Subject: [PATCH 02/12] Dummy change in JIT

---
 src/coreclr/jit/abi.h | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/src/coreclr/jit/abi.h b/src/coreclr/jit/abi.h
index 66566f44db5fa6..1632382b01bd1a 100644
--- a/src/coreclr/jit/abi.h
+++ b/src/coreclr/jit/abi.h
@@ -1,6 +1,8 @@
 // Licensed to the .NET Foundation under one or more agreements.
 // The .NET Foundation licenses this file to you under the MIT license.
 
+// dummy change
+
 #pragma once
 
 class ClassLayout;

From e92d469d090139c5dad9a367f755a8aa26a65ee0 Mon Sep 17 00:00:00 2001
From: Adeel Mujahid <3840695+am11@users.noreply.github.com>
Date: Tue, 3 Dec 2024 19:41:28 +0200
Subject: [PATCH 03/12] Use POST_BUILD in add_custom_command

---
 src/coreclr/nativeaot/Runtime/Full/CMakeLists.txt | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/src/coreclr/nativeaot/Runtime/Full/CMakeLists.txt b/src/coreclr/nativeaot/Runtime/Full/CMakeLists.txt
index d9eae26c9a4303..f717c2786e0a2f 100644
--- a/src/coreclr/nativeaot/Runtime/Full/CMakeLists.txt
+++ b/src/coreclr/nativeaot/Runtime/Full/CMakeLists.txt
@@ -92,8 +92,9 @@ endif()
 add_custom_command(
     # The AsmOffsets.cs is consumed later by the managed build
     TARGET Runtime.WorkstationGC
-    COMMAND ${CMAKE_CXX_COMPILER} ${COMPILER_LANGUAGE} ${DEFINITIONS} ${PREPROCESSOR_FLAGS} -I"${ARCH_SOURCES_DIR}" "${ASM_OFFSETS_CSPP}" >"${CMAKE_CURRENT_BINARY_DIR}/AsmOffsets.cs"
-    DEPENDS "${RUNTIME_DIR}/AsmOffsets.cpp" "${RUNTIME_DIR}/AsmOffsets.h"
+    POST_BUILD
+    COMMAND ${CMAKE_CXX_COMPILER} ${COMPILER_LANGUAGE} ${DEFINITIONS} ${PREPROCESSOR_FLAGS}
+            -I"${ARCH_SOURCES_DIR}" "${ASM_OFFSETS_CSPP}" >"${CMAKE_CURRENT_BINARY_DIR}/AsmOffsets.cs"
 )
 
 add_custom_command(

From 52ff89dc282f1a172fe8f14267c2de3c4a15a3e2 Mon Sep 17 00:00:00 2001
From: Adeel Mujahid <3840695+am11@users.noreply.github.com>
Date: Tue, 3 Dec 2024 19:42:08 +0200
Subject: [PATCH 04/12] Normalize paths before install

---
 eng/native/functions.cmake | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/eng/native/functions.cmake b/eng/native/functions.cmake
index 337538a6ba163e..0eae6a0db58f52 100644
--- a/eng/native/functions.cmake
+++ b/eng/native/functions.cmake
@@ -489,10 +489,11 @@ endfunction()
 
 function(install_symbol_file symbol_file destination_path)
   if(CLR_CMAKE_TARGET_WIN32)
-      install(FILES ${symbol_file} DESTINATION ${destination_path}/PDB ${ARGN})
+      get_filename_component(DST_PATH_ABS ${destination_path}/PDB ABSOLUTE)
   else()
-      install(FILES ${symbol_file} DESTINATION ${destination_path} ${ARGN})
+      get_filename_component(DST_PATH_ABS ${destination_path} ABSOLUTE)
   endif()
+  install(FILES ${symbol_file} DESTINATION ${DST_PATH_ABS} ${ARGN})
 endfunction()
 
 function(install_static_library targetName destination component)

From 236168d4ee4b705caace9d933cf577165521cb81 Mon Sep 17 00:00:00 2001
From: Adeel Mujahid <3840695+am11@users.noreply.github.com>
Date: Tue, 3 Dec 2024 19:56:37 +0200
Subject: [PATCH 05/12] Revert dummy change; CI is green

---
 src/coreclr/jit/abi.h | 2 --
 1 file changed, 2 deletions(-)

diff --git a/src/coreclr/jit/abi.h b/src/coreclr/jit/abi.h
index 1632382b01bd1a..66566f44db5fa6 100644
--- a/src/coreclr/jit/abi.h
+++ b/src/coreclr/jit/abi.h
@@ -1,8 +1,6 @@
 // Licensed to the .NET Foundation under one or more agreements.
 // The .NET Foundation licenses this file to you under the MIT license.
 
-// dummy change
-
 #pragma once
 
 class ClassLayout;

From c6ac18a81cc94b8ebbf2320b2f4621e2395dc5e5 Mon Sep 17 00:00:00 2001
From: Adeel Mujahid <3840695+am11@users.noreply.github.com>
Date: Tue, 3 Dec 2024 20:25:55 +0200
Subject: [PATCH 06/12] Update functions.cmake

---
 eng/native/functions.cmake | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/eng/native/functions.cmake b/eng/native/functions.cmake
index 0eae6a0db58f52..b29be4c09db331 100644
--- a/eng/native/functions.cmake
+++ b/eng/native/functions.cmake
@@ -489,11 +489,10 @@ endfunction()
 
 function(install_symbol_file symbol_file destination_path)
   if(CLR_CMAKE_TARGET_WIN32)
-      get_filename_component(DST_PATH_ABS ${destination_path}/PDB ABSOLUTE)
+      install(FILES ${symbol_file} DESTINATION "${destination_path}\\PDB" ${ARGN})
   else()
-      get_filename_component(DST_PATH_ABS ${destination_path} ABSOLUTE)
+      install(FILES ${symbol_file} DESTINATION "${destination_path}" ${ARGN})
   endif()
-  install(FILES ${symbol_file} DESTINATION ${DST_PATH_ABS} ${ARGN})
 endfunction()
 
 function(install_static_library targetName destination component)

From cf6df9dc3b301070484385681470eaaa57c16d40 Mon Sep 17 00:00:00 2001
From: Adeel Mujahid <3840695+am11@users.noreply.github.com>
Date: Tue, 3 Dec 2024 20:46:10 +0200
Subject: [PATCH 07/12] Update functions.cmake

---
 eng/native/functions.cmake | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/eng/native/functions.cmake b/eng/native/functions.cmake
index b29be4c09db331..7022a46a7a2778 100644
--- a/eng/native/functions.cmake
+++ b/eng/native/functions.cmake
@@ -489,9 +489,10 @@ endfunction()
 
 function(install_symbol_file symbol_file destination_path)
   if(CLR_CMAKE_TARGET_WIN32)
-      install(FILES ${symbol_file} DESTINATION "${destination_path}\\PDB" ${ARGN})
+      cmake_path(SET DEST NORMALIZE "${destination_path}/PDB")
+      install(FILES ${symbol_file} DESTINATION ${DEST} ${ARGN})
   else()
-      install(FILES ${symbol_file} DESTINATION "${destination_path}" ${ARGN})
+      install(FILES ${symbol_file} DESTINATION ${destination_path} ${ARGN})
   endif()
 endfunction()
 

From 87b6a5c1ed934caa77a765fef1a2070e56bc82eb Mon Sep 17 00:00:00 2001
From: Adeel Mujahid <3840695+am11@users.noreply.github.com>
Date: Tue, 3 Dec 2024 21:21:11 +0200
Subject: [PATCH 08/12] Update src/native/external/zlib-ng/CMakeLists.txt

Co-authored-by: Jeremy Koritzinsky <jkoritzinsky@gmail.com>
---
 src/native/external/zlib-ng/CMakeLists.txt | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/native/external/zlib-ng/CMakeLists.txt b/src/native/external/zlib-ng/CMakeLists.txt
index 052675b3850335..86e54f858bf6e1 100644
--- a/src/native/external/zlib-ng/CMakeLists.txt
+++ b/src/native/external/zlib-ng/CMakeLists.txt
@@ -1,4 +1,4 @@
-cmake_minimum_required(VERSION 3.5.1...3.31.0)
+cmake_minimum_required(VERSION 3.5.1...3.29.0)
 if(CMAKE_VERSION VERSION_LESS 3.12)
     cmake_policy(VERSION ${CMAKE_VERSION})
 endif()

From 4b6bf30a29a13c9e1ea530514f8f0a0cf0879352 Mon Sep 17 00:00:00 2001
From: Adeel Mujahid <3840695+am11@users.noreply.github.com>
Date: Tue, 3 Dec 2024 21:23:59 +0200
Subject: [PATCH 09/12] Update zlib-ng-version.txt

---
 src/native/external/zlib-ng-version.txt | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/src/native/external/zlib-ng-version.txt b/src/native/external/zlib-ng-version.txt
index 70d6d1f88b75ea..3384f5f8617e73 100644
--- a/src/native/external/zlib-ng-version.txt
+++ b/src/native/external/zlib-ng-version.txt
@@ -10,3 +10,5 @@ We have removed the following folders from our local copy as these files are not
 - zlib-ng/arch/s390/self-hosted-builder/
 
 Also, if the next version does not yet contain the fixes included in 12bc7edc73308f017ec40c6b2db694a6e3490ac2, cherry-pick it as a patch.
+
+Apply https://github.com/zlib-ng/zlib-ng/pull/1812

From 8ecfee82c9724affc7355dd9cb04c342b005c0a9 Mon Sep 17 00:00:00 2001
From: Adeel Mujahid <3840695+am11@users.noreply.github.com>
Date: Wed, 4 Dec 2024 00:56:35 +0200
Subject: [PATCH 10/12] Try deleting 'Build jitutils' step

---
 .github/workflows/jit-format.yml | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/.github/workflows/jit-format.yml b/.github/workflows/jit-format.yml
index 18fb209c628afc..693e0d8ef8058d 100644
--- a/.github/workflows/jit-format.yml
+++ b/.github/workflows/jit-format.yml
@@ -39,10 +39,6 @@ jobs:
         uses: actions/setup-dotnet@v4
         with:
           dotnet-version: '8.0.x'
-      - name: Build jitutils
-        run: |
-          ./bootstrap${{ matrix.os.extension }}
-        working-directory: jitutils
       - name: Checkout runtime
         uses: actions/checkout@v4
         with:
@@ -61,4 +57,4 @@ jobs:
         with:
           path: runtime/format.patch
           name: format.${{matrix.os.name}}.patch
-        if: failure()
\ No newline at end of file
+        if: failure()

From 4ad9b5a824e165f97d040b07d19f9008d4668c9b Mon Sep 17 00:00:00 2001
From: Adeel Mujahid <3840695+am11@users.noreply.github.com>
Date: Wed, 4 Dec 2024 01:02:05 +0200
Subject: [PATCH 11/12] Update jit-format.yml

---
 .github/workflows/jit-format.yml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/.github/workflows/jit-format.yml b/.github/workflows/jit-format.yml
index 693e0d8ef8058d..17f1bcb85477de 100644
--- a/.github/workflows/jit-format.yml
+++ b/.github/workflows/jit-format.yml
@@ -48,7 +48,7 @@ jobs:
       
       - name: Run jitformat.py
         run: |
-          python3 runtime/src/coreclr/scripts/jitformat.py --jitutils jitutils -r runtime -o ${{ matrix.os.name }} -a x64 ${{ matrix.os.cross }}
+          python3 runtime/src/coreclr/scripts/jitformat.py -r runtime -o ${{ matrix.os.name }} -a x64 ${{ matrix.os.cross }}
         env:
           ROOTFS_DIR: ${{ matrix.os.rootfs }}
       

From effb41fca183e905cbc007a3199d9fe9c76a93e6 Mon Sep 17 00:00:00 2001
From: Adeel Mujahid <3840695+am11@users.noreply.github.com>
Date: Wed, 4 Dec 2024 01:54:10 +0200
Subject: [PATCH 12/12] Remove checkout jitutils

---
 .github/workflows/jit-format.yml | 7 -------
 1 file changed, 7 deletions(-)

diff --git a/.github/workflows/jit-format.yml b/.github/workflows/jit-format.yml
index 17f1bcb85477de..0f04abf58cce10 100644
--- a/.github/workflows/jit-format.yml
+++ b/.github/workflows/jit-format.yml
@@ -28,13 +28,6 @@ jobs:
     container: ${{ matrix.os.container }}
     name: Format jit codebase ${{ matrix.os.name }}
     steps:
-      - name: Checkout jitutils
-        uses: actions/checkout@v4
-        with:
-          path: jitutils
-          repository: dotnet/jitutils
-          ref: main
-          token: ${{ secrets.GITHUB_TOKEN }}
       - name: Install .NET
         uses: actions/setup-dotnet@v4
         with:
