Skip to content

Commit be5f2ff

Browse files
committed
Use architecture-specific compiler flags to configure bit width during preprocessing
1 parent 8187bdd commit be5f2ff

File tree

1 file changed

+34
-3
lines changed

1 file changed

+34
-3
lines changed

src/ansi-c/c_preprocess.cpp

+34-3
Original file line numberDiff line numberDiff line change
@@ -541,12 +541,43 @@ bool c_preprocess_gcc_clang(
541541

542542
command += " -E -D__CPROVER__";
543543

544+
const irep_idt &arch = config.ansi_c.arch;
545+
544546
if(config.ansi_c.pointer_width == 16)
545-
command += " -m16";
547+
{
548+
if(arch == "i386" || arch == "x86_64" || arch == "x32")
549+
command += " -m16";
550+
else if(has_prefix(id2string(arch), "mips"))
551+
command += " -mips16";
552+
}
546553
else if(config.ansi_c.pointer_width == 32)
547-
command += " -m32";
554+
{
555+
if(arch == "i386" || arch == "x86_64")
556+
command += " -m32";
557+
else if(arch == "x32")
558+
command += " -mx32";
559+
else if(has_prefix(id2string(arch), "mips"))
560+
command += " -mabi=32";
561+
else if(arch == "powerpc" || arch == "ppc64" || arch == "ppc64le")
562+
command += " -m32";
563+
else if(arch == "s390" || arch == "s390x")
564+
command += " -m31"; // yes, 31, not 32!
565+
else if(arch == "sparc" || arch == "sparc64")
566+
command += " -m32";
567+
}
548568
else if(config.ansi_c.pointer_width == 64)
549-
command += " -m64";
569+
{
570+
if(arch == "i386" || arch == "x86_64" || arch == "x32")
571+
command += " -m64";
572+
else if(has_prefix(id2string(arch), "mips"))
573+
command += " -mabi=64";
574+
else if(arch == "powerpc" || arch == "ppc64" || arch == "ppc64le")
575+
command += " -m64";
576+
else if(arch == "s390" || arch == "s390x")
577+
command += " -m64";
578+
else if(arch == "sparc" || arch == "sparc64")
579+
command += " -m64";
580+
}
550581

551582
// The width of wchar_t depends on the OS!
552583
if(config.ansi_c.wchar_t_width == config.ansi_c.short_int_width)

0 commit comments

Comments
 (0)