[llvm] Fix warnings while building llvm against emscripten for web assembly (PR #118262)

Anutosh Bhat via llvm-commits llvm-commits at lists.llvm.org
Sun Dec 1 22:52:40 PST 2024


https://github.com/anutosh491 updated https://github.com/llvm/llvm-project/pull/118262

>From 62fcc4d9e104b5ce756269370931d239f083a8b7 Mon Sep 17 00:00:00 2001
From: anutosh491 <andersonbhat491 at gmail.com>
Date: Mon, 2 Dec 2024 12:09:54 +0530
Subject: [PATCH 1/2] Fix warnings while building llvm against emscripten for
 web assembly

---
 llvm/cmake/modules/AddLLVM.cmake | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/llvm/cmake/modules/AddLLVM.cmake b/llvm/cmake/modules/AddLLVM.cmake
index 006dfb6de3a199..11ccd22fb4f2ea 100644
--- a/llvm/cmake/modules/AddLLVM.cmake
+++ b/llvm/cmake/modules/AddLLVM.cmake
@@ -636,10 +636,18 @@ function(llvm_add_library name)
   endif()
 
   if(ARG_MODULE)
-    add_library(${name} MODULE ${ALL_FILES})
+    if(EMSCRIPTEN)
+      add_library(${name} STATIC ${ALL_FILES})
+    else()
+      add_library(${name} MODULE ${ALL_FILES})
+    endif()
   elseif(ARG_SHARED)
     add_windows_version_resource_file(ALL_FILES ${ALL_FILES})
-    add_library(${name} SHARED ${ALL_FILES})
+    if(EMSCRIPTEN)
+      add_library(${name} STATIC ${ALL_FILES})
+    else()
+      add_library(${name} MODULE ${ALL_FILES})
+    endif()
   else()
     add_library(${name} STATIC ${ALL_FILES})
   endif()

>From a69d42d11a318fde2d4df937f63d4d7b30ce3b3d Mon Sep 17 00:00:00 2001
From: anutosh491 <andersonbhat491 at gmail.com>
Date: Mon, 2 Dec 2024 12:22:24 +0530
Subject: [PATCH 2/2] minor fix

---
 llvm/cmake/modules/AddLLVM.cmake | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/llvm/cmake/modules/AddLLVM.cmake b/llvm/cmake/modules/AddLLVM.cmake
index 11ccd22fb4f2ea..11fb568b932fe1 100644
--- a/llvm/cmake/modules/AddLLVM.cmake
+++ b/llvm/cmake/modules/AddLLVM.cmake
@@ -646,7 +646,7 @@ function(llvm_add_library name)
     if(EMSCRIPTEN)
       add_library(${name} STATIC ${ALL_FILES})
     else()
-      add_library(${name} MODULE ${ALL_FILES})
+      add_library(${name} SHARED ${ALL_FILES})
     endif()
   else()
     add_library(${name} STATIC ${ALL_FILES})



More information about the llvm-commits mailing list