File tree Expand file tree Collapse file tree 4 files changed +24
-3
lines changed Expand file tree Collapse file tree 4 files changed +24
-3
lines changed Original file line number Diff line number Diff line change @@ -16,3 +16,6 @@ endif()
1616
1717# Check whether to enable interprocedural optimization.
1818include (PHP/InterproceduralOptimization)
19+
20+ # Set CMAKE_POSITION_INDEPENDENT_CODE.
21+ include (PHP/PositionIndependentCode)
Original file line number Diff line number Diff line change 2626 set (CMAKE_COLOR_DIAGNOSTICS ON )
2727endif ()
2828
29- # Disable PIC for all targets. PIC is enabled for shared extensions manually.
30- set (CMAKE_POSITION_INDEPENDENT_CODE OFF )
31-
3229# Set empty prefix for targets instead of default "lib".
3330set (CMAKE_SHARED_LIBRARY_PREFIX_C "" )
3431set (CMAKE_SHARED_MODULE_PREFIX_C "" )
Original file line number Diff line number Diff line change @@ -42,6 +42,14 @@ elseif(CMAKE_C_COMPILER_ID STREQUAL "AppleClang")
4242 STATUS
4343 "Interprocedural optimization (IPO) disabled (AppleClang)"
4444 )
45+ elseif (CMAKE_C_COMPILER_ID STREQUAL "Clang" AND CMAKE_SIZEOF_VOID_P EQUAL 4)
46+ # On 32-bit Linux machine, this produced undefined references linker errors.
47+ set (CMAKE_INTERPROCEDURAL_OPTIMIZATION OFF )
48+
49+ message (
50+ STATUS
51+ "Interprocedural optimization (IPO) disabled (Clang on 32-bit)"
52+ )
4553else ()
4654 include (CheckIPOSupported)
4755 check_ipo_supported(RESULT result)
Original file line number Diff line number Diff line change 1+ #[=============================================================================[
2+ Check whether to enable the POSITION_INDEPENDENT_CODE or not.
3+
4+ https://cmake.org/cmake/help/latest/variable/CMAKE_POSITION_INDEPENDENT_CODE.html
5+ ]=============================================================================]#
6+
7+ if (CMAKE_COMPILER_ID STREQUAL "Clang" AND CMAKE_SIZEOF_VOID_P EQUAL 4)
8+ # On 32-bit Linux and FreeBSD at least when using Clang, the pic is required.
9+ set (CMAKE_POSITION_INDEPENDENT_CODE ON )
10+ else ()
11+ # Disable PIC for all targets. PIC is enabled for shared extensions manually.
12+ set (CMAKE_POSITION_INDEPENDENT_CODE OFF )
13+ endif ()
You can’t perform that action at this time.
0 commit comments