Files
CMake/Modules/Platform/Emscripten-Clang.cmake
Brad King 86574083a8 Emscripten: Drop hard-coded -fPIC flag
In commit 96d9b94a98 (Emscripten: Add platform modules, 2025-05-16,
v4.2.0-rc1~607^2~3) this flag was added as part of an attempt to support
shared libraries without requiring projects to set much themselves. That
attempt was reverted by commit d361bf365e (Emscripten: Drop hard-coded
-sMAIN_MODULE and -sSIDE_MODULE flags, 2025-09-18, v4.2.0-rc1~146^2).
Also avoid hard-coding `-fPIC`.  `POSITION_INDEPENDENT_CODE` is already
enabled for shared library targets.  Projects can enable it themselves
where `-fPIC` is needed outside of shared libraries.

Fixes: #27424
Issue: #27240
2025-11-25 10:32:04 -05:00

20 lines
857 B
CMake

# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file LICENSE.rst or https://cmake.org/licensing for details.
include_guard()
macro(__emscripten_clang lang)
set(CMAKE_SHARED_LIBRARY_SONAME_${lang}_FLAG "-Wl,-soname,")
# FIXME(#27240): We do not add -sMAIN_MODULE to CMAKE_${lang}_LINK_EXECUTABLE
# because it is not always needed, and can break things if added unnecessarily.
# We also do not add -sMAIN_MODULE to CMAKE_SHARED_LIBRARY_CREATE_${lang}_FLAGS
# to preserve legacy behavior in which projects added it as needed.
# In the future we may add both flags with suitable controls.
set(CMAKE_SHARED_LIBRARY_CREATE_${lang}_FLAGS "")
set(CMAKE_${lang}_USE_RESPONSE_FILE_FOR_LIBRARIES 1)
set(CMAKE_${lang}_USE_RESPONSE_FILE_FOR_OBJECTS 1)
set(CMAKE_${lang}_USE_RESPONSE_FILE_FOR_INCLUDES 1)
endmacro()