Remove IceConverter when LLVM IR is not allowed.

BUG=
R=stichnot@chromium.org

Review URL: https://codereview.chromium.org/689433002
diff --git a/Makefile.standalone b/Makefile.standalone
index ceff1fa..29fcef9 100644
--- a/Makefile.standalone
+++ b/Makefile.standalone
@@ -86,12 +86,11 @@
 	-I$(LIBCXX_INSTALL_PATH)/include/c++/v1
 LDFLAGS := $(HOST_FLAGS) -L$(LIBCXX_INSTALL_PATH)/lib
 
-SRCS= \
+SRCS = \
 	assembler.cpp \
 	assembler_ia32.cpp \
 	IceCfg.cpp \
 	IceCfgNode.cpp \
-	IceConverter.cpp \
 	IceGlobalContext.cpp \
 	IceGlobalInits.cpp \
 	IceInst.cpp \
@@ -111,6 +110,10 @@
 	llvm2ice.cpp \
 	PNaClTranslator.cpp
 
+ifndef MINIMAL
+  SRCS += IceConverter.cpp
+endif
+
 OBJS=$(patsubst %.cpp, $(OBJDIR)/%.o, $(SRCS))
 
 # Keep all the first target so it's the default.
@@ -146,8 +149,13 @@
 	LLVM_BIN_PATH=$(LLVM_BIN_PATH) \
 	$(LLVM_SRC_PATH)/utils/lit/lit.py -sv tests_lit
 
+ifdef MINIMAL
+check: check-lit
+	@echo "Crosstests ignored, minimal build"
+else
 check: check-lit
 	(cd crosstest; ./runtests.sh)
+endif
 
 # TODO: Fix the use of wildcards.
 # Assumes clang-format is within $PATH.
diff --git a/pydir/crosstest.py b/pydir/crosstest.py
index 20e58a0..e30caba 100755
--- a/pydir/crosstest.py
+++ b/pydir/crosstest.py
@@ -105,6 +105,7 @@
                   '--target=' + args.target,
                   '--prefix=' + args.prefix,
                   '-allow-uninitialized-globals',
+                  '-build-on-read=0',
                   '-o=' + asm_sz,
                   bitcode])
         shellcmd(['llvm-mc',
diff --git a/pydir/run-llvm2ice.py b/pydir/run-llvm2ice.py
index 583d7f8..3824673 100755
--- a/pydir/run-llvm2ice.py
+++ b/pydir/run-llvm2ice.py
@@ -74,8 +74,10 @@
       cmd += ['--bitcode-format=pnacl']
       if not args.no_local_syms:
         cmd += ['--allow-local-symbol-tables']
-    if not (args.llvm or args.llvm_source):
-      cmd += ['--build-on-read']
+    if args.llvm or args.llvm_source:
+      cmd += ['--build-on-read=0']
+    else:
+      cmd += ['--build-on-read=1']
     if args.args:
       cmd += args.args
     if args.llvm_source:
diff --git a/src/llvm2ice.cpp b/src/llvm2ice.cpp
index 6573acd..d117b58 100644
--- a/src/llvm2ice.cpp
+++ b/src/llvm2ice.cpp
@@ -148,10 +148,14 @@
                                    "unnamed functions"),
                           cl::init("Function"));
 
+// Note: While this flag isn't used in the minimal build, we keep this
+// flag so that tests can set this command-line flag without concern
+// to the type of build. We double check that this flag at runtime
+// to make sure the consistency is maintained.
 static cl::opt<bool>
-BuildOnRead("build-on-read",
-            cl::desc("Build ICE instructions when reading bitcode"),
-            cl::init(false));
+    BuildOnRead("build-on-read",
+                cl::desc("Build ICE instructions when reading bitcode"),
+                cl::init(true));
 
 static cl::opt<bool>
     UseIntegratedAssembler("integrated-as",
@@ -271,7 +275,7 @@
     Ice::PNaClTranslator Translator(&Ctx, Flags);
     Translator.translate(IRFilename);
     ErrorStatus = Translator.getErrorStatus();
-  } else {
+  } else if (ALLOW_LLVM_IR) {
     // Parse the input LLVM IR file into a module.
     SMDiagnostic Err;
     Ice::TimerMarker T1(Ice::TimerStack::TT_parse, &Ctx);
@@ -286,6 +290,10 @@
     Ice::Converter Converter(Mod, &Ctx, Flags);
     Converter.convertToIce();
     ErrorStatus = Converter.getErrorStatus();
+  } else {
+    *Ls << "Error: Build doesn't allow LLVM IR, "
+        << "--build-on-read=0 not allowed\n";
+    return GetReturnValue(1);
   }
   if (TimeEachFunction) {
     const bool DumpCumulative = false;