[PATCH] Support Solaris unused sections' gc link syntax

Xan López xan at igalia.com
Fri Jun 19 03:35:06 PDT 2015


-Wl,--gc-sections is not supported by Solaris' linker, which makes the build fail. Use the right syntax for the job.
-------------- next part --------------
>From d34adad408ddcc9d77c1fcc75162cafec6f9e354 Mon Sep 17 00:00:00 2001
From: Xan Lopez <xan at igalia.com>
Date: Thu, 18 Jun 2015 09:51:16 -0400
Subject: [PATCH] AddLLVM: support Solaris ld syntax

Use the right syntax in Solaris to gc unused sections.
---
 cmake/modules/AddLLVM.cmake | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/cmake/modules/AddLLVM.cmake b/cmake/modules/AddLLVM.cmake
index ba14761..571339f 100644
--- a/cmake/modules/AddLLVM.cmake
+++ b/cmake/modules/AddLLVM.cmake
@@ -182,6 +182,9 @@ function(add_link_opts target_name)
         # ld64's implementation of -dead_strip breaks tools that use plugins.
         set_property(TARGET ${target_name} APPEND_STRING PROPERTY
                      LINK_FLAGS " -Wl,-dead_strip")
+      elseif(${CMAKE_SYSTEM_NAME} MATCHES "SunOS")
+        set_property(TARGET ${target_name} APPEND_STRING PROPERTY
+                     LINK_FLAGS " -Wl,-z -Wl,discard-unused=sections")
       elseif(NOT WIN32 AND NOT LLVM_LINKER_IS_GOLD)
         # Object files are compiled with -ffunction-data-sections.
         # Versions of bfd ld < 2.23.1 have a bug in --gc-sections that breaks
-- 
2.4.3



More information about the llvm-commits mailing list