Skip to content

Commit c4c4785

Browse files
committed
Merge branch 'PHP-8.4'
2 parents 95327b5 + ad34505 commit c4c4785

File tree

2 files changed

+36
-51
lines changed

2 files changed

+36
-51
lines changed

cmake/cmake/modules/PHP/PositionIndependentCode.cmake

Lines changed: 20 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,24 @@
11
#[=============================================================================[
22
# PHP/PositionIndependentCode
33
4-
Wrapper module for CMake's `CheckPIESupported` module and
5-
`CMAKE_POSITION_INDEPENDENT_CODE` variable.
4+
This module wraps the
5+
[CheckPIESupported](https://cmake.org/cmake/help/latest/module/CheckPIESupported.html)
6+
module and sets the `CMAKE_POSITION_INDEPENDENT_CODE` variable.
67
7-
This module checks whether to enable the `POSITION_INDEPENDENT_CODE` target
8-
property for all targets globally. The SHARED and MODULE targets have PIC always
9-
enabled by default regardless of this module.
8+
With this module, the position-independent code (PIC) and position-independent
9+
executable (PIE) compile-time and link-time options are globally enabled for all
10+
targets. This enables building shared apache2handler, embed, and phpdbg SAPI
11+
libraries without duplicating builds or targets for executables, static and
12+
shared libraries.
1013
11-
Position independent code (PIC) and position independent executable (PIE)
12-
compile-time and link-time options are for now unconditionally added globally to
13-
all targets, to be able to build shared apache2handler, embed, and phpdbg SAPI
14-
libraries. This probably could be fine tuned in the future further but it can
15-
exponentially complicate the build system code or the build usability.
14+
While finer control over PIC/PIE settings may be possible, doing so
15+
significantly increases build system complexity (two types of library and
16+
extension objects should be built - ones with PIC enabled and those with PIC
17+
disabled - which increases build time) or reduce usability (doing two builds
18+
- one for executable and static SAPIs and one for shared SAPIs).
19+
20+
SHARED and MODULE targets always have PIC enabled by default, regardless of
21+
this module.
1622
1723
## Usage
1824
@@ -24,38 +30,11 @@ include(PHP/PositionIndependentCode)
2430

2531
include_guard(GLOBAL)
2632

27-
block()
28-
include(CheckPIESupported)
29-
30-
message(CHECK_START "Checking if linker supports PIE")
31-
32-
check_pie_supported(OUTPUT_VARIABLE output)
33-
34-
if(CMAKE_C_LINK_PIE_SUPPORTED)
35-
message(CHECK_PASS "yes")
36-
else()
37-
message(CHECK_FAIL "no")
38-
39-
if(
40-
CMAKE_VERSION VERSION_GREATER_EQUAL 3.26
41-
AND NOT DEFINED _PHP_POSITION_INDEPENDENT_CODE_LOGGED
42-
)
43-
message(
44-
CONFIGURE_LOG
45-
"Position independent executable (PIE) is not supported at link time:\n"
46-
"${output}"
47-
"PIE link options will not be passed to linker."
48-
)
33+
include(CheckPIESupported)
4934

50-
set(
51-
_PHP_POSITION_INDEPENDENT_CODE_LOGGED
52-
TRUE
53-
CACHE INTERNAL
54-
"Internal marker whether PIE check has been logged."
55-
)
56-
endif()
57-
endif()
58-
endblock()
35+
message(CHECK_START "Detecting linker PIE support")
36+
check_pie_supported()
37+
message(CHECK_PASS "done")
5938

6039
if(NOT DEFINED CMAKE_POSITION_INDEPENDENT_CODE)
6140
set(CMAKE_POSITION_INDEPENDENT_CODE ON)

docs/cmake/modules/PHP/PositionIndependentCode.md

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,24 @@
33

44
# PHP/PositionIndependentCode
55

6-
Wrapper module for CMake's `CheckPIESupported` module and
7-
`CMAKE_POSITION_INDEPENDENT_CODE` variable.
6+
This module wraps the
7+
[CheckPIESupported](https://cmake.org/cmake/help/latest/module/CheckPIESupported.html)
8+
module and sets the `CMAKE_POSITION_INDEPENDENT_CODE` variable.
89

9-
This module checks whether to enable the `POSITION_INDEPENDENT_CODE` target
10-
property for all targets globally. The SHARED and MODULE targets have PIC always
11-
enabled by default regardless of this module.
10+
With this module, the position-independent code (PIC) and position-independent
11+
executable (PIE) compile-time and link-time options are globally enabled for all
12+
targets. This enables building shared apache2handler, embed, and phpdbg SAPI
13+
libraries without duplicating builds or targets for executables, static and
14+
shared libraries.
1215

13-
Position independent code (PIC) and position independent executable (PIE)
14-
compile-time and link-time options are for now unconditionally added globally to
15-
all targets, to be able to build shared apache2handler, embed, and phpdbg SAPI
16-
libraries. This probably could be fine tuned in the future further but it can
17-
exponentially complicate the build system code or the build usability.
16+
While finer control over PIC/PIE settings may be possible, doing so
17+
significantly increases build system complexity (two types of library and
18+
extension objects should be built - ones with PIC enabled and those with PIC
19+
disabled - which increases build time) or reduce usability (doing two builds
20+
- one for executable and static SAPIs and one for shared SAPIs).
21+
22+
SHARED and MODULE targets always have PIC enabled by default, regardless of
23+
this module.
1824

1925
## Usage
2026

0 commit comments

Comments
 (0)