Skip to content

Commit

Permalink
fix(ci): fix relocation overflow
Browse files Browse the repository at this point in the history
GitOrigin-RevId: df78532d5bf8238a8135f8f9e24765ccd83d0e5d
  • Loading branch information
megvii-mge committed Mar 21, 2024
1 parent dc24f9c commit 1b87c4a
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
15 changes: 14 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,8 @@ if(NOT MGE_WITH_MIDOUT_PROFILE AND NOT WIN32)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -include ${BIN_REDUCE}")
endif()

check_cxx_compiler_flag(-fuse-ld=gold CXX_SUPPORT_GOLD)

if(NOT APPLE)
# check CXX_FUNCTION_DATA_GC_SECTIONS_SUPPORT on APPLE will leak cmake crash
check_cxx_compiler_flag("-ffunction-sections -fdata-sections -Wl,--gc-sections"
Expand All @@ -235,12 +237,24 @@ if(NOT APPLE)
# ANDROID
check_cxx_compiler_flag("-Wl,-z,nocopyreloc -Wl,--icf=all -fuse-ld=lld"
LINKER_SUPPORT_Z_NOCOPYRELOC_ICF_ALL)
check_cxx_compiler_flag("-Wl,-z,nocopyreloc -Wl,--icf=safe"
LINKER_SUPPORT_Z_NOCOPYRELOC_ICF_SAFE_NO_LLD)
if(LINKER_SUPPORT_Z_NOCOPYRELOC_ICF_ALL AND (ANDROID OR OHOS))
message(STATUS "icf is supported in this compiler")
set(CMAKE_EXE_LINKER_FLAGS
"${CMAKE_EXE_LINKER_FLAGS} -Wl,-z,nocopyreloc -Wl,--icf=all -fuse-ld=lld")
set(CMAKE_SHARED_LINKER_FLAGS
"${CMAKE_SHARED_LINKER_FLAGS} -Wl,-z,nocopyreloc -Wl,--icf=all -fuse-ld=lld")
elseif(LINKER_SUPPORT_Z_NOCOPYRELOC_ICF_SAFE_NO_LLD)
message(STATUS "icf=safe is supported in this compiler without lld")
set(CMAKE_EXE_LINKER_FLAGS
"${CMAKE_EXE_LINKER_FLAGS} -Wl,-z,nocopyreloc -Wl,--icf=safe")
set(CMAKE_SHARED_LINKER_FLAGS
"${CMAKE_SHARED_LINKER_FLAGS} -Wl,-z,nocopyreloc -Wl,--icf=safe")
if(CMAKE_SYSTEM_NAME MATCHES "Linux")
add_compile_options($<$<COMPILE_LANGUAGE:C>:-fPIC>)
add_compile_options($<$<COMPILE_LANGUAGE:CXX>:-fPIC>)
endif()
endif()

endif()
Expand Down Expand Up @@ -561,7 +575,6 @@ if(MGE_WITH_CUDA)
set(MGE_WITH_LARGE_ARCHIVE ON)
endif()
endif()
check_cxx_compiler_flag(-fuse-ld=gold CXX_SUPPORT_GOLD)
if(MGE_WITH_LARGE_ARCHIVE)
message(STATUS "Set -mcmodel=large and disable -fuse-ld=gold")
set(MGE_COMMON_LINKER_FLAGS "-mcmodel=large")
Expand Down
2 changes: 1 addition & 1 deletion scripts/whl/manylinux2014/Dockerfile_aarch64_ubuntu2004
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ RUN cd /tmp ; wget https://cmake.org/files/v3.15/cmake-3.15.2.tar.gz;tar -xzvf c

# install base python3
RUN apt-get install -y python3
RUN apt-get install -y python3-dev python3-pip python3-numpy python3-setuptools
RUN apt-get update -y && apt-get install --fix-missing && apt-get install -y python3-dev python3-pip python3-numpy python3-setuptools

# install pyenv
RUN curl https://pyenv.run | bash
Expand Down

0 comments on commit 1b87c4a

Please sign in to comment.