Skip to content

Commit

Permalink
Remove -flat_namespace flag in configure.ac on Darwin (ocaml#10723)
Browse files Browse the repository at this point in the history
Apple discourages use of the `-flat_namespace` flag, and it exists only
for compatibility with very old versions of OS X. Using
`-flat_namespace` can cause various cryptic linker errors (e.g. due to
name collisions), so it's best to avoid its use unless needed.

This change removes the flag, and also changes `-undefined suppress` to
`-undefined dynamic_lookup`. We need to change the argument to
`-undefined` because omitting the `-flat_namespace` flag will build
shared libraries with a two-level namespace, and this does not support
`-undefined suppress`. `dynamic_lookup` means that the dynamic linker
will resolve undefined symbols at runtime.

This should have no visible impact on any users who do not explicitly
exploit the flat namespace, but this is of often only useful for
debugging purposes. Users who need this still have alternatives such as
setting `DYLD_FORCE_FLAT_NAMESPACE`, which instructs the linker to treat
libraries as if they were compiled with a flat namespace.
  • Loading branch information
carlocab authored Feb 18, 2022
1 parent 78539b5 commit a88c1db
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
3 changes: 3 additions & 0 deletions Changes
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ Working version
- #10831: Multicore OCaml
(The multicore team, caml-devel and more)

* #10723: do not use `-flat-namespace` linking for macOS.
(Carlo Cabrera, review by Damien Doligez)

* #10863, #10933: Remove support for old, unprefixed C runtime function names
such as `alloc`. The new names prefixed with `caml_` must be used instead,
such as `caml_alloc`. Consequently, it is no longer needed to define
Expand Down
2 changes: 1 addition & 1 deletion configure

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -934,7 +934,7 @@ AS_IF([test x"$enable_shared" != "xno"],
[AS_CASE([$host],
[*-apple-darwin*],
[mksharedlib="$CC -shared \
-flat_namespace -undefined suppress -Wl,-no_compact_unwind \
-undefined dynamic_lookup -Wl,-no_compact_unwind \
\$(LDFLAGS)"
supports_shared_libraries=true],
[*-*-mingw32],
Expand Down

0 comments on commit a88c1db

Please sign in to comment.