Add -ffreestanding to suppress the implicit declaration of library builtins like printf and malloc. Fixes PR3586
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@64566 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/Driver/clang.cpp b/Driver/clang.cpp
index 1452a61..2f7ce69 100644
--- a/Driver/clang.cpp
+++ b/Driver/clang.cpp
@@ -209,6 +209,14 @@
llvm::cl::desc("View C++ inheritance for a specified class"));
//===----------------------------------------------------------------------===//
+// Builtin Options
+//===----------------------------------------------------------------------===//
+static llvm::cl::opt<bool>
+Freestanding("ffreestanding",
+ llvm::cl::desc("Assert that the compiler takes place in a "
+ "freestanding environment"));
+
+//===----------------------------------------------------------------------===//
// Analyzer Options.
//===----------------------------------------------------------------------===//
@@ -636,6 +644,9 @@
if (EnableBlocks.getPosition())
Options.Blocks = EnableBlocks;
+ if (Freestanding)
+ Options.Freestanding = 1;
+
// Override the default runtime if the user requested it.
if (NeXTRuntime)
Options.NeXTRuntime = 1;