Skip to content

Commit 9d077e1

Browse files
carlocabOctachron
authored andcommitted
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. (cherry picked from commit a88c1db)
1 parent ebd03c6 commit 9d077e1

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
@@ -10,6 +10,9 @@ OCaml 4.14 maintenance version
1010
(Antonin Décimo, review by Xavier Leroy, David Allsopp, Sébastien
1111
Hinderer and Nick Barnes)
1212

13+
* #10723: do not use `-flat-namespace` linking for macOS.
14+
(Carlo Cabrera, review by Damien Doligez)
15+
1316
### Build system:
1417

1518
- #11590: Allow installing to a destination path containing spaces.

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
@@ -944,7 +944,7 @@ AS_IF([test x"$enable_shared" != "xno"],
944944
[AS_CASE([$host],
945945
[*-apple-darwin*],
946946
[mksharedlib="$CC -shared \
947-
-flat_namespace -undefined suppress -Wl,-no_compact_unwind \
947+
-undefined dynamic_lookup -Wl,-no_compact_unwind \
948948
\$(LDFLAGS)"
949949
supports_shared_libraries=true],
950950
[*-*-mingw32],

0 commit comments

Comments
 (0)