1

I am currently in directory - /usr/lib/llvm-9/build

The include/ directory is a symlink -

reikdas@reikdas-VirtualBox:/usr/lib/llvm-9/build$ ls -l
lrwxrwxrwx 1 root root 10 Jan 31 2020 include -> ../include

But since I will be patching this via a script, I cannot manually put in the actual path of the symlink.

I have a .diff file that looks like this -

diff --git a/include/llvm/Demangle/MicrosoftDemangleNodes.h b/include/llvm/Demangle/MicrosoftDemangleNodes.h
index da9d9d5bfdc..3d47471f0ef 100644
--- a/include/llvm/Demangle/MicrosoftDemangleNodes.h
+++ b/include/llvm/Demangle/MicrosoftDemangleNodes.h
@@ -16,6 +16,8 @@
 #include "llvm/Demangle/DemangleConfig.h"
 #include "llvm/Demangle/StringView.h"
 #include <array>
+#include <cstdint>
+#include <string>
 
 namespace llvm {
 namespace itanium_demangle {

I do - patch -p1 < nameofthepatch.diff

but, I get an error -

Can't find file to patch at input line 3
Perhaps you used the wrong -p or --strip option?
The text leading upto this was:
....
File to patch:

But the file does exist -

reikdas@reikdas-VirtualBox:/usr/lib/llvm-9/build$ ls include/llvm/Demangle/ | grep MicrosoftDemangleNodes.h
MicrosoftDemangleNodes.h

I get the same error with - patch -p1 --follow-symlinks < nameofthepatch.diff

(please note that I specified which directory I executed these commands from)

The diff was generated on a Linux machine, so there are no hidden carriage returns.

Also, this works -

patch -p1 include/llvm/Demangle/MicrosoftDemangleNodes.h nameofthepatch.diff

which is not tenable, since a single .diff file might contain the diff for multiple files.

Why do I get this error?

2
  • Assuming you're on Linux, did you try with the --follow-symlinks option to patch? Commented Mar 11, 2021 at 8:38
  • I get the same error with --follow-symlinks (I had forgotten to add that to the post - should be there now). Commented Mar 11, 2021 at 8:46

0

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.