From 5a63c197477d59567424faab3b56329c426394b9 Mon Sep 17 00:00:00 2001
From: Eddie Hung <eddie@fpgeh.com>
Date: Wed, 15 Jan 2020 13:14:48 -0800
Subject: [PATCH] abc9_ops: -write_box is empty, output a dummy box to prevent
 ABC error

---
 passes/techmap/abc9_exe.cc   | 3 +--
 passes/techmap/abc9_ops.cc   | 3 +++
 techlibs/common/Makefile.inc | 1 -
 techlibs/common/dummy.box    | 1 -
 4 files changed, 4 insertions(+), 4 deletions(-)
 delete mode 100644 techlibs/common/dummy.box

diff --git a/passes/techmap/abc9_exe.cc b/passes/techmap/abc9_exe.cc
index a2acfac91..484964ddf 100644
--- a/passes/techmap/abc9_exe.cc
+++ b/passes/techmap/abc9_exe.cc
@@ -510,9 +510,8 @@ struct Abc9ExePass : public Pass {
 			}
 		}
 
-		// ABC expects a box file for XAIG
 		if (box_file.empty())
-			box_file = "+/dummy.box";
+			log_cmd_error("abc9_exe '-box' option is mandatory.\n");
 
 		rewrite_filename(box_file);
 		if (!box_file.empty() && !is_absolute_path(box_file) && box_file[0] != '+')
diff --git a/passes/techmap/abc9_ops.cc b/passes/techmap/abc9_ops.cc
index fd2759ae5..13340f311 100644
--- a/passes/techmap/abc9_ops.cc
+++ b/passes/techmap/abc9_ops.cc
@@ -569,6 +569,9 @@ void write_box(RTLIL::Module *module, const std::string &src, const std::string
 		module->attributes.erase(it);
 	}
 
+	if (ofs.tellp() == 0)
+		ofs << "(dummy) 1 0 0 0";
+
 	ofs.close();
 }
 
diff --git a/techlibs/common/Makefile.inc b/techlibs/common/Makefile.inc
index a42f63128..42f1068ad 100644
--- a/techlibs/common/Makefile.inc
+++ b/techlibs/common/Makefile.inc
@@ -29,4 +29,3 @@ $(eval $(call add_share_file,share,techlibs/common/gate2lut.v))
 $(eval $(call add_share_file,share,techlibs/common/cmp2lut.v))
 $(eval $(call add_share_file,share,techlibs/common/cells.lib))
 $(eval $(call add_share_file,share,techlibs/common/mul2dsp.v))
-$(eval $(call add_share_file,share,techlibs/common/dummy.box))
diff --git a/techlibs/common/dummy.box b/techlibs/common/dummy.box
deleted file mode 100644
index 0c18070a0..000000000
--- a/techlibs/common/dummy.box
+++ /dev/null
@@ -1 +0,0 @@
-(dummy) 1 0 0 0