Skip to content

Commit 2d8afb9

Browse files
bnoordhuiscodebytere
authored andcommitted
test: export public symbols in addons tests
Upcoming changes to node-gyp will turn on `-fvisibility=hidden` on macOS. Ensure that public symbols that are dlsym'd have default visibility. Refs: #28647 Refs: nodejs/node-gyp#1828 PR-URL: #28717 Reviewed-By: Rich Trott <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Anna Henningsen <[email protected]>
1 parent 44fafa6 commit 2d8afb9

File tree

4 files changed

+20
-5
lines changed

4 files changed

+20
-5
lines changed

test/addons/dlopen-ping-pong/binding.cc

+3-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@
55

66
#include <dlfcn.h>
77

8-
extern "C" const char* dlopen_pong(void) {
8+
extern "C"
9+
__attribute__((visibility("default")))
10+
const char* dlopen_pong(void) {
911
return "pong";
1012
}
1113

test/addons/dlopen-ping-pong/ping.c

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
const char* dlopen_pong(void);
44

5+
__attribute__((visibility("default")))
56
const char* dlopen_ping(void) {
67
return dlopen_pong();
78
}

test/addons/openssl-client-cert-engine/testengine.cc

+8-2
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,12 @@
1919
#define AGENT_KEY "test/fixtures/keys/agent1-key.pem"
2020
#define AGENT_CERT "test/fixtures/keys/agent1-cert.pem"
2121

22+
#ifdef _WIN32
23+
# define DEFAULT_VISIBILITY __declspec(dllexport)
24+
#else
25+
# define DEFAULT_VISIBILITY __attribute__((visibility("default")))
26+
#endif
27+
2228
namespace {
2329

2430
int EngineInit(ENGINE* engine) {
@@ -93,8 +99,8 @@ int bind_fn(ENGINE* engine, const char* id) {
9399
}
94100

95101
extern "C" {
96-
IMPLEMENT_DYNAMIC_CHECK_FN();
97-
IMPLEMENT_DYNAMIC_BIND_FN(bind_fn);
102+
DEFAULT_VISIBILITY IMPLEMENT_DYNAMIC_CHECK_FN();
103+
DEFAULT_VISIBILITY IMPLEMENT_DYNAMIC_BIND_FN(bind_fn);
98104
}
99105

100106
} // anonymous namespace

test/addons/openssl-key-engine/testkeyengine.cc

+8-2
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,12 @@
1818

1919
#define PRIVATE_KEY "test/fixtures/keys/agent1-key.pem"
2020

21+
#ifdef _WIN32
22+
# define DEFAULT_VISIBILITY __declspec(dllexport)
23+
#else
24+
# define DEFAULT_VISIBILITY __attribute__((visibility("default")))
25+
#endif
26+
2127
namespace {
2228

2329
int EngineInit(ENGINE* engine) {
@@ -66,8 +72,8 @@ int bind_fn(ENGINE* engine, const char* id) {
6672
}
6773

6874
extern "C" {
69-
IMPLEMENT_DYNAMIC_CHECK_FN();
70-
IMPLEMENT_DYNAMIC_BIND_FN(bind_fn);
75+
DEFAULT_VISIBILITY IMPLEMENT_DYNAMIC_CHECK_FN();
76+
DEFAULT_VISIBILITY IMPLEMENT_DYNAMIC_BIND_FN(bind_fn);
7177
}
7278

7379
} // anonymous namespace

0 commit comments

Comments
 (0)