ocamlrpcgen native code

Gerd Stolpmann
2021-01-25T12:26:17Z

Hi Gerd,

The following patch changes ocamlrpcgen so it is built as a native code program (only).

The problem we have in Fedora is that ocamlrpcgen is currently built with the legacy -custom option which attaches bytecode to the executable. This bytecode gets stripped automatically, resulting in a broken executable. To get around that we had to disable stripping, but that causes other problems (https://bugzilla.redhat.com/show_bug.cgi?id=1915570).

In Fedora we no longer have any bytecode-only architectures, so the real fix for this is to stop buiding the binary as bytecode.

I guess an ideal patch would build the best available out of { bytecode, nativecode } but I couldn't work out how to do that given the custom build system used by ocamlnet.

Rich.

---
 code/src/rpc-generator/Makefile | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/code/src/rpc-generator/Makefile b/code/src/rpc-generator/Makefile
index e0ed4f5..a475e83 100644
--- a/code/src/rpc-generator/Makefile
+++ b/code/src/rpc-generator/Makefile
@@ -6,9 +6,11 @@ PKGNAME  = rpc-generator
 ARCHIVE  = rpc_generator
 OBJECTS  = config.cmo syntax.cmo options.cmo parser.cmo lexer.cmo rename.cmo \
            generate.cmo direct.cmo
+XOBJECTS = config.cmx syntax.cmx options.cmx parser.cmx lexer.cmx rename.cmx \
+           generate.cmx direct.cmx
 DOBJECTS =

-ALL_EXTRA = ocamlrpcgen$(EXEC_SUFFIX) rpcgen-packlist
+OPT_EXTRA = ocamlrpcgen$(EXEC_SUFFIX) rpcgen-packlist

 PACKLIST = rpcgen-packlist

@@ -21,12 +23,12 @@ PP_OPTIONS = -pp "$(CPPO) $(PP_BYTES) $(PP_DEPRECATED)"

 include $(TOP_DIR)/Makefile.rules

-ocamlrpcgen$(EXEC_SUFFIX): $(ARCHIVE).cma main.cmo
+ocamlrpcgen$(EXEC_SUFFIX): $(ARCHIVE).cmxa main.cmx
 	rm -f ocamlrpcgen ocamlrpcgen$(EXEC_SUFFIX)
 	OCAMLPATH="..$(PATH_SEP)$$OCAMLPATH" \
-	$(OCAMLC) -custom -o ocamlrpcgen \
+	$(OCAMLOPT) -o ocamlrpcgen \
 		-package unix,netstring,$(REGEXP_PROVIDER) \
-		$(ARCHIVE).cma main.cmo -linkpkg
+		$(ARCHIVE).cmxa main.cmx -linkpkg

 rpcgen-packlist:
 	echo $(BINDIR)/ocamlrpcgen >rpcgen-packlist
--
2.28.0.rc2