From ce379beeb23947c3dc17f540d31e885b03bdaf3f Mon Sep 17 00:00:00 2001 From: Rafal Kupiec Date: Sat, 27 Sep 2025 14:27:27 +0200 Subject: [PATCH] Update LLVM to 21.1.2 and add Mtools --- build.sh | 53 ++++++++++++++++++- ...ix-WaitForSingleObject-cast-on-MinGW.patch | 13 +++++ 2 files changed, 65 insertions(+), 1 deletion(-) create mode 100644 patches/llvm/21.1.2/01-Fix-WaitForSingleObject-cast-on-MinGW.patch diff --git a/build.sh b/build.sh index 935d5d5..b4454e9 100755 --- a/build.sh +++ b/build.sh @@ -31,9 +31,14 @@ CMAKEVCS="https://gitlab.kitware.com/cmake/cmake.git" # LLVM Settings LLVMDIR="${SRCDIR}/llvm" -LLVMTAG="llvmorg-21.1.1" +LLVMTAG="llvmorg-21.1.2" LLVMVCS="https://github.com/llvm/llvm-project.git" +# Mtools Settings +MTOOLSDIR="${SRCDIR}/mtools" +MTOOLSTAG="v4.0.49" +MTOOLSVCS="https://github.com/xt-sys/mtools.git" + # Ninja Settings NINJADIR="${SRCDIR}/ninja" NINJATAG="v1.13.1" @@ -207,6 +212,48 @@ llvm_fetch() fi } +# This function compiles and installs MTOOLS +mtools_build() +{ + local CONFIGURE_PARAMETERS="" + local EXTENSION="" + + # Clean old build if necessary + [ "${CLEAN_BUILD}" -eq 1 ] && rm -rf ${MTOOLSDIR}/build-${SYSTEM_NAME} + + # Additional, target-specific configuration options + case "${SYSTEM_NAME}" in + Windows) + CONFIGURE_PARAMETERS="${CONFIGURE_PARAMETERS} --host=${SYSTEM_HOST}" + EXTENSION=".exe" + ;; + esac + + # Build Mtools + echo ">>> Building MTOOLS ..." + mkdir -p ${MTOOLSDIR}/build-${SYSTEM_NAME} + cd ${MTOOLSDIR}/build-${SYSTEM_NAME} + ../configure ${CONFIGURE_PARAMETERS} + make -j ${BUILD_JOBS} + cp mtools${EXTENSION} ${BINDIR}/bin/ + for TOOL in mcat mcd mcopy mdel mdir mformat minfo mlabel mmd mmove mpartition mrd mren mshowfat mtype mzip; do + cp mtools${EXTENSION} ${BINDIR}/bin/${TOOL}${EXTENSION} + done + cd ${WRKDIR} +} + +# This function downloads MTOOLS from VCS +mtools_fetch() +{ + if [ ! -d ${MTOOLSDIR} ]; then + echo ">>> Downloading MTOOLS ..." + git clone --depth 1 --branch ${MTOOLSTAG} ${MTOOLSVCS} ${MTOOLSDIR} + cd ${MTOOLSDIR} + apply_patches ${MTOOLSDIR##*/} ${MTOOLSTAG} + cd ${WRKDIR} + fi +} + # This function compiles and installs NINJA ninja_build() { @@ -479,6 +526,10 @@ xtchain_build wine_fetch wine_build +# Download and build GNU Mtools +mtools_fetch +mtools_build + if [ ${BUILD_MINIMAL} -eq 0 ]; then # Download and build LLVM llvm_fetch diff --git a/patches/llvm/21.1.2/01-Fix-WaitForSingleObject-cast-on-MinGW.patch b/patches/llvm/21.1.2/01-Fix-WaitForSingleObject-cast-on-MinGW.patch new file mode 100644 index 0000000..8e739d8 --- /dev/null +++ b/patches/llvm/21.1.2/01-Fix-WaitForSingleObject-cast-on-MinGW.patch @@ -0,0 +1,13 @@ +diff --git a/lldb/source/Host/windows/MainLoopWindows.cpp b/lldb/source/Host/windows/MainLoopWindows.cpp +index c0b10797e..e971b8cfd 100644 +--- a/lldb/source/Host/windows/MainLoopWindows.cpp ++++ b/lldb/source/Host/windows/MainLoopWindows.cpp +@@ -58,7 +58,7 @@ public: + // Keep trying to cancel ReadFile() until the thread exits. + do { + CancelIoEx(m_handle, /*lpOverlapped=*/NULL); +- } while (WaitForSingleObject(m_monitor_thread.native_handle(), 1) == ++ } while (WaitForSingleObject((HANDLE)m_monitor_thread.native_handle(), 1) == + WAIT_TIMEOUT); + m_monitor_thread.join(); + }