Skip to content

Commit

Permalink
macOS: Check for -ld_classic linker flag
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 601387358
Change-Id: I0af8da4d6dccccbaebb75d6b23947eab100f4b7a
  • Loading branch information
cblichmann authored and copybara-github committed Jan 25, 2024
1 parent e71954b commit 85c89a4
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions cmake/CompileOptions.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.

include(CheckLinkerFlag)

# These affect ABI and linking, so set them globally, even for dependencies
set(CMAKE_CXX_STANDARD_REQUIRED TRUE)
set(CMAKE_CXX_STANDARD 17)
Expand Down Expand Up @@ -62,11 +64,15 @@ if(UNIX)
add_compile_options(-gfull)
add_link_options(
-dead_strip
# Work around assertion failure with LTO symbols
# https://developer.apple.com/documentation/xcode-release-notes/xcode-15-release-notes#Linking
LINKER:-ld_classic
)

# Work around assertion failure with LTO symbols
# https://developer.apple.com/documentation/xcode-release-notes/xcode-15-release-notes#Linking
check_linker_flag(CXX "LINKER:-ld_classic" _binexport_ld_classic_supported)
if(_binexport_ld_classic_supported)
add_link_options(LINKER:-ld_classic)
endif()

# Suppress ranlib warnings "file has no symbols"
set(CMAKE_C_ARCHIVE_CREATE
"<CMAKE_AR> Scr <TARGET> <LINK_FLAGS> <OBJECTS>")
Expand Down

0 comments on commit 85c89a4

Please sign in to comment.