llvm12/clang-fuse-ld.patch
Eugene Shatokhin 7b77fc65f5 Sync to 2014.1
2014-12-19 11:29:21 +03:00

39 lines
2 KiB
Diff

--- llvm-3.5/tools/clang/include/clang/Driver/Options.td.fuseLd~ 2014-08-22 22:54:39.000000000 +0200
+++ llvm-3.5/tools/clang/include/clang/Driver/Options.td 2014-08-25 22:26:24.253526434 +0200
@@ -533,6 +533,7 @@ def funsafe_math_optimizations : Flag<["
Group<f_Group>;
def fno_unsafe_math_optimizations : Flag<["-"], "fno-unsafe-math-optimizations">,
Group<f_Group>;
+def fuse_ld_EQ : Joined<["-"], "fuse-ld=">, Group<f_Group>;
def fassociative_math : Flag<["-"], "fassociative-math">, Group<f_Group>;
def fno_associative_math : Flag<["-"], "fno-associative-math">, Group<f_Group>;
def freciprocal_math : Flag<["-"], "freciprocal-math">, Group<f_Group>;
@@ -1597,7 +1598,6 @@ def fprofile_dir : Joined<["-"], "fprofi
defm profile_use : BooleanFFlag<"profile-use">, Group<clang_ignored_gcc_optimization_f_Group>;
def fprofile_use_EQ : Joined<["-"], "fprofile-use=">, Group<clang_ignored_gcc_optimization_f_Group>;
-def fuse_ld_EQ : Joined<["-"], "fuse-ld=">, Group<f_Group>;
defm align_functions : BooleanFFlag<"align-functions">, Group<clang_ignored_gcc_optimization_f_Group>;
def falign_functions_EQ : Joined<["-"], "falign-functions=">, Group<clang_ignored_gcc_optimization_f_Group>;
--- llvm-3.5/tools/clang/lib/Driver/ToolChain.cpp.fuseLd~ 2014-08-22 22:54:39.000000000 +0200
+++ llvm-3.5/tools/clang/lib/Driver/ToolChain.cpp 2014-08-25 22:25:41.383062388 +0200
@@ -145,6 +145,18 @@ std::string ToolChain::GetFilePath(const
}
std::string ToolChain::GetProgramPath(const char *Name) const {
+ if(!strcmp(Name, "ld")) {
+ // Handle -fuse-ld=XXX the way gcc does
+ if (Arg *A = Args.getLastArg(options::OPT_fuse_ld_EQ)) {
+ StringRef Value = A->getValue();
+ if(Value.empty())
+ return D.GetProgramPath(Name, *this);
+ const char *suffix = Value.str().c_str();
+ char *newName = (char *) alloca(strlen(Name) + strlen(suffix) + 2);
+ sprintf(newName, "%s.%s", Name, suffix);
+ return D.GetProgramPath(newName, *this);
+ }
+ }
return D.GetProgramPath(Name, *this);
}