aminya / aminya/setup-cpp

Add linker tools

Open
#289 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
Dominant language
TypeScript
Stars
276
Forks
37
Avg merge
1d 4h
Merged PRs (30d)
12

Description

Tasks

  • lld can be easily added as it is already supported. We just need to add a CLI and actions option for it. It should be treated the same as clangtidy, etc.
  • mold
  • sold
  • gold

Description

Hi,
I was using setup-cpp with project_options (in my docker build) and custemize the linker option, see find_linker.

Would be nice to install mold or one of the other (better) Linker, rather then (gcc) ld or gold.

image
Improving C++ Compilation Times: Tools & Techniques - Vittorio Romeo - ACCU 2023

So install (?) ...

  • mold (e.g. when compiler is gcc)
  • lld when compiler is llvm (default)
  • sold for Mac OS
  • windows: ???
npx setup-cpp --compiler gcc --linker mold --cmake true --ninja true --ccache true --vcpkg true

More Context

I was getting this Error: /usr/bin/ld.gold: separate-code: unknown -z option.

CMakeOptions.cmake

find_linker(PROJECT_OPTIONS_LINKER)
MESSAGE(STATUS "Use Linker: ${PROJECT_OPTIONS_LINKER}")
project_options(
  ...
  LINKER
  ${PROJECT_OPTIONS_LINKER})
Compiler found: /usr/bin/g++-13
Use Linker: gold

After that I just installed mold and everything works:

RUN apt-get update -qq && \
    # install nodejs
    apt-get install -y --no-install-recommends nodejs npm && \
    # install setup-cpp
    npm install -g setup-cpp@v0.41.0 && \
    # install the compiler and tools
    setup-cpp \
        --nala true \
        --compiler ${compiler} \
        --cmake true \
        --ninja true \
        --task true \
        --vcpkg true \
        --cppcheck true \
        --gcovr true \
        --doxygen true \
        --ccache true && \
    # install custom linker
    apt-get install -y --no-install-recommends mold && \
    # cleanup
    nala autoremove -y && \
    nala autopurge -y && \
    apt-get clean && \
    nala clean --lists && \
    rm -rf /var/lib/apt/lists/* && \
    rm -rf /tmp/*

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 by tracing the setup-cpp CLI and GitHub Actions option handling for compiler tools, comparing the existing clangtidy-style support mentioned in the task. Review the CMakeOptions.cmake and find_linker usage shown in the issue, then define installation and selection behavior for lld, mold, sold, and gold across the stated platforms. Done means the requested linker options can be selected through the CLI and actions configuration.

Written by the indexing model from the issue text.

Assessment

Tech stack
cmake, cpp, github-actions, typescript
Domain
build-system, ci-cd, tooling
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.