Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Fix lib/perl5/patcher #128

Merged
merged 1 commit into from
Jan 4, 2023
Merged

Conversation

edwintorok
Copy link

I'm not currently using the patcher, but I was trying it out (seems right for patching some OCaml runtime headers for a cusotm CIL analysis) and noticed it wasn't actually working. Looks like a previous patch to remove MSVC was a bit too eager, and actually removed the line that runs the preprocessor. Restore it with this patch.

Commit b01b404 has removed MSVC, but also removed the 'system' line, which was important for its side effect of running the preprocessor (even if the body of the if would never be entered with GCC)

Fixes: b01b404 ("Remove remaining MSVC things")

Tested with:

$ perl -I$(opam var lib)/perl5 lib/perl5/patcher --patch=mypatch.cillypatch --dest=destpatch --ufile caml/misc.h --verbose --mode=GNUCC -I$(ocamlc -where)
Patching files for GNU CC version gcc_11
Loaded patches from mypatch.cillypatch
Patching "caml/misc.h"
   Absolute name is /home/edwin/.opam/4.14.0/lib/ocaml/caml/misc.h
   Destination is destpatch/gcc_11/caml/misc.h

With the following mypatch.cillypatch as a test:

<<<<
 #define CAMLprim
====
 #define CAMLprim foo
>>>>

And the patcher has performed the following modification:

diff -wu /home/edwin/.opam/4.14.0/lib/ocaml/caml/misc.h destpatch/gcc_11/caml/misc.h
--- /home/edwin/.opam/4.14.0/lib/ocaml/caml/misc.h	2022-08-23 09:48:26.263777010 +0100
+++ destpatch/gcc_11/caml/misc.h	2023-01-03 14:25:59.180139744 +0000
@@ -121,7 +121,9 @@
 #endif

 #define CAMLexport
-#define CAMLprim
+#line 4 "mypatch.cillypatch"
+#define CAMLprim foo
+#line 125 "/home/edwin/.opam/4.14.0/lib/ocaml/caml/misc.h"
 #define CAMLextern CAMLDLLIMPORT extern

 /* Weak function definitions that can be overridden by external libs */

Commit b01b404 has removed MSVC, but also removed the 'system' line,
which was important for its side effect of running the preprocessor
(even if the body of the if would never be entered with GCC)

Fixes: b01b404 ("Remove remaining MSVC things")

Tested with:
```
$ perl -I$(opam var lib)/perl5 lib/perl5/patcher --patch=mypatch.cillypatch --dest=destpatch --ufile caml/misc.h --verbose --mode=GNUCC -I$(ocamlc -where)
Patching files for GNU CC version gcc_11
Loaded patches from mypatch.cillypatch
Patching "caml/misc.h"
   Absolute name is /home/edwin/.opam/4.14.0/lib/ocaml/caml/misc.h
   Destination is destpatch/gcc_11/caml/misc.h
```

With the following mypatch.cillypatch as a test:
```
<<<<
 #define CAMLprim
====
 #define CAMLprim foo
>>>>
```

And the patcher has performed the following modification:
```
diff -wu /home/edwin/.opam/4.14.0/lib/ocaml/caml/misc.h destpatch/gcc_11/caml/misc.h
--- /home/edwin/.opam/4.14.0/lib/ocaml/caml/misc.h	2022-08-23 09:48:26.263777010 +0100
+++ destpatch/gcc_11/caml/misc.h	2023-01-03 14:25:59.180139744 +0000
@@ -121,7 +121,9 @@
 #endif

 #define CAMLexport
-#define CAMLprim
+#line 4 "mypatch.cillypatch"
+#define CAMLprim foo
+#line 125 "/home/edwin/.opam/4.14.0/lib/ocaml/caml/misc.h"
 #define CAMLextern CAMLDLLIMPORT extern

 /* Weak function definitions that can be overridden by external libs */
```

Signed-off-by: Edwin Török <edwin.torok@cloud.com>
@michael-schwarz
Copy link
Member

Thank you!

References #52

@michael-schwarz michael-schwarz merged commit 3edded1 into goblint:develop Jan 4, 2023
@sim642 sim642 added this to the 2.0.2 milestone Apr 5, 2023
sim642 added a commit to sim642/opam-repository that referenced this pull request Sep 11, 2023
CHANGES:

* Rename `Rmtmps` to `RmUnused` (goblint/cil#135).
* Add option to add return statement to `noreturn` functions (goblint/cil#129).
* Fix empty `if`s being removed (goblint/cil#140).
* Fix `_Float128` support (goblint/cil#118, goblint/cil#119).
* Fix C11 `_Alignas` computation (goblint/cil#130).
* Fix renaming and merging of `inline` functions based on C standard (goblint/cil#120, goblint/cil#124).
* Fix `Pretty` not resetting all global state between calls (goblint/cil#133, goblint/cil#134).
* Fix `fundec` location in merger (goblint/cil#139).
* Fix `cilly` patcher (goblint/cil#128).
* Disable basename by default in parser.
nberth pushed a commit to nberth/opam-repository that referenced this pull request Jun 18, 2024
CHANGES:

* Rename `Rmtmps` to `RmUnused` (goblint/cil#135).
* Add option to add return statement to `noreturn` functions (goblint/cil#129).
* Fix empty `if`s being removed (goblint/cil#140).
* Fix `_Float128` support (goblint/cil#118, goblint/cil#119).
* Fix C11 `_Alignas` computation (goblint/cil#130).
* Fix renaming and merging of `inline` functions based on C standard (goblint/cil#120, goblint/cil#124).
* Fix `Pretty` not resetting all global state between calls (goblint/cil#133, goblint/cil#134).
* Fix `fundec` location in merger (goblint/cil#139).
* Fix `cilly` patcher (goblint/cil#128).
* Disable basename by default in parser.
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants