LEFT | RIGHT |
1 //===--- Tools.cpp - Tools Implementations --------------------------------===// | 1 //===--- Tools.cpp - Tools Implementations --------------------------------===// |
2 // | 2 // |
3 // The LLVM Compiler Infrastructure | 3 // The LLVM Compiler Infrastructure |
4 // | 4 // |
5 // This file is distributed under the University of Illinois Open Source | 5 // This file is distributed under the University of Illinois Open Source |
6 // License. See LICENSE.TXT for details. | 6 // License. See LICENSE.TXT for details. |
7 // | 7 // |
8 //===----------------------------------------------------------------------===// | 8 //===----------------------------------------------------------------------===// |
9 | 9 |
10 #include "Tools.h" | 10 #include "Tools.h" |
(...skipping 1599 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1610 CmdArgs.push_back("-menable-no-infs"); | 1610 CmdArgs.push_back("-menable-no-infs"); |
1611 if (Arg *A = Args.getLastArg(options::OPT_ffast_math, | 1611 if (Arg *A = Args.getLastArg(options::OPT_ffast_math, |
1612 options::OPT_ffinite_math_only, | 1612 options::OPT_ffinite_math_only, |
1613 options::OPT_fno_finite_math_only, | 1613 options::OPT_fno_finite_math_only, |
1614 options::OPT_fhonor_nans, | 1614 options::OPT_fhonor_nans, |
1615 options::OPT_fno_honor_nans)) | 1615 options::OPT_fno_honor_nans)) |
1616 if (A->getOption().getID() != options::OPT_fno_finite_math_only && | 1616 if (A->getOption().getID() != options::OPT_fno_finite_math_only && |
1617 A->getOption().getID() != options::OPT_fhonor_nans) | 1617 A->getOption().getID() != options::OPT_fhonor_nans) |
1618 CmdArgs.push_back("-menable-no-nans"); | 1618 CmdArgs.push_back("-menable-no-nans"); |
1619 | 1619 |
1620 // -fno-math-errno is default on Darwin. Other platforms, -fmath-errno is the | 1620 // -fmath-errno is the default on some platforms, e.g. BSD-derived OSes. |
1621 // default. | 1621 bool MathErrno = getToolChain().IsMathErrnoDefault(); |
1622 bool MathErrno = !getToolChain().getTriple().isOSDarwin(); | |
1623 if (Arg *A = Args.getLastArg(options::OPT_ffast_math, | 1622 if (Arg *A = Args.getLastArg(options::OPT_ffast_math, |
1624 options::OPT_fmath_errno, | 1623 options::OPT_fmath_errno, |
1625 options::OPT_fno_math_errno)) | 1624 options::OPT_fno_math_errno)) |
1626 MathErrno = A->getOption().getID() == options::OPT_fmath_errno; | 1625 MathErrno = A->getOption().getID() == options::OPT_fmath_errno; |
1627 if (MathErrno) | 1626 if (MathErrno) |
1628 CmdArgs.push_back("-fmath-errno"); | 1627 CmdArgs.push_back("-fmath-errno"); |
1629 | 1628 |
1630 // There are several flags which require disabling very specific | 1629 // There are several flags which require disabling very specific |
1631 // optimizations. Any of these being disabled forces us to turn off the | 1630 // optimizations. Any of these being disabled forces us to turn off the |
1632 // entire set of LLVM optimizations, so collect them through all the flag | 1631 // entire set of LLVM optimizations, so collect them through all the flag |
(...skipping 862 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2495 options::OPT_fno_pascal_strings, | 2494 options::OPT_fno_pascal_strings, |
2496 false) || | 2495 false) || |
2497 Args.hasFlag(options::OPT_mpascal_strings, | 2496 Args.hasFlag(options::OPT_mpascal_strings, |
2498 options::OPT_mno_pascal_strings, | 2497 options::OPT_mno_pascal_strings, |
2499 false)) | 2498 false)) |
2500 CmdArgs.push_back("-fpascal-strings"); | 2499 CmdArgs.push_back("-fpascal-strings"); |
2501 | 2500 |
2502 // Honor -fpack-struct= and -fpack-struct, if given. Note that | 2501 // Honor -fpack-struct= and -fpack-struct, if given. Note that |
2503 // -fno-pack-struct doesn't apply to -fpack-struct=. | 2502 // -fno-pack-struct doesn't apply to -fpack-struct=. |
2504 if (Arg *A = Args.getLastArg(options::OPT_fpack_struct_EQ)) { | 2503 if (Arg *A = Args.getLastArg(options::OPT_fpack_struct_EQ)) { |
2505 CmdArgs.push_back("-fpack-struct"); | 2504 std::string PackStructStr = "-fpack-struct="; |
2506 CmdArgs.push_back(A->getValue(Args)); | 2505 PackStructStr += A->getValue(Args); |
| 2506 CmdArgs.push_back(Args.MakeArgString(PackStructStr)); |
2507 } else if (Args.hasFlag(options::OPT_fpack_struct, | 2507 } else if (Args.hasFlag(options::OPT_fpack_struct, |
2508 options::OPT_fno_pack_struct, false)) { | 2508 options::OPT_fno_pack_struct, false)) { |
2509 CmdArgs.push_back("-fpack-struct"); | 2509 CmdArgs.push_back("-fpack-struct=1"); |
2510 CmdArgs.push_back("1"); | |
2511 } | 2510 } |
2512 | 2511 |
2513 if (Args.hasArg(options::OPT_mkernel) || | 2512 if (Args.hasArg(options::OPT_mkernel) || |
2514 Args.hasArg(options::OPT_fapple_kext)) { | 2513 Args.hasArg(options::OPT_fapple_kext)) { |
2515 if (!Args.hasArg(options::OPT_fcommon)) | 2514 if (!Args.hasArg(options::OPT_fcommon)) |
2516 CmdArgs.push_back("-fno-common"); | 2515 CmdArgs.push_back("-fno-common"); |
2517 Args.ClaimAllArgs(options::OPT_fno_common); | 2516 Args.ClaimAllArgs(options::OPT_fno_common); |
2518 } | 2517 } |
2519 | 2518 |
2520 // -fcommon is default, only pass non-default. | 2519 // -fcommon is default, only pass non-default. |
(...skipping 1508 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4029 | 4028 |
4030 // Give --sysroot= preference, over the Apple specific behavior to also use | 4029 // Give --sysroot= preference, over the Apple specific behavior to also use |
4031 // --isysroot as the syslibroot. | 4030 // --isysroot as the syslibroot. |
4032 StringRef sysroot = C.getSysRoot(); | 4031 StringRef sysroot = C.getSysRoot(); |
4033 if (sysroot != "") { | 4032 if (sysroot != "") { |
4034 CmdArgs.push_back("-syslibroot"); | 4033 CmdArgs.push_back("-syslibroot"); |
4035 CmdArgs.push_back(C.getArgs().MakeArgString(sysroot)); | 4034 CmdArgs.push_back(C.getArgs().MakeArgString(sysroot)); |
4036 } else if (const Arg *A = Args.getLastArg(options::OPT_isysroot)) { | 4035 } else if (const Arg *A = Args.getLastArg(options::OPT_isysroot)) { |
4037 CmdArgs.push_back("-syslibroot"); | 4036 CmdArgs.push_back("-syslibroot"); |
4038 CmdArgs.push_back(A->getValue(Args)); | 4037 CmdArgs.push_back(A->getValue(Args)); |
4039 } else if (getDarwinToolChain().isTargetIPhoneOS()) { | |
4040 CmdArgs.push_back("-syslibroot"); | |
4041 CmdArgs.push_back("/Developer/SDKs/Extra"); | |
4042 } | 4038 } |
4043 | 4039 |
4044 Args.AddLastArg(CmdArgs, options::OPT_twolevel__namespace); | 4040 Args.AddLastArg(CmdArgs, options::OPT_twolevel__namespace); |
4045 Args.AddLastArg(CmdArgs, options::OPT_twolevel__namespace__hints); | 4041 Args.AddLastArg(CmdArgs, options::OPT_twolevel__namespace__hints); |
4046 Args.AddAllArgs(CmdArgs, options::OPT_umbrella); | 4042 Args.AddAllArgs(CmdArgs, options::OPT_umbrella); |
4047 Args.AddAllArgs(CmdArgs, options::OPT_undefined); | 4043 Args.AddAllArgs(CmdArgs, options::OPT_undefined); |
4048 Args.AddAllArgs(CmdArgs, options::OPT_unexported__symbols__list); | 4044 Args.AddAllArgs(CmdArgs, options::OPT_unexported__symbols__list); |
4049 Args.AddAllArgs(CmdArgs, options::OPT_weak__reference__mismatches); | 4045 Args.AddAllArgs(CmdArgs, options::OPT_weak__reference__mismatches); |
4050 Args.AddLastArg(CmdArgs, options::OPT_X_Flag); | 4046 Args.AddLastArg(CmdArgs, options::OPT_X_Flag); |
4051 Args.AddAllArgs(CmdArgs, options::OPT_y); | 4047 Args.AddAllArgs(CmdArgs, options::OPT_y); |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4206 Args.hasArg(options::OPT_bundle)) { | 4202 Args.hasArg(options::OPT_bundle)) { |
4207 CmdArgs.push_back("-undefined"); | 4203 CmdArgs.push_back("-undefined"); |
4208 CmdArgs.push_back("dynamic_lookup"); | 4204 CmdArgs.push_back("dynamic_lookup"); |
4209 } | 4205 } |
4210 } | 4206 } |
4211 | 4207 |
4212 if (Args.hasArg(options::OPT_fopenmp)) | 4208 if (Args.hasArg(options::OPT_fopenmp)) |
4213 // This is more complicated in gcc... | 4209 // This is more complicated in gcc... |
4214 CmdArgs.push_back("-lgomp"); | 4210 CmdArgs.push_back("-lgomp"); |
4215 | 4211 |
4216 getDarwinToolChain().AddLinkSearchPathArgs(Args, CmdArgs); | |
4217 | |
4218 if (isObjCRuntimeLinked(Args)) { | 4212 if (isObjCRuntimeLinked(Args)) { |
4219 // Avoid linking compatibility stubs on i386 mac. | 4213 // Avoid linking compatibility stubs on i386 mac. |
4220 if (!getDarwinToolChain().isTargetMacOS() || | 4214 if (!getDarwinToolChain().isTargetMacOS() || |
4221 getDarwinToolChain().getArchName() != "i386") { | 4215 getDarwinToolChain().getArchName() != "i386") { |
4222 // If we don't have ARC or subscripting runtime support, link in the | 4216 // If we don't have ARC or subscripting runtime support, link in the |
4223 // runtime stubs. We have to do this *before* adding any of the normal | 4217 // runtime stubs. We have to do this *before* adding any of the normal |
4224 // linker inputs so that its initializer gets run first. | 4218 // linker inputs so that its initializer gets run first. |
4225 ObjCRuntime runtime; | 4219 ObjCRuntime runtime; |
4226 getDarwinToolChain().configureObjCRuntime(runtime); | 4220 getDarwinToolChain().configureObjCRuntime(runtime); |
4227 // We use arclite library for both ARC and subscripting support. | 4221 // We use arclite library for both ARC and subscripting support. |
(...skipping 1381 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5609 } | 5603 } |
5610 | 5604 |
5611 CmdArgs.push_back("-nologo"); | 5605 CmdArgs.push_back("-nologo"); |
5612 | 5606 |
5613 AddLinkerInputs(getToolChain(), Inputs, Args, CmdArgs); | 5607 AddLinkerInputs(getToolChain(), Inputs, Args, CmdArgs); |
5614 | 5608 |
5615 const char *Exec = | 5609 const char *Exec = |
5616 Args.MakeArgString(getToolChain().GetProgramPath("link.exe")); | 5610 Args.MakeArgString(getToolChain().GetProgramPath("link.exe")); |
5617 C.addCommand(new Command(JA, *this, Exec, CmdArgs)); | 5611 C.addCommand(new Command(JA, *this, Exec, CmdArgs)); |
5618 } | 5612 } |
LEFT | RIGHT |