Skip to content

[cmake] Reenable libclang.dll when LLVM_ENABLE_PIC #138343

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 5, 2025
Merged

Conversation

aeubanks
Copy link
Contributor

@aeubanks aeubanks commented May 2, 2025

This was disabled for Windows/Mingw in #138343, but it's actually linkable and is being used by some people.

This was accidentally disabled in llvm#138119 for non-mingw Windows.
@llvmbot llvmbot added clang Clang issues not falling into any other category clang:as-a-library libclang and C++ API labels May 2, 2025
@aeubanks aeubanks requested a review from mstorsjo May 2, 2025 20:41
@llvmbot
Copy link
Member

llvmbot commented May 2, 2025

@llvm/pr-subscribers-clang

Author: Arthur Eubanks (aeubanks)

Changes

This was accidentally disabled in #138119 for non-mingw Windows.


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

1 Files Affected:

  • (modified) clang/tools/libclang/CMakeLists.txt (+1-1)
diff --git a/clang/tools/libclang/CMakeLists.txt b/clang/tools/libclang/CMakeLists.txt
index 37a939ffcada7..8fbee71e02882 100644
--- a/clang/tools/libclang/CMakeLists.txt
+++ b/clang/tools/libclang/CMakeLists.txt
@@ -106,7 +106,7 @@ if (LLVM_EXPORTED_SYMBOL_FILE)
                      DEPENDS ${LIBCLANG_VERSION_SCRIPT_FILE})
 endif()
 
-if((NOT (WIN32 OR CYGWIN) AND LLVM_ENABLE_PIC) OR
+if((NOT CYGWIN AND LLVM_ENABLE_PIC) OR
   ((WIN32 OR CYGWIN) AND NOT LIBCLANG_BUILD_STATIC))
   set(ENABLE_SHARED SHARED)
 endif()

Comment on lines 109 to 110
if((NOT CYGWIN AND LLVM_ENABLE_PIC) OR
((WIN32 OR CYGWIN) AND NOT LIBCLANG_BUILD_STATIC))
Copy link
Contributor

@jeremyd2019 jeremyd2019 May 2, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd just do

Suggested change
if((NOT CYGWIN AND LLVM_ENABLE_PIC) OR
((WIN32 OR CYGWIN) AND NOT LIBCLANG_BUILD_STATIC))
if(LLVM_ENABLE_PIC OR ((WIN32 OR CYGWIN) AND NOT LIBCLANG_BUILD_STATIC))

since LIBCLANG_BUILD_STATIC is documented to build a static libclang in addition to the shared libclang

I'm running a build on Cygwin right now with that version of the change

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My build just failed with too many exports. But I bet it can be fixed in a better way so it'd be fine with me to merge this to unbreak actually entirely working platforms and leave me to fix it later.

Copy link
Contributor

@jeremyd2019 jeremyd2019 May 2, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I opened #138351 to try to figure out how to fix this on Cygwin. If nothing else works, maybe for our static build bootstrapping workaround we need to do both -DLLVM_ENABLE_PIC=OFF -DLIBCLANG_BUILD_STATIC=ON.

Copy link
Contributor

@jeremyd2019 jeremyd2019 May 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did confirm that -DLLVM_ENABLE_PIC=OFF -DLIBCLANG_BUILD_STATIC=ON works to build on Cygwin with GCC, so we do still have a workaround with this revert.

@aeubanks aeubanks changed the title [cmake] Reenable libclang.dll on Windows when LLVM_ENABLE_PIC [cmake] Reenable libclang.dll LLVM_ENABLE_PIC May 2, 2025
@aeubanks aeubanks changed the title [cmake] Reenable libclang.dll LLVM_ENABLE_PIC [cmake] Reenable libclang.dll when LLVM_ENABLE_PIC May 2, 2025
Copy link
Member

@mstorsjo mstorsjo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@zmodem zmodem merged commit b06a014 into llvm:main May 5, 2025
13 checks passed
IanWood1 pushed a commit to IanWood1/llvm-project that referenced this pull request May 6, 2025
This was disabled for Windows/Mingw in llvm#138343, but it's actually
linkable and is being used by some people.
IanWood1 pushed a commit to IanWood1/llvm-project that referenced this pull request May 6, 2025
This was disabled for Windows/Mingw in llvm#138343, but it's actually
linkable and is being used by some people.
IanWood1 pushed a commit to IanWood1/llvm-project that referenced this pull request May 6, 2025
This was disabled for Windows/Mingw in llvm#138343, but it's actually
linkable and is being used by some people.
@aeubanks aeubanks deleted the dll branch May 6, 2025 16:53
GeorgeARM pushed a commit to GeorgeARM/llvm-project that referenced this pull request May 7, 2025
This was disabled for Windows/Mingw in llvm#138343, but it's actually
linkable and is being used by some people.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clang:as-a-library libclang and C++ API clang Clang issues not falling into any other category
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants