Skip to content

Commit 05058d1

Browse files
ADKasterlinusg
authored andcommitted
Toolchain: Update Platform files to match those in upstream cmake
Serenity support was merged into the CMake master branch for the 3.25.0 milestone (https://gitlab.kitware.com/cmake/cmake/-/merge_requests/6837) Remove some settings that are now redundant from the Toolchain files.
1 parent ca85e15 commit 05058d1

11 files changed

+49
-23
lines changed

Toolchain/CMake/ClangToolchain.txt.in

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
list(APPEND CMAKE_MODULE_PATH "@SERENITY_SOURCE_DIR@/Toolchain/CMake")
1+
if (${CMAKE_VERSION} VERSION_LESS "3.25.0")
2+
list(APPEND CMAKE_MODULE_PATH "@SERENITY_SOURCE_DIR@/Toolchain/CMake")
3+
endif()
24

35
set(CMAKE_SYSTEM_NAME SerenityOS)
46
set(CMAKE_SYSTEM_PROCESSOR "@SERENITY_ARCH@")
57

6-
set(SERENITYOS 1)
78
set(triple @SERENITY_ARCH@-pc-serenity)
89
set(TOOLCHAIN_ROOT @SERENITY_SOURCE_DIR@/Toolchain/Local/clang/)
910
set(TOOLCHAIN_PATH ${TOOLCHAIN_ROOT}/bin)
@@ -28,8 +29,6 @@ set(CMAKE_RANLIB ${TOOLCHAIN_PATH}/llvm-ranlib)
2829
set(CMAKE_STRIP ${TOOLCHAIN_PATH}/llvm-strip)
2930
set(SERENITY_CXXFILT ${TOOLCHAIN_PATH}/llvm-cxxfilt)
3031

31-
set(CMAKE_EXE_LINKER_FLAGS_INIT "-Wl,--hash-style=gnu,-z,relro,-z,now,-z,noexecstack,-z,max-page-size=0x1000,-z,separate-code")
32-
3332
# FIXME: We could eliminate this setting by building LibC and support asm files (crti.o, crtn.o)
3433
# in a separate build stage before the main build to ensure that LibC is available
3534
# for the try_compile check for the main build.

Toolchain/CMake/GNUToolchain.txt.in

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
list(APPEND CMAKE_MODULE_PATH "@SERENITY_SOURCE_DIR@/Toolchain/CMake")
1+
if (${CMAKE_VERSION} VERSION_LESS "3.25.0")
2+
list(APPEND CMAKE_MODULE_PATH "@SERENITY_SOURCE_DIR@/Toolchain/CMake")
3+
endif()
24

35
set(CMAKE_SYSTEM_NAME SerenityOS)
46
set(CMAKE_SYSTEM_PROCESSOR "@SERENITY_ARCH@")
57

6-
set(SERENITYOS 1)
78
set(triple @SERENITY_ARCH@-pc-serenity)
89
set(TOOLCHAIN_PATH @SERENITY_SOURCE_DIR@/Toolchain/Local/@SERENITY_ARCH@/bin)
910
set(TOOLCHAIN_PREFIX ${TOOLCHAIN_PATH}/${triple}-)
@@ -25,8 +26,6 @@ set(CMAKE_RANLIB ${TOOLCHAIN_PREFIX}gcc-ranlib)
2526
set(CMAKE_STRIP ${TOOLCHAIN_PREFIX}strip)
2627
set(SERENITY_CXXFILT ${TOOLCHAIN_PREFIX}c++filt)
2728

28-
set(CMAKE_EXE_LINKER_FLAGS_INIT "-Wl,--hash-style=gnu,-z,relro,-z,now,-z,noexecstack,-z,max-page-size=0x1000,-z,separate-code")
29-
3029
# FIXME: We could eliminate this setting by building LibC and support asm files (crti.o, crtn.o)
3130
# in a separate build stage before the main build to ensure that LibC is available
3231
# for the try_compile check for the main build.

Toolchain/CMake/Platform/README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
2+
This directory contains Platform files for CMake to identify flags for SerenityOS when ``CMAKE_SYSTEM_NAME`` is "SerenityOS".
3+
4+
Please keep these files in sync with upstream ``Modules/Platform/SerenityOS*.cmake`` in https://gitlab.kitware.com/cmake/cmake
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
include(Platform/SerenityOS-GNU)
2+
__serenity_compiler_gnu(ASM)
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
include(Platform/SerenityOS-GNU)
2+
__serenity_compiler_gnu(C)
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
include(Platform/SerenityOS-GNU)
2+
__serenity_compiler_gnu(CXX)
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
include(Platform/SerenityOS-GNU)
2+
__serenity_compiler_gnu(ASM)
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
include(Platform/SerenityOS-GNU)
2+
__serenity_compiler_gnu(C)
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
include(Platform/SerenityOS-GNU)
2+
__serenity_compiler_gnu(CXX)
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# This module is shared by multiple languages; use include blocker.
2+
include_guard()
3+
4+
set(CMAKE_EXE_LINKER_FLAGS_INIT "-Wl,--hash-style=gnu,-z,relro,-z,now,-z,noexecstack,-z,separate-code,-z,max-page-size=0x1000")
5+
6+
macro(__serenity_compiler_gnu lang)
7+
set(CMAKE_SHARED_LIBRARY_RUNTIME_${lang}_FLAG "-Wl,-rpath,")
8+
set(CMAKE_SHARED_LIBRARY_RUNTIME_${lang}_FLAG_SEP ":")
9+
set(CMAKE_SHARED_LIBRARY_RPATH_LINK_${lang}_FLAG "-Wl,-rpath-link,")
10+
set(CMAKE_SHARED_LIBRARY_SONAME_${lang}_FLAG "-Wl,-soname,")
11+
set(CMAKE_EXE_EXPORTS_${lang}_FLAG "-Wl,--export-dynamic")
12+
13+
set(CMAKE_SHARED_LIBRARY_CREATE_${lang}_FLAGS "-shared -Wl,--hash-style=gnu,-z,relro,-z,now,-z,noexecstack,-z,separate-code")
14+
15+
# Initialize link type selection flags. These flags are used when
16+
# building a shared library, shared module, or executable that links
17+
# to other libraries to select whether to use the static or shared
18+
# versions of the libraries.
19+
foreach(type SHARED_LIBRARY SHARED_MODULE EXE)
20+
set(CMAKE_${type}_LINK_STATIC_${lang}_FLAGS "-Wl,-Bstatic")
21+
set(CMAKE_${type}_LINK_DYNAMIC_${lang}_FLAGS "-Wl,-Bdynamic")
22+
endforeach()
23+
24+
endmacro()

0 commit comments

Comments
 (0)