Skip to content

Commit 78ee9a0

Browse files
committed
Create Zend library as OBJECT library
When linking static libraries to final or transitional targets, only those symbols that are used in the final binary will be added from the linked library. For now this is a quick fix to get the all Zend library symbols in the final binary and fix the shared extensions builds. Probably a nicer and proper solution could be done in the API provided by the C code.
1 parent 4d96a9e commit 78ee9a0

File tree

10 files changed

+32
-7
lines changed

10 files changed

+32
-7
lines changed

cmake/Zend/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ mark_as_advanced(ZEND_MAX_EXECUTION_TIMERS)
7878
# Add library.
7979
################################################################################
8080

81-
add_library(zend STATIC)
81+
add_library(zend OBJECT)
8282
add_library(Zend::Zend ALIAS zend)
8383

8484
file(GLOB _zend_headers ${CMAKE_CURRENT_SOURCE_DIR}/*.h)

cmake/main/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,6 @@ target_link_libraries(
8787
# Link publicly for PHP SAPIs.
8888
PUBLIC
8989
PHP::configuration
90-
Zend::Zend
9190
)
9291

9392
if(TARGET PHP::win32)

cmake/sapi/apache2handler/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ target_link_libraries(
8888
php_apache2handler
8989
PRIVATE
9090
PHP::main
91+
Zend::Zend
9192
Apache::Apache
9293
)
9394

cmake/sapi/cgi/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ target_link_libraries(
2828
php_cgi
2929
PRIVATE
3030
PHP::main
31+
Zend::Zend
3132
$<$<PLATFORM_ID:Windows>:ws2_32;kernel32;advapi32>
3233
)
3334

cmake/sapi/cli/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ target_link_libraries(
8282
php_cli
8383
PRIVATE
8484
PHP::main
85+
Zend::Zend
8586
$<$<PLATFORM_ID:Windows>:ws2_32;shell32>
8687
)
8788

@@ -132,6 +133,7 @@ if(SAPI_CLI_WIN_NO_CONSOLE)
132133
php_cli_win_no_console
133134
PRIVATE
134135
PHP::main
136+
Zend::Zend
135137
shell32
136138
)
137139

cmake/sapi/embed/CMakeLists.txt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,12 @@ target_sources(
2929
php_embed.h
3030
)
3131

32-
target_link_libraries(php_embed PRIVATE PHP::main)
32+
target_link_libraries(
33+
php_embed
34+
PRIVATE
35+
PHP::main
36+
Zend::Zend
37+
)
3338

3439
target_compile_definitions(php_embed PRIVATE ZEND_ENABLE_STATIC_TSRMLS_CACHE=1)
3540

cmake/sapi/fpm/CMakeLists.txt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,12 @@ target_include_directories(
154154

155155
target_compile_definitions(php_fpm PRIVATE ZEND_ENABLE_STATIC_TSRMLS_CACHE=1)
156156

157-
target_link_libraries(php_fpm PRIVATE PHP::main)
157+
target_link_libraries(
158+
php_fpm
159+
PRIVATE
160+
PHP::main
161+
Zend::Zend
162+
)
158163

159164
set_target_properties(
160165
php_fpm

cmake/sapi/fuzzer/CMakeLists.txt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,11 @@ set_target_properties(
118118
OUTPUT_NAME ${PHP_PROGRAM_PREFIX}fuzzer${PHP_PROGRAM_SUFFIX}
119119
)
120120

121-
target_link_libraries(php_fuzzer PRIVATE PHP::main)
121+
target_link_libraries(
122+
php_fuzzer
123+
PRIVATE
124+
PHP::main
125+
Zend::Zend
126+
)
122127

123128
install(TARGETS php_fuzzer RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})

cmake/sapi/litespeed/CMakeLists.txt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,12 @@ add_executable(php_litespeed
2727
lsapilib.c
2828
)
2929

30-
target_link_libraries(php_litespeed PRIVATE PHP::main)
30+
target_link_libraries(
31+
php_litespeed
32+
PRIVATE
33+
PHP::main
34+
Zend::Zend
35+
)
3136

3237
set_target_properties(
3338
php_litespeed

cmake/sapi/phpdbg/CMakeLists.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ target_link_libraries(
9595
php_phpdbg
9696
PRIVATE
9797
PHP::main
98+
Zend::Zend
9899
$<$<PLATFORM_ID:Windows>:ws2_32;user32>
99100
)
100101

@@ -190,7 +191,8 @@ if(SAPI_PHPDBG_SHARED)
190191
php_phpdbg_shared
191192
PRIVATE
192193
# TODO: fix this better in the future (building with -fPIC etc).
193-
#PHP::main
194+
PHP::main
195+
Zend::Zend
194196
$<$<PLATFORM_ID:Windows>:ws2_32;user32>
195197
)
196198
endif()

0 commit comments

Comments
 (0)