[clang] [libclang][Cygwin] Use __declspec(dllexport) for libclang on Cygwin (PR #147122)

2025-07-07 Thread Martin Storsjö via cfe-commits

https://github.com/mstorsjo closed 
https://github.com/llvm/llvm-project/pull/147122
___
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [libclang][Cygwin] Use __declspec(dllexport) for libclang on Cygwin (PR #147122)

2025-07-06 Thread Martin Storsjö via cfe-commits

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

LGTM, thanks.

But we should wait for https://github.com/llvm/llvm-project/pull/147108 to land 
first before merging this.

https://github.com/llvm/llvm-project/pull/147122
___
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [libclang][Cygwin] Use __declspec(dllexport) for libclang on Cygwin (PR #147122)

2025-07-06 Thread Martin Storsjö via cfe-commits

mstorsjo wrote:

> > > Before merge this, requires #147108
> > 
> > 
> > Can you elaborate on why this is needed - what happens without it - 
> > wouldn't that issue be happening already now in regular win32 builds so far?
> 
> The linker reports undefined reference to 
> clang_install_aborting_llvm_fatal_error_handler, and cannot run testsuite.
> 
> ```
> FAILED: tools/clang/unittests/libclang/CrashTests/libclangCrashTests.exe
> : && /usr/bin/g++.exe  -pipe -Wa,-mbig-obj -Werror=date-time -Wall -Wextra 
> -Wno-unused-parameter -Wwrite-strings -Wcast-qual 
> -Wno-missing-field-initializers -pedantic -Wno-long-long 
> -Wimplicit-fallthrough -Wno-maybe-uninitialized -Wno-nonnull 
> -Wno-class-memaccess -Wno-redundant-move -Wno-pessimizing-move 
> -Wno-noexcept-type -Wdelete-non-virtual-dtor -Wsuggest-override -Wno-comment 
> -Wno-misleading-indentation -Wctad-maybe-unsupported -fdiagnostics-color 
> -fno-common -Woverloaded-virtual -O2 -DNDEBUG -Wl,--enable-auto-import 
> -Wl,--stack,16777216-Wl,--gc-sections 
> tools/clang/unittests/libclang/CrashTests/CMakeFiles/libclangCrashTests.dir/LibclangCrashTest.cpp.o
>  -o tools/clang/unittests/libclang/CrashTests/libclangCrashTests.exe 
> -Wl,--out-implib,tools/clang/unittests/libclang/CrashTests/liblibclangCrashTests.dll.a
>  -Wl,--major-image-version,0,--minor-image-version,0  lib/libLLVMSupport.a  
> lib/libllvm_gtest_main.a  lib/libllvm_gtest.a  lib/libclang.dll.a  
> lib/libLLVMSupport.a  -lrt  -ldl  -lm  /usr/lib/libz.dll.a  
> /usr/lib/libzstd.dll.a  lib/libLLVMDemangle.a  -lpthread && :
> /usr/lib/gcc/x86_64-pc-cygwin/15/../../../../x86_64-pc-cygwin/bin/ld: 
> tools/clang/unittests/libclang/CrashTests/CMakeFiles/libclangCrashTests.dir/LibclangCrashTest.cpp.o:LibclangCrashTest.cpp:(.text+0x21d):
>  undefined reference to `clang_install_aborting_llvm_fatal_error_handler'
> /usr/lib/gcc/x86_64-pc-cygwin/15/../../../../x86_64-pc-cygwin/bin/ld: 
> tools/clang/unittests/libclang/CrashTests/CMakeFiles/libclangCrashTests.dir/LibclangCrashTest.cpp.o:LibclangCrashTest.cpp:(.text+0x61f):
>  undefined reference to `clang_install_aborting_llvm_fatal_error_handler'
> /usr/lib/gcc/x86_64-pc-cygwin/15/../../../../x86_64-pc-cygwin/bin/ld: 
> tools/clang/unittests/libclang/CrashTests/CMakeFiles/libclangCrashTests.dir/LibclangCrashTest.cpp.o:LibclangCrashTest.cpp:(.text+0x624):
>  undefined reference to `clang_uninstall_llvm_fatal_error_handler'
> collect2: エラー: ld はステータス 1 で終了しました
> ```
> 
> For regular Win32 targets, this unittest is disabled.
> 
> https://github.com/llvm/llvm-project/blob/4406a457b7cf3713dc9bea67bd7b68ecb61966bd/clang/unittests/CMakeLists.txt#L98-L102

Thanks, that explains why this hasn't been noticed before!

https://github.com/llvm/llvm-project/pull/147122
___
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [libclang][Cygwin] Use __declspec(dllexport) for libclang on Cygwin (PR #147122)

2025-07-05 Thread Tomohiro Kashiwada via cfe-commits

kikairoya wrote:

> > Before merge this, requires #147108
> 
> Can you elaborate on why this is needed - what happens without it - wouldn't 
> that issue be happening already now in regular win32 builds so far?

The linker reports undefined reference to 
clang_install_aborting_llvm_fatal_error_handler, and cannot run testsuite.

```
FAILED: tools/clang/unittests/libclang/CrashTests/libclangCrashTests.exe
: && /usr/bin/g++.exe  -pipe -Wa,-mbig-obj -Werror=date-time -Wall -Wextra 
-Wno-unused-parameter -Wwrite-strings -Wcast-qual 
-Wno-missing-field-initializers -pedantic -Wno-long-long -Wimplicit-fallthrough 
-Wno-maybe-uninitialized -Wno-nonnull -Wno-class-memaccess -Wno-redundant-move 
-Wno-pessimizing-move -Wno-noexcept-type -Wdelete-non-virtual-dtor 
-Wsuggest-override -Wno-comment -Wno-misleading-indentation 
-Wctad-maybe-unsupported -fdiagnostics-color -fno-common -Woverloaded-virtual 
-O2 -DNDEBUG -Wl,--enable-auto-import -Wl,--stack,16777216-Wl,--gc-sections 
tools/clang/unittests/libclang/CrashTests/CMakeFiles/libclangCrashTests.dir/LibclangCrashTest.cpp.o
 -o tools/clang/unittests/libclang/CrashTests/libclangCrashTests.exe 
-Wl,--out-implib,tools/clang/unittests/libclang/CrashTests/liblibclangCrashTests.dll.a
 -Wl,--major-image-version,0,--minor-image-version,0  lib/libLLVMSupport.a  
lib/libllvm_gtest_main.a  lib/libllvm_gtest.a  lib/libclang.dll.a  
lib/libLLVMSupport.a  -lrt  -ldl  -lm  /usr/lib/libz.dll.a  
/usr/lib/libzstd.dll.a  lib/libLLVMDemangle.a  -lpthread && :
/usr/lib/gcc/x86_64-pc-cygwin/15/../../../../x86_64-pc-cygwin/bin/ld: 
tools/clang/unittests/libclang/CrashTests/CMakeFiles/libclangCrashTests.dir/LibclangCrashTest.cpp.o:LibclangCrashTest.cpp:(.text+0x21d):
 undefined reference to `clang_install_aborting_llvm_fatal_error_handler'
/usr/lib/gcc/x86_64-pc-cygwin/15/../../../../x86_64-pc-cygwin/bin/ld: 
tools/clang/unittests/libclang/CrashTests/CMakeFiles/libclangCrashTests.dir/LibclangCrashTest.cpp.o:LibclangCrashTest.cpp:(.text+0x61f):
 undefined reference to `clang_install_aborting_llvm_fatal_error_handler'
/usr/lib/gcc/x86_64-pc-cygwin/15/../../../../x86_64-pc-cygwin/bin/ld: 
tools/clang/unittests/libclang/CrashTests/CMakeFiles/libclangCrashTests.dir/LibclangCrashTest.cpp.o:LibclangCrashTest.cpp:(.text+0x624):
 undefined reference to `clang_uninstall_llvm_fatal_error_handler'
collect2: エラー: ld はステータス 1 で終了しました
```

For regular Win32 targets, this unittest is disabled.

https://github.com/llvm/llvm-project/blob/4406a457b7cf3713dc9bea67bd7b68ecb61966bd/clang/unittests/CMakeLists.txt#L98-L102


https://github.com/llvm/llvm-project/pull/147122
___
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [libclang][Cygwin] Use __declspec(dllexport) for libclang on Cygwin (PR #147122)

2025-07-05 Thread Martin Storsjö via cfe-commits

mstorsjo wrote:

> Before merge this, requires #147108

Can you elaborate on why this is needed - what happens without it - wouldn't 
that issue be happening already now in regular win32 builds so far?

https://github.com/llvm/llvm-project/pull/147122
___
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [libclang][Cygwin] Use __declspec(dllexport) for libclang on Cygwin (PR #147122)

2025-07-04 Thread Tomohiro Kashiwada via cfe-commits

kikairoya wrote:

`git clang-format` makes reformat below, should it be applied?
```diff
diff --git a/clang/include/clang-c/Platform.h b/clang/include/clang-c/Platform.h
index 8d341ddd6f8e..1c28ccf81981 100644
--- a/clang/include/clang-c/Platform.h
+++ b/clang/include/clang-c/Platform.h
@@ -23,13 +23,13 @@ LLVM_CLANG_C_EXTERN_C_BEGIN
   #define CINDEX_EXPORTS
 #endif
 #if defined(_WIN32) || defined(__CYGWIN__)
-  #ifdef CINDEX_EXPORTS
-#ifdef _CINDEX_LIB_
-  #define CINDEX_LINKAGE __declspec(dllexport)
-#else
-  #define CINDEX_LINKAGE __declspec(dllimport)
-#endif
-  #endif
+#ifdef CINDEX_EXPORTS
+#ifdef _CINDEX_LIB_
+#define CINDEX_LINKAGE __declspec(dllexport)
+#else
+#define CINDEX_LINKAGE __declspec(dllimport)
+#endif
+#endif
 #elif defined(CINDEX_EXPORTS) && defined(__GNUC__)
   #define CINDEX_LINKAGE __attribute__((visibility("default")))
 #endif
```

https://github.com/llvm/llvm-project/pull/147122
___
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [libclang][Cygwin] Use __declspec(dllexport) for libclang on Cygwin (PR #147122)

2025-07-04 Thread via cfe-commits

github-actions[bot] wrote:




:warning: C/C++ code formatter, clang-format found issues in your code. 
:warning:



You can test this locally with the following command:


``bash
git-clang-format --diff HEAD~1 HEAD --extensions h -- 
clang/include/clang-c/Platform.h
``





View the diff from clang-format here.


``diff
diff --git a/clang/include/clang-c/Platform.h b/clang/include/clang-c/Platform.h
index 8d341ddd6..1c28ccf81 100644
--- a/clang/include/clang-c/Platform.h
+++ b/clang/include/clang-c/Platform.h
@@ -23,13 +23,13 @@ LLVM_CLANG_C_EXTERN_C_BEGIN
   #define CINDEX_EXPORTS
 #endif
 #if defined(_WIN32) || defined(__CYGWIN__)
-  #ifdef CINDEX_EXPORTS
-#ifdef _CINDEX_LIB_
-  #define CINDEX_LINKAGE __declspec(dllexport)
-#else
-  #define CINDEX_LINKAGE __declspec(dllimport)
-#endif
-  #endif
+#ifdef CINDEX_EXPORTS
+#ifdef _CINDEX_LIB_
+#define CINDEX_LINKAGE __declspec(dllexport)
+#else
+#define CINDEX_LINKAGE __declspec(dllimport)
+#endif
+#endif
 #elif defined(CINDEX_EXPORTS) && defined(__GNUC__)
   #define CINDEX_LINKAGE __attribute__((visibility("default")))
 #endif

``




https://github.com/llvm/llvm-project/pull/147122
___
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [libclang][Cygwin] Use __declspec(dllexport) for libclang on Cygwin (PR #147122)

2025-07-04 Thread Tomohiro Kashiwada via cfe-commits

kikairoya wrote:

Before merge this, requires https://github.com/llvm/llvm-project/pull/147108

https://github.com/llvm/llvm-project/pull/147122
___
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [libclang][Cygwin] Use __declspec(dllexport) for libclang on Cygwin (PR #147122)

2025-07-04 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Tomohiro Kashiwada (kikairoya)


Changes

This is needed for Cygwin build without `-DLLVM_LINK_LLVM_DYLIB=ON`, otherwise 
causes a linker error 'export ordinal too large'.

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


1 Files Affected:

- (modified) clang/include/clang-c/Platform.h (+1-1) 


``diff
diff --git a/clang/include/clang-c/Platform.h b/clang/include/clang-c/Platform.h
index 67c1fff8ff783..8d341ddd6f8eb 100644
--- a/clang/include/clang-c/Platform.h
+++ b/clang/include/clang-c/Platform.h
@@ -22,7 +22,7 @@ LLVM_CLANG_C_EXTERN_C_BEGIN
 #ifndef CINDEX_NO_EXPORTS
   #define CINDEX_EXPORTS
 #endif
-#ifdef _WIN32
+#if defined(_WIN32) || defined(__CYGWIN__)
   #ifdef CINDEX_EXPORTS
 #ifdef _CINDEX_LIB_
   #define CINDEX_LINKAGE __declspec(dllexport)

``




https://github.com/llvm/llvm-project/pull/147122
___
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [libclang][Cygwin] Use __declspec(dllexport) for libclang on Cygwin (PR #147122)

2025-07-04 Thread Tomohiro Kashiwada via cfe-commits

https://github.com/kikairoya created 
https://github.com/llvm/llvm-project/pull/147122

This is needed for Cygwin build without `-DLLVM_LINK_LLVM_DYLIB=ON`, otherwise 
causes a linker error 'export ordinal too large'.

>From 4406a457b7cf3713dc9bea67bd7b68ecb61966bd Mon Sep 17 00:00:00 2001
From: kikairoya 
Date: Sat, 28 Jun 2025 10:54:25 +0900
Subject: [PATCH] [libclang][Cygwin] Use __declspec(dllexport) for libclang on
 Cygwin

This is needed for Cygwin build without LLVM_LINK_LLVM_DYLIB, otherwise
causes a linker error 'export ordinal too large'.
---
 clang/include/clang-c/Platform.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/clang/include/clang-c/Platform.h b/clang/include/clang-c/Platform.h
index 67c1fff8ff783..8d341ddd6f8eb 100644
--- a/clang/include/clang-c/Platform.h
+++ b/clang/include/clang-c/Platform.h
@@ -22,7 +22,7 @@ LLVM_CLANG_C_EXTERN_C_BEGIN
 #ifndef CINDEX_NO_EXPORTS
   #define CINDEX_EXPORTS
 #endif
-#ifdef _WIN32
+#if defined(_WIN32) || defined(__CYGWIN__)
   #ifdef CINDEX_EXPORTS
 #ifdef _CINDEX_LIB_
   #define CINDEX_LINKAGE __declspec(dllexport)

___
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits