Description: Architecture-specific command-line options
 .
 cbmc (5.9-3) unstable; urgency=low
 .
   * Make bitwidth preprocessor options architecture-specific
Author: Michael Tautschnig <mt@debian.org>

---
The information above should follow the Patch Tagging Guidelines, please
checkout http://dep.debian.net/deps/dep3/ to learn about the format. Here
are templates for supplementary fields that you might want to add:

Origin: <vendor|upstream|other>, <url of original patch>
Bug: <url in upstream bugtracker>
Bug-Debian: https://bugs.debian.org/<bugnumber>
Bug-Ubuntu: https://launchpad.net/bugs/<bugnumber>
Forwarded: <no|not-needed|url proving that it has been forwarded>
Reviewed-By: <name and email of someone who approved the patch>
Last-Update: 2018-07-03

--- cbmc-5.9.orig/src/ansi-c/c_preprocess.cpp
+++ cbmc-5.9/src/ansi-c/c_preprocess.cpp
@@ -541,12 +541,41 @@ bool c_preprocess_gcc_clang(
 
   command += " -E -D__CPROVER__";
 
+  const irep_idt &arch = config.ansi_c.arch;
+
   if(config.ansi_c.pointer_width == 16)
-    command += " -m16";
+  {
+    if(arch == "i386" || arch == "x86_64" || arch == "x32")
+      command += " -m16";
+    else if(has_prefix(id2string(arch), "mips"))
+      command += " -mips16";
+  }
   else if(config.ansi_c.pointer_width == 32)
-    command += " -m32";
+  {
+    if(arch == "i386" || arch == "x86_64" || arch == "x32")
+      command += " -m32";
+    else if(has_prefix(id2string(arch), "mips"))
+      command += " -mips32";
+    else if(arch == "powerpc" || arch == "ppc64" || arch == "ppc64le")
+      command += " -m32";
+    else if(arch == "s390" || arch == "s390x")
+      command += " -m31"; // yes, 31, not 32!
+    else if(arch == "sparc" || arch == "sparc64")
+      command += " -m32";
+  }
   else if(config.ansi_c.pointer_width == 64)
-    command += " -m64";
+  {
+    if(arch == "i386" || arch == "x86_64" || arch == "x32")
+      command += " -m64";
+    else if(has_prefix(id2string(arch), "mips"))
+      command += " -mips64";
+    else if(arch == "powerpc" || arch == "ppc64" || arch == "ppc64le")
+      command += " -m64";
+    else if(arch == "s390" || arch == "s390x")
+      command += " -m64";
+    else if(arch == "sparc" || arch == "sparc64")
+      command += " -m64";
+  }
 
   // The width of wchar_t depends on the OS!
   if(config.ansi_c.wchar_t_width == config.ansi_c.short_int_width)
