[all-commits] [llvm/llvm-project] a17f63: Reland [Driver] Fix link order of BareMetal toolc...

Garvit Gupta via All-commits all-commits at lists.llvm.org
Sun Jun 29 20:17:58 PDT 2025


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: a17f63590ac077a5705c9bed8d4e025b3ef4b299
      https://github.com/llvm/llvm-project/commit/a17f63590ac077a5705c9bed8d4e025b3ef4b299
  Author: Garvit Gupta <quic_garvgupt at quicinc.com>
  Date:   2025-06-30 (Mon, 30 Jun 2025)

  Changed paths:
    M clang/lib/Driver/ToolChains/BareMetal.cpp
    M clang/test/Driver/aarch64-toolchain-extra.c
    M clang/test/Driver/aarch64-toolchain.c
    M clang/test/Driver/arm-toolchain-extra.c
    M clang/test/Driver/arm-toolchain.c
    M clang/test/Driver/baremetal-multilib.yaml
    M clang/test/Driver/baremetal-sysroot.cpp
    M clang/test/Driver/baremetal.cpp

  Log Message:
  -----------
  Reland  [Driver] Fix link order of BareMetal toolchain object (#146291)

The linker job in BareMetal toolchain object will be used by GNU ld and
lld both.
However, gnuld process the arguments in the order in which they appear
on command
line, whereas there is no such restriction with lld.

The previous order was:
LibraryPaths -> Libraries -> LTOOptions -> LinkerInputs The new order
is:
LibraryPaths -> LTOOptions -> LinkerInputs -> Libraries

LTO options need to be added before adding any linker inputs because
file format
after compile stage during LTO is bitcode which gnuld natively cannot
process.
Hence will need to pass appropriate plugins before adding any bitcode
file on the
command line.

Object files that are getting linked need to be passed before processing
any
libraries so that gnuld can appropriately do symbol resolution for the
symbols
for which no definition is provided through user code.

Similar link order is also followed by other linker jobs for gnuld such
as in
gnutools::Linker in Gnu.cpp

This is the 3rd patch in the series of patches of merging RISCVToolchain
into
BareMetal toolchain object.

RFC:
https:
//discourse.llvm.org/t/merging-riscvtoolchain-and-baremetal-toolchains/75524



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list