Skip to content

Commit 0d3eeac

Browse files
authored
[clang-repl] Fix BUILD_SHARED_LIBS symbols from libclangInterpreter on MinGW (#71393)
A few symbols within libclangInterpreter have got explicit dllexport attributes, in order to make them exported (and thus visible at runtime) in any build, not only when they are part of e.g. a DLL libclang-cpp, but also when they are part of a plain .exe. Due to the explicit dllexports, these symbols would sidestep the regular MinGW logic of exporting all symbols if there are no dllexports. Therefore, for libclang-cpp, a separate fix was made in 592e935, to pass --export-all-symbols to the build of libclang-cpp. If building with BUILD_SHARED_LIBS enabled, then the same issue appears in libclangInterpreter; pass the same flag --export-all-symbols there as well, to make sure all symbols are visible, not only the ones that are explicitly marked as dllexport.
1 parent 0a362f1 commit 0d3eeac

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

clang/lib/Interpreter/CMakeLists.txt

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,3 +38,14 @@ add_clang_library(clangInterpreter
3838
clangSema
3939
clangSerialization
4040
)
41+
42+
if ((MINGW OR CYGWIN) AND BUILD_SHARED_LIBS)
43+
# The DLLs are supposed to export all symbols (except for ones that are
44+
# explicitly hidden). Normally, this is what happens anyway, but if there
45+
# are symbols that are marked explicitly as dllexport, we'd only export them
46+
# and nothing else. The Interpreter contains a few cases of such dllexports
47+
# (for symbols that need to be exported even from standalone exe files);
48+
# therefore, add --export-all-symbols to make sure we export all symbols
49+
# despite potential dllexports.
50+
target_link_options(clangInterpreter PRIVATE LINKER:--export-all-symbols)
51+
endif()

0 commit comments

Comments
 (0)