Commit Graph

10 Commits

Author SHA1 Message Date
Harmen Stoppels 02f3e5be6a file(RPATH_CHANGE ...): no-op for static binary
Setting `CMAKE_INSTALL_RPATH` on a project that contains statically
linked executables breaks the install step, since rpaths cannot be
changed.

This commit makes rpath adjustments not an error on static libraries.

Fixes #26078
2024-06-24 11:32:30 -04:00
Harmen Stoppels ccbbf64552 Tests/RunCMake/file-RPATH: Prepare to cover statically linked binaries 2024-06-24 11:32:20 -04:00
Martin Duffy 615a1c6691 cmELF: Get correct section count for large ELF binaries
Fixes: #24877
2024-03-22 10:18:06 -04:00
Brad King 643fc46bdc file(RPATH): Restore tolerance of unknown formats if new RPATH is empty
Since commit 2e1149874d (cmSystemTools: Support multiple binary formats,
2021-06-14, v3.22.0-rc1~575^2) the `file(RPATH_...)` operations fail on
files that are not ELF or XCOFF format.  Previously the RPATH operations
tolerated files of unknown format if the goal was to produce a file with
an empty RPATH.  Restore this tolerance in order to support setting an
empty RPATH on GNU ld scripts.

Fixes: #22963
2021-12-01 12:58:11 -05:00
Alex Richardson 115ff6a347 cmELF: Include the ELF parsing code unconditionally
Now that the ELF definitions are provided on all platforms there is no
need to keep the CMake_USE_ELF_PARSER option.
2021-06-24 10:57:51 -04:00
Alex Richardson 5dfa3ddbe5 cmELF: Allow building without system ELF headers
Use ELF headers vendored in `Utilities/cmelf` to get the ELF constants
and types. Using the same ELF definition header for all compilation
targets allows removing some #ifdefs depending on the host OS since we
know all required ELF constants will always be present. To reduce the
size of this commit, the CMake_USE_ELF_PARSER definite will be removed
in a separate commit.

This allows me to use CMAKE_BUILD_WITH_INSTALL_RPATH=False and the Ninja
generator on macOS, whereas before it would always give me the following
error message (despite cross-compiling for an ELF-based platform):

```
The install of the <name> target requires changing an RPATH from
  the build tree, but this is not supported with the Ninja generator unless
  on an ELF-based platform.  The CMAKE_BUILD_WITH_INSTALL_RPATH variable may
  be set to avoid this relinking step.
```
2021-06-24 10:57:51 -04:00
Kyle Edwards 9f6cfe7169 file: Add undocumented RPATH_SET command 2021-06-04 08:52:01 -04:00
Brad King e017ba046c AIX: Enable XCOFF editing to replace RPATH on installation
Avoid relinking before installation.
2021-02-03 12:26:58 -05:00
Brad King 69e1d95a8a Tests: Add sample XCOFF binaries
Generate the binaries as follows:

    $ cat main.c
    int main(void) { return 0; }
    $ xlc -q64 -o xcoff64.bin -Wl,-blibpath:/sample/rpath:/usr/lib:/lib main.c
    $ strip -X 64 xcoff64.bin
    $ xlc -q32 -o xcoff32.bin -Wl,-blibpath:/sample/rpath:/usr/lib:/lib main.c
    $ strip -X 32 xcoff32.bin
2021-02-03 12:26:23 -05:00
Brad King f79d991dfd Tests: Convert CMake.ELF to RunCMake.file-RPATH ELF case 2021-02-03 12:26:02 -05:00