Lines Matching refs:Args
44 static void CheckPreprocessingOptions(const Driver &D, const ArgList &Args) {
45 if (Arg *A = Args.getLastArg(options::OPT_C, options::OPT_CC))
46 if (!Args.hasArg(options::OPT_E) && !D.CCCIsCPP)
48 << A->getAsString(Args) << "-E";
53 static void CheckCodeGenerationOptions(const Driver &D, const ArgList &Args) {
55 if (Args.hasArg(options::OPT_static))
56 if (const Arg *A = Args.getLastArg(options::OPT_dynamic,
59 << A->getAsString(Args) << "-static";
91 static void addDirectoryList(const ArgList &Args,
110 CmdArgs.push_back(Args.MakeArgString(Dirs.substr(0, Delim)));
120 CmdArgs.push_back(Args.MakeArgString(Dirs));
125 const InputInfoList &Inputs, const ArgList &Args,
131 Args.AddAllArgValues(CmdArgs, options::OPT_Zlinker_input);
158 TC.AddCXXStdlibLibArgs(Args, CmdArgs);
160 TC.AddCCKextLibArgs(Args, CmdArgs);
162 A.renderAsInput(Args, CmdArgs);
166 addDirectoryList(Args, CmdArgs, "-L", "LIBRARY_PATH");
171 static bool isObjCAutoRefCount(const ArgList &Args) {
172 return Args.hasFlag(options::OPT_fobjc_arc, options::OPT_fno_objc_arc, false);
176 static bool isObjCRuntimeLinked(const ArgList &Args) {
177 if (isObjCAutoRefCount(Args))
179 return Args.hasArg(options::OPT_fobjc_link_runtime);
182 static void addProfileRT(const ToolChain &TC, const ArgList &Args,
185 if (!(Args.hasArg(options::OPT_fprofile_arcs) ||
186 Args.hasArg(options::OPT_fprofile_generate) ||
187 Args.hasArg(options::OPT_fcreate_profile) ||
188 Args.hasArg(options::OPT_coverage)))
198 CmdArgs.push_back(Args.MakeArgString(ProfileRT));
203 const ArgList &Args,
209 CheckPreprocessingOptions(D, Args);
211 Args.AddLastArg(CmdArgs, options::OPT_C);
212 Args.AddLastArg(CmdArgs, options::OPT_CC);
215 if ((A = Args.getLastArg(options::OPT_M, options::OPT_MM)) ||
216 (A = Args.getLastArg(options::OPT_MD)) ||
217 (A = Args.getLastArg(options::OPT_MMD))) {
222 } else if (Arg *MF = Args.getLastArg(options::OPT_MF)) {
223 DepFile = MF->getValue(Args);
229 DepFile = darwin::CC1::getDependencyFileName(Args, Inputs);
236 if (!Args.hasArg(options::OPT_MT) && !Args.hasArg(options::OPT_MQ)) {
241 Arg *OutputOpt = Args.getLastArg(options::OPT_o);
243 DepTarget = OutputOpt->getValue(Args);
250 DepTarget = Args.MakeArgString(llvm::sys::path::filename(P));
256 CmdArgs.push_back(Args.MakeArgString(Quoted));
264 if (Args.hasArg(options::OPT_MG)) {
271 Args.AddLastArg(CmdArgs, options::OPT_MP);
273 // Convert all -MQ <target> args to -MT <quoted target>
274 for (arg_iterator it = Args.filtered_begin(options::OPT_MT,
276 ie = Args.filtered_end(); it != ie; ++it) {
283 QuoteTarget(A->getValue(Args), Quoted);
284 CmdArgs.push_back(Args.MakeArgString(Quoted));
288 A->render(Args, CmdArgs);
298 for (arg_iterator it = Args.filtered_begin(options::OPT_clang_i_Group),
299 ie = Args.filtered_end(); it != ie; ++it) {
311 llvm::sys::Path P(A->getValue(Args));
346 CmdArgs.push_back(Args.MakeArgString(P.str()));
351 << P.str() << A->getAsString(Args);
358 A->render(Args, CmdArgs);
361 Args.AddAllArgs(CmdArgs, options::OPT_D, options::OPT_U);
362 Args.AddAllArgs(CmdArgs, options::OPT_I_Group, options::OPT_F,
371 Args.AddAllArgValues(CmdArgs, options::OPT_Wp_COMMA,
375 if (Arg *A = Args.getLastArg(options::OPT_I_))
376 D.Diag(diag::err_drv_I_dash_not_supported) << A->getAsString(Args);
382 if (!Args.hasArg(options::OPT_isysroot)) {
390 if (Arg *A = Args.getLastArg(options::OPT_fmodule_cache_path)) {
392 A->render(Args, CmdArgs);
399 CmdArgs.push_back(Args.MakeArgString(DefaultModuleCache));
407 addDirectoryList(Args, CmdArgs, "-I", "CPATH");
409 addDirectoryList(Args, CmdArgs, "-c-isystem", "C_INCLUDE_PATH");
411 addDirectoryList(Args, CmdArgs, "-cxx-isystem", "CPLUS_INCLUDE_PATH");
413 addDirectoryList(Args, CmdArgs, "-objc-isystem", "OBJC_INCLUDE_PATH");
415 addDirectoryList(Args, CmdArgs, "-objcxx-isystem", "OBJCPLUS_INCLUDE_PATH");
419 getToolChain().AddClangCXXStdlibIncludeArgs(Args, CmdArgs);
422 getToolChain().AddClangSystemIncludeArgs(Args, CmdArgs);
428 static const char *getARMTargetCPU(const ArgList &Args,
433 if (Arg *A = Args.getLastArg(options::OPT_mcpu_EQ))
434 return A->getValue(Args);
437 if (Arg *A = Args.getLastArg(options::OPT_march_EQ)) {
439 MArch = A->getValue(Args);
512 static void addFPUArgs(const Driver &D, const Arg *A, const ArgList &Args,
514 StringRef FPU = A->getValue(Args);
546 D.Diag(diag::err_drv_clang_unsupported) << A->getAsString(Args);
550 static void addFPMathArgs(const Driver &D, const Arg *A, const ArgList &Args,
552 StringRef FPMath = A->getValue(Args);
569 D.Diag(diag::err_drv_clang_unsupported) << A->getAsString(Args);
575 const ArgList &Args,
578 if (Arg *A = Args.getLastArg(options::OPT_msoft_float,
586 FloatABI = A->getValue(Args);
589 << A->getAsString(Args);
605 getLLVMArchSuffixForARM(getARMTargetCPU(Args, Triple));
632 getLLVMArchSuffixForARM(getARMTargetCPU(Args, Triple));
652 void Clang::AddARMTargetArgs(const ArgList &Args,
662 if (Arg *A = Args.getLastArg(options::OPT_mabi_EQ)) {
663 ABIName = A->getValue(Args);
683 CmdArgs.push_back(getARMTargetCPU(Args, Triple));
686 StringRef FloatABI = getARMFloatABI(D, Args, Triple);
724 if (const Arg *A = Args.getLastArg(options::OPT_mfpu_EQ))
725 addFPUArgs(D, A, Args, CmdArgs);
728 if (const Arg *A = Args.getLastArg(options::OPT_mfpmath_EQ))
729 addFPMathArgs(D, A, Args, CmdArgs, getARMTargetCPU(Args, Triple));
753 if (Arg *A = Args.getLastArg(options::OPT_mglobal_merge,
802 static void getMipsCPUAndABI(const ArgList &Args,
809 if (Arg *A = Args.getLastArg(options::OPT_mcpu_EQ)) {
810 CPUName = A->getValue(Args);
814 ArchName = Args.MakeArgString(TC.getArchName());
822 if (Arg *A = Args.getLastArg(options::OPT_mabi_EQ))
823 ABIName = A->getValue(Args);
828 void Clang::AddMIPSTargetArgs(const ArgList &Args,
833 getMipsCPUAndABI(Args, getToolChain(), CPUName, ABIName);
844 if (Arg *A = Args.getLastArg(options::OPT_msoft_float,
852 FloatABI = A->getValue(Args);
855 << A->getAsString(Args);
895 void Clang::AddSparcTargetArgs(const ArgList &Args,
899 if (const Arg *A = Args.getLastArg(options::OPT_march_EQ)) {
901 CmdArgs.push_back(A->getValue(Args));
906 if (Arg *A = Args.getLastArg(options::OPT_msoft_float,
938 void Clang::AddX86TargetArgs(const ArgList &Args,
940 if (!Args.hasFlag(options::OPT_mred_zone,
943 Args.hasArg(options::OPT_mkernel) ||
944 Args.hasArg(options::OPT_fapple_kext))
947 if (Args.hasFlag(options::OPT_msoft_float,
953 if (const Arg *A = Args.getLastArg(options::OPT_march_EQ)) {
954 if (StringRef(A->getValue(Args)) == "native") {
962 CPUName = Args.MakeArgString(CPU);
964 CPUName = A->getValue(Args);
1016 for (arg_iterator it = Args.filtered_begin(options::OPT_m_x86_Features_Group),
1017 ie = Args.filtered_end(); it != ie; ++it) {
1033 Features.push_back(Args.MakeArgString((IsNegative ? "-" : "+") + Name));
1043 static Arg* getLastHexagonArchArg (const ArgList &Args)
1047 for (ArgList::const_iterator it = Args.begin(), ie = Args.end();
1055 StringRef Value = (*it)->getValue(Args,0);
1065 static StringRef getHexagonTargetCPU(const ArgList &Args)
1071 if ((A = getLastHexagonArchArg (Args))) {
1072 WhichHexagon = A->getValue(Args);
1082 void Clang::AddHexagonTargetArgs(const ArgList &Args,
1087 CmdArgs.push_back(Args.MakeArgString("hexagon" + getHexagonTargetCPU(Args)));
1091 if (Args.hasArg(options::OPT_mqdsp6_compat))
1094 if (Arg *A = Args.getLastArg(options::OPT_G,
1097 SmallDataThreshold += A->getValue(Args);
1099 CmdArgs.push_back(Args.MakeArgString(SmallDataThreshold));
1130 static void addExceptionArgs(const ArgList &Args, types::ID InputType,
1138 Args.ClaimAllArgs(options::OPT_fexceptions);
1139 Args.ClaimAllArgs(options::OPT_fno_exceptions);
1140 Args.ClaimAllArgs(options::OPT_fobjc_exceptions);
1141 Args.ClaimAllArgs(options::OPT_fno_objc_exceptions);
1142 Args.ClaimAllArgs(options::OPT_fcxx_exceptions);
1143 Args.ClaimAllArgs(options::OPT_fno_cxx_exceptions);
1153 if (Arg *A = Args.getLastArg(options::OPT_fexceptions,
1173 Args.hasFlag(options::OPT_fobjc_exceptions,
1185 if (Arg *A = Args.getLastArg(options::OPT_fcxx_exceptions,
1206 static bool ShouldDisableCFI(const ArgList &Args,
1212 Default = Args.hasFlag(options::OPT_integrated_as,
1216 return !Args.hasFlag(options::OPT_fdwarf2_cfi_asm,
1221 static bool ShouldDisableDwarfDirectory(const ArgList &Args,
1224 bool UseIntegratedAs = Args.hasFlag(options::OPT_integrated_as,
1227 bool UseDwarfDirectory = Args.hasFlag(options::OPT_fdwarf_directory_asm,
1247 static bool UseRelaxAll(Compilation &C, const ArgList &Args) {
1250 if (Arg *A = Args.getLastArg(options::OPT_O_Group))
1264 return Args.hasFlag(options::OPT_mrelax_all, options::OPT_mno_relax_all,
1270 static void addAsanRTLinux(const ToolChain &TC, const ArgList &Args,
1273 if (Args.hasArg(options::OPT_shared) ||
1274 !Args.hasFlag(options::OPT_faddress_sanitizer,
1284 CmdArgs.push_back(Args.MakeArgString(LibAsan));
1290 static bool shouldUseFramePointer(const ArgList &Args,
1292 if (Arg *A = Args.getLastArg(options::OPT_fno_omit_frame_pointer,
1300 if (Arg *A = Args.getLastArg(options::OPT_O_Group))
1311 const ArgList &Args,
1313 bool KernelOrKext = Args.hasArg(options::OPT_mkernel,
1327 std::string TripleStr = getToolChain().ComputeEffectiveClangTriple(Args);
1328 CmdArgs.push_back(Args.MakeArgString(TripleStr));
1347 if (UseRelaxAll(C, Args))
1352 for (arg_iterator it = Args.filtered_begin(options::OPT_Wa_COMMA,
1354 ie = Args.filtered_end(); it != ie; ++it) {
1359 StringRef Value = A->getValue(Args, i);
1378 (void) Args.hasArg(options::OPT_force__cpusubtype__ALL);
1425 CmdArgs.push_back(darwin::CC1::getBaseInputName(Args, Inputs));
1429 if (Args.hasArg(options::OPT_static))
1444 if (!Args.hasArg(options::OPT__analyzer_no_default_checks)) {
1467 if (Arg *A = Args.getLastArg(options::OPT__analyzer_output))
1468 CmdArgs.push_back(A->getValue(Args));
1478 Args.AddAllArgValues(CmdArgs, options::OPT_Xanalyzer);
1481 CheckCodeGenerationOptions(D, Args);
1494 for (ArgList::const_iterator I = Args.begin(), E = Args.end(); I != E; ++I) {
1520 if (Args.hasArg(options::OPT_mkernel))
1522 if (Args.hasArg(options::OPT_static))
1524 bool DynamicNoPIC = Args.hasArg(options::OPT_mdynamic_no_pic);
1557 if (!Args.hasFlag(options::OPT_fmerge_all_constants,
1563 if (Arg *A = Args.getLastArg(options::OPT_mregparm_EQ)) {
1565 CmdArgs.push_back(A->getValue(Args));
1568 if (Args.hasFlag(options::OPT_mrtd, options::OPT_mno_rtd, false))
1571 if (shouldUseFramePointer(Args, getToolChain().getTriple()))
1573 if (!Args.hasFlag(options::OPT_fzero_initialized_in_bss,
1576 if (!Args.hasFlag(options::OPT_fstrict_aliasing,
1580 if (Args.hasFlag(options::OPT_fstrict_enums, options::OPT_fno_strict_enums,
1583 if (!Args.hasFlag(options::OPT_foptimize_sibling_calls,
1592 if (Arg *A = Args.getLastArg(options::OPT_ffast_math,
1600 if (Arg *A = Args.getLastArg(options::OPT_ffast_math,
1611 if (Arg *A = Args.getLastArg(options::OPT_ffast_math,
1625 if (Arg *A = Args.getLastArg(options::OPT_ffast_math,
1634 if (Arg *A = Args.getLastArg(options::OPT_ffast_math,
1643 if (Arg *A = Args.getLastArg(options::OPT_ffast_math,
1652 if (Arg *A = Args.getLastArg(options::OPT_ffast_math,
1668 if (Args.hasArg(options::OPT_ffast_math))
1674 if (Args.hasFlag(options::OPT_fverbose_asm, options::OPT_fno_verbose_asm,
1676 Args.hasArg(options::OPT_dA))
1679 if (Args.hasArg(options::OPT_fdebug_pass_structure)) {
1683 if (Args.hasArg(options::OPT_fdebug_pass_arguments)) {
1698 if (Args.hasArg(options::OPT_mms_bitfields)) {
1706 Args.hasFlag(options::OPT_fasynchronous_unwind_tables,
1710 if (Args.hasFlag(options::OPT_funwind_tables, options::OPT_fno_unwind_tables,
1714 if (Arg *A = Args.getLastArg(options::OPT_flimited_precision_EQ)) {
1716 CmdArgs.push_back(A->getValue(Args));
1720 (void) Args.hasArg(options::OPT_mtune_EQ);
1722 if (Arg *A = Args.getLastArg(options::OPT_mcmodel_EQ)) {
1724 CmdArgs.push_back(A->getValue(Args));
1734 AddARMTargetArgs(Args, CmdArgs, KernelOrKext);
1741 AddMIPSTargetArgs(Args, CmdArgs);
1745 AddSparcTargetArgs(Args, CmdArgs);
1750 AddX86TargetArgs(Args, CmdArgs);
1754 AddHexagonTargetArgs(Args, CmdArgs);
1761 if (Arg *A = Args.getLastArg(options::OPT_mlinker_version_EQ)) {
1763 CmdArgs.push_back(A->getValue(Args));
1767 if (Args.hasFlag(options::OPT_momit_leaf_frame_pointer,
1775 if (!Args.hasArg(options::OPT_fallow_unsupported)) {
1780 if ((Unsupported = Args.getLastArg(options::OPT_fapple_kext)) ||
1781 (Unsupported = Args.getLastArg(options::OPT_mkernel)))
1787 Args.AddAllArgs(CmdArgs, options::OPT_v);
1788 Args.AddLastArg(CmdArgs, options::OPT_H);
1794 Args.AddLastArg(CmdArgs, options::OPT_P);
1795 Args.AddLastArg(CmdArgs, options::OPT_print_ivar_layout);
1805 Args.ClaimAllArgs(options::OPT_g_Group);
1806 if (Arg *A = Args.getLastArg(options::OPT_g_Group))
1811 Args.AddAllArgs(CmdArgs, options::OPT_ffunction_sections);
1812 Args.AddAllArgs(CmdArgs, options::OPT_fdata_sections);
1814 Args.AddAllArgs(CmdArgs, options::OPT_finstrument_functions);
1816 if (Args.hasArg(options::OPT_ftest_coverage) ||
1817 Args
1819 if (Args.hasArg(options::OPT_fprofile_arcs) ||
1820 Args.hasArg(options::OPT_coverage))
1827 CmdArgs.push_back(Args.MakeArgString(Output.getFilename()));
1832 if (Args.hasArg(options::OPT_nostdinc)) {
1836 if (Args.hasArg(options::OPT_nostdlibinc))
1838 Args.AddLastArg(CmdArgs, options::OPT_nostdincxx);
1839 Args.AddLastArg(CmdArgs, options::OPT_nobuiltininc);
1846 Args.AddLastArg(CmdArgs, options::OPT_working_directory);
1849 if (!Args.hasArg(options::OPT_fno_objc_arc)) {
1850 if (const Arg *A = Args.getLastArg(options::OPT_ccc_arcmt_check,
1866 CmdArgs.push_back(A->getValue(Args));
1868 Args.AddLastArg(CmdArgs, options::OPT_arcmt_migrate_report_output);
1869 Args.AddLastArg(CmdArgs, options::OPT_arcmt_migrate_emit_arc_errors);
1875 if (const Arg *A = Args.getLastArg(options::OPT_ccc_objcmt_migrate)) {
1878 << A->getAsString(Args) << "-ccc-arcmt-migrate";
1881 CmdArgs.push_back(A->getValue(Args));
1883 if (!Args.hasArg(options::OPT_objcmt_migrate_literals,
1889 Args.AddLastArg(CmdArgs, options::OPT_objcmt_migrate_literals);
1890 Args.AddLastArg(CmdArgs, options::OPT_objcmt_migrate_subscripting);
1899 AddPreprocessingOptions(C, D, Args, CmdArgs, Output, Inputs);
1905 Args.ClaimAllArgs(options::OPT_D);
1909 if (Arg *A = Args.getLastArg(options::OPT_O_Group)) {
1913 A->getValue(Args)[0] == '\0')
1916 A->render(Args, CmdArgs);
1919 Args.AddAllArgs(CmdArgs, options::OPT_W_Group);
1920 Args.AddLastArg(CmdArgs, options::OPT_pedantic);
1921 Args.AddLastArg(CmdArgs, options::OPT_pedantic_errors);
1922 Args.AddLastArg(CmdArgs, options::OPT_w);
1929 if (Arg *Std = Args.getLastArg(options::OPT_std_EQ, options::OPT_ansi)) {
1936 Std->render(Args, CmdArgs);
1938 if (Arg *A = Args.getLastArg(options::OPT_std_EQ, options::OPT_ansi,
1941 A->render(Args, CmdArgs);
1950 Args.AddAllArgsTranslated(CmdArgs, options::OPT_std_default_EQ,
1952 Args.AddLastArg(CmdArgs, options::OPT_trigraphs);
1957 if (Args.hasFlag(options::OPT_Wwrite_strings, options::OPT_Wno_write_strings,
1968 Args.hasFlag(options::OPT_Wdeprecated, options::OPT_Wno_deprecated,
1974 if (Arg *Asm = Args.getLastArg(options::OPT_fasm, options::OPT_fno_asm)) {
1981 if (ShouldDisableCFI(Args, getToolChain()))
1984 if (ShouldDisableDwarfDirectory(Args, getToolChain()))
1993 CmdArgs.push_back(Args.MakeArgString(CompDir));
1997 if (Arg *A = Args.getLastArg(options::OPT_ftemplate_depth_,
2000 CmdArgs.push_back(A->getValue(Args));
2003 if (Arg *A = Args.getLastArg(options::OPT_fconstexpr_depth_EQ)) {
2005 CmdArgs.push_back(A->getValue(Args));
2008 if (Arg *A = Args.getLastArg(options::OPT_Wlarge_by_value_copy_EQ,
2012 CmdArgs.push_back(A->getValue(Args));
2017 if (Args.hasArg(options::OPT__relocatable_pch))
2020 if (Arg *A = Args.getLastArg(options::OPT_fconstant_string_class_EQ)) {
2022 CmdArgs.push_back(A->getValue(Args));
2025 if (Arg *A = Args.getLastArg(options::OPT_ftabstop_EQ)) {
2027 CmdArgs.push_back(A->getValue(Args));
2031 if (Arg *A = Args.getLastArg(options::OPT_ferror_limit_EQ))
2032 CmdArgs.push_back(A->getValue(Args));
2036 if (Arg *A = Args.getLastArg(options::OPT_fmacro_backtrace_limit_EQ)) {
2038 CmdArgs.push_back(A->getValue(Args));
2041 if (Arg *A = Args.getLastArg(options::OPT_ftemplate_backtrace_limit_EQ)) {
2043 CmdArgs.push_back(A->getValue(Args));
2046 if (Arg *A = Args.getLastArg(options::OPT_fconstexpr_backtrace_limit_EQ)) {
2048 CmdArgs.push_back(A->getValue(Args));
2053 if (Arg *A = Args.getLastArg(options::OPT_fmessage_length_EQ)) {
2054 CmdArgs.push_back(A->getValue(Args));
2059 CmdArgs.push_back(Args.MakeArgString(Twine(N)));
2062 if (const Arg *A = Args.getLastArg(options::OPT_fvisibility_EQ)) {
2064 CmdArgs.push_back(A->getValue(Args));
2067 Args.AddLastArg(CmdArgs, options::OPT_fvisibility_inlines_hidden);
2070 if (Args.hasFlag(options::OPT_ffreestanding, options::OPT_fhosted, false) ||
2075 Args.AddLastArg(CmdArgs, options::OPT_fcatch_undefined_behavior);
2076 Args.AddLastArg(CmdArgs, options::OPT_femit_all_decls);
2077 Args.AddLastArg(CmdArgs, options::OPT_fheinous_gnu_extensions);
2078 Args.AddLastArg(CmdArgs, options::OPT_flimit_debug_info);
2079 Args.AddLastArg(CmdArgs, options::OPT_fno_limit_debug_info);
2080 Args.AddLastArg(CmdArgs, options::OPT_fno_operator_names);
2081 Args.AddLastArg(CmdArgs, options::OPT_faltivec);
2084 if (const Arg *A = Args.getLastArg(options::OPT_faltivec))
2088 << A->getAsString(Args) << "ppc/ppc64";
2091 Args.AddLastArg(CmdArgs, options::OPT_pg);
2093 if (Args.hasFlag(options::OPT_faddress_sanitizer,
2097 if (Args.hasFlag(options::OPT_fthread_sanitizer,
2102 if (!Args.hasFlag(options::OPT_flax_vector_conversions,
2106 if (Args.getLastArg(options::OPT_fapple_kext))
2109 Args.AddLastArg(CmdArgs, options::OPT_fobjc_sender_dependent_dispatch);
2110 Args.AddLastArg(CmdArgs, options::OPT_fdiagnostics_print_source_range_info);
2111 Args.AddLastArg(CmdArgs, options::OPT_fdiagnostics_parseable_fixits);
2112 Args.AddLastArg(CmdArgs, options::OPT_ftime_report);
2113 Args.AddLastArg(CmdArgs, options::OPT_ftrapv);
2115 if (Arg *A = Args.getLastArg(options::OPT_ftrapv_handler_EQ)) {
2117 CmdArgs.push_back(A->getValue(Args));
2120 Args.AddLastArg(CmdArgs, options::OPT_ftrap_function_EQ);
2124 if (Arg *A = Args.getLastArg(options::OPT_fwrapv,
2128 } else if (Arg *A = Args.getLastArg(options::OPT_fstrict_overflow,
2133 Args.AddLastArg(CmdArgs, options::OPT_fwritable_strings);
2134 Args.AddLastArg(CmdArgs, options::OPT_funroll_loops);
2136 Args.AddLastArg(CmdArgs, options::OPT_pthread);
2140 if (Arg *A = Args.getLastArg(options::OPT_fno_stack_protector,
2153 CmdArgs.push_back(Args.MakeArgString(Twine(StackProtectorLevel)));
2157 if (Args.hasFlag(options::OPT_mstackrealign, options::OPT_mno_stackrealign,
2162 if (!Args.hasFlag(options::OPT_mno_stackrealign, options::OPT_mstackrealign,
2164 CmdArgs.push_back(Args.MakeArgString("-mstackrealign"));
2167 if (Args.hasArg(options::OPT_mstack_alignment)) {
2168 StringRef alignment = Args.getLastArgValue(options::OPT_mstack_alignment);
2169 CmdArgs.push_back(Args.MakeArgString("-mstack-alignment=" + alignment));
2175 if (Args.hasArg(options::OPT_mkernel)) {
2176 if (!Args.hasArg(options::OPT_fapple_kext) && types::isCXX(InputType))
2178 if (!Args.hasArg(options::OPT_fbuiltin))
2180 Args.ClaimAllArgs(options::OPT_fno_builtin);
2183 else if (!Args.hasFlag(options::OPT_fbuiltin, options::OPT_fno_builtin))
2186 if (!Args.hasFlag(options::OPT_fassume_sane_operator_new,
2191 if (Args.hasFlag(options::OPT_fblocks, options::OPT_fno_blocks,
2193 (Args.hasArg(options::OPT_fgnu_runtime) &&
2194 Args.hasArg(options::OPT_fobjc_nonfragile_abi) &&
2195 !Args.hasArg(options::OPT_fno_blocks))) {
2198 if (!Args.hasArg(options::OPT_fgnu_runtime) &&
2206 if (Args.hasFlag(options::OPT_fmodules, options::OPT_fno_modules, false)) {
2207 bool AllowedInCXX = Args.hasFlag(options::OPT_fcxx_modules,
2215 if (Args.hasFlag(options::OPT_fno_access_control,
2221 if (Args.hasFlag(options::OPT_fno_elide_constructors,
2227 if (!Args.hasFlag(options::OPT_frtti, options::OPT_fno_rtti) ||
2232 if (Args.hasFlag(options::OPT_fshort_enums,
2239 if (!Args.hasFlag(options::OPT_fsigned_char, options::OPT_funsigned_char,
2244 if (!Args.hasFlag(options::OPT_fthreadsafe_statics,
2249 if (!Args.hasFlag(options::OPT_fuse_cxa_atexit,
2258 if (Args.hasFlag(options::OPT_fms_extensions, options::OPT_fno_ms_extensions,
2263 if (Args.hasFlag(options::OPT_fms_compatibility,
2266 Args.hasFlag(options::OPT_fms_extensions,
2272 if (Args.hasFlag(options::OPT_fms_extensions, options::OPT_fno_ms_extensions,
2274 Args.hasArg(options::OPT_fmsc_version)) {
2275 StringRef msc_ver = Args.getLastArgValue(options::OPT_fmsc_version);
2279 CmdArgs.push_back(Args.MakeArgString("-fmsc-version=" + msc_ver));
2284 if (Args.hasFlag(options::OPT_fborland_extensions,
2290 if (Args.hasFlag(options::OPT_fdelayed_template_parsing,
2297 if (Arg *A = Args.getLastArg(options::OPT_fgnu_keywords,
2299 A->render(Args, CmdArgs);
2301 if (Args.hasFlag(options::OPT_fgnu89_inline,
2306 if (Args.hasArg(options::OPT_fno_inline))
2309 if (Args.hasArg(options::OPT_fno_inline_functions))
2318 if (Args.hasFlag(options::OPT_fnext_runtime, options::OPT_fgnu_runtime,
2340 if (Arg *A = Args.getLastArg(options::OPT_fobjc_abi_version_EQ)) {
2341 if (StringRef(A->getValue(Args)) == "1")
2343 else if (StringRef(A->getValue(Args)) == "2")
2345 else if (StringRef(A->getValue(Args)) == "3")
2348 D.Diag(diag::err_drv_clang_unsupported) << A->getAsString(Args);
2354 if (Args.hasFlag(options::OPT_fobjc_nonfragile_abi,
2364 if (Arg *A = Args.getLastArg(
2366 if (StringRef(A->getValue(Args)) == "1")
2368 else if (StringRef(A->getValue(Args)) == "2")
2372 << A->getAsString(Args);
2386 if (!Args.hasFlag(options::OPT_fobjc_legacy_dispatch,
2404 bool ARC = isObjCAutoRefCount(Args);
2415 if (getToolChain().GetCXXStdlibType(Args) == ToolChain::CST_Libcxx)
2423 if (Args.hasFlag(options::OPT_fobjc_arc_exceptions,
2436 const Arg *GCArg = Args.getLastArg(options::OPT_fobjc_gc_only);
2438 GCArg = Args.getLastArg(options::OPT_fobjc_gc);
2442 << GCArg->getAsString(Args);
2444 GCArg->render(Args, CmdArgs);
2448 << GCArg->getAsString(Args);
2452 // Add exception args.
2453 addExceptionArgs(Args, InputType, getToolChain().getTriple(),
2460 if (!Args.hasFlag(options::OPT_fassume_sane_operator_new,
2466 if (!Args.hasFlag(options::OPT_fconstant_cfstrings,
2468 !Args.hasFlag(options::OPT_mconstant_cfstrings,
2474 if (Arg *A = Args.getLastArg(options::OPT_fshort_wchar))
2475 A->render(Args, CmdArgs);
2482 if (Args.hasFlag(options::OPT_fpascal_strings,
2485 Args.hasFlag(options::OPT_mpascal_strings,
2492 if (Arg *A = Args.getLastArg(options::OPT_fpack_struct_EQ)) {
2494 CmdArgs.push_back(A->getValue(Args));
2495 } else if (Args.hasFlag(options::OPT_fpack_struct,
2501 if (Args.hasArg(options::OPT_mkernel) ||
2502 Args.hasArg(options::OPT_fapple_kext)) {
2503 if (!Args.hasArg(options::OPT_fcommon))
2505 Args.ClaimAllArgs(options::OPT_fno_common);
2509 else if (!Args.hasFlag(options::OPT_fcommon, options::OPT_fno_common))
2514 if (!Args.hasFlag(options::OPT_fsigned_bitfields,
2517 << Args.getLastArg(options::OPT_funsigned_bitfields)->getAsString(Args);
2520 if (!Args.hasFlag(options::OPT_ffor_scope,
2523 << Args.getLastArg(options::OPT_fno_for_scope)->getAsString(Args);
2526 if (!Args.hasFlag(options::OPT_fcaret_diagnostics,
2531 if (!Args.hasFlag(options::OPT_fdiagnostics_fixit_info,
2536 if (Args.hasFlag(options::OPT_fdiagnostics_show_option,
2541 Args.getLastArg(options::OPT_fdiagnostics_show_category_EQ)) {
2543 CmdArgs.push_back(A->getValue(Args));
2547 Args.getLastArg(options::OPT_fdiagnostics_format_EQ)) {
2549 CmdArgs.push_back(A->getValue(Args));
2552 if (Arg *A = Args.getLastArg(
2564 if (Args.hasFlag(options::OPT_fcolor_diagnostics,
2569 if (!Args.hasFlag(options::OPT_fshow_source_location,
2573 if (!Args.hasFlag(options::OPT_fshow_column,
2578 if (!Args.hasFlag(options::OPT_fspell_checking,
2584 (void) Args.hasFlag(options::OPT_fasm_blocks, options::OPT_fno_asm_blocks,
2587 if (Arg *A = Args.getLastArg(options::OPT_fshow_overloads_EQ))
2588 A->render(Args, CmdArgs);
2592 if (Arg *A = Args.getLastArg(options::OPT_fdollars_in_identifiers,
2602 if (Arg *A = Args.getLastArg(options::OPT_funit_at_a_time,
2605 D.Diag(diag::warn_drv_clang_unsupported) << A->getAsString(Args);
2608 if (Args.hasFlag(options::OPT_fapple_pragma_pack,
2619 if (!Args.hasArg(options::OPT_fbuiltin_strcat))
2621 if (!Args.hasArg(options::OPT_fbuiltin_strcpy))
2627 if (Arg *A = Args.getLastArg(options::OPT_traditional,
2632 D.Diag(diag::err_drv_clang_unsupported) << A->getAsString(Args);
2635 Args.AddLastArg(CmdArgs, options::OPT_dM);
2636 Args.AddLastArg(CmdArgs, options::OPT_dD);
2639 if (Arg *A = Args.getLastArg(options::OPT__serialize_diags)) {
2641 CmdArgs.push_back(Args.MakeArgString(A->getValue(Args)));
2646 Args
2647 for (arg_iterator it = Args.filtered_begin(options::OPT_mllvm),
2648 ie = Args.filtered_end(); it != ie; ++it) {
2653 if (StringRef((*it)->getValue(Args, 0)) == "-disable-llvm-optzns")
2656 (*it)->render(Args, CmdArgs);
2676 II.getInputArg().renderAsInput(Args, CmdArgs);
2679 Args.AddAllArgs(CmdArgs, options::OPT_undef);
2687 for (ArgList::const_iterator it = Args.begin(),
2688 ie = Args.end(); it != ie; ++it)
2689 (*it)->render(Args, OriginalArgs);
2698 CmdArgs.push_back(Args.MakeArgString(Flags.str()));
2703 if (Arg *A = Args.getLastArg(options::OPT_pg))
2704 if (Args.hasArg(options::OPT_fomit_frame_pointer))
2706 << "-fomit-frame-pointer" << A->getAsString(Args);
2713 Args.ClaimAllArgs(options::OPT_fpch_preprocess);
2717 Args.ClaimAllArgs(options::OPT_clang_ignored_f_Group);
2718 Args.ClaimAllArgs(options::OPT_clang_ignored_m_Group);
2721 Args.ClaimAllArgs(options::OPT_use_gold_plugin);
2722 Args.ClaimAllArgs(options::OPT_emit_llvm);
2725 void ClangAs::AddARMTargetArgs(const ArgList &Args,
2732 CmdArgs.push_back(getARMTargetCPU(Args, Triple));
2735 if (const Arg *A = Args.getLastArg(options::OPT_mfpu_EQ))
2736 addFPUArgs(D, A, Args, CmdArgs);
2739 if (const Arg *A = Args.getLastArg(options::OPT_mfpmath_EQ))
2740 addFPMathArgs(D, A, Args, CmdArgs, getARMTargetCPU(Args, Triple));
2746 const ArgList &Args,
2754 Args.ClaimAllArgs(options::OPT_w);
2756 Args.ClaimAllArgs(options::OPT_emit_llvm);
2758 Args.ClaimAllArgs(options::OPT_use_gold_plugin);
2768 getToolChain().ComputeEffectiveClangTriple(Args, Input.getType());
2769 CmdArgs.push_back(Args.MakeArgString(TripleStr));
2776 if (UseRelaxAll(C, Args))
2786 AddARMTargetArgs(Args, CmdArgs);
2791 (void) Args.hasArg(options::OPT_force__cpusubtype__ALL);
2803 Args.ClaimAllArgs(options::OPT_g_Group);
2804 if (Arg *A = Args.getLastArg(options::OPT_g_Group))
2813 for (ArgList::const_iterator it = Args.begin(),
2814 ie = Args.end(); it != ie; ++it)
2815 (*it)->render(Args, OriginalArgs);
2825 CmdArgs.push_back(Args.MakeArgString(Flags.str()));
2830 Args.AddAllArgValues(CmdArgs, options::OPT_Wa_COMMA,
2832 Args.AddAllArgs(CmdArgs, options::OPT_mllvm);
2848 const ArgList &Args,
2854 it = Args.begin(), ie = Args.end(); it != ie; ++it) {
2867 A->render(Args, CmdArgs);
2884 CmdArgs.push_back(Args.MakeArgString(Arch));
2905 Args.AddAllArgValues(CmdArgs, options::OPT_Wa_COMMA,
2946 A.render(Args, CmdArgs);
2960 Args.MakeArgString(getToolChain().GetProgramPath(GCCName));
3009 const ArgList &Args,
3016 MarchString += getHexagonTargetCPU(Args);
3017 CmdArgs.push_back(Args.MakeArgString(MarchString));
3055 II.getInputArg().render(Args, CmdArgs);
3060 Args.MakeArgString(getToolChain().GetProgramPath(GCCName));
3072 const ArgList &Args,
3079 it = Args.begin(), ie = Args.end(); it != ie; ++it) {
3092 A->render(Args, CmdArgs);
3100 if ((A = getLastHexagonArchArg(Args))) {
3102 A->render(Args, CmdArgs);
3104 CmdArgs.push_back (Args.MakeArgString("-m" + getHexagonTargetCPU(Args)));
3107 CmdArgs.push_back (Args.MakeArgString("-m" + getHexagonTargetCPU(Args)));
3118 Args.MakeArgString(getToolChain().GetProgramPath(GCCName));
3142 II.getInputArg().render(Args, CmdArgs);
3174 const char *darwin::CC1::getBaseInputName(const ArgList &Args,
3176 return Args.MakeArgString(
3180 const char *darwin::CC1::getBaseInputStem(const ArgList &Args,
3182 const char *Str = getBaseInputName(Args, Inputs);
3185 return Args.MakeArgString(std::string(Str, End));
3191 darwin::CC1::getDependencyFileName(const ArgList &Args,
3196 if (Arg *OutputOpt = Args.getLastArg(options::OPT_o)) {
3197 std::string Str(OutputOpt->getValue(Args));
3200 Res = darwin::CC1::getBaseInputStem(Args, Inputs);
3202 return Args.MakeArgString(Res + ".d");
3301 .Case("local-type-template-args", true)
3330 .Case("unnamed-type-template-args", true)
3352 void darwin::CC1::AddCC1Args(const ArgList &Args,
3356 CheckCodeGenerationOptions(D, Args);
3359 if (!Args.hasArg(options::OPT_mkernel) && !Args.hasArg(options::OPT_static) &&
3360 !Args.hasArg(options::OPT_mdynamic_no_pic))
3365 if (!Args.hasArg(options::OPT_fbuiltin_strcat))
3367 if (!Args.hasArg(options::OPT_fbuiltin_strcpy))
3371 if (Args.hasArg(options::OPT_g_Flag) &&
3372 !Args.hasArg(options::OPT_fno_eliminate_unused_debug_symbols))
3376 void darwin::CC1::AddCC1OptionsArgs(const ArgList &Args, ArgStringList &CmdArgs,
3382 if (Args.hasArg(options::OPT_fast) ||
3383 Args.hasArg(options::OPT_fastf) ||
3384 Args.hasArg(options::OPT_fastcp))
3387 if (Arg *A = Args.getLastArg(options::OPT_pg))
3388 if (Args.hasArg(options::OPT_fomit_frame_pointer))
3390 << A->getAsString(Args) << "-fomit-frame-pointer";
3392 AddCC1Args(Args, CmdArgs);
3394 if (!Args.hasArg(options::OPT_Q))
3398 CmdArgs.push_back(darwin::CC1::getBaseInputName(Args, Inputs));
3400 Args.AddAllArgs(CmdArgs, options::OPT_d_Group);
3402 Args.AddAllArgs(CmdArgs, options::OPT_m_Group);
3403 Args.AddAllArgs(CmdArgs, options::OPT_a_Group);
3408 if ((Args.hasArg(options::OPT_c) || Args.hasArg(options::OPT_S)) &&
3409 Args.hasArg(options::OPT_o)) {
3410 Arg *OutputOpt = Args.getLastArg(options::OPT_o);
3412 CmdArgs.push_back(OutputOpt->getValue(Args));
3415 CmdArgs.push_back(darwin::CC1::getBaseInputStem(Args, Inputs));
3418 Args.AddAllArgs(CmdArgs, options::OPT_g_Group);
3420 Args.AddAllArgs(CmdArgs, options::OPT_O);
3422 Args.AddAllArgs(CmdArgs, options::OPT_W_Group, options::OPT_pedantic_Group);
3423 Args.AddLastArg(CmdArgs, options::OPT_w);
3424 Args.AddAllArgs(CmdArgs, options::OPT_std_EQ, options::OPT_ansi,
3426 if (!Args.getLastArg(options::OPT_std_EQ, options::OPT_ansi)) {
3428 Args.AddAllArgsTranslated(CmdArgs, options::OPT_std_default_EQ,
3432 if (Args.hasArg(options::OPT_v))
3434 if (Args.hasArg(options::OPT_pg) &&
3437 Args.AddLastArg(CmdArgs, options::OPT_p);
3445 // FIXME: Should we grow a better way to deal with "removing" args?
3446 for (arg_iterator it = Args.filtered_begin(options::OPT_f_Group,
3448 ie = Args.filtered_end(); it != ie; ++it) {
3452 (*it)->render(Args, CmdArgs);
3456 Args.AddAllArgs(CmdArgs, options::OPT_f_Group, options::OPT_fsyntax_only);
3459 Args.ClaimAllArgs(options::OPT_f_clang_Group);
3461 Args.AddAllArgs(CmdArgs, options::OPT_undef);
3462 if (Args.hasArg(options::OPT_Qn))
3466 //Args.AddLastArg(CmdArgs, options::OPT__help)
3467 //Args.AddLastArg(CmdArgs, options::OPT__targetHelp)
3472 Args.AddAllArgs(CmdArgs, options::OPT__param);
3474 if (Args.hasArg(options::OPT_fmudflap) ||
3475 Args.hasArg(options::OPT_fmudflapth)) {
3480 if (Args.hasArg(options::OPT_coverage)) {
3489 void darwin::CC1::AddCPPOptionsArgs(const ArgList &Args, ArgStringList &CmdArgs,
3493 AddCPPUniqueOptionsArgs(Args, CmdArgs, Inputs);
3497 AddCC1Args(Args, CmdArgs);
3504 Args.AddAllArgs(CmdArgs, options::OPT_m_Group);
3505 Args.AddAllArgs(CmdArgs, options::OPT_std_EQ, options::OPT_ansi,
3507 if (!Args.getLastArg(options::OPT_std_EQ, options::OPT_ansi)) {
3509 Args.AddAllArgsTranslated(CmdArgs, options::OPT_std_default_EQ,
3512 Args.AddAllArgs(CmdArgs, options::OPT_W_Group, options::OPT_pedantic_Group);
3513 Args.AddLastArg(CmdArgs, options::OPT_w);
3516 Args.AddAllArgs(CmdArgs, options::OPT_f_Group, options::OPT_fsyntax_only);
3519 Args.ClaimAllArgs(options::OPT_f_clang_Group);
3521 if (Args.hasArg(options::OPT_g_Group) && !Args.hasArg(options::OPT_g0) &&
3522 !Args.hasArg(options::OPT_fno_working_directory))
3525 Args.AddAllArgs(CmdArgs, options::OPT_O);
3526 Args.AddAllArgs(CmdArgs, options::OPT_undef);
3527 if (Args.hasArg(options::OPT_save_temps))
3531 void darwin::CC1::AddCPPUniqueOptionsArgs(const ArgList &Args,
3536 CheckPreprocessingOptions(D, Args);
3540 Args.AddLastArg(CmdArgs, options::OPT_C);
3541 Args.AddLastArg(CmdArgs, options::OPT_CC);
3542 if (!Args.hasArg(options::OPT_Q))
3544 Args.AddAllArgs(CmdArgs, options::OPT_nostdinc);
3545 Args.AddAllArgs(CmdArgs, options::OPT_nostdincxx);
3546 Args.AddLastArg(CmdArgs, options::OPT_v);
3547 Args.AddAllArgs(CmdArgs, options::OPT_I_Group, options::OPT_F);
3548 Args.AddLastArg(CmdArgs, options::OPT_P);
3556 if (Args.hasArg(options::OPT_MD)) {
3558 CmdArgs.push_back(darwin::CC1::getDependencyFileName(Args
3561 if (Args.hasArg(options::OPT_MMD)) {
3563 CmdArgs.push_back(darwin::CC1::getDependencyFileName(Args, Inputs));
3566 Args.AddLastArg(CmdArgs, options::OPT_M);
3567 Args.AddLastArg(CmdArgs, options::OPT_MM);
3568 Args.AddAllArgs(CmdArgs, options::OPT_MF);
3569 Args.AddLastArg(CmdArgs, options::OPT_MG);
3570 Args.AddLastArg(CmdArgs, options::OPT_MP);
3571 Args.AddAllArgs(CmdArgs, options::OPT_MQ);
3572 Args.AddAllArgs(CmdArgs, options::OPT_MT);
3573 if (!Args.hasArg(options::OPT_M) && !Args.hasArg(options::OPT_MM) &&
3574 (Args.hasArg(options::OPT_MD) || Args.hasArg(options::OPT_MMD))) {
3575 if (Arg *OutputOpt = Args.getLastArg(options::OPT_o)) {
3577 CmdArgs.push_back(OutputOpt->getValue(Args));
3581 Args.AddLastArg(CmdArgs, options::OPT_remap);
3582 if (Args.hasArg(options::OPT_g3))
3584 Args.AddLastArg(CmdArgs, options::OPT_H);
3586 AddCPPArgs(Args, CmdArgs);
3588 Args.AddAllArgs(CmdArgs, options::OPT_D, options::OPT_U, options::OPT_A);
3589 Args.AddAllArgs(CmdArgs, options::OPT_i_Group);
3598 Args.AddAllArgValues(CmdArgs, options::OPT_Wp_COMMA,
3601 if (Args.hasArg(options::OPT_fmudflap)) {
3607 if (Args.hasArg(options::OPT_fmudflapth)) {
3615 void darwin::CC1::AddCPPArgs(const ArgList &Args,
3619 if (Args.hasArg(options::OPT_static)) {
3623 // if (!Args.hasArg(arglist.parser.dynamicOption))
3628 if (Args.hasArg(options::OPT_pthread))
3635 const ArgList &Args,
3643 if (Args.hasArg(options::OPT_traditional) ||
3644 Args.hasArg(options::OPT_traditional_cpp))
3652 if (Args.hasArg(options::OPT_E) || getToolChain().getDriver().CCCIsCPP) {
3653 AddCPPOptionsArgs(Args, CmdArgs, Inputs, OutputArgs);
3655 AddCPPOptionsArgs(Args, CmdArgs, Inputs, ArgStringList());
3659 Args.AddAllArgs(CmdArgs, options::OPT_d_Group);
3665 Args.MakeArgString(getToolChain().GetProgramPath(CC1Name));
3672 const ArgList &Args,
3680 Args.ClaimAllArgs(options::OPT__serialize_diags);
3683 if (const Arg *A = Args.getLastArg(options::OPT_traditional))
3685 << A->getAsString(Args) << "-E";
3712 bool OutputArgsEarly = (Args.hasArg(options::OPT_fsyntax_only) ||
3713 Args.hasArg(options::OPT_S));
3716 AddCPPUniqueOptionsArgs(Args, CmdArgs, Inputs);
3718 AddCC1OptionsArgs(Args, CmdArgs, Inputs, OutputArgs);
3720 AddCC1OptionsArgs(Args, CmdArgs, Inputs, ArgStringList());
3741 AddCC1OptionsArgs(Args, CmdArgs, Inputs, OutputArgs);
3743 AddCC1OptionsArgs(Args, CmdArgs, Inputs, ArgStringList());
3773 Args.MakeArgString(getToolChain().GetProgramPath(CC1Name));
3780 const ArgList &Args,
3797 if (Args.hasArg(options::OPT_gstabs))
3799 else if (Args.hasArg(options::OPT_g_Group))
3804 AddDarwinArch(Args, CmdArgs);
3809 Args.hasArg(options::OPT_force__cpusubtype__ALL))
3813 (Args.hasArg(options::OPT_mkernel) ||
3814 Args.hasArg(options::OPT_static) ||
3815 Args.hasArg(options::OPT_fapple_kext)))
3818 Args.AddAllArgValues(CmdArgs, options::OPT_Wa_COMMA,
3831 Args.MakeArgString(getToolChain().GetProgramPath("as"));
3837 void darwin::DarwinTool::AddDarwinArch(const ArgList &Args,
3839 StringRef ArchName = getDarwinToolChain().getDarwinArchName(Args);
3843 CmdArgs.push_back(Args.MakeArgString(ArchName));
3851 const ArgList &Args,
3857 if (Arg *A = Args.getLastArg(options::OPT_mlinker_version_EQ)) {
3859 if (!Driver::GetReleaseVersion(A->getValue(Args), Version[0],
3863 << A->getAsString(Args);
3868 if (Version[0] >= 100 && !Args.hasArg(options::OPT_Z_Xlinker__no_demangle)) {
3873 Args.hasArg(options::OPT_static));
3875 for (arg_iterator it = Args.filtered_begin(options::OPT_Xlinker,
3877 ie = Args.filtered_end(); it != ie; ++it) {
3880 if (StringRef(A->getValue(Args, i)) == "-kext")
3891 if (Version[0] >= 116 && D.IsUsingLTO(Args)) {
3900 Args.AddAllArgs(CmdArgs, options::OPT_static);
3901 if (!Args.hasArg(options::OPT_static))
3903 if (Args.hasArg(options::OPT_fgnu_runtime)) {
3904 // FIXME: gcc replaces -lobjc in forward args with -lobjc-gnu
3908 if (!Args.hasArg(options::OPT_dynamiclib)) {
3909 AddDarwinArch(Args, CmdArgs);
3911 Args.AddLastArg(CmdArgs, options::OPT_force__cpusubtype__ALL);
3913 Args.AddLastArg(CmdArgs, options::OPT_bundle);
3914 Args.AddAllArgs(CmdArgs, options::OPT_bundle__loader);
3915 Args.AddAllArgs(CmdArgs, options::OPT_client__name);
3918 if ((A = Args.getLastArg(options::OPT_compatibility__version)) ||
3919 (A = Args.getLastArg(options::OPT_current__version)) ||
3920 (A = Args.getLastArg(options::OPT_install__name)))
3922 << A->getAsString(Args) << "-dynamiclib";
3924 Args.AddLastArg(CmdArgs, options::OPT_force__flat__namespace);
3925 Args.AddLastArg(CmdArgs, options::OPT_keep__private__externs);
3926 Args.AddLastArg(CmdArgs, options::OPT_private__bundle);
3931 if ((A = Args.getLastArg(options::OPT_bundle)) ||
3932 (A = Args.getLastArg(options::OPT_bundle__loader)) ||
3933 (A = Args.getLastArg(options::OPT_client__name)) ||
3934 (A = Args.getLastArg(options::OPT_force__flat__namespace)) ||
3935 (A = Args.getLastArg(options::OPT_keep__private__externs)) ||
3936 (A = Args.getLastArg(options::OPT_private__bundle)))
3938 << A->getAsString(Args) << "-dynamiclib";
3940 Args.AddAllArgsTranslated(CmdArgs, options::OPT_compatibility__version,
3942 Args.AddAllArgsTranslated(CmdArgs, options::OPT_current__version,
3945 AddDarwinArch(Args, CmdArgs);
3947 Args.AddAllArgsTranslated(CmdArgs, options::OPT_install__name,
3951 Args.AddLastArg(CmdArgs, options::OPT_all__load);
3952 Args.AddAllArgs(CmdArgs, options::OPT_allowable__client);
3953 Args.AddLastArg(CmdArgs, options::OPT_bind__at__load);
3955 Args.AddLastArg(CmdArgs, options::OPT_arch__errors__fatal);
3956 Args.AddLastArg(CmdArgs, options::OPT_dead__strip);
3957 Args.AddLastArg(CmdArgs, options::OPT_no__dead__strip__inits__and__terms);
3958 Args.AddAllArgs(CmdArgs, options::OPT_dylib__file);
3959 Args.AddLastArg(CmdArgs, options::OPT_dynamic);
3960 Args.AddAllArgs(CmdArgs, options::OPT_exported__symbols__list);
3961 Args.AddLastArg(CmdArgs, options::OPT_flat__namespace);
3962 Args.AddAllArgs(CmdArgs, options::OPT_force__load);
3963 Args.AddAllArgs(CmdArgs, options::OPT_headerpad__max__install__names);
3964 Args.AddAllArgs(CmdArgs, options::OPT_image__base);
3965 Args.AddAllArgs(CmdArgs, options::OPT_init);
3977 if (Args.hasArg(options::OPT_mios_simulator_version_min_EQ))
3983 CmdArgs.push_back(Args.MakeArgString(TargetVersion.getAsString()));
3985 Args.AddLastArg(CmdArgs, options::OPT_nomultidefs);
3986 Args.AddLastArg(CmdArgs, options::OPT_multi__module);
3987 Args.AddLastArg(CmdArgs, options::OPT_single__module);
3988 Args.AddAllArgs(CmdArgs, options::OPT_multiply__defined);
3989 Args.AddAllArgs(CmdArgs, options::OPT_multiply__defined__unused);
3991 if (const Arg *A = Args.getLastArg(options::OPT_fpie, options::OPT_fPIE,
4001 Args.AddLastArg(CmdArgs, options::OPT_prebind);
4002 Args.AddLastArg(CmdArgs, options::OPT_noprebind);
4003 Args.AddLastArg(CmdArgs, options::OPT_nofixprebinding);
4004 Args.AddLastArg(CmdArgs, options::OPT_prebind__all__twolevel__modules);
4005 Args.AddLastArg(CmdArgs, options::OPT_read__only__relocs);
4006 Args.AddAllArgs(CmdArgs, options::OPT_sectcreate);
4007 Args.AddAllArgs(CmdArgs, options::OPT_sectorder);
4008 Args.AddAllArgs(CmdArgs, options::OPT_seg1addr);
4009 Args.AddAllArgs(CmdArgs, options::OPT_segprot);
4010 Args.AddAllArgs(CmdArgs, options::OPT_segaddr);
4011 Args.AddAllArgs(CmdArgs, options::OPT_segs__read__only__addr);
4012 Args.AddAllArgs(CmdArgs, options::OPT_segs__read__write__addr);
4013 Args.AddAllArgs(CmdArgs, options::OPT_seg__addr__table);
4014 Args.AddAllArgs(CmdArgs, options::OPT_seg__addr__table__filename);
4015 Args.AddAllArgs(CmdArgs, options::OPT_sub__library);
4016 Args.AddAllArgs(CmdArgs, options::OPT_sub__umbrella);
4024 } else if (const Arg *A = Args.getLastArg(options::OPT_isysroot)) {
4026 CmdArgs.push_back(A->getValue(Args));
4032 Args.AddLastArg(CmdArgs, options::OPT_twolevel__namespace);
4033 Args.AddLastArg(CmdArgs, options::OPT_twolevel__namespace__hints);
4034 Args.AddAllArgs(CmdArgs, options::OPT_umbrella);
4035 Args.AddAllArgs(CmdArgs, options::OPT_undefined);
4036 Args.AddAllArgs(CmdArgs, options::OPT_unexported__symbols__list);
4037 Args.AddAllArgs(CmdArgs, options::OPT_weak__reference__mismatches);
4038 Args.AddLastArg(CmdArgs, options::OPT_X_Flag);
4039 Args.AddAllArgs(CmdArgs, options::OPT_y);
4040 Args.AddLastArg(CmdArgs, options::OPT_w);
4041 Args.AddAllArgs(CmdArgs, options::OPT_pagezero__size);
4042 Args.AddAllArgs(CmdArgs, options::OPT_segs__read__);
4043 Args.AddLastArg(CmdArgs, options::OPT_seglinkedit);
4044 Args.AddLastArg(CmdArgs, options::OPT_noseglinkedit);
4045 Args.AddAllArgs(CmdArgs, options::OPT_sectalign);
4046 Args.AddAllArgs(CmdArgs, options::OPT_sectobjectsymbols);
4047 Args.AddAllArgs(CmdArgs, options::OPT_segcreate);
4048 Args.AddLastArg(CmdArgs, options::OPT_whyload);
4049 Args.AddLastArg(CmdArgs, options::OPT_whatsloaded);
4050 Args.AddAllArgs(CmdArgs, options::OPT_dylinker__install__name);
4051 Args.AddLastArg(CmdArgs, options::OPT_dylinker);
4052 Args.AddLastArg(CmdArgs, options::OPT_Mach);
4058 const ArgList &Args,
4068 if (Args.hasArg(options::OPT_ccc_arcmt_check,
4070 for (ArgList::const_iterator I = Args.begin(), E = Args.end(); I != E; ++I)
4073 Args.MakeArgString(getToolChain().GetProgramPath("touch"));
4081 AddLinkArgs(C, Args, CmdArgs);
4083 Args.AddAllArgs(CmdArgs, options::OPT_d_Flag);
4084 Args.AddAllArgs(CmdArgs, options::OPT_s);
4085 Args.AddAllArgs(CmdArgs, options::OPT_t);
4086 Args.AddAllArgs(CmdArgs, options::OPT_Z_Flag);
4087 Args.AddAllArgs(CmdArgs, options::OPT_u_Group);
4088 Args.AddAllArgs(CmdArgs, options::OPT_A);
4089 Args.AddLastArg(CmdArgs, options::OPT_e);
4090 Args.AddAllArgs(CmdArgs, options::OPT_m_Separate);
4091 Args.AddAllArgs(CmdArgs, options::OPT_r);
4096 if (Args.hasArg(options::OPT_ObjC) || Args.hasArg(options::OPT_ObjCXX))
4102 if (!Args.hasArg(options::OPT_A) &&
4103 !Args.hasArg(options::OPT_nostdlib) &&
4104 !Args.hasArg(options::OPT_nostartfiles)) {
4106 if (Args.hasArg(options::OPT_dynamiclib)) {
4121 if (Args.hasArg(options::OPT_bundle)) {
4122 if (!Args.hasArg(options::OPT_static)) {
4136 if (Args.hasArg(options::OPT_pg) &&
4138 if (Args.hasArg(options::OPT_static) ||
4139 Args.hasArg(options::OPT_object) ||
4140 Args.hasArg(options::OPT_preload)) {
4148 if (Args.hasArg(options::OPT_static) ||
4149 Args.hasArg(options::OPT_object) ||
4150 Args.hasArg(options::OPT_preload)) {
4178 Args.hasArg(options::OPT_shared_libgcc) &&
4181 Args.MakeArgString(getToolChain().GetFilePath("crt3.o"));
4186 Args.AddAllArgs(CmdArgs, options::OPT_L);
4191 if (Args.hasFlag(options::OPT_faddress_sanitizer,
4193 if (Args.hasArg(options::OPT_dynamiclib) ||
4194 Args.hasArg(options::OPT_bundle)) {
4200 if (Args.hasArg(options::OPT_fopenmp))
4204 getDarwinToolChain().AddLinkSearchPathArgs(Args, CmdArgs);
4206 if (isObjCRuntimeLinked(Args)) {
4216 if ((!runtime.HasARC && isObjCAutoRefCount(Args)) ||
4218 getDarwinToolChain().AddLinkARCArgs(Args, CmdArgs);
4226 AddLinkerInputs(getToolChain(), Inputs, Args, CmdArgs);
4234 if (Args.hasArg(options::OPT_fnested_functions))
4237 if (!Args.hasArg(options::OPT_nostdlib) &&
4238 !Args.hasArg(options::OPT_nodefaultlibs)) {
4240 getToolChain().AddCXXStdlibLibArgs(Args, CmdArgs);
4245 getDarwinToolChain().AddLinkRuntimeLibArgs(Args, CmdArgs);
4248 if (!Args.hasArg(options::OPT_A) &&
4249 !Args.hasArg(options::OPT_nostdlib) &&
4250 !Args.hasArg(options::OPT_nostartfiles)) {
4254 Args.AddAllArgs(CmdArgs, options::OPT_T_Group);
4255 Args.AddAllArgs(CmdArgs, options::OPT_F);
4258 Args.MakeArgString(getToolChain().GetProgramPath("ld"));
4265 const ArgList &Args,
4282 Args.MakeArgString(getToolChain().GetProgramPath("lipo"));
4289 const ArgList &Args,
4302 Args.MakeArgString(getToolChain().GetProgramPath("dsymutil"));
4309 const ArgList &Args,
4325 Args.MakeArgString(getToolChain().GetProgramPath("dwarfdump"));
4332 const ArgList &Args,
4336 Args.AddAllArgValues(CmdArgs, options::OPT_Wa_COMMA,
4349 Args.MakeArgString(getToolChain().GetProgramPath("as"));
4357 const ArgList &Args,
4384 if ((!Args.hasArg(options::OPT_nostdlib)) &&
4385 (!Args.hasArg(options::OPT_shared))) {
4390 if (Args.hasArg(options::OPT_static)) {
4395 if (Args.hasArg(options::OPT_shared)) {
4399 CmdArgs.push_back(Args.MakeArgString(LibPath + "ld.so.1"));
4410 if (!Args.hasArg(options::OPT_nostdlib) &&
4411 !Args.hasArg(options::OPT_nostartfiles)) {
4412 if (!Args.hasArg(options::OPT_shared)) {
4413 CmdArgs.push_back(Args.MakeArgString(LibPath + "crt1.o"));
4414 CmdArgs.push_back(Args.MakeArgString(LibPath + "crti.o"));
4415 CmdArgs.push_back(Args.MakeArgString(LibPath + "values-Xa.o"));
4416 CmdArgs.push_back(Args
4418 CmdArgs.push_back(Args.MakeArgString(LibPath + "crti.o"));
4419 CmdArgs.push_back(Args.MakeArgString(LibPath + "values-Xa.o"));
4420 CmdArgs.push_back(Args.MakeArgString(GCCLibPath + "crtbegin.o"));
4423 CmdArgs.push_back(Args.MakeArgString(LibPath + "cxa_finalize.o"));
4426 CmdArgs.push_back(Args.MakeArgString("-L" + GCCLibPath));
4428 Args.AddAllArgs(CmdArgs, options::OPT_L);
4429 Args.AddAllArgs(CmdArgs, options::OPT_T_Group);
4430 Args.AddAllArgs(CmdArgs, options::OPT_e);
4431 Args.AddAllArgs(CmdArgs, options::OPT_r);
4433 AddLinkerInputs(getToolChain(), Inputs, Args, CmdArgs);
4435 if (!Args.hasArg(options::OPT_nostdlib) &&
4436 !Args.hasArg(options::OPT_nodefaultlibs)) {
4438 getToolChain().AddCXXStdlibLibArgs(Args, CmdArgs);
4440 if (!Args.hasArg(options::OPT_shared)) {
4447 if (!Args.hasArg(options::OPT_nostdlib) &&
4448 !Args.hasArg(options::OPT_nostartfiles)) {
4449 CmdArgs.push_back(Args.MakeArgString(GCCLibPath + "crtend.o"));
4451 CmdArgs.push_back(Args.MakeArgString(LibPath + "crtn.o"));
4453 addProfileRT(getToolChain(), Args, CmdArgs, getToolChain().getTriple());
4456 Args.MakeArgString(getToolChain().GetProgramPath("ld"));
4463 const ArgList &Args,
4467 Args.AddAllArgValues(CmdArgs, options::OPT_Wa_COMMA,
4480 Args.MakeArgString(getToolChain().GetProgramPath("gas"));
4487 const ArgList &Args,
4491 if ((!Args.hasArg(options::OPT_nostdlib)) &&
4492 (!Args.hasArg(options::OPT_shared))) {
4497 if (Args.hasArg(options::OPT_static)) {
4503 if (Args.hasArg(options::OPT_shared)) {
4518 if (!Args.hasArg(options::OPT_nostdlib) &&
4519 !Args.hasArg(options::OPT_nostartfiles)) {
4520 if (!Args.hasArg(options::OPT_shared)) {
4521 CmdArgs.push_back(Args.MakeArgString(
4523 CmdArgs.push_back(Args.MakeArgString(
4525 CmdArgs.push_back(Args.MakeArgString(
4528 CmdArgs.push_back(Args.MakeArgString(
4531 CmdArgs.push_back(Args.MakeArgString(
4535 CmdArgs.push_back(Args.MakeArgString("-L/opt/gcc4/lib/gcc/"
4539 Args.AddAllArgs(CmdArgs, options::OPT_L);
4540 Args.AddAllArgs(CmdArgs, options::OPT_T_Group);
4541 Args.AddAllArgs(CmdArgs, options::OPT_e);
4543 AddLinkerInputs(getToolChain(), Inputs, Args, CmdArgs);
4545 if (!Args.hasArg(options::OPT_nostdlib) &&
4546 !Args.hasArg(options::OPT_nodefaultlibs)) {
4551 if (Args.hasArg(options::OPT_pthread))
4553 if (!Args.hasArg(options::OPT_shared))
4558 if (!Args.hasArg(options::OPT_nostdlib) &&
4559 !Args.hasArg(options::OPT_nostartfiles)) {
4560 if (!Args.hasArg(options::OPT_shared))
4561 CmdArgs.push_back(Args.MakeArgString(
4565 addProfileRT(getToolChain(), Args, CmdArgs, getToolChain().getTriple());
4568 Args.MakeArgString(getToolChain().GetProgramPath("ld"));
4575 const ArgList &Args,
4579 Args.AddAllArgValues(CmdArgs, options::OPT_Wa_COMMA,
4592 Args.MakeArgString(getToolChain().GetProgramPath("as"));
4599 const ArgList &Args,
4604 if ((!Args.hasArg(options::OPT_nostdlib)) &&
4605 (!Args.hasArg(options::OPT_shared))) {
4610 if (Args.hasArg(options::OPT_static)) {
4613 if (Args.hasArg(options::OPT_rdynamic))
4617 if (Args.hasArg(options::OPT_shared)) {
4632 if (!Args.hasArg(options::OPT_nostdlib) &&
4633 !Args.hasArg(options::OPT_nostartfiles)) {
4634 if (!Args.hasArg(options::OPT_shared)) {
4635 if (Args.hasArg(options::OPT_pg))
4636 CmdArgs.push_back(Args.MakeArgString(
4639 CmdArgs.push_back(Args.MakeArgString(
4641 CmdArgs.push_back(Args.MakeArgString(
4644 CmdArgs.push_back(Args.MakeArgString(
4652 CmdArgs.push_back(Args.MakeArgString("-L/usr/lib/gcc-lib/" + Triple +
4655 Args.AddAllArgs(CmdArgs, options::OPT_L);
4656 Args.AddAllArgs(CmdArgs, options::OPT_T_Group);
4657 Args.AddAllArgs(CmdArgs, options::OPT_e);
4659 AddLinkerInputs(getToolChain(), Inputs, Args, CmdArgs);
4661 if (!Args.hasArg(options::OPT_nostdlib) &&
4662 !Args.hasArg(options::OPT_nodefaultlibs)) {
4664 getToolChain().AddCXXStdlibLibArgs(Args, CmdArgs);
4665 if (Args.hasArg(options::OPT_pg))
4675 if (Args.hasArg(options::OPT_pthread))
4677 if (!Args.hasArg(options::OPT_shared)) {
4678 if (Args.hasArg(options::OPT_pg))
4686 if (!Args.hasArg(options::OPT_nostdlib) &&
4687 !Args.hasArg(options::OPT_nostartfiles)) {
4688 if (!Args.hasArg(options::OPT_shared))
4689 CmdArgs.push_back(Args.MakeArgString(
4692 CmdArgs.push_back(Args.MakeArgString(
4697 Args.MakeArgString(getToolChain().GetProgramPath("ld"));
4704 const ArgList &Args,
4722 Args.AddAllArgValues(CmdArgs, options::OPT_Wa_COMMA,
4735 Args.MakeArgString(getToolChain().GetProgramPath("as"));
4742 const ArgList &Args,
4748 CmdArgs.push_back(Args.MakeArgString("--sysroot=" + D.SysRoot));
4750 if (Args.hasArg(options::OPT_static)) {
4753 if (Args.hasArg(options::OPT_rdynamic))
4756 if (Args.hasArg(options::OPT_shared)) {
4783 if (!Args.hasArg(options::OPT_nostdlib) &&
4784 !Args.hasArg(options::OPT_nostartfiles)) {
4785 if (!Args.hasArg(options::OPT_shared)) {
4786 if (Args.hasArg(options::OPT_pg))
4787 CmdArgs.push_back(Args.MakeArgString(
4790 const char *crt = Args.hasArg(options::OPT_pie) ? "Scrt1.o" : "crt1.o";
4791 CmdArgs.push_back(Args.MakeArgString(
4794 CmdArgs.push_back(Args.MakeArgString(
4796 CmdArgs.push_back(Args.MakeArgString(
4799 CmdArgs.push_back(Args.MakeArgString(
4801 CmdArgs.push_back(Args.MakeArgString(
4806 Args.AddAllArgs(CmdArgs, options::OPT_L);
4810 CmdArgs.push_back(Args.MakeArgString(StringRef("-L") + *i));
4811 Args.AddAllArgs(CmdArgs, options::OPT_T_Group);
4812 Args.AddAllArgs(CmdArgs, options::OPT_e);
4813 Args.AddAllArgs(CmdArgs, options::OPT_s);
4814 Args.AddAllArgs(CmdArgs, options::OPT_t);
4815 Args.AddAllArgs(CmdArgs, options::OPT_Z_Flag);
4816 Args.AddAllArgs(CmdArgs, options::OPT_r);
4818 AddLinkerInputs(getToolChain(), Inputs, Args, CmdArgs);
4820 if (!Args.hasArg(options::OPT_nostdlib) &&
4821 !Args.hasArg(options::OPT_nodefaultlibs)) {
4823 getToolChain().AddCXXStdlibLibArgs(Args, CmdArgs);
4824 if (Args.hasArg(options::OPT_pg))
4831 if (Args.hasArg(options::OPT_pg))
4835 if (Args.hasArg(options::OPT_static)) {
4837 } else if (Args.hasArg(options::OPT_pg)) {
4845 if (Args.hasArg(options::OPT_pthread)) {
4846 if (Args.hasArg(options::OPT_pg))
4852 if (Args.hasArg(options::OPT_pg)) {
4853 if (Args.hasArg(options::OPT_shared))
4863 if (Args.hasArg(options::OPT_static)) {
4865 } else if (Args.hasArg(options::OPT_pg)) {
4874 if (!Args.hasArg(options::OPT_nostdlib) &&
4875 !Args.hasArg(options::OPT_nostartfiles)) {
4876 if (!Args.hasArg(options::OPT_shared))
4877 CmdArgs.push_back(Args.MakeArgString(getToolChain().GetFilePath(
4880 CmdArgs.push_back(Args.MakeArgString(getToolChain().GetFilePath(
4882 CmdArgs.push_back(Args.MakeArgString(getToolChain().GetFilePath(
4886 addProfileRT(getToolChain(), Args, CmdArgs, getToolChain().getTriple());
4889 Args.MakeArgString(getToolChain().GetProgramPath("ld"));
4896 const ArgList &Args,
4911 Args.AddAllArgValues(CmdArgs, options::OPT_Wa_COMMA,
4923 const char *Exec = Args.MakeArgString((getToolChain().GetProgramPath("as")));
4930 const ArgList &Args,
4936 CmdArgs.push_back(Args.MakeArgString("--sysroot=" + D.SysRoot));
4938 if (Args.hasArg(options::OPT_static)) {
4941 if (Args.hasArg(options::OPT_rdynamic))
4944 if (Args.hasArg(options::OPT_shared)) {
4966 if (!Args.hasArg(options::OPT_nostdlib) &&
4967 !Args.hasArg(options::OPT_nostartfiles)) {
4968 if (!Args.hasArg(options::OPT_shared)) {
4969 CmdArgs.push_back(Args.MakeArgString(
4971 CmdArgs.push_back(Args.MakeArgString(
4973 CmdArgs.push_back(Args.MakeArgString(
4976 CmdArgs.push_back(Args.MakeArgString(
4978 CmdArgs.push_back(Args.MakeArgString(
4983 Args.AddAllArgs(CmdArgs, options::OPT_L);
4984 Args.AddAllArgs(CmdArgs, options::OPT_T_Group);
4985 Args.AddAllArgs(CmdArgs, options::OPT_e);
4986 Args.AddAllArgs(CmdArgs, options::OPT_s);
4987 Args.AddAllArgs(CmdArgs, options::OPT_t);
4988 Args.AddAllArgs(CmdArgs, options::OPT_Z_Flag);
4989 Args.AddAllArgs(CmdArgs, options::OPT_r);
4991 AddLinkerInputs(getToolChain(), Inputs, Args, CmdArgs);
4993 if (!Args.hasArg(options::OPT_nostdlib) &&
4994 !Args.hasArg(options::OPT_nodefaultlibs)) {
4996 getToolChain().AddCXXStdlibLibArgs(Args, CmdArgs);
5001 if (Args.hasArg(options::OPT_static)) {
5010 if (Args.hasArg(options::OPT_pthread))
5015 if (Args.hasArg(options::OPT_static)) {
5024 if (!Args.hasArg(options::OPT_nostdlib) &&
5025 !Args.hasArg(options::OPT_nostartfiles)) {
5026 if (!Args.hasArg(options::OPT_shared))
5027 CmdArgs.push_back(Args.MakeArgString(getToolChain().GetFilePath(
5030 CmdArgs.push_back(Args.MakeArgString(getToolChain().GetFilePath(
5032 CmdArgs.push_back(Args.MakeArgString(getToolChain().GetFilePath(
5036 addProfileRT(getToolChain(), Args, CmdArgs, getToolChain().getTriple());
5038 const char *Exec = Args.MakeArgString(getToolChain().GetProgramPath("ld"));
5045 const ArgList &Args,
5073 getMipsCPUAndABI(Args, getToolChain(), CPUName, ABIName);
5094 Args.AddLastArg(CmdArgs, options::OPT_march_EQ);
5095 Args.AddLastArg(CmdArgs, options::OPT_mcpu_EQ);
5096 Args.AddLastArg(CmdArgs, options::OPT_mfpu_EQ);
5098 Args.AddAllArgValues(CmdArgs, options::OPT_Wa_COMMA,
5111 Args.MakeArgString(getToolChain().GetProgramPath("as"));
5116 const ArgList &Args) {
5117 bool StaticLibgcc = Args.hasArg(options::OPT_static) ||
5118 Args.hasArg(options::OPT_static_libgcc);
5135 else if (!Args.hasArg(options::OPT_shared) && D.CCCIsCXX)
5142 const ArgList &Args,
5150 Args.ClaimAllArgs(options::OPT_g_Group);
5152 Args.ClaimAllArgs(options::OPT_emit_llvm);
5155 Args.ClaimAllArgs(options::OPT_w);
5158 CmdArgs.push_back(Args.MakeArgString("--sysroot=" + D.SysRoot));
5160 if (Args.hasArg(options::OPT_pie))
5163 if (Args.hasArg(options::OPT_rdynamic))
5166 if (Args.hasArg(options::OPT_s))
5174 if (!Args.hasArg(options::OPT_static)) {
5199 if (Args.hasArg(options::OPT_static)) {
5205 } else if (Args.hasArg(options::OPT_shared)) {
5211 (!Args.hasArg(options::OPT_static) &&
5212 !Args.hasArg(options::OPT_shared))) {
5236 if (!Args.hasArg(options::OPT_nostdlib) &&
5237 !Args.hasArg(options::OPT_nostartfiles)) {
5239 if (!Args.hasArg(options::OPT_shared)){
5240 if (Args.hasArg(options::OPT_pie))
5246 CmdArgs.push_back(Args.MakeArgString(ToolChain.GetFilePath(crt1)));
5248 CmdArgs.push_back(Args.MakeArgString(ToolChain.GetFilePath("crti.o")));
5251 if (Args.hasArg(options::OPT_static))
5253 else if (Args.hasArg(options::OPT_shared) || Args.hasArg(options::OPT_pie))
5257 CmdArgs.push_back(Args.MakeArgString(ToolChain.GetFilePath(crtbegin)));
5260 Args.AddAllArgs(CmdArgs, options::OPT_L);
5266 CmdArgs.push_back(Args.MakeArgString(StringRef("-L") + *i));
5271 if (D.IsUsingLTO(Args) || Args.hasArg(options::OPT_use_gold_plugin)) {
5274 CmdArgs.push_back(Args.MakeArgString(Plugin));
5277 AddLinkerInputs(ToolChain, Inputs, Args, CmdArgs);
5279 if (D.CCCIsCXX && !Args.hasArg(options::OPT_nostdlib)) {
5280 bool OnlyLibstdcxxStatic = Args.hasArg(options::OPT_static_libstdcxx) &&
5281 !Args.hasArg(options::OPT_static);
5284 ToolChain.AddCXXStdlibLibArgs(Args, CmdArgs);
5291 addAsanRTLinux(getToolChain(), Args, CmdArgs);
5293 if (!Args.hasArg(options::OPT_nostdlib)) {
5294 if (Args.hasArg(options::OPT_static))
5297 AddLibgcc(D, CmdArgs, Args);
5299 if (Args.hasArg(options::OPT_pthread) ||
5300 Args.hasArg(options::OPT_pthreads))
5305 if (Args.hasArg(options::OPT_static))
5308 AddLibgcc(D, CmdArgs, Args);
5311 if (!Args.hasArg(options::OPT_nostartfiles)) {
5313 if (Args.hasArg(options::OPT_shared) || Args.hasArg(options::OPT_pie))
5318 CmdArgs.push_back(Args.MakeArgString(ToolChain.GetFilePath(crtend)));
5319 CmdArgs.push_back(Args.MakeArgString(ToolChain.GetFilePath("crtn.o")));
5323 addProfileRT(getToolChain(), Args, CmdArgs, getToolChain().getTriple());
5331 const ArgList &Args,
5335 Args
5348 Args.MakeArgString(getToolChain().GetProgramPath("as"));
5355 const ArgList &Args,
5367 if (!Args.hasArg(options::OPT_nostdlib) &&
5368 !Args.hasArg(options::OPT_nostartfiles)) {
5369 CmdArgs.push_back(Args.MakeArgString(getToolChain().GetFilePath("crt1.o")));
5370 CmdArgs.push_back(Args.MakeArgString(getToolChain().GetFilePath("crti.o")));
5371 CmdArgs.push_back(Args.MakeArgString(getToolChain().GetFilePath("crtbegin.o")));
5372 CmdArgs.push_back(Args.MakeArgString(getToolChain().GetFilePath("crtn.o")));
5375 Args.AddAllArgs(CmdArgs, options::OPT_L);
5376 Args.AddAllArgs(CmdArgs, options::OPT_T_Group);
5377 Args.AddAllArgs(CmdArgs, options::OPT_e);
5379 AddLinkerInputs(getToolChain(), Inputs, Args, CmdArgs);
5381 addProfileRT(getToolChain(), Args, CmdArgs, getToolChain().getTriple());
5383 if (!Args.hasArg(options::OPT_nostdlib) &&
5384 !Args.hasArg(options::OPT_nodefaultlibs)) {
5386 getToolChain().AddCXXStdlibLibArgs(Args, CmdArgs);
5391 if (!Args.hasArg(options::OPT_nostdlib) &&
5392 !Args.hasArg(options::OPT_nostartfiles)) {
5393 if (Args.hasArg(options::OPT_pthread))
5399 Args.MakeArgString(getToolChain().GetFilePath("crtend.o")));
5402 const char *Exec = Args.MakeArgString(getToolChain().GetProgramPath("ld"));
5413 const ArgList &Args,
5422 Args.AddAllArgValues(CmdArgs, options::OPT_Wa_COMMA,
5435 Args.MakeArgString(getToolChain().GetProgramPath("as"));
5442 const ArgList &Args,
5448 CmdArgs.push_back(Args.MakeArgString("--sysroot=" + D.SysRoot));
5450 if (Args.hasArg(options::OPT_static)) {
5453 if (Args.hasArg(options::OPT_shared))
5475 if (!Args.hasArg(options::OPT_nostdlib) &&
5476 !Args.hasArg(options::OPT_nostartfiles)) {
5477 if (!Args.hasArg(options::OPT_shared)) {
5479 Args.MakeArgString(getToolChain().GetFilePath("crt1.o")));
5481 Args.MakeArgString(getToolChain().GetFilePath("crti.o")));
5483 Args.MakeArgString(getToolChain().GetFilePath("crtbegin.o")));
5486 Args.MakeArgString(getToolChain().GetFilePath("crti.o")));
5488 Args.MakeArgString(getToolChain().GetFilePath("crtbeginS.o")));
5492 Args.AddAllArgs(CmdArgs, options::OPT_L);
5493 Args.AddAllArgs(CmdArgs, options::OPT_T_Group);
5494 Args.AddAllArgs(CmdArgs, options::OPT_e);
5496 AddLinkerInputs(getToolChain(), Inputs, Args, CmdArgs);
5498 if (!Args.hasArg(options::OPT_nostdlib) &&
5499 !Args.hasArg(options::OPT_nodefaultlibs)) {
5504 if (!Args.hasArg(options::OPT_static)) {
5519 getToolChain().AddCXXStdlibLibArgs(Args, CmdArgs);
5523 if (Args.hasArg(options::OPT_shared)) {
5530 if (Args.hasArg(options::OPT_pthread))
5533 if (!Args.hasArg(options::OPT_nolibc)) {
5537 if (Args.hasArg(options::OPT_shared)) {
5544 if (!Args.hasArg(options::OPT_nostdlib) &&
5545 !Args.hasArg(options::OPT_nostartfiles)) {
5546 if (!Args.hasArg(options::OPT_shared))
5547 CmdArgs.push_back(Args.MakeArgString(
5550 CmdArgs.push_back(Args.MakeArgString(
5552 CmdArgs.push_back(Args.MakeArgString(
5556 addProfileRT(getToolChain(), Args, CmdArgs, getToolChain().getTriple());
5559 Args.MakeArgString(getToolChain().GetProgramPath("ld"));
5566 const ArgList &Args,
5571 CmdArgs.push_back(Args.MakeArgString(std::string("-out:") +
5577 if (!Args.hasArg(options::OPT_nostdlib) &&
5578 !Args.hasArg(options::OPT_nostartfiles)) {
5584 AddLinkerInputs(getToolChain(), Inputs, Args, CmdArgs);
5587 Args.MakeArgString(getToolChain().GetProgramPath("link.exe"));