diff --git a/clang/lib/Driver/ToolChains/RISCVToolchain.cpp b/clang/lib/Driver/ToolChains/RISCVToolchain.cpp --- a/clang/lib/Driver/ToolChains/RISCVToolchain.cpp +++ b/clang/lib/Driver/ToolChains/RISCVToolchain.cpp @@ -184,6 +184,7 @@ AddLinkerInputs(ToolChain, Inputs, Args, CmdArgs, JA); Args.AddAllArgs(CmdArgs, options::OPT_L); + Args.AddAllArgs(CmdArgs, options::OPT_u); ToolChain.AddFilePathLibArgs(Args, CmdArgs); Args.AddAllArgs(CmdArgs, {options::OPT_T_Group, options::OPT_e, options::OPT_s, diff --git a/clang/test/Driver/riscv-args.c b/clang/test/Driver/riscv-args.c --- a/clang/test/Driver/riscv-args.c +++ b/clang/test/Driver/riscv-args.c @@ -5,3 +5,8 @@ // RUN: --gcc-toolchain= -Xlinker --defsym=FOO=10 -T a.lds %s 2>&1 \ // RUN: | FileCheck -check-prefix=CHECK-LD %s // CHECK-LD: {{.*}} "--defsym=FOO=10" {{.*}} "-T" "a.lds" + +// Make sure -u has passed to linker +// RUN: %clang -### -target riscv32 --gcc-toolchain= -u foo %s 2>&1 \ +// RUN: | FileCheck -check-prefix=CHECK-U-LD %s +// CHECK-U-LD: {{.*}} "-u" "foo"