Skip to content

Commit a88c1db

Browse files
authored
Remove -flat_namespace flag in configure.ac on Darwin (ocaml#10723)
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.
1 parent 78539b5 commit a88c1db

File tree

3 files changed

+5
-2
lines changed

3 files changed

+5
-2
lines changed

Changes

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ Working version
88
- #10831: Multicore OCaml
99
(The multicore team, caml-devel and more)
1010

11+
* #10723: do not use `-flat-namespace` linking for macOS.
12+
(Carlo Cabrera, review by Damien Doligez)
13+
1114
* #10863, #10933: Remove support for old, unprefixed C runtime function names
1215
such as `alloc`. The new names prefixed with `caml_` must be used instead,
1316
such as `caml_alloc`. Consequently, it is no longer needed to define

configure

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

configure.ac

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -934,7 +934,7 @@ AS_IF([test x"$enable_shared" != "xno"],
934934
[AS_CASE([$host],
935935
[*-apple-darwin*],
936936
[mksharedlib="$CC -shared \
937-
-flat_namespace -undefined suppress -Wl,-no_compact_unwind \
937+
-undefined dynamic_lookup -Wl,-no_compact_unwind \
938938
\$(LDFLAGS)"
939939
supports_shared_libraries=true],
940940
[*-*-mingw32],

0 commit comments

Comments
 (0)