[PATCH] D105243: [cmake] Invoke strip without -l and with non-grouped flags.

Daniel Rodríguez Troitiño via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jun 30 16:06:12 PDT 2021


drodriguez created this revision.
drodriguez added reviewers: beanz, delcypher.
Herald added a subscriber: mgorny.
drodriguez requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

`llvm-strip` does not support `-l`. Apple's `strip` supports `-l`, but
it is not documented, and the latest code doesn't seem to do anything
meaningful. From the old source code drops it seems that `-l` was added
around version 795 of cctools and removed before 898. The code around
the flag usage in 795 talks about problems with kext and forcing the
execution of `ld -r`, which seems a behaviour that is not enforceable in
latest versions of cctools.

The `-l` flag was added in https://reviews.llvm.org/D15133 without a lot
of explanation.

Since the flag is not active, removing it should not modify the
behaviour for most people (except if someone is trying to compile LLVM
with a really old version of `strip`).

Additionally, break the invocation into two different flags, since
`llvm-strip` doesn't at the moment support grouped flags, and other
`strip` implementations should work the same no matter if grouped or
not.

Test Plan:

Using `strip` from Xcode 12.5 in Big Sur to strip the same binary (a
simple Hello World), using both `-Sxl` and `-Sx` produces exactly the
same binary.

Repeating the same process with `clang` results also in the same binary.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D105243

Files:
  llvm/cmake/modules/AddLLVM.cmake


Index: llvm/cmake/modules/AddLLVM.cmake
===================================================================
--- llvm/cmake/modules/AddLLVM.cmake
+++ llvm/cmake/modules/AddLLVM.cmake
@@ -2007,7 +2007,7 @@
       if(NOT CMAKE_STRIP)
         set(CMAKE_STRIP xcrun strip)
       endif()
-      set(strip_command COMMAND ${CMAKE_STRIP} -Sxl $<TARGET_FILE:${name}>)
+      set(strip_command COMMAND ${CMAKE_STRIP} -S -x $<TARGET_FILE:${name}>)
     else()
       set(strip_command COMMAND ${CMAKE_STRIP} -g -x $<TARGET_FILE:${name}>)
     endif()


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D105243.355715.patch
Type: text/x-patch
Size: 542 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210630/4c2962ce/attachment.bin>


More information about the llvm-commits mailing list