This is an automated email from the ASF dual-hosted git repository. vatamane pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/couchdb.git
commit 2e92334b8d4ac571a170523512fd8cce5b06ff13 Author: Nick Vatamaniuc <[email protected]> AuthorDate: Wed Mar 4 22:12:04 2026 -0500 Use -fvisibility=hidden for some C bits Use `-fvisibility=hidden` to prevent potential surprises on MacOS. This is the same fix applied to `jiffy` in [1]. The reason this is a MacOS-only issue is that `dlopen()` on MacOS defaults to `RTLD_GLOBAL`, and on Linux it defaults to `RTLD_LOCAL`. Since Erlang/OTP NIF `dlopen()` doesn't explicitly set 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 start to collide with their version. 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"} ]}.
