-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Improve objcopy detection #71742
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve objcopy detection #71742
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -51,13 +51,16 @@ if(NOT WIN32 AND NOT CLR_CMAKE_TARGET_BROWSER) | |
| locate_toolchain_exec(objdump CMAKE_OBJDUMP) | ||
| locate_toolchain_exec(objcopy CMAKE_OBJCOPY) | ||
|
|
||
| execute_process( | ||
| COMMAND ${CMAKE_OBJCOPY} --help | ||
| OUTPUT_VARIABLE OBJCOPY_HELP_OUTPUT | ||
| ) | ||
|
|
||
| if(CLR_CMAKE_TARGET_ANDROID) | ||
| set(TOOLSET_PREFIX ${ANDROID_TOOLCHAIN_PREFIX}) | ||
| elseif(CMAKE_CROSSCOMPILING AND NOT DEFINED CLR_CROSS_COMPONENTS_BUILD AND | ||
| CMAKE_SYSTEM_PROCESSOR MATCHES "^(armv8l|armv7l|armv6l|aarch64|arm|s390x|ppc64le)$") | ||
| set(TOOLSET_PREFIX "${TOOLCHAIN}-") | ||
| endif() | ||
| # if llvm-objcopy does not support --only-keep-debug argument, try to locate binutils' objcopy | ||
| if (CMAKE_C_COMPILER_ID MATCHES "Clang" AND NOT "${OBJCOPY_HELP_OUTPUT}" MATCHES "--only-keep-debug") | ||
| set(TOOLSET_PREFIX "") | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. llvm also has a
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. My test was: $ docker run -it ubuntu:18.04
# inside the container, install different versions
$ apt update; apt install -y llvm-6 llvm-7 llvm-8 llvm-9 llvm-10
# test for only-keep-debug
# v6 - desired argument is unsupported
$ llvm-objcopy-6.0 --help | grep only-keep-debug
# nothing found
# v7 - supported with single hyphen but is a no-op
$ llvm-objcopy-7 --help | grep only-keep-debug
-only-keep-debug Currently ignored. Only for compaitability with GNU objcopy.
# v8 - same as v7
$ llvm-objcopy-8 --help | grep only-keep-debug
-only-keep-debug Currently ignored. Only for compatibility with GNU objcopy.
# v9 - supported with double hyphen
$ llvm-objcopy-9 --help | grep only-keep-debug
--only-keep-debug Clear sections that would not be stripped by --strip-debug. Currently only implemented for COFF.
# v10 - same as v9
$ llvm-objcopy-10 --help | grep only-keep-debug
--only-keep-debug Produce a debug file as the output that only preserves contents of sections useful for debugging purposesWe want only-keep-debug for consistent output; avoid binary size bloat and avoid repeating issues like #49081. Therefore, we fallback to binutils' objcopy when llvm-objcopy is incapable of stripping the symbols. As you can see above, versions of llvm-objcopy which support double hyphened argument provide non-nop functionality. |
||
| locate_toolchain_exec(objcopy CMAKE_OBJCOPY) | ||
| endif () | ||
|
|
||
| endif() | ||
| endif() | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This block was unused.