Newer
Older
minerva / Toolchain / Patches / llvm / 0003-tools-Support-building-shared-libLLVM-and-libClang-f.patch
@minerva minerva on 13 Jul 2 KB Initial commit
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Daniel Bertalan <dani@danielbertalan.dev>
Date: Mon, 18 Apr 2022 22:32:29 +0200
Subject: [PATCH] [tools] Support building shared libLLVM and libClang for
 Minerva

This patch tells CMake that the --whole-archive linker option should be
used for specifying the archives whose members will constitute these
shared libraries.

Symbol versioning is disabled, as the Minerva loader doesn't support
it, and the ELF sections that store version data would just waste space.
---
 llvm/cmake/modules/HandleLLVMOptions.cmake | 2 +-
 llvm/tools/llvm-shlib/CMakeLists.txt       | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/llvm/cmake/modules/HandleLLVMOptions.cmake b/llvm/cmake/modules/HandleLLVMOptions.cmake
index e82cda307ddfd053fa1434c955b3a37e54f864c5..ffb11803c545b29d7eeef9ef04d7daea4b22aea2 100644
--- a/llvm/cmake/modules/HandleLLVMOptions.cmake
+++ b/llvm/cmake/modules/HandleLLVMOptions.cmake
@@ -222,7 +222,7 @@ if(WIN32)
 elseif(FUCHSIA OR UNIX)
   set(LLVM_ON_WIN32 0)
   set(LLVM_ON_UNIX 1)
-  if(APPLE OR ${CMAKE_SYSTEM_NAME} MATCHES "AIX")
+  if(APPLE OR MINERVA OR ${CMAKE_SYSTEM_NAME} MATCHES "AIX")
     set(LLVM_HAVE_LINK_VERSION_SCRIPT 0)
   else()
     set(LLVM_HAVE_LINK_VERSION_SCRIPT 1)
diff --git a/llvm/tools/llvm-shlib/CMakeLists.txt b/llvm/tools/llvm-shlib/CMakeLists.txt
index ede3c5034e045f7739aa7d1d06d8ec508cc8f9dd..dcef1e89845de3c985d98b58537f2693006f4e2a 100644
--- a/llvm/tools/llvm-shlib/CMakeLists.txt
+++ b/llvm/tools/llvm-shlib/CMakeLists.txt
@@ -57,7 +57,7 @@ if(LLVM_BUILD_LLVM_DYLIB)
     else()
       # GNU ld doesn't resolve symbols in the version script.
       set(LIB_NAMES -Wl,--whole-archive ${LIB_NAMES} -Wl,--no-whole-archive)
-      if (NOT LLVM_LINKER_IS_SOLARISLD AND NOT MINGW)
+      if (NOT LLVM_LINKER_IS_SOLARISLD AND NOT MINGW AND NOT MINERVA)
         # Solaris ld does not accept global: *; so there is no way to version *all* global symbols
         set(LIB_NAMES -Wl,--version-script,${LLVM_LIBRARY_DIR}/tools/llvm-shlib/simple_version_script.map ${LIB_NAMES})
       endif()