Index: lib/Driver/ToolChains/Gnu.cpp =================================================================== --- lib/Driver/ToolChains/Gnu.cpp +++ lib/Driver/ToolChains/Gnu.cpp @@ -2554,7 +2554,9 @@ getTriple().getOS() == llvm::Triple::NaCl || (getTriple().getVendor() == llvm::Triple::MipsTechnologies && !getTriple().hasEnvironment()) || - getTriple().getOS() == llvm::Triple::Solaris; + getTriple().getOS() == llvm::Triple::Solaris || + getTriple().getArch() == llvm::Triple::riscv32 || + getTriple().getArch() == llvm::Triple::riscv64; if (DriverArgs.hasFlag(options::OPT_fuse_init_array, options::OPT_fno_use_init_array, UseInitArrayDefault)) Index: test/Driver/riscv32-toolchain.c =================================================================== --- test/Driver/riscv32-toolchain.c +++ test/Driver/riscv32-toolchain.c @@ -9,6 +9,7 @@ // RUN: --sysroot=%S/Inputs/basic_riscv32_tree/riscv32-unknown-elf 2>&1 \ // RUN: | FileCheck -check-prefix=C-RV32-BAREMETAL-ILP32 %s +// C-RV32-BAREMETAL-ILP32: "-fuse-init-array" // C-RV32-BAREMETAL-ILP32: "{{.*}}Inputs/basic_riscv32_tree/lib/gcc/riscv32-unknown-elf/8.0.1/../../../../bin{{/|\\\\}}riscv32-unknown-elf-ld" // C-RV32-BAREMETAL-ILP32: "--sysroot={{.*}}/Inputs/basic_riscv32_tree/riscv32-unknown-elf" // C-RV32-BAREMETAL-ILP32: "{{.*}}/Inputs/basic_riscv32_tree/riscv32-unknown-elf/lib{{/|\\\\}}crt0.o" @@ -24,6 +25,7 @@ // RUN: --sysroot=%S/Inputs/basic_riscv32_tree/riscv32-unknown-elf 2>&1 \ // RUN: | FileCheck -check-prefix=CXX-RV32-BAREMETAL-ILP32 %s +// CXX-RV32-BAREMETAL-ILP32: "-fuse-init-array" // CXX-RV32-BAREMETAL-ILP32: "-internal-isystem" "{{.*}}Inputs/basic_riscv32_tree/lib/gcc/riscv32-unknown-elf/8.0.1/../../../../riscv32-unknown-elf/include/c++{{/|\\\\}}8.0.1" // CXX-RV32-BAREMETAL-ILP32: "{{.*}}Inputs/basic_riscv32_tree/lib/gcc/riscv32-unknown-elf/8.0.1/../../../../bin{{/|\\\\}}riscv32-unknown-elf-ld" // CXX-RV32-BAREMETAL-ILP32: "--sysroot={{.*}}/Inputs/basic_riscv32_tree/riscv32-unknown-elf" @@ -40,6 +42,7 @@ // RUN: --sysroot=%S/Inputs/multilib_riscv_linux_sdk/sysroot 2>&1 \ // RUN: | FileCheck -check-prefix=C-RV32-LINUX-MULTI-ILP32 %s +// C-RV32-LINUX-MULTI-ILP32: "-fuse-init-array" // C-RV32-LINUX-MULTI-ILP32: "{{.*}}/Inputs/multilib_riscv_linux_sdk/lib/gcc/riscv64-unknown-linux-gnu/7.2.0/../../../../riscv64-unknown-linux-gnu/bin{{/|\\\\}}ld" // C-RV32-LINUX-MULTI-ILP32: "--sysroot={{.*}}/Inputs/multilib_riscv_linux_sdk/sysroot" // C-RV32-LINUX-MULTI-ILP32: "-m" "elf32lriscv" @@ -55,6 +58,7 @@ // RUN: --sysroot=%S/Inputs/multilib_riscv_linux_sdk/sysroot 2>&1 \ // RUN: | FileCheck -check-prefix=C-RV32-LINUX-MULTI-ILP32D %s +// C-RV32-LINUX-MULTI-ILP32D: "-fuse-init-array" // C-RV32-LINUX-MULTI-ILP32D: "{{.*}}/Inputs/multilib_riscv_linux_sdk/lib/gcc/riscv64-unknown-linux-gnu/7.2.0/../../../../riscv64-unknown-linux-gnu/bin{{/|\\\\}}ld" // C-RV32-LINUX-MULTI-ILP32D: "--sysroot={{.*}}/Inputs/multilib_riscv_linux_sdk/sysroot" // C-RV32-LINUX-MULTI-ILP32D: "-m" "elf32lriscv"