Skip to content

Commit 9112b4c

Browse files
[compiler-rt][cmake] Add option to control shared library builds
This patch introduces a new option `COMPILER_RT_BUILD_SHARED_LIBS` to control whether shared libraries are built for runtime libraries in compiler-rt. By default, this option is set to ON, allowing shared libraries to be built. If set to OFF, shared libraries will not be built, which can be useful for projects that do not require them or when building for environments where shared libraries are still not yet matured, such as WebAssembly/WASI.
1 parent e55172f commit 9112b4c

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

compiler-rt/CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,9 @@ mark_as_advanced(COMPILER_RT_SCUDO_STANDALONE_BUILD_SHARED)
9191
option(COMPILER_RT_BUILD_SCUDO_STANDALONE_WITH_LLVM_LIBC "Build SCUDO standalone with LLVM's libc headers" OFF)
9292
mark_as_advanced(COMPILER_RT_BUILD_SCUDO_STANDALONE_WITH_LLVM_LIBC)
9393

94+
option(BUILD_SHARED_LIBS "Build all libraries as shared libraries in addition to static libraries" ON)
95+
mark_as_advanced(BUILD_SHARED_LIBS)
96+
9497
if(FUCHSIA)
9598
set(COMPILER_RT_HWASAN_WITH_INTERCEPTORS_DEFAULT OFF)
9699
else()

compiler-rt/cmake/Modules/AddCompilerRT.cmake

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,10 @@ function(add_compiler_rt_runtime name type)
169169
"type argument must be OBJECT, STATIC, SHARED or MODULE")
170170
return()
171171
endif()
172+
if(type STREQUAL "SHARED" AND NOT BUILD_SHARED_LIBS)
173+
message(STATUS "Skipping shared library ${name} because BUILD_SHARED_LIBS is OFF")
174+
return()
175+
endif()
172176
cmake_parse_arguments(LIB
173177
""
174178
"PARENT_TARGET"

0 commit comments

Comments
 (0)