summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorLuc Van Oostenryck <luc.vanoostenryck@gmail.com>2019-02-25 18:25:59 +0100
committerLuc Van Oostenryck <luc.vanoostenryck@gmail.com>2019-02-25 23:02:30 +0100
commit4b6e02c17bcfb9aecf544f3f2b52846892ceaef1 (patch)
tree26be67ab36f479a811036e5cea9264d259ffae9f
parent4f21b05f3c28e45d283344a02391c182e0667968 (diff)
parent70d043e5c7845b338c08b66cdb5e724ac6f2a508 (diff)
downloadsparse-4b6e02c17bcfb9aecf544f3f2b52846892ceaef1.tar.gz
Merge branch 'cgcc-dumpmachine' into tip
* cgcc: add support for x86-x32 * cgcc: favor using 'gcc -dumpmachine' to determine specifics * cgcc: simpler handling of hard-float ARM * cgcc: add pseudo-archs for ppc64be/ppc64le * cgcc: -dumpmachine should be fetched with '$ccom'
-rwxr-xr-xcgcc50
1 files changed, 39 insertions, 11 deletions
diff --git a/cgcc b/cgcc
index e0be5893..90cc5f77 100755
--- a/cgcc
+++ b/cgcc
@@ -315,6 +315,10 @@ sub add_specs {
} elsif ($spec eq 'ppc64') {
return (' -D_STRING_ARCH_unaligned=1 -m64' .
&float_types (1, 1, 21, [24,8], [53,11], [113,15]));
+ } elsif ($spec eq 'ppc64+be') {
+ return &add_specs ('ppc64') . ' -mbig-endian -D_CALL_ELF=1';
+ } elsif ($spec eq 'ppc64+le') {
+ return &add_specs ('ppc64') . ' -mlittle-endian -D_CALL_ELF=2';
} elsif ($spec eq 's390x') {
return (' -D_BIG_ENDIAN' .
&integer_types (8, 16, 32, $m64 ? 64 : 32, 64) .
@@ -322,15 +326,10 @@ sub add_specs {
&define_size_t ("long unsigned int") .
' -D__SIZEOF_POINTER__=' . ($m64 ? '8' : '4'));
} elsif ($spec eq 'arm') {
- chomp (my $gccmachine = `$cc -dumpmachine`);
- my $cppsymbols = ' -m32';
-
- if ($gccmachine eq 'arm-linux-gnueabihf') {
- $cppsymbols .= ' -D__ARM_PCS_VFP=1';
- }
-
- return ($cppsymbols .
+ return (' -m32' .
&float_types (1, 1, 36, [24,8], [53,11], [53, 11]));
+ } elsif ($spec eq 'arm+hf') {
+ return &add_specs ('arm') . ' -D__ARM_PCS_VFP=1';
} elsif ($spec eq 'aarch64') {
return (' -m64' .
&float_types (1, 1, 36, [24,8], [53,11], [113,15]));
@@ -339,7 +338,36 @@ sub add_specs {
chomp $os;
return &add_specs (lc $os);
} elsif ($spec eq 'host_arch_specs') {
- my $arch = `uname -m`;
+ my $gccmachine;
+ my $arch;
+
+ $gccmachine = `$ccom -dumpmachine`;
+ chomp $gccmachine;
+
+ if ($gccmachine =~ '^aarch64-') {
+ return &add_specs ('aarch64');
+ } elsif ($gccmachine =~ '^arm-.*eabihf$') {
+ return &add_specs ('arm+hf');
+ } elsif ($gccmachine =~ '^arm-') {
+ return &add_specs ('arm');
+ } elsif ($gccmachine =~ '^i[23456]86-') {
+ return &add_specs ('i386');
+ } elsif ($gccmachine =~ '^(powerpc|ppc)64le-') {
+ return &add_specs ('ppc64+le');
+ } elsif ($gccmachine =~ '^s390x-') {
+ return &add_specs ('s390x');
+ } elsif ($gccmachine eq 'x86_64-linux-gnux32') {
+ return &add_specs ('x86_64') . ' -mx32';
+ } elsif ($gccmachine =~ '^x86_64-') {
+ return &add_specs ('x86_64');
+ }
+
+ # fall back to uname -m to determine the specifics.
+ # Note: this is only meaningful when using natively
+ # since information about the host is used to
+ # guess characteristics of the target.
+
+ $arch = `uname -m`;
chomp $arch;
if ($arch =~ /^(i.?86|athlon)$/i) {
return &add_specs ('i386');
@@ -350,9 +378,9 @@ sub add_specs {
} elsif ($arch =~ /^(ppc)$/i) {
return &add_specs ('ppc');
} elsif ($arch =~ /^(ppc64)$/i) {
- return &add_specs ('ppc64') . ' -mbig-endian -D_CALL_ELF=1';
+ return &add_specs ('ppc64+be');
} elsif ($arch =~ /^(ppc64le)$/i) {
- return &add_specs ('ppc64') . ' -mlittle-endian -D_CALL_ELF=2';
+ return &add_specs ('ppc64+le');
} elsif ($arch =~ /^(s390x)$/i) {
return &add_specs ('s390x');
} elsif ($arch =~ /^(sparc64)$/i) {