Skip to content

Ubuntu GCC 15 defaults to -Wa,-gsframe, causing "relocation refers to a discarded section: " linker errorΒ #156667

@mstorsjo

Description

@mstorsjo

This can be reproduced by building LLVM itself, with GCC 15. Not sure if this specifically is caused by GCC 15 or something else. It can be reproduced on Ubuntu 25.10 at least.

It's easily reproducible in almost any environment, with the following docker file:

FROM ubuntu:25.10

RUN apt-get update -qq && \
    DEBIAN_FRONTEND="noninteractive" apt-get install -qqy --no-install-recommends \
    git build-essential lld cmake ninja-build ca-certificates python3 && \
    apt-get clean -y && \
    rm -rf /var/lib/apt/lists/*

WORKDIR /build

RUN git clone -b release/21.x --depth 1 https://github.com/llvm/llvm-project

RUN cd llvm-project/llvm && \
    mkdir build && \
    cd build && \
    cmake .. \
        -G Ninja \
        -DCMAKE_BUILD_TYPE=Release \
        -DLLVM_TARGETS_TO_BUILD=X86 \
        -DLLVM_USE_LINKER=lld && \
    ninja llc

Currently, this ends up with:

ld.lld: error: relocation refers to a discarded section: .text._ZN4llvm7remarks14EndOfFileErrorD2Ev
>>> defined in lib/libLLVMRemarks.a(YAMLRemarkParser.cpp.o)
>>> referenced by YAMLRemarkParser.cpp
>>>               YAMLRemarkParser.cpp.o:(.sframe+0x1c) in archive lib/libLLVMRemarks.a

[... multiple similar errors ...]

Compiling the source with Clang rather than with the distro-provided GCC 15, or by not passing -DLLVM_USE_LINKER=lld, avoids the issue.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions