6fbb4db
From 50fbd6685ec88f1dc81451923d7c80fb0d18ca8b Mon Sep 17 00:00:00 2001
6fbb4db
From: =?UTF-8?q?S=C3=A9bastien=20Hinderer?= <Sebastien.Hinderer@inria.fr>
6fbb4db
Date: Thu, 14 Apr 2022 19:19:46 +0200
6fbb4db
Subject: [PATCH 12/24] Stop calling ranlib on created / installed libraries
6fbb4db
 (#11184)
6fbb4db
6fbb4db
`ranlib` seems unnecessary if a POSIX-compliant `ar` is used and time stamps are preserved when a `.a` file is installed.
6fbb4db
6fbb4db
(cherry picked from commit c8e41bade529998c4e66975c88fabf3ac47d7078)
6fbb4db
---
6fbb4db
 Changes                             |   5 +++++
6fbb4db
 INSTALL.adoc                        |   4 ++--
6fbb4db
 Makefile                            |   2 --
6fbb4db
 Makefile.build_config.in            |   2 +-
6fbb4db
 Makefile.config.in                  |   4 ----
6fbb4db
 configure                           | Bin 581827 -> 581549 bytes
6fbb4db
 configure.ac                        |  16 +++-------------
6fbb4db
 otherlibs/Makefile.otherlibs.common |   2 --
6fbb4db
 otherlibs/dynlink/Makefile          |  11 +++++------
6fbb4db
 otherlibs/systhreads/Makefile       |   3 ---
6fbb4db
 stdlib/Makefile                     |   1 -
6fbb4db
 tools/ocamlmklib.ml                 |   6 ++----
6fbb4db
 utils/Makefile                      |   1 -
6fbb4db
 utils/ccomp.ml                      |   8 ++------
6fbb4db
 utils/config.mli                    |   3 ---
6fbb4db
 utils/config.mlp                    |   2 --
6fbb4db
 16 files changed, 20 insertions(+), 50 deletions(-)
6fbb4db
6fbb4db
diff --git a/Changes b/Changes
6fbb4db
index 13eb7fef98..6f92ee9965 100644
6fbb4db
--- a/Changes
6fbb4db
+++ b/Changes
6fbb4db
@@ -25,6 +25,11 @@ OCaml 4.14 maintenance branch
6fbb4db
 - #11392, #11392: assertion failure with -rectypes and external definitions
6fbb4db
   (Gabriel Scherer, review by Florian Angeletti, report by Dmitrii Kosarev)
6fbb4db
 
6fbb4db
+### Compiler user-interface and warnings:
6fbb4db
+
6fbb4db
+- #11184: Stop calling ranlib on created / installed libraries
6fbb4db
+  (S├ębastien Hinderer, review by Xavier Leroy)
6fbb4db
+
6fbb4db
 ### Manual and documentation:
6fbb4db
 
6fbb4db
 - #11045, #11409: document that the array argument to `caml_callbackN`
6fbb4db
diff --git a/INSTALL.adoc b/INSTALL.adoc
6fbb4db
index f4199ca49a..08d67ebbbe 100644
6fbb4db
--- a/INSTALL.adoc
6fbb4db
+++ b/INSTALL.adoc
6fbb4db
@@ -43,8 +43,8 @@
6fbb4db
 * Under Cygwin, the `gcc-core` package is required. `flexdll` is also necessary
6fbb4db
   for shared library support.
6fbb4db
 
6fbb4db
-* Binutils including `ar`, `ranlib`, and `strip` are required if your
6fbb4db
-  distribution does not already provide them with the C compiler.
6fbb4db
+* Binutils including `ar` and `strip` are required if your distribution
6fbb4db
+  does not already provide them with the C compiler.
6fbb4db
 
6fbb4db
 == Configuration
6fbb4db
 
6fbb4db
diff --git a/Makefile b/Makefile
6fbb4db
index 3c74bc79df..0e92785da2 100644
6fbb4db
--- a/Makefile
6fbb4db
+++ b/Makefile
6fbb4db
@@ -585,8 +585,6 @@ endif
6fbb4db
 ifeq "$(INSTALL_OCAMLNAT)" "true"
6fbb4db
 	  $(INSTALL_PROG) ocamlnat$(EXE) "$(INSTALL_BINDIR)"
6fbb4db
 endif
6fbb4db
-	cd "$(INSTALL_COMPLIBDIR)" && \
6fbb4db
-	   $(RANLIB) ocamlcommon.$(A) ocamlbytecomp.$(A) ocamloptcomp.$(A)
6fbb4db
 
6fbb4db
 # Installation of the *.ml sources of compiler-libs
6fbb4db
 .PHONY: install-compiler-sources
6fbb4db
diff --git a/Makefile.build_config.in b/Makefile.build_config.in
6fbb4db
index eeac09dd76..4d6705d252 100644
6fbb4db
--- a/Makefile.build_config.in
6fbb4db
+++ b/Makefile.build_config.in
6fbb4db
@@ -20,7 +20,7 @@
6fbb4db
 # $(ROOTDIR) has been defined.
6fbb4db
 
6fbb4db
 include $(ROOTDIR)/Makefile.config
6fbb4db
-INSTALL ?= @INSTALL@
6fbb4db
+INSTALL ?= @INSTALL@ -p
6fbb4db
 INSTALL_DATA ?= @INSTALL_DATA@
6fbb4db
 INSTALL_PROG ?= @INSTALL_PROGRAM@
6fbb4db
 
6fbb4db
diff --git a/Makefile.config.in b/Makefile.config.in
6fbb4db
index eb3d85eb1d..4badb74c3f 100644
6fbb4db
--- a/Makefile.config.in
6fbb4db
+++ b/Makefile.config.in
6fbb4db
@@ -88,10 +88,6 @@ LDFLAGS?=@LDFLAGS@
6fbb4db
 ### How to invoke the C preprocessor through the C compiler
6fbb4db
 CPP=@CPP@
6fbb4db
 
6fbb4db
-### How to invoke ranlib
6fbb4db
-RANLIB=@RANLIB@
6fbb4db
-RANLIBCMD=@RANLIBCMD@
6fbb4db
-
6fbb4db
 ### How to invoke ar
6fbb4db
 ARCMD=@AR@
6fbb4db
 
6fbb4db
diff --git a/configure b/configure
6fbb4db
index 8a2c007fd221bc897a255b4aa80c7f23710fcb10..73ce66bfa0a3de5e886a88c973b2db288b5e4d03 100755
6fbb4db
GIT binary patch
6fbb4db
delta 91
6fbb4db
zcmX?nP
6fbb4db
q!qe@iu=Y&nn98a>-EJyt==60{S#P(`nZ^plY(UJuea
6fbb4db
6fbb4db
delta 343
6fbb4db
zcmZ3xU-|Gs
6fbb4db
z%gt0-!L_2KC^5MtGcR2sGcPT_C^xYrGe1uuttdZNAty7bBtJh#y;vbRKQApay|f4{
6fbb4db
zIlXW-lc=kLwL(coYMz1>mx2P^N?Ror2wRCOHK#ZgE(H{K3{og6R
6fbb4db
z^!bxndn_ROY*jQu{QZ3bf?VA+ixTsIE&!ULjHC%ee!AKeRs(K@#Jm&*h=%E5Q&>YK
6fbb4db
zU>4b?CTHZsIKV)ezG4dNJs|}(H3gMwh?TVpF)A8{?X6Q;ftU@5*|)b&<
6fbb4db
ARR910
6fbb4db
6fbb4db
diff --git a/configure.ac b/configure.ac
6fbb4db
index 2f4ebf9b30..13d6d1a326 100644
6fbb4db
--- a/configure.ac
6fbb4db
+++ b/configure.ac
6fbb4db
@@ -119,8 +119,6 @@ AC_SUBST([bootstrapping_flexdll])
6fbb4db
 AC_SUBST([long_shebang])
6fbb4db
 AC_SUBST([shebangscripts])
6fbb4db
 AC_SUBST([AR])
6fbb4db
-AC_SUBST([RANLIB])
6fbb4db
-AC_SUBST([RANLIBCMD])
6fbb4db
 AC_SUBST([mklib])
6fbb4db
 AC_SUBST([supports_shared_libraries])
6fbb4db
 AC_SUBST([natdynlink])
6fbb4db
@@ -474,32 +472,24 @@ AS_CASE([$enable_dependency_generation],
6fbb4db
       [compute_deps=true])],
6fbb4db
     [compute_deps=false])])
6fbb4db
 
6fbb4db
-# Extracting information from libtool's configuration
6fbb4db
-AS_IF([test -n "$RANLIB" ],
6fbb4db
-  [RANLIBCMD="$RANLIB"],
6fbb4db
-  [RANLIB="$AR rs"; RANLIBCMD=""]
6fbb4db
-)
6fbb4db
-
6fbb4db
 AS_CASE([$host],
6fbb4db
   # In config/Makefile.mingw*, we had:
6fbb4db
   # TARGET=i686-w64-mingw32 and x86_64-w64-mingw32
6fbb4db
   # TOOLPREF=$(TARGET)-
6fbb4db
   # ARCMD=$(TOOLPREF)ar
6fbb4db
-  # RANLIB=$(TOOLPREF)ranlib
6fbb4db
-  # RANLIBCMD=$(TOOLPREF)ranlib
6fbb4db
-  # However autoconf and libtool seem to use ar and ranlib
6fbb4db
+  # However autoconf and libtool seem to use ar
6fbb4db
   # So we let them do, at the moment
6fbb4db
   [*-pc-windows],
6fbb4db
     [
6fbb4db
       libext=lib
6fbb4db
-      AR=""; RANLIB=echo; RANLIBCMD=""
6fbb4db
+      AR=""
6fbb4db
       AS_IF([test "$host_cpu" = "x86_64" ],
6fbb4db
         [machine="-machine:AMD64 "],
6fbb4db
         [machine=""])
6fbb4db
       mklib="link -lib -nologo $machine /out:\$(1) \$(2)"
6fbb4db
     ],
6fbb4db
   [
6fbb4db
-    mklib="rm -f \$(1) && ${AR} rc \$(1) \$(2) && ${RANLIB} \$(1)"
6fbb4db
+    mklib="rm -f \$(1) && ${AR} rc \$(1) \$(2)"
6fbb4db
   ])
6fbb4db
 
6fbb4db
 ## Find vendor of the C compiler
6fbb4db
diff --git a/otherlibs/Makefile.otherlibs.common b/otherlibs/Makefile.otherlibs.common
6fbb4db
index 95ff4d58fe..17c8e2dfd7 100644
6fbb4db
--- a/otherlibs/Makefile.otherlibs.common
6fbb4db
+++ b/otherlibs/Makefile.otherlibs.common
6fbb4db
@@ -95,7 +95,6 @@ install::
6fbb4db
 	fi
6fbb4db
 ifneq "$(STUBSLIB)" ""
6fbb4db
 	$(INSTALL_DATA) $(STUBSLIB) "$(INSTALL_LIBDIR)/"
6fbb4db
-	cd "$(INSTALL_LIBDIR)"; $(RANLIB) lib$(CLIBNAME).$(A)
6fbb4db
 endif
6fbb4db
 
6fbb4db
 	$(INSTALL_DATA) \
6fbb4db
@@ -115,7 +114,6 @@ installopt:
6fbb4db
 	$(INSTALL_DATA) \
6fbb4db
 	   $(CAMLOBJS_NAT) $(LIBNAME).cmxa $(LIBNAME).$(A) \
6fbb4db
 	   "$(INSTALL_LIBDIR)/"
6fbb4db
-	cd "$(INSTALL_LIBDIR)"; $(RANLIB) $(LIBNAME).a
6fbb4db
 	if test -f $(LIBNAME).cmxs; then \
6fbb4db
 	  $(INSTALL_PROG) $(LIBNAME).cmxs "$(INSTALL_LIBDIR)"; \
6fbb4db
 	fi
6fbb4db
diff --git a/otherlibs/dynlink/Makefile b/otherlibs/dynlink/Makefile
6fbb4db
index 6b02dc1979..c21bf573da 100644
6fbb4db
--- a/otherlibs/dynlink/Makefile
6fbb4db
+++ b/otherlibs/dynlink/Makefile
6fbb4db
@@ -249,12 +249,11 @@ ifeq "$(INSTALL_SOURCE_ARTIFACTS)" "true"
6fbb4db
 endif
6fbb4db
 
6fbb4db
 installopt:
6fbb4db
-	if $(NATDYNLINK); then \
6fbb4db
-	  $(INSTALL_DATA) \
6fbb4db
-	    $(NATOBJS) dynlink.cmxa dynlink.$(A) \
6fbb4db
-	    "$(INSTALL_LIBDIR)" && \
6fbb4db
-	  cd "$(INSTALL_LIBDIR)" && $(RANLIB) dynlink.$(A); \
6fbb4db
-	fi
6fbb4db
+ifeq "$(strip $(NATDYNLINK))" "true"
6fbb4db
+	$(INSTALL_DATA) \
6fbb4db
+	  $(NATOBJS) dynlink.cmxa dynlink.$(A) \
6fbb4db
+	  "$(INSTALL_LIBDIR)"
6fbb4db
+endif
6fbb4db
 
6fbb4db
 partialclean:
6fbb4db
 	rm -f $(extract_crc) *.cm[ioaxt] *.cmti *.cmxa \
6fbb4db
diff --git a/otherlibs/systhreads/Makefile b/otherlibs/systhreads/Makefile
6fbb4db
index 8fc1bdb926..640a7666a8 100644
6fbb4db
--- a/otherlibs/systhreads/Makefile
6fbb4db
+++ b/otherlibs/systhreads/Makefile
6fbb4db
@@ -121,7 +121,6 @@ install:
6fbb4db
 	  $(INSTALL_PROG) dllthreads$(EXT_DLL) "$(INSTALL_STUBLIBDIR)"; \
6fbb4db
 	fi
6fbb4db
 	$(INSTALL_DATA) libthreads.$(A) "$(INSTALL_LIBDIR)"
6fbb4db
-	cd "$(INSTALL_LIBDIR)"; $(RANLIB) libthreads.$(A)
6fbb4db
 	mkdir -p "$(INSTALL_THREADSLIBDIR)"
6fbb4db
 	$(INSTALL_DATA) \
6fbb4db
 	  $(CMIFILES) threads.cma \
6fbb4db
@@ -136,11 +135,9 @@ endif
6fbb4db
 
6fbb4db
 installopt:
6fbb4db
 	$(INSTALL_DATA) libthreadsnat.$(A) "$(INSTALL_LIBDIR)"
6fbb4db
-	cd "$(INSTALL_LIBDIR)"; $(RANLIB) libthreadsnat.$(A)
6fbb4db
 	$(INSTALL_DATA) \
6fbb4db
 	  $(THREADS_NCOBJS) threads.cmxa threads.$(A) \
6fbb4db
 	  "$(INSTALL_THREADSLIBDIR)"
6fbb4db
-	cd "$(INSTALL_THREADSLIBDIR)" && $(RANLIB) threads.$(A)
6fbb4db
 
6fbb4db
 %.cmi: %.mli
6fbb4db
 	$(CAMLC) -c $(COMPFLAGS) $<
6fbb4db
diff --git a/stdlib/Makefile b/stdlib/Makefile
6fbb4db
index df34bc2d49..f367956fbd 100644
6fbb4db
--- a/stdlib/Makefile
6fbb4db
+++ b/stdlib/Makefile
6fbb4db
@@ -105,7 +105,6 @@ installopt-default::
6fbb4db
 	$(INSTALL_DATA) \
6fbb4db
 	  stdlib.cmxa stdlib.$(A) std_exit.$(O) *.cmx \
6fbb4db
 	  "$(INSTALL_LIBDIR)"
6fbb4db
-	cd "$(INSTALL_LIBDIR)"; $(RANLIB) stdlib.$(A)
6fbb4db
 
6fbb4db
 ifeq "$(UNIX_OR_WIN32)" "unix"
6fbb4db
 HEADERPROGRAM = header
6fbb4db
diff --git a/tools/ocamlmklib.ml b/tools/ocamlmklib.ml
6fbb4db
index 0ca7b80f3b..48f636bc10 100644
6fbb4db
--- a/tools/ocamlmklib.ml
6fbb4db
+++ b/tools/ocamlmklib.ml
6fbb4db
@@ -25,10 +25,8 @@ let mklib out files opts =
6fbb4db
     then "-machine:AMD64 "
6fbb4db
     else ""
6fbb4db
   in
6fbb4db
-  Printf.sprintf "link -lib -nologo %s-out:%s %s %s"
6fbb4db
-                 machine out opts files
6fbb4db
-  else Printf.sprintf "%s rcs %s %s %s && %s %s"
6fbb4db
-                      Config.ar out opts files Config.ranlib out
6fbb4db
+  Printf.sprintf "link -lib -nologo %s-out:%s %s %s" machine out opts files
6fbb4db
+  else Printf.sprintf "%s rc %s %s %s" Config.ar out opts files
6fbb4db
 
6fbb4db
 (* PR#4783: under Windows, don't use absolute paths because we do
6fbb4db
    not know where the binary distribution will be installed. *)
6fbb4db
diff --git a/utils/Makefile b/utils/Makefile
6fbb4db
index 7231fae28e..de923900f1 100644
6fbb4db
--- a/utils/Makefile
6fbb4db
+++ b/utils/Makefile
6fbb4db
@@ -73,7 +73,6 @@ config.ml: config.mlp $(ROOTDIR)/Makefile.config Makefile
6fbb4db
 	    $(call SUBST_STRING,OCAMLOPT_CPPFLAGS) \
6fbb4db
 	    $(call SUBST_STRING,PACKLD) \
6fbb4db
 	    $(call SUBST,PROFINFO_WIDTH) \
6fbb4db
-	    $(call SUBST_STRING,RANLIBCMD) \
6fbb4db
 	    $(call SUBST_STRING,RPATH) \
6fbb4db
 	    $(call SUBST_STRING,MKSHAREDLIBRPATH) \
6fbb4db
 	    $(call SUBST,FORCE_SAFE_STRING) \
6fbb4db
diff --git a/utils/ccomp.ml b/utils/ccomp.ml
6fbb4db
index 955968d1cd..d23c3f2baa 100644
6fbb4db
--- a/utils/ccomp.ml
6fbb4db
+++ b/utils/ccomp.ml
6fbb4db
@@ -140,12 +140,8 @@ let create_archive archive file_list =
6fbb4db
                                quoted_archive (quote_files file_list))
6fbb4db
     | _ ->
6fbb4db
         assert(String.length Config.ar > 0);
6fbb4db
-        let r1 =
6fbb4db
-          command(Printf.sprintf "%s rc %s %s"
6fbb4db
-                  Config.ar quoted_archive (quote_files file_list)) in
6fbb4db
-        if r1 <> 0 || String.length Config.ranlib = 0
6fbb4db
-        then r1
6fbb4db
-        else command(Config.ranlib ^ " " ^ quoted_archive)
6fbb4db
+        command(Printf.sprintf "%s rc %s %s"
6fbb4db
+                Config.ar quoted_archive (quote_files file_list))
6fbb4db
 
6fbb4db
 let expand_libname cclibs =
6fbb4db
   cclibs |> List.map (fun cclib ->
6fbb4db
diff --git a/utils/config.mli b/utils/config.mli
6fbb4db
index 7f70a52d52..94dee3cb92 100644
6fbb4db
--- a/utils/config.mli
6fbb4db
+++ b/utils/config.mli
6fbb4db
@@ -82,9 +82,6 @@ val mkexe: string
6fbb4db
 val mkmaindll: string
6fbb4db
 (** The linker command line to build main programs as dlls. *)
6fbb4db
 
6fbb4db
-val ranlib: string
6fbb4db
-(** Command to randomize a library, or "" if not needed *)
6fbb4db
-
6fbb4db
 val default_rpath: string
6fbb4db
 (** Option to add a directory to be searched for libraries at runtime
6fbb4db
     (used by ocamlmklib) *)
6fbb4db
diff --git a/utils/config.mlp b/utils/config.mlp
6fbb4db
index 44c6ff8fa5..f758a9b483 100644
6fbb4db
--- a/utils/config.mlp
6fbb4db
+++ b/utils/config.mlp
6fbb4db
@@ -54,7 +54,6 @@ let native_c_compiler =
6fbb4db
   c_compiler ^ " " ^ ocamlopt_cflags ^ " " ^ ocamlopt_cppflags
6fbb4db
 let native_c_libraries = "%%NATIVECCLIBS%%"
6fbb4db
 let native_pack_linker = "%%PACKLD%%"
6fbb4db
-let ranlib = "%%RANLIBCMD%%"
6fbb4db
 let default_rpath = "%%RPATH%%"
6fbb4db
 let mksharedlibrpath = "%%MKSHAREDLIBRPATH%%"
6fbb4db
 let ar = "%%ARCMD%%"
6fbb4db
@@ -177,7 +176,6 @@ let configuration_variables =
6fbb4db
   p "bytecomp_c_libraries" bytecomp_c_libraries;
6fbb4db
   p "native_c_libraries" native_c_libraries;
6fbb4db
   p "native_pack_linker" native_pack_linker;
6fbb4db
-  p "ranlib" ranlib;
6fbb4db
   p "architecture" architecture;
6fbb4db
   p "model" model;
6fbb4db
   p_int "int_size" Sys.int_size;
6fbb4db
-- 
6fbb4db
2.37.0.rc2
6fbb4db