Skip to content

Commit 9cb7545

Browse files
[Driver] Add option to force undefined symbols during linking in BareMetal toolchain object. (#132807)
Add support for `-u` option to force defined symbols. This option is supported by both lld and gnuld. This is done as a part of the effort to merge RISCVToolchain object into BareMetal toolchain object. This is the 4th patch in the series of patches for merging RISCVToolchain object into BareMetal toolchain object. RFC: https://discourse.llvm.org/t/merging-riscvtoolchain-and-baremetal-toolchains/75524
1 parent dd65e6e commit 9cb7545

File tree

3 files changed

+17
-8
lines changed

3 files changed

+17
-8
lines changed

clang/lib/Driver/ToolChains/BareMetal.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -609,8 +609,9 @@ void baremetal::Linker::ConstructJob(Compilation &C, const JobAction &JA,
609609
}
610610
}
611611

612-
Args.addAllArgs(CmdArgs, {options::OPT_L, options::OPT_T_Group,
613-
options::OPT_s, options::OPT_t, options::OPT_r});
612+
Args.addAllArgs(CmdArgs,
613+
{options::OPT_L, options::OPT_u, options::OPT_T_Group,
614+
options::OPT_s, options::OPT_t, options::OPT_r});
614615

615616
TC.AddFilePathLibArgs(Args, CmdArgs);
616617

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// Check the arguments are correctly passed
2+
3+
// Make sure -T is the last with gcc-toolchain option
4+
// RUN: %clang -### --target=riscv32 --gcc-toolchain= -Xlinker --defsym=FOO=10 -T a.lds -u foo %s 2>&1 \
5+
// RUN: | FileCheck -check-prefix=CHECK-LD %s
6+
// CHECK-LD: {{.*}} "--defsym=FOO=10" {{.*}} "-u" "foo" {{.*}} "-T" "a.lds"
7+
8+
// TODO: Merge this test with the above in the last patch when finally integrating riscv
9+
// Make sure -T is the last with gcc-toolchain option
10+
// RUN: %clang -### --target=aarch64-none-elf --gcc-toolchain= -Xlinker --defsym=FOO=10 -T a.lds -u foo %s 2>&1 \
11+
// RUN: | FileCheck -check-prefix=CHECK-ARM-LD %s
12+
// RUN: %clang -### --target=armv6m-none-eabi --gcc-toolchain= -Xlinker --defsym=FOO=10 -T a.lds -u foo %s 2>&1 \
13+
// RUN: | FileCheck -check-prefix=CHECK-ARM-LD %s
14+
// CHECK-ARM-LD: {{.*}} "-T" "a.lds" "-u" "foo" {{.*}} "--defsym=FOO=10"

clang/test/Driver/riscv-args.c

Lines changed: 0 additions & 6 deletions
This file was deleted.

0 commit comments

Comments
 (0)