diff options
| author | Volodymyr Sapsai <vsapsai@apple.com> | 2019-02-14 23:50:44 +0000 |
|---|---|---|
| committer | Volodymyr Sapsai <vsapsai@apple.com> | 2019-02-14 23:50:44 +0000 |
| commit | 78899aed7f1b911844c5175afdbfc0e963cf0db9 (patch) | |
| tree | 4a12c6f67dbcf5bae65d4ed08d7fd6910fc2f914 /clang/lib | |
| parent | 123be5d4c0dd5c332adc7dc3e75e7f5bde179b42 (diff) | |
| download | bcm5719-llvm-78899aed7f1b911844c5175afdbfc0e963cf0db9.tar.gz bcm5719-llvm-78899aed7f1b911844c5175afdbfc0e963cf0db9.zip | |
[Driver][Darwin] Emit an error when using -pg on OS without support for it.
Instead of letting a program fail at runtime, emit an error during
compilation.
rdar://problem/12206955
Reviewers: dexonsmith, bob.wilson, steven_wu
Reviewed By: steven_wu
Subscribers: jkorous, cfe-commits
Differential Revision: https://reviews.llvm.org/D57991
llvm-svn: 354084
Diffstat (limited to 'clang/lib')
| -rw-r--r-- | clang/lib/Driver/ToolChains/Darwin.cpp | 33 |
1 files changed, 19 insertions, 14 deletions
diff --git a/clang/lib/Driver/ToolChains/Darwin.cpp b/clang/lib/Driver/ToolChains/Darwin.cpp index 582f3f9c4aa..9b3f3740fd4 100644 --- a/clang/lib/Driver/ToolChains/Darwin.cpp +++ b/clang/lib/Driver/ToolChains/Darwin.cpp @@ -2289,22 +2289,27 @@ void Darwin::addStartObjectFileArgs(const ArgList &Args, } } else { if (Args.hasArg(options::OPT_pg) && SupportsProfiling()) { - if (Args.hasArg(options::OPT_static) || - Args.hasArg(options::OPT_object) || - Args.hasArg(options::OPT_preload)) { - CmdArgs.push_back("-lgcrt0.o"); - } else { - CmdArgs.push_back("-lgcrt1.o"); + if (isTargetMacOS() && isMacosxVersionLT(10, 9)) { + if (Args.hasArg(options::OPT_static) || + Args.hasArg(options::OPT_object) || + Args.hasArg(options::OPT_preload)) { + CmdArgs.push_back("-lgcrt0.o"); + } else { + CmdArgs.push_back("-lgcrt1.o"); - // darwin_crt2 spec is empty. + // darwin_crt2 spec is empty. + } + // By default on OS X 10.8 and later, we don't link with a crt1.o + // file and the linker knows to use _main as the entry point. But, + // when compiling with -pg, we need to link with the gcrt1.o file, + // so pass the -no_new_main option to tell the linker to use the + // "start" symbol as the entry point. + if (isTargetMacOS() && !isMacosxVersionLT(10, 8)) + CmdArgs.push_back("-no_new_main"); + } else { + getDriver().Diag(diag::err_drv_clang_unsupported_opt_pg_darwin) + << isTargetMacOS(); } - // By default on OS X 10.8 and later, we don't link with a crt1.o - // file and the linker knows to use _main as the entry point. But, - // when compiling with -pg, we need to link with the gcrt1.o file, - // so pass the -no_new_main option to tell the linker to use the - // "start" symbol as the entry point. - if (isTargetMacOS() && !isMacosxVersionLT(10, 8)) - CmdArgs.push_back("-no_new_main"); } else { if (Args.hasArg(options::OPT_static) || Args.hasArg(options::OPT_object) || |

