Skip to content

Commit

Permalink
ocamlmklib: use ar rcs instead of ar rc (#11670)
Browse files Browse the repository at this point in the history
Under macOS at least, `ar rc` on an empty list of files produces an archive
with no table of contents, which triggers an error when linked.

With `ar rcs`, we force the creation of a table of contents.  macOS prints
a warning, but the resulting archive causes no errors during linking.

The `s` option to `ar` is specified as "an XSI extension" in
IEEE Std 1003.1-2017, but seems supported by all the toolchains we care about.

The call to `ar rc` in utils/ccomp.ml is unchanged because the list
of object files is never empty, and IEEE Std 1003.1 says that `ar rc`
must create a symbol table in this case.

Follow-up to #11184

(cherry picked from commit 2f0c77c)
  • Loading branch information
xavierleroy committed Oct 27, 2022
1 parent 83762af commit bd87a61
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
5 changes: 5 additions & 0 deletions Changes
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
OCaml 4.14 maintenance branch
-----------------------------

### Compiler user-interface and warnings:

- #11184, #11670: Stop calling ranlib on created / installed libraries
(Sébastien Hinderer and Xavier Leroy, review by the same)

### Build system:

- #11370, #11373: Don't pass CFLAGS to flexlink during configure.
Expand Down
2 changes: 1 addition & 1 deletion tools/ocamlmklib.ml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ let mklib out files opts =
else ""
in
Printf.sprintf "link -lib -nologo %s-out:%s %s %s" machine out opts files
else Printf.sprintf "%s rc %s %s %s" Config.ar out opts files
else Printf.sprintf "%s rcs %s %s %s" Config.ar out opts files

(* PR#4783: under Windows, don't use absolute paths because we do
not know where the binary distribution will be installed. *)
Expand Down

0 comments on commit bd87a61

Please sign in to comment.