Skip to content

Conversation

@andrurogerz
Copy link
Contributor

Purpose

This patch ensures that the BLAKE3 implementation in the LLVM Support library exports its public interface with __declspec(dllexport) when building LLVM as a Windows DLL.

Background

The effort to support building LLVM as a Windows DLL is tracked in #109483. Additional context is provided in this discourse.

Overview

Replicate this logic from llvm_add_library() for the LLVMSupportBlake3 target. Without this change, the llvm_blake_ functions will only be annotated with __declspec(dllimport) when building LLVM as a Windows DLL which leads to inconsistent DLL linkage warnings from MSVC and clang-cl.

@andrurogerz andrurogerz marked this pull request as ready for review June 18, 2025 18:35
@llvmbot
Copy link
Member

llvmbot commented Jun 18, 2025

@llvm/pr-subscribers-llvm-support

Author: Andrew Rogers (andrurogerz)

Changes

Purpose

This patch ensures that the BLAKE3 implementation in the LLVM Support library exports its public interface with __declspec(dllexport) when building LLVM as a Windows DLL.

Background

The effort to support building LLVM as a Windows DLL is tracked in #109483. Additional context is provided in this discourse.

Overview

Replicate this logic from llvm_add_library() for the LLVMSupportBlake3 target. Without this change, the llvm_blake_ functions will only be annotated with __declspec(dllimport) when building LLVM as a Windows DLL which leads to inconsistent DLL linkage warnings from MSVC and clang-cl.


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

1 Files Affected:

  • (modified) llvm/lib/Support/BLAKE3/CMakeLists.txt (+6)
diff --git a/llvm/lib/Support/BLAKE3/CMakeLists.txt b/llvm/lib/Support/BLAKE3/CMakeLists.txt
index 99cb78881ec47..eae2b0280e5d3 100644
--- a/llvm/lib/Support/BLAKE3/CMakeLists.txt
+++ b/llvm/lib/Support/BLAKE3/CMakeLists.txt
@@ -85,3 +85,9 @@ endif()
 add_library(LLVMSupportBlake3 OBJECT EXCLUDE_FROM_ALL ${LLVM_BLAKE3_FILES})
 set_target_properties(LLVMSupportBlake3 PROPERTIES FOLDER "LLVM/Libraries")
 llvm_update_compile_flags(LLVMSupportBlake3)
+if(LLVM_BUILD_LLVM_DYLIB OR BUILD_SHARED_LIBS)
+  # Since LLVMSupportBlake3 is not defined using llvm_add_library(), we must
+  # define LLVM_EXPORTS here so its public interface is annotated with
+  # __declspec(dllexport) when building as a DLL on Windows.
+  target_compile_definitions(LLVMSupportBlake3 PRIVATE LLVM_EXPORTS)
+endif()

@andrurogerz
Copy link
Contributor Author

@compnerd, @vgvassilev this one should be straight-forward, but I thought it was worth making into its own PR for discussion if needed. Thanks!

Copy link
Member

@compnerd compnerd left a comment

Choose a reason for hiding this comment

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

It is unfortunate that we cannot use standard CMake tooling to control the behaviour here. I think that given the state of the build, this is reasonable.

@compnerd compnerd merged commit a88e655 into llvm:main Jun 18, 2025
11 checks passed
@andrurogerz andrurogerz deleted the llvm-abi-blake3 branch July 7, 2025 21:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants