[clang] [clang-repl] Fix BUILD_SHARED_LIBS symbols from libclangInterpreter on MinGW (PR #71393)

2023-11-07 Thread Martin Storsjö via cfe-commits

https://github.com/mstorsjo closed 
https://github.com/llvm/llvm-project/pull/71393
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang-repl] Fix BUILD_SHARED_LIBS symbols from libclangInterpreter on MinGW (PR #71393)

2023-11-06 Thread Vassil Vassilev via cfe-commits

https://github.com/vgvassilev approved this pull request.

Thank you, @mstorsjo!

https://github.com/llvm/llvm-project/pull/71393
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang-repl] Fix BUILD_SHARED_LIBS symbols from libclangInterpreter on MinGW (PR #71393)

2023-11-06 Thread Jun Zhang via cfe-commits

https://github.com/junaire approved this pull request.

Thanks for the fix! I'm fine with it if this fixes your problem. But yeah, 
please make sure @vgvassilev is aware of it.

https://github.com/llvm/llvm-project/pull/71393
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang-repl] Fix BUILD_SHARED_LIBS symbols from libclangInterpreter on MinGW (PR #71393)

2023-11-06 Thread Martin Storsjö via cfe-commits

mstorsjo wrote:

CC @brechtsanders, this is an alternative to #66881.

https://github.com/llvm/llvm-project/pull/71393
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang-repl] Fix BUILD_SHARED_LIBS symbols from libclangInterpreter on MinGW (PR #71393)

2023-11-06 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Martin Storsjö (mstorsjo)


Changes

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 
592e935e115ffb451eb9b782376711dab6558fe0, 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.

---
Full diff: https://github.com/llvm/llvm-project/pull/71393.diff


1 Files Affected:

- (modified) clang/lib/Interpreter/CMakeLists.txt (+11) 


``diff
diff --git a/clang/lib/Interpreter/CMakeLists.txt 
b/clang/lib/Interpreter/CMakeLists.txt
index 84f6ca5271d2ab0..9065f998f73c473 100644
--- a/clang/lib/Interpreter/CMakeLists.txt
+++ b/clang/lib/Interpreter/CMakeLists.txt
@@ -38,3 +38,14 @@ add_clang_library(clangInterpreter
   clangSema
   clangSerialization
   )
+
+if ((MINGW OR CYGWIN) AND BUILD_SHARED_LIBS)
+  # The DLLs are supposed to export all symbols (except for ones that are
+  # explicitly hidden). Normally, this is what happens anyway, but if there
+  # are symbols that are marked explicitly as dllexport, we'd only export them
+  # and nothing else. The Interpreter contains a few cases of such dllexports
+  # (for symbols that need to be exported even from standalone exe files);
+  # therefore, add --export-all-symbols to make sure we export all symbols
+  # despite potential dllexports.
+  target_link_options(clangInterpreter PRIVATE LINKER:--export-all-symbols)
+endif()

``




https://github.com/llvm/llvm-project/pull/71393
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang-repl] Fix BUILD_SHARED_LIBS symbols from libclangInterpreter on MinGW (PR #71393)

2023-11-06 Thread Martin Storsjö via cfe-commits

https://github.com/mstorsjo created 
https://github.com/llvm/llvm-project/pull/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 
592e935e115ffb451eb9b782376711dab6558fe0, 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.

From 9de9617b46bd3c2ff4abd9446afc72c6e91f2493 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Martin=20Storsj=C3=B6?= 
Date: Mon, 6 Nov 2023 15:42:42 +0200
Subject: [PATCH] [clang-repl] Fix BUILD_SHARED_LIBS symbols from
 libclangInterpreter on MinGW

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 592e935e115ffb451eb9b782376711dab6558fe0, 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.
---
 clang/lib/Interpreter/CMakeLists.txt | 11 +++
 1 file changed, 11 insertions(+)

diff --git a/clang/lib/Interpreter/CMakeLists.txt 
b/clang/lib/Interpreter/CMakeLists.txt
index 84f6ca5271d2ab0..9065f998f73c473 100644
--- a/clang/lib/Interpreter/CMakeLists.txt
+++ b/clang/lib/Interpreter/CMakeLists.txt
@@ -38,3 +38,14 @@ add_clang_library(clangInterpreter
   clangSema
   clangSerialization
   )
+
+if ((MINGW OR CYGWIN) AND BUILD_SHARED_LIBS)
+  # The DLLs are supposed to export all symbols (except for ones that are
+  # explicitly hidden). Normally, this is what happens anyway, but if there
+  # are symbols that are marked explicitly as dllexport, we'd only export them
+  # and nothing else. The Interpreter contains a few cases of such dllexports
+  # (for symbols that need to be exported even from standalone exe files);
+  # therefore, add --export-all-symbols to make sure we export all symbols
+  # despite potential dllexports.
+  target_link_options(clangInterpreter PRIVATE LINKER:--export-all-symbols)
+endif()

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits