From 152920c078cfda371aaf4d3db9e55b479eb2becd Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Thu, 14 Jan 2021 12:24:54 +0000 Subject: [PATCH] Build ocamlrpcgen as native code. Enable stripping. Enable LTO (RHBZ#1915570). --- 0001-Build-ocamlrpcgen-as-native-code.patch | 45 +++++++++++++++++++++ ocaml-ocamlnet.spec | 32 ++++++++------- 2 files changed, 63 insertions(+), 14 deletions(-) create mode 100644 0001-Build-ocamlrpcgen-as-native-code.patch diff --git a/0001-Build-ocamlrpcgen-as-native-code.patch b/0001-Build-ocamlrpcgen-as-native-code.patch new file mode 100644 index 0000000..81a21dc --- /dev/null +++ b/0001-Build-ocamlrpcgen-as-native-code.patch @@ -0,0 +1,45 @@ +From 828a873df2b838e46faa5700dbae18601cb8dcb9 Mon Sep 17 00:00:00 2001 +From: "Richard W.M. Jones" +Date: Thu, 14 Jan 2021 12:20:03 +0000 +Subject: [PATCH] Build ocamlrpcgen as native code. + +--- + 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 + diff --git a/ocaml-ocamlnet.spec b/ocaml-ocamlnet.spec index 9c42c7b..477f235 100644 --- a/ocaml-ocamlnet.spec +++ b/ocaml-ocamlnet.spec @@ -1,25 +1,16 @@ -# Disable LTO, see RHBZ#1915570. -%define _lto_cflags %{nil} - -# Prevent RPM from stripping the binaries & debuginfo. -# -# NB: Only required because this package uses the obsolete -custom -# parameter and builds a bytecode 'ocamlrpcgen'. I tried to fix the -# build to make a native code 'ocamlrpcgen' but the build system got -# the better of me. -%global debug_package %{nil} -%global __strip /bin/true - Name: ocaml-ocamlnet Version: 4.1.8 -Release: 1%{?dist} +Release: 2%{?dist} Summary: Network protocols for OCaml License: BSD URL: http://projects.camlcity.org/projects/ocamlnet.html Source0: http://download.camlcity.org/download/ocamlnet-%{version}.tar.gz -BuildRequires: make +# Build ocamlrpcgen as native code. Sent upstream 2021-01-14. +Patch1: 0001-Build-ocamlrpcgen-as-native-code.patch + +BuildRequires: make BuildRequires: ocaml >= 3.12.1-3 BuildRequires: ocaml-ocamldoc BuildRequires: ocaml-findlib-devel @@ -111,6 +102,7 @@ files for developing applications that use %{name}-nethttpd. %prep %setup -q -n ocamlnet-%{version} +%patch1 -p2 %build @@ -129,6 +121,13 @@ unset MAKEFLAGS -enable-tcl \ -enable-zip +# This is a hack caused by the ocamlrpcgen patch. Because "make all" +# no longer builds ocamlrpcgen (it is now built by "make opt") but +# some other parts of the build depend on this program, we have to run +# make opt first and ignore the result. Hopefully we'll get a better +# result when upstream integrate the patch. RWMJ 2021-01. +make opt ||: + make all %ifarch %{ocaml_native_compiler} @@ -221,6 +220,11 @@ echo -e '-b /usr/bin/netplex-admin\n-b /usr/bin/ocamlrpcgen' \ %changelog +* Thu Jan 14 2021 Richard W.M. Jones - 4.1.8-2 +- Build ocamlrpcgen as native code. +- Enable stripping. +- Enable LTO (RHBZ#1915570). + * Wed Jan 13 2021 Richard W.M. Jones - 4.1.8-1 - New upstream version 4.1.8. - Disable LTO (RHBZ#1915570).