[all-commits] [llvm/llvm-project] 31523d: [Driver] Fix link order of BareMetal toolchain obj...

Garvit Gupta via All-commits all-commits at lists.llvm.org
Tue Jun 17 11:13:28 PDT 2025


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 31523de4b000ca254259ae3167d28922e1302648
      https://github.com/llvm/llvm-project/commit/31523de4b000ca254259ae3167d28922e1302648
  Author: Garvit Gupta <quic_garvgupt at quicinc.com>
  Date:   2025-06-17 (Tue, 17 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:
  -----------
  [Driver] Fix link order of BareMetal toolchain object (#132806)

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