I am trying to apply the following patch which repeatedly fails (hunk failure)
From 256ad97f332010ab6673052fe4e562e5ed2dadd2 Mon Sep 17 00:00:00 2001
From: Siu Kwan Lam <michael.lam.sk@gmail.com>
Date: Mon, 3 Feb 2020 14:44:54 -0600
Subject: [PATCH] Update LTO patch
LTO is the only shared library built by LLVM. It breaks llvmlite
builds under Windows with the following message:
LINK : fatal error LNK1181: cannot open input file 'LTO-NOTFOUND.obj'
---
tools/lto/CMakeLists.txt | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/lto/CMakeLists.txt b/tools/lto/CMakeLists.txt
index b86e4ab..88e5ba0 100644
--- a/tools/lto/CMakeLists.txt
+++ b/tools/lto/CMakeLists.txt
@@ -20,7 +20,7 @@ set(SOURCES
set(LLVM_EXPORTED_SYMBOL_FILE ${CMAKE_CURRENT_SOURCE_DIR}/lto.exports)
-add_llvm_library(LTO SHARED INSTALL_WITH_TOOLCHAIN ${SOURCES} DEPENDS intrinsics_gen)
+add_llvm_library(LTO INSTALL_WITH_TOOLCHAIN ${SOURCES} DEPENDS intrinsics_gen)
install(FILES ${LLVM_MAIN_INCLUDE_DIR}/llvm-c/lto.h
DESTINATION include/llvm-c
--
2.16.2
Below is the file that I'm trying to patch
set(LLVM_LINK_COMPONENTS
AllTargetsAsmParsers
AllTargetsCodeGens
AllTargetsDescs
AllTargetsDisassemblers
AllTargetsInfos
BitReader
Core
CodeGen
LTO
MC
MCDisassembler
Support
Target
)
set(SOURCES
LTODisassembler.cpp
lto.cpp
)
set(LLVM_EXPORTED_SYMBOL_FILE ${CMAKE_CURRENT_SOURCE_DIR}/lto.exports)
add_llvm_library(LTO SHARED INSTALL_WITH_TOOLCHAIN ${SOURCES} DEPENDS
intrinsics_gen)
install(FILES ${LLVM_MAIN_INCLUDE_DIR}/llvm-c/lto.h
DESTINATION include/llvm-c
COMPONENT LTO)
if (APPLE)
set(LTO_VERSION ${LLVM_VERSION_MAJOR})
if(LLVM_LTO_VERSION_OFFSET)
math(EXPR LTO_VERSION "${LLVM_VERSION_MAJOR} + ${LLVM_LTO_VERSION_OFFSET}")
endif()
set_property(TARGET LTO APPEND_STRING PROPERTY
LINK_FLAGS
" -compatibility_version 1 -current_version
${LTO_VERSION}.${LLVM_VERSION_MINOR}.${LLVM_VERSION_PATCH}")
endif()
Notice that the patch shows
-add_llvm_library(LTO SHARED INSTALL_WITH_TOOLCHAIN ${SOURCES} DEPENDS intrinsics_gen)
+add_llvm_library(LTO INSTALL_WITH_TOOLCHAIN ${SOURCES} DEPENDS intrinsics_gen)
and the file to be patched has
add_llvm_library(LTO SHARED INSTALL_WITH_TOOLCHAIN ${SOURCES} DEPENDS
intrinsics_gen)
Essentially, the file to be patched has line wrapping; the patch has one line
add_llvm_library(LTO SHARED INSTALL_WITH_TOOLCHAIN ${SOURCES} DEPENDS intrinsics_gen)
but is on two lines in the file I want to patch
add_llvm_library(LTO SHARED INSTALL_WITH_TOOLCHAIN ${SOURCES} DEPENDS
intrinsics_gen)
Manually changing the file to be patched to
add_llvm_library(LTO SHARED INSTALL_WITH_TOOLCHAIN ${SOURCES} DEPENDS intrinsics_gen)
solves the problem and allows the patch to complete successfully. My question is following. Is there a way to apply patches when text wrapping like this occurs without going to each file manually and removing text wrap? I have played around with patch --ignore-whitespace and patch --fuzz=#lines, but I haven't been able to get around this problem with these flags.