diff options
author | Andrey Ponomarenko <aponomarenko@rosalab.ru> | 2014-03-05 17:34:32 +0400 |
---|---|---|
committer | Andrey Ponomarenko <aponomarenko@rosalab.ru> | 2014-03-05 17:34:32 +0400 |
commit | d2ed4c6fe9e08b31b17b1a93054396d40f5dc9ef (patch) | |
tree | 53d4dd006fa7b04208297b4a320b4a64e5605740 | |
parent | 54040a158d7d3fdeba2c37a1e88f14fac6ddd407 (diff) | |
download | abi-compliance-checker-d2ed4c6fe9e08b31b17b1a93054396d40f5dc9ef.tar.gz |
Corrected detection of the GCC target architecture; Added -gcc-options option;
-rw-r--r-- | INSTALL | 2 | ||||
-rwxr-xr-x | abi-compliance-checker.pl | 174 | ||||
-rw-r--r-- | modules/Internals/RegTests.pm | 9 | ||||
-rw-r--r-- | modules/RulesBin.xml | 36 |
4 files changed, 153 insertions, 68 deletions
@@ -10,7 +10,7 @@ RELEASE INFORMATION Project: ABI Compliance Checker (ACC) Version: 1.99.9 -Date: 2014-03-04 +Date: 2014-03-05 This file explains how to install and setup environment diff --git a/abi-compliance-checker.pl b/abi-compliance-checker.pl index 6ac2bf2..f92660e 100755 --- a/abi-compliance-checker.pl +++ b/abi-compliance-checker.pl @@ -94,7 +94,7 @@ $UserLang, $TargetHeadersPath, $BinaryOnly, $SourceOnly, $BinaryReportPath, $SourceReportPath, $UseXML, $Browse, $OpenReport, $SortDump, $DumpFormat, $ExtraInfo, $ExtraDump, $Force, $Tolerance, $Tolerant, $SkipSymbolsListPath, $CheckInfo, $Quick, $AffectLimit, $AllAffected, $CppIncompat, $SkipInternal, -$TargetArch); +$TargetArch, $GccOptions); my $CmdName = get_filename($0); my %OS_LibExt = ( @@ -217,8 +217,9 @@ GetOptions("h|help!" => \$Help, "d|descriptor-template!" => \$GenerateTemplate, "app|application=s" => \$AppPath, "static-libs!" => \$UseStaticLibs, - "cross-gcc|gcc-path=s" => \$CrossGcc, - "cross-prefix|gcc-prefix=s" => \$CrossPrefix, + "gcc-path|cross-gcc=s" => \$CrossGcc, + "gcc-prefix|cross-prefix=s" => \$CrossPrefix, + "gcc-options=s" => \$GccOptions, "sysroot=s" => \$SystemRoot_Opt, "v1|version1|vnum=s" => \$TargetVersion{1}, "v2|version2=s" => \$TargetVersion{2}, @@ -1582,6 +1583,8 @@ my %RegisteredObjects_Short; my %RegisteredSONAMEs; my %RegisteredObject_Dirs; +my %CheckedArch; + # System Objects my %SystemObjects; my @DefaultLibPaths; @@ -8176,7 +8179,7 @@ sub getCompileCmd($$$) $GccCall .= "c++"; } if(my $Opts = platformSpecs($Version)) - {# platform-specific options + { # platform-specific options $GccCall .= " ".$Opts; } # allow extra qualifications @@ -8188,9 +8191,9 @@ sub getCompileCmd($$$) $GccCall .= " -nostdinc"; $GccCall .= " -nostdinc++"; } - if($CompilerOptions{$Version}) + if(my $Opts_GCC = getGCC_Opts($Version)) { # user-defined options - $GccCall .= " ".$CompilerOptions{$Version}; + $GccCall .= " ".$Opts_GCC; } $GccCall .= " \"$Path\""; if($Inc) @@ -15571,8 +15574,7 @@ sub getArch($) if($TargetArch) { return $TargetArch; } - - if($CPU_ARCH{$LibVersion}) + elsif($CPU_ARCH{$LibVersion}) { # dump version return $CPU_ARCH{$LibVersion}; } @@ -15581,29 +15583,7 @@ sub getArch($) return "unknown"; } - return getArch_GCC(); -} - -sub getArch_GCC() -{ - if(defined $Cache{"getArch_GCC"}) { - return $Cache{"getArch_GCC"}; - } - my $Arch = get_dumpmachine($GCC_PATH); # host version - if(not $Arch) { - return "unknown"; - } - if($Arch=~/\A([\w]{3,})(-|\Z)/) { - $Arch = $1; - } - $Arch = "x86" if($Arch=~/\Ai[3-7]86\Z/i); - $Arch = "x86_64" if($Arch=~/\Aamd64\Z/i); - if($OSgroup eq "windows") - { - $Arch = "x86" if($Arch=~/win32|mingw32/i); - $Arch = "x86_64" if($Arch=~/win64|mingw64/i); - } - return ($Cache{"getArch_GCC"} = $Arch); + return getArch_GCC($LibVersion); } sub get_Report_Header($) @@ -19836,19 +19816,14 @@ sub registerObject($$) $RegisteredObjects_Short{$LibVersion}{$Short} = $Path; } - if(not $CPU_ARCH{$LibVersion}) + if(not $CheckedArch{$LibVersion}) { - $CPU_ARCH{$LibVersion} = getArch_Object($Path); - - if($CPU_ARCH{$LibVersion}) + if(my $ObjArch = getArch_Object($Path)) { - if(my $GccArch = getArch_GCC()) - { - if($CPU_ARCH{$LibVersion} ne $GccArch) - { # translation unit dump generated by the GCC compiler should correspond to the input objects - printMsg("WARNING", "the architectures of input objects and the used GCC compiler are not equal, please change the compiler by --gcc-path=PATH option."); - $CPU_ARCH{$LibVersion} = $GccArch; - } + if($ObjArch ne getArch_GCC($LibVersion)) + { # translation unit dump generated by the GCC compiler should correspond to the input objects + $CheckedArch{$LibVersion} = 1; + printMsg("WARNING", "the architectures of input objects and the used GCC compiler are not equal, please change the compiler by --gcc-path=PATH option."); } } } @@ -19925,10 +19900,7 @@ sub getArch_Object($) $Arch = "x86_64"; } - if($Arch=~/\A(x86|x86_64|arm|ia64)\Z/) - { - return $Arch; - } + return $Arch; } } else @@ -20034,53 +20006,123 @@ sub isCyclical($$) return (grep {$_ eq $Value} @{$Stack}); } +sub getGCC_Opts($) +{ # to use in module + my $LibVersion = $_[0]; + + my @Opts = (); + + if($CompilerOptions{$LibVersion}) + { # user-defined options + push(@Opts, $CompilerOptions{$LibVersion}); + } + if($GccOptions) + { # additional + push(@Opts, $GccOptions); + } + + if(@Opts) { + return join(" ", @Opts); + } + + return undef; +} + +sub getArch_GCC($) # get_dumpmachine +{ + my $LibVersion = $_[0]; + + if(defined $Cache{"getArch_GCC"}{$LibVersion}) { + return $Cache{"getArch_GCC"}{$LibVersion}; + } + + my $Arch = undef; + + if($GCC_PATH) + { + writeFile("$TMP_DIR/test.c", "int main(){return 0;}\n"); + + my $Cmd = $GCC_PATH." test.c -o test"; + if(my $Opts = getGCC_Opts($LibVersion)) + { # user-defined options + $Cmd .= " ".$Opts; + } + + chdir($TMP_DIR); + system($Cmd); + chdir($ORIG_DIR); + + $Arch = getArch_Object("$TMP_DIR/test"); + + unlink("$TMP_DIR/test.c"); + unlink("$TMP_DIR/test"); + } + + if(not $Arch) { + exitStatus("Error", "can't check ARCH type"); + } + + return ($Cache{"getArch_GCC"}{$LibVersion} = $Arch); +} + sub detectWordSize($) { my $LibVersion = $_[0]; + my $Size = undef; + + # speed up detection if(my $Arch = getArch($LibVersion)) { - if($Arch=~/64|390x/) - { # x86_64, ppc64, s390x, ia64, etc. - return "8"; + if($Arch=~/\A(x86_64|s390x|ppc64|ia64)\Z/) { + $Size = "8"; } - else - { # x86, ppc, s390, etc. - return "4"; + elsif($Arch=~/\A(x86|s390|ppc32)\Z/) { + $Size = "4"; } } - elsif($GCC_PATH) + + if($GCC_PATH) { writeFile("$TMP_DIR/empty.h", ""); - my $Defines = `$GCC_PATH -E -dD \"$TMP_DIR/empty.h\"`; + + my $Cmd = $GCC_PATH." -E -dD empty.h"; + if(my $Opts = getGCC_Opts($LibVersion)) + { # user-defined options + $Cmd .= " ".$Opts; + } + + chdir($TMP_DIR); + my $Defines = `$Cmd`; + chdir($ORIG_DIR); + unlink("$TMP_DIR/empty.h"); - my $WSize = 0; if($Defines=~/ __SIZEOF_POINTER__\s+(\d+)/) { # GCC 4 - $WSize = $1; + $Size = $1; } elsif($Defines=~/ __PTRDIFF_TYPE__\s+(\w+)/) { # GCC 3 my $PTRDIFF = $1; if($PTRDIFF=~/long/) { - $WSize = "8"; + $Size = "8"; } else { - $WSize = "4"; + $Size = "4"; } } - if(not $WSize) { - exitStatus("Error", "can't check WORD size"); - } - return $WSize; } - # error - return undef; + if(not $Size) { + exitStatus("Error", "can't check WORD size"); + } + + return $Size; } -sub getWordSize($) { +sub getWordSize($) +{ # to use in module return $WORD_SIZE{$_[0]}; } @@ -21096,7 +21138,7 @@ sub detect_default_paths($) if(my $GCC_Ver = get_dumpversion($GCC_PATH)) { my $GccTarget = get_dumpmachine($GCC_PATH); - printMsg("INFO", "Using GCC $GCC_Ver ($GccTarget)"); + printMsg("INFO", "Using GCC $GCC_Ver ($GccTarget, target: ".getArch_GCC(1).")"); if($GccTarget=~/symbian/) { $OStarget = "symbian"; diff --git a/modules/Internals/RegTests.pm b/modules/Internals/RegTests.pm index f9b89ea..8fdaaf0 100644 --- a/modules/Internals/RegTests.pm +++ b/modules/Internals/RegTests.pm @@ -4748,7 +4748,7 @@ sub runTests($$$$$$$$) $BuildCmd = $GCC_PATH." -shared -x c++ libsample.$Ext -lstdc++ -o libsample.$LIB_EXT -g"; $BuildCmd_Test = $GCC_PATH." -x c++ test.$Ext -lstdc++ -Wl,libsample.$LIB_EXT -o test"; } - if(getArch(1)=~/\A(arm|x86_64)\Z/i) + if(getArch_GCC(1)=~/\A(arm|x86_64)\Z/i) { # relocation R_ARM_MOVW_ABS_NC against `a local symbol' can not be used when making a shared object; recompile with -fPIC $BuildCmd .= " -fPIC"; $BuildCmd_Test .= " -fPIC"; @@ -4781,6 +4781,13 @@ sub runTests($$$$$$$$) $BuildCmd_Test = $GCC_PATH." -x c++ test.$Ext -Wl,libsample.$LIB_EXT -o test"; } } + + if(my $Opts = getGCC_Opts(1)) + { # user-defined options + $BuildCmd .= " ".$Opts; + $BuildCmd_Test .= " ".$Opts; + } + my $MkContent = "all:\n\t$BuildCmd\ntest:\n\t$BuildCmd_Test\n"; if($OSgroup eq "windows") { $MkContent .= "clean:\n\tdel test libsample.so\n"; diff --git a/modules/RulesBin.xml b/modules/RulesBin.xml index 285d07f..6929f2e 100644 --- a/modules/RulesBin.xml +++ b/modules/RulesBin.xml @@ -1295,6 +1295,24 @@ <rule> <id> + Private_Field_Type_And_Size + </id> + <severity> + Safe + </severity> + <kind> + Fields + </kind> + <change> + Type of field @target has been changed from @old_value (@old_size) to @new_value (@new_size). + </change> + <effect> + No effect. + </effect> +</rule> + +<rule> + <id> Private_Field_Type_And_Size_And_Type_Size </id> <severity> @@ -1514,6 +1532,24 @@ <rule> <id> + Private_Field_Size + </id> + <severity> + Safe + </severity> + <kind> + Fields + </kind> + <change> + Size of field @target has been changed from @old_size to @new_size. + </change> + <effect> + No effect. + </effect> +</rule> + +<rule> + <id> Private_Field_Size_And_Type_Size </id> <severity> |