You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by va...@apache.org on 2026/03/05 03:32:47 UTC
(couchdb) branch use-fvisibility-hidden-for-c-bits created (now a249e4bc3)
This is an automated email from the ASF dual-hosted git repository.
vatamane pushed a change to branch use-fvisibility-hidden-for-c-bits
in repository https://gitbox.apache.org/repos/asf/couchdb.git
at a249e4bc3 Use fvisibility=hidden for some C bits
This branch includes the following new commits:
new a249e4bc3 Use fvisibility=hidden for some C bits
The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
(couchdb) 01/01: Use fvisibility=hidden for some C bits
Posted by va...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
vatamane pushed a commit to branch use-fvisibility-hidden-for-c-bits
in repository https://gitbox.apache.org/repos/asf/couchdb.git
commit a249e4bc3238918644569d974eb3e6fa9dcdc104
Author: Nick Vatamaniuc <va...@gmail.com>
AuthorDate: Wed Mar 4 22:12:04 2026 -0500
Use fvisibility=hidden for some C bits
Use `-fvisibility=hidden` to prevent potential suprises on MacOS. This is the
same fix applied to `jiffy` in [1].
The reason this is a MacOS-only issue is that `dlopen()` MacOS defaults to
`RTLD_GLOBAL`, and on Linux it defaults to `RTLD_LOCAL`. Since Erlang/OTP NIF
`dlopen()` doesn't explicitly pass in this flag, the defaults take effect.
`RTLD_GLOBAL` flag makes the symbols from the newly `dlopen()`-ed module
available for the global symbol resolution. So, if some library in MacOS starts
using xxhash, our exxhash NIF symbols may may start to collide with thier
version and possibly break things. This PR should hopefully prevent such
surprises.
[1] https://github.com/davisp/jiffy/pull/245.
---
src/b64url/rebar.config | 2 +-
src/couch/rebar.config.script | 4 ++--
src/couch_quickjs/rebar.config.script | 2 +-
src/exxhash/rebar.config | 2 +-
4 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/src/b64url/rebar.config b/src/b64url/rebar.config
index d9512aed3..f21ec9590 100644
--- a/src/b64url/rebar.config
+++ b/src/b64url/rebar.config
@@ -22,7 +22,7 @@
% {".*", "CFLAGS", "$CFLAGS -g -Wall -Werror -fPIC"}
% Production compilation
- {"(linux|solaris|darwin|freebsd)", "CFLAGS", "$CFLAGS -Wall -Werror -DNDEBUG -O3"},
+ {"(linux|solaris|darwin|freebsd)", "CFLAGS", "$CFLAGS -Wall -Werror -DNDEBUG -O3 -fvisibility=hidden"},
{"win32", "CFLAGS", "$CFLAGS /O2 /DNDEBUG /Wall"}
]}.
diff --git a/src/couch/rebar.config.script b/src/couch/rebar.config.script
index f64f2268b..558825f88 100644
--- a/src/couch/rebar.config.script
+++ b/src/couch/rebar.config.script
@@ -275,7 +275,7 @@ IcuLibPath = case WithBrew of
true -> "-L" ++ string:trim(os:cmd(BrewIcuPrefixCmd)) ++ "/lib"
end.
-IcuEnv = [{"DRV_CFLAGS", "$DRV_CFLAGS -DPIC -O2 -fno-common"},
+IcuEnv = [{"DRV_CFLAGS", "$DRV_CFLAGS -DPIC -O2 -fno-common -fvisibility=hidden"},
{"DRV_LDFLAGS", "$DRV_LDFLAGS -lm -licuuc -licudata -licui18n -lpthread"},
{"LDFLAGS", "$LDFLAGS"},
{"CFLAGS", "$CFLAGS"}].
@@ -289,7 +289,7 @@ IcuWinEnv = [{"CFLAGS", "$DRV_CFLAGS /DXP_WIN"},
ComparePath = "priv/couch_ejson_compare.so".
CompareSrc = ["priv/couch_ejson_compare/*.c"].
-CouchCFileEnv = [{"CFLAGS", "$CFLAGS -Wall -Werror -DNDEBUG -O3"}].
+CouchCFileEnv = [{"CFLAGS", "$CFLAGS -Wall -Werror -DNDEBUG -O3 -fvisibility=hidden"}].
CouchCFilePath = "priv/couch_cfile.so".
CouchCFileSrc = ["priv/couch_cfile/*.c"].
diff --git a/src/couch_quickjs/rebar.config.script b/src/couch_quickjs/rebar.config.script
index f6546e999..08e12a0cc 100644
--- a/src/couch_quickjs/rebar.config.script
+++ b/src/couch_quickjs/rebar.config.script
@@ -44,7 +44,7 @@ ResetFlags = [
].
UnixEnv = [
- {"CFLAGS", "$CFLAGS -g -Wall -O2 -Iquickjs"},
+ {"CFLAGS", "$CFLAGS -g -Wall -O2 -Iquickjs -fvisibility=hidden"},
{"LDFLAGS", "$LDFLAGS quickjs/libquickjs.a -lpthread -lm"}
] ++ ResetFlags.
diff --git a/src/exxhash/rebar.config b/src/exxhash/rebar.config
index d33bd0b5f..17d73c7a4 100644
--- a/src/exxhash/rebar.config
+++ b/src/exxhash/rebar.config
@@ -22,7 +22,7 @@
% {".*", "CFLAGS", "$CFLAGS -g -Wall -Werror -fPIC"}
% Production compilation
- {"(linux|solaris|darwin|freebsd)", "CFLAGS", "$CFLAGS -Wall -Werror -DNDEBUG -O3"},
+ {"(linux|solaris|darwin|freebsd)", "CFLAGS", "$CFLAGS -Wall -Werror -DNDEBUG -O3 -fvisibility=hidden"},
{"win32", "CFLAGS", "$CFLAGS /O2 /DNDEBUG /Wall"}
]}.