Index: clang/lib/Driver/ToolChains/FreeBSD.cpp =================================================================== --- clang/lib/Driver/ToolChains/FreeBSD.cpp +++ clang/lib/Driver/ToolChains/FreeBSD.cpp @@ -293,8 +293,8 @@ addLinkerCompressDebugSectionsOption(ToolChain, Args, CmdArgs); AddLinkerInputs(ToolChain, Inputs, Args, CmdArgs, JA); - bool Profiling = Args.hasArg(options::OPT_pg) && - ToolChain.getTriple().getOSMajorVersion() < 14; + unsigned Major = ToolChain.getTriple().getOSMajorVersion(); + bool Profiling = Args.hasArg(options::OPT_pg) && Major != 0 && Major < 14; if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nodefaultlibs)) { // Use the static OpenMP runtime with -static-openmp bool StaticOpenMP = Args.hasArg(options::OPT_static_openmp) && @@ -419,8 +419,8 @@ void FreeBSD::AddCXXStdlibLibArgs(const ArgList &Args, ArgStringList &CmdArgs) const { CXXStdlibType Type = GetCXXStdlibType(Args); - bool Profiling = - Args.hasArg(options::OPT_pg) && getTriple().getOSMajorVersion() < 14; + unsigned Major = getTriple().getOSMajorVersion(); + bool Profiling = Args.hasArg(options::OPT_pg) && Major != 0 && Major < 14; switch (Type) { case ToolChain::CST_Libcxx: Index: clang/test/Driver/freebsd.cpp =================================================================== --- clang/test/Driver/freebsd.cpp +++ clang/test/Driver/freebsd.cpp @@ -16,7 +16,7 @@ // RUN: | FileCheck --check-prefix=CHECK-PG-TEN %s // RUN: %clangxx %s -### -pg -o %t.o -target amd64-unknown-freebsd9.2 -stdlib=platform 2>&1 \ // RUN: | FileCheck --check-prefix=CHECK-PG-NINE %s -// CHECK-PG-DEFAULT: "-lc++_p" "-lm_p" +// CHECK-PG-DEFAULT: "-lc++" "-lm" // CHECK-PG-FOURTEEN: "-lc++" "-lm" // CHECK-PG-TEN: "-lc++_p" "-lm_p" // CHECK-PG-NINE: "-lstdc++_p" "-lm_p"