Skip to content

Commit 30cbc34

Browse files
committed
fix: add MIPS-specific compiler flag to avoid GOT overflow
MIPS architecture and globally applies the `-mxgot` flag to compiler settings to address potential GOT overflow issues caused by the architecture's strict limitations on GOT size.
1 parent d8a3191 commit 30cbc34

1 file changed

Lines changed: 12 additions & 2 deletions

File tree

CMakeLists.txt

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,7 @@ set(LINGLONG_EXPORT_PATH
6161
if(NOT LINGLONG_EXPORT_PATH MATCHES ".*share$")
6262
message(
6363
WARNING
64-
"LINGLONG_EXPORT_PATH '${LINGLONG_EXPORT_PATH}' must end with 'share'"
65-
)
64+
"LINGLONG_EXPORT_PATH '${LINGLONG_EXPORT_PATH}' must end with 'share'")
6665
set(LINGLONG_EXPORT_PATH "share")
6766
endif()
6867

@@ -131,6 +130,17 @@ endif()
131130

132131
set(linglong_EXTERNALS "ytj ytj::ytj")
133132

133+
if(CMAKE_SYSTEM_PROCESSOR MATCHES "^mips" OR CMAKE_SYSTEM_PROCESSOR MATCHES
134+
"^MIPS")
135+
message(
136+
STATUS
137+
"MIPS architecture detected. Globally adding -mxgot to CMAKE_CXX_FLAGS.")
138+
139+
set(CMAKE_CXX_FLAGS
140+
"${CMAKE_CXX_FLAGS} -mxgot"
141+
CACHE STRING "C++ compiler flags" FORCE)
142+
endif()
143+
134144
# NOTE: UOS v20 do not have tl-expected packaged.
135145
find_package(tl-expected 1.0.0 QUIET)
136146
if(NOT tl-expected_FOUND)

0 commit comments

Comments
 (0)