Skip to content

Commit 904895f

Browse files
committedDec 27, 2015
For FreeBSD on mips, pass -G options to the linker
Summary: On {mips,mipsel,mips64,mips64el}-freebsd, we need to pass any -G option to the linker. See also: https://gcc.gnu.org/onlinedocs/gcc/MIPS-Options.html#index-G-2007 This has been adapted from https://reviews.freebsd.org/D1190, with an added test case. Reviewers: theraven, atanasyan, emaste Subscribers: brooks, tomatabacu, cfe-commits, seanbruno, emaste Differential Revision: http://reviews.llvm.org/D9114 llvm-svn: 256461
1 parent 2f2625c commit 904895f

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed
 

‎clang/lib/Driver/Tools.cpp

+11
Original file line numberDiff line numberDiff line change
@@ -7885,6 +7885,17 @@ void freebsd::Linker::ConstructJob(Compilation &C, const JobAction &JA,
78857885
CmdArgs.push_back("elf32ppc_fbsd");
78867886
}
78877887

7888+
if (Arg *A = Args.getLastArg(options::OPT_G)) {
7889+
if (ToolChain.getArch() == llvm::Triple::mips ||
7890+
ToolChain.getArch() == llvm::Triple::mipsel ||
7891+
ToolChain.getArch() == llvm::Triple::mips64 ||
7892+
ToolChain.getArch() == llvm::Triple::mips64el) {
7893+
StringRef v = A->getValue();
7894+
CmdArgs.push_back(Args.MakeArgString("-G" + v));
7895+
A->claim();
7896+
}
7897+
}
7898+
78887899
if (Output.isFilename()) {
78897900
CmdArgs.push_back("-o");
78907901
CmdArgs.push_back(Output.getFilename());

‎clang/test/Driver/freebsd.c

+5
Original file line numberDiff line numberDiff line change
@@ -136,3 +136,8 @@
136136
// RUN: | FileCheck --check-prefix=CHECK-SPARC-CPU %s
137137
// CHECK-SPARC-CPU: cc1{{.*}}" "-target-cpu" "ultrasparc"
138138
// CHECK-SPARC-CPU: as{{.*}}" "-Av9
139+
140+
// Check that -G flags are passed to the linker for mips
141+
// RUN: %clang -target mips-unknown-freebsd %s -### -G0 2>&1 \
142+
// RUN: | FileCheck --check-prefix=CHECK-MIPS-G %s
143+
// CHECK-MIPS-G: ld{{.*}}" "-G0"

0 commit comments

Comments
 (0)