llnl / llnl/blt

Link options from MPI compiler wrapper collapsed incorrectly (CMake 3.13+)

Open
#294 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C++
Stars
296
Forks
66
Avg merge
1h 3m
Merged PRs (30d)
1

Description

CMake: 3.14.3
BLT: https://github.com/LLNL/blt/commit/938345715810c6457d3e57a2c20d4ee0fa253632

When using e.g. Intel MPI, link flags obtained from mpicc may look like the following:

-Xlinker -rpath -Xlinker /path/to/A -Xlinker -rpath -Xlinker /path/to/B -Xlinker -rpath -Xlinker /path/to/C ...

After the link options are set on the target in blt_add_target_link_flags via LINK_OPTIONS, the resulting command line looks like:

-Xlinker -rpath /path/to/A /path/to/B /path/to/C ...

which is incorrect. This is because CMake removes duplicates, as per documentation.

Unless there is a way to pass the link flags verbatim (as opposed to splitting and adding one by one), perhaps the correct treatment would be:

  1. Collect and concatenate all consecutive options that have a preceding -Xlinker into a comma-separated string
  2. Add the resulting string with a LINKER: prefix.

So we end up adding

LINKER:-rpath,/path/to/A,-rpath,/path/to/B,-rpath,/path/to/C

as a single link option, which CMake translates back into the correct string (using -Xlinker or -Wl syntax, as appropriate).

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at blt_add_target_link_flags and reproduce the issue with the Intel MPI-style flags shown in the report under CMake 3.14.3. Check how LINK_OPTIONS handles repeated -Xlinker arguments, then verify that the generated command preserves each rpath option and path rather than collapsing them.

Written by the indexing model from the issue text.

Assessment

Tech stack
cmake, cpp
Domain
build-system
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.