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

Anutosh Bhat via llvm-commits llvm-commits at lists.llvm.org
Mon Dec 2 18:37:09 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/3] 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/3] 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})

>From abf61f5937402740155e4673933e8c3e78c40cab Mon Sep 17 00:00:00 2001
From: anutosh491 <andersonbhat491 at gmail.com>
Date: Tue, 3 Dec 2024 08:06:50 +0530
Subject: [PATCH 3/3] Made suggested change

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

diff --git a/llvm/cmake/modules/AddLLVM.cmake b/llvm/cmake/modules/AddLLVM.cmake
index 11fb568b932fe1..b8a470337998be 100644
--- a/llvm/cmake/modules/AddLLVM.cmake
+++ b/llvm/cmake/modules/AddLLVM.cmake
@@ -635,19 +635,16 @@ function(llvm_add_library name)
     set(ARG_STATIC)
   endif()
 
+  if(EMSCRIPTEN)
+    set(ARG_MODULE FALSE)
+    set(ARG_SHARED FALSE)
+  endif()
+
   if(ARG_MODULE)
-    if(EMSCRIPTEN)
-      add_library(${name} STATIC ${ALL_FILES})
-    else()
-      add_library(${name} MODULE ${ALL_FILES})
-    endif()
+    add_library(${name} MODULE ${ALL_FILES})
   elseif(ARG_SHARED)
     add_windows_version_resource_file(ALL_FILES ${ALL_FILES})
-    if(EMSCRIPTEN)
-      add_library(${name} STATIC ${ALL_FILES})
-    else()
-      add_library(${name} SHARED ${ALL_FILES})
-    endif()
+    add_library(${name} SHARED ${ALL_FILES})
   else()
     add_library(${name} STATIC ${ALL_FILES})
   endif()



More information about the llvm-commits mailing list