Skip to content

Commit 3c53554

Browse files
authored
gh-88267: Avoid DLL exporting functions from static builds on Windows(GH-99888)
1 parent 748c6c0 commit 3c53554

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

Include/exports.h

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,15 @@
22
#define Py_EXPORTS_H
33

44
#if defined(_WIN32) || defined(__CYGWIN__)
5-
#define Py_IMPORTED_SYMBOL __declspec(dllimport)
6-
#define Py_EXPORTED_SYMBOL __declspec(dllexport)
7-
#define Py_LOCAL_SYMBOL
5+
#if defined(Py_ENABLE_SHARED)
6+
#define Py_IMPORTED_SYMBOL __declspec(dllimport)
7+
#define Py_EXPORTED_SYMBOL __declspec(dllexport)
8+
#define Py_LOCAL_SYMBOL
9+
#else
10+
#define Py_IMPORTED_SYMBOL
11+
#define Py_EXPORTED_SYMBOL
12+
#define Py_LOCAL_SYMBOL
13+
#endif
814
#else
915
/*
1016
* If we only ever used gcc >= 5, we could use __has_attribute(visibility)
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Avoid exporting Python symbols in linked Windows applications when the core is built as static.

0 commit comments

Comments
 (0)