Subversion Repositories DevTools

Rev

Rev 7304 | Rev 7320 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 7304 Rev 7307
Line -... Line 1...
-
 
1
########################################################################
1
# -*- mode: perl; tabs: 8; indent-width: 4; show-tabs: yes; -*-
2
# COPYRIGHT - VIX IP PTY LTD ("VIX"). ALL RIGHTS RESERVED.
2
#
3
#
3
# Module name   : GCC
4
# Module name   : GCC.PL
4
# Module type   : Makefile system
5
# Module type   : JATS Utility
5
# Compiler(s)   : ANSI C
6
# Compiler(s)   : Perl
6
# Environment(s): GCC
7
# Environment(s): jats
7
#
8
#
8
# Description:
-
 
9
#       GCC C/C++ toolset
9
# Description   : GCC C/C++ toolset
10
#
10
#
11
#............................................................................#
11
#......................................................................#
12
 
12
 
13
use strict;
13
use strict;
14
use warnings;
14
use warnings;
15
 
15
 
16
# Global variables
16
# Global variables
Line 20... Line 20...
20
#   Misc variables
20
#   Misc variables
21
my $UseGcov = 0;
21
my $UseGcov = 0;
22
my $LcovExplicitBranch = '';
22
my $LcovExplicitBranch = '';
23
my $UseCppcheck = 0;
23
my $UseCppcheck = 0;
24
my $GCCRPath;
24
my $GCCRPath;
-
 
25
my @ldFixups;
25
 
26
 
26
##############################################################################
27
##############################################################################
27
#   Configuration information
28
#   Configuration information
28
#   Cross reference from CrossCompiler Alias to actual paths
29
#   Cross reference from CrossCompiler Alias to actual paths
29
#   Structure:
30
#   Structure:
Line 122... Line 123...
122
       BASE         => 'bin/arm-unknown-linux-gnueabi-',
123
       BASE         => 'bin/arm-unknown-linux-gnueabi-',
123
       VERSION      => '4.8.2',
124
       VERSION      => '4.8.2',
124
       MACHINE      => 'arm-unknown-linux-gnueabi'
125
       MACHINE      => 'arm-unknown-linux-gnueabi'
125
    },
126
    },
126
 
127
 
-
 
128
    'gmx-sdk-imx6-toolchain-5.0.0.0'  => {
-
 
129
       ROOT         => '/opt/gmx-sdk-imx6-toolchain-5.0.0.0',
-
 
130
       BASE         => 'bin/arm-unknown-linux-gnueabi-',
-
 
131
       VERSION      => '4.9.1',
-
 
132
       MACHINE      => 'arm-unknown-linux-gnueabi',
-
 
133
       COMPILER_OPTIONS =>  'pic,brokenldscripts',
-
 
134
    },
-
 
135
 
127
    'x86_64-linux-gnu'    => {
136
    'x86_64-linux-gnu'    => {
128
       ROOT         => '/usr',
137
       ROOT         => '/usr',
129
       BASE         => 'bin/',
138
       BASE         => 'bin/',
130
       PACKAGE_ARCH => 'amd64',
139
       PACKAGE_ARCH => 'amd64',
131
       VERSION      => '4.8',
140
       VERSION      => '4.8',
Line 506... Line 515...
506
        'staticprogs'        => { 'STATIC_PROGS' , '1' },      # Progams link staticlly
515
        'staticprogs'        => { 'STATIC_PROGS' , '1' },      # Progams link staticlly
507
        'no_staticprogs'     => { 'STATIC_PROGS' , undef },    # Default
516
        'no_staticprogs'     => { 'STATIC_PROGS' , undef },    # Default
508
        'noversiondll'       => { 'NO_VERSIONED_DLLS', 1 },    # Matches usage elsewhere
517
        'noversiondll'       => { 'NO_VERSIONED_DLLS', 1 },    # Matches usage elsewhere
509
        'pic'                => { 'GEN_PIC' , '1' },           # Force PIC for static libs
518
        'pic'                => { 'GEN_PIC' , '1' },           # Force PIC for static libs
510
        'nopic'              => { 'GEN_PIC' , undef },         # No Pic on Static libs
519
        'nopic'              => { 'GEN_PIC' , undef },         # No Pic on Static libs
-
 
520
        'brokenldscripts'    => { 'BROKEN_LDSCRIPTS' , 1 },    # the linker is brken and cannot handle linker scripts
511
    );
521
    );
512
 
522
 
513
    #
523
    #
514
    #   Set default options
524
    #   Set default options
515
    #
525
    #
Line 763... Line 773...
763
###############################################################################
773
###############################################################################
764
 
774
 
765
sub ToolsetSHLD
775
sub ToolsetSHLD
766
{
776
{
767
    my( $name, $pArgs, $pObjs, $pLibs, $ver ) = @_;
777
    my( $name, $pArgs, $pObjs, $pLibs, $ver ) = @_;
768
    my( $linkname, $soname, $shared, $dbgname, $def, $def_pref, $multi_scan );
778
    my( $linkname, $soname, $shared, $dbgname, @preReqFiles, @scripts, $multi_scan );
769
    my $sosuffix;
779
    my $sosuffix;
770
    my $noVersionedLib = $::ScmCompilerOpts{'NO_VERSIONED_DLLS'};
780
    my $noVersionedLib = $::ScmCompilerOpts{'NO_VERSIONED_DLLS'};
771
 
-
 
-
 
781
    my $brokenLd = $::ScmCompilerOpts{'BROKEN_LDSCRIPTS'};
772
 
782
 
773
#.. Parse arguments
783
#.. Parse arguments
774
#
784
#
775
    foreach $_ ( @$pArgs )
785
    foreach $_ ( @$pArgs )
776
    {
786
    {
Line 778... Line 788...
778
            #
788
            #
779
            #   Locate the Def file.
789
            #   Locate the Def file.
780
            #   If it is a generate file so it will be in the SRCS hash
790
            #   If it is a generate file so it will be in the SRCS hash
781
            #   Otherwise the user will have to use Src to locate the file
791
            #   Otherwise the user will have to use Src to locate the file
782
            #
792
            #
783
            $def = MakeSrcResolve($1);
793
            my $def = MakeSrcResolve($1);
-
 
794
 
-
 
795
            if ($brokenLd) {
-
 
796
                #   The linker cannot handle the linker script
-
 
797
                #   The work around is to split the script into two that it can handle
-
 
798
                #   Only works with a Linker Script with VERSION and EXTERN entries    
-
 
799
                my $index = scalar @ldFixups; 
-
 
800
                my %data;
784
            $def_pref = '';
801
                $data{src} = $def;
-
 
802
                $data{vs} = '$(OBJDIR)/linkscript_' . $index . '.def';
-
 
803
                $data{ls} = '$(OBJDIR)/linkscript_' . $index . '.scr';
-
 
804
                push @ldFixups, \%data;
-
 
805
 
-
 
806
                push @scripts, $data{ls};
-
 
807
                push @scripts, '--version-script=' . $data{vs};
-
 
808
 
-
 
809
                push @preReqFiles, $data{vs};
-
 
810
                push @preReqFiles, $data{ls};
-
 
811
 
-
 
812
            }  else {
-
 
813
                # Normal operation. Linker is not broken
-
 
814
                push @preReqFiles, $def;
785
            if ( $1 =~ m~\.def$~ ) {
815
                if ( $1 =~ m~\.def$~ ) {
786
                $def_pref = '--version-script='; # Old def file
816
                    $def = '--version-script=' .$def; # Old def file
-
 
817
                }
-
 
818
                push @scripts, $def;
787
            }
819
            }
-
 
820
 
788
        } elsif ( /^--MultiScan/i ) {
821
        } elsif ( /^--MultiScan/i ) {
789
            $multi_scan = 1;
822
            $multi_scan = 1;
790
 
823
 
791
        } elsif ( /^--NoMultiScan/i ) {
824
        } elsif ( /^--NoMultiScan/i ) {
792
            $multi_scan = 0;
825
            $multi_scan = 0;
Line 843... Line 876...
843
 
876
 
844
    $io->Prt( "\$(LIBDIR)/${shared}:\tSHBASE=${name}\n" );
877
    $io->Prt( "\$(LIBDIR)/${shared}:\tSHBASE=${name}\n" );
845
    $io->Prt( "\$(LIBDIR)/${shared}:\tSHNAME=${soname}\n" );
878
    $io->Prt( "\$(LIBDIR)/${shared}:\tSHNAME=${soname}\n" );
846
    $io->Prt( "\$(LIBDIR)/${shared}: \\\n\t\t${dep}" );
879
    $io->Prt( "\$(LIBDIR)/${shared}: \\\n\t\t${dep}" );
847
    $io->Entry( "", "", " \\\n\t\t", ".$::o", @$pObjs );
880
    $io->Entry( "", "", " \\\n\t\t", ".$::o", @$pObjs );
848
    $io->Prt( "\\\n\t\t$def" ) if($def);
881
    $io->Entry( "", "", " \\\n\t\t", "", @preReqFiles );
849
    $io->Prt( "\n\t\$(SHLD)" );
882
    $io->Prt( "\n\t\$(SHLD)" );
850
    $io->Prt( "\n\t\$(call LDSTRIP,$shared_path,$dbg_path)\n\n" );
883
    $io->Prt( "\n\t\$(call LDSTRIP,$shared_path,$dbg_path)\n\n" );
851
    
884
    
852
#
885
#
853
#   Create soft links
886
#   Create soft links
Line 896... Line 929...
896
                                                # object list
929
                                                # object list
897
    $io->ObjList( $name, $pObjs, \&ToolsetObjRecipe );
930
    $io->ObjList( $name, $pObjs, \&ToolsetObjRecipe );
898
 
931
 
899
    ToolsetLibStd( $pLibs );                    # push standard libraries
932
    ToolsetLibStd( $pLibs );                    # push standard libraries
900
 
933
 
901
    $io->Cmd( "-Wl,$def_pref$def" ) if ($def);
934
    $io->Cmd( "-Wl," . join (',', @scripts) ) if (@scripts);
902
 
935
 
903
    $io->Cmd( "-Wl,--start-group" ) if ($multi_scan);
936
    $io->Cmd( "-Wl,--start-group" ) if ($multi_scan);
904
    $io->LibList( $name, $pLibs, \&ToolsetLibRecipe );
937
    $io->LibList( $name, $pLibs, \&ToolsetLibRecipe );
905
    $io->Cmd( "-Wl,--end-group" ) if ($multi_scan);
938
    $io->Cmd( "-Wl,--end-group" ) if ($multi_scan);
906
 
939
 
Line 1057... Line 1090...
1057
sub ToolsetPostprocess
1090
sub ToolsetPostprocess
1058
{
1091
{
1059
    ToolsetPreprocessTests();
1092
    ToolsetPreprocessTests();
1060
    ToolsetPostprocessTests();
1093
    ToolsetPostprocessTests();
1061
    ToolsetCollateTestResults();
1094
    ToolsetCollateTestResults();
-
 
1095
    ToolsetGenLdScripts();
1062
}
1096
}
1063
 
1097
 
1064
###############################################################################
1098
###############################################################################
1065
# Function        : ToolsetPreprocessTests
1099
# Function        : ToolsetPreprocessTests
1066
#
1100
#
Line 1285... Line 1319...
1285
                      . ' ' . $finalTmp1);
1319
                      . ' ' . $finalTmp1);
1286
        $io->Newline();
1320
        $io->Newline();
1287
    }
1321
    }
1288
}
1322
}
1289
 
1323
 
-
 
1324
#-------------------------------------------------------------------------------
-
 
1325
# Function        : ToolsetGenLdScripts 
-
 
1326
#
-
 
1327
# Description     : Generate Linker (ld) scripts to to support the Broken Linker
-
 
1328
#                   Enabled via BROKEN_LDSCRIPTS
-
 
1329
#                   The linker cannot handle a linkerscript with a 'VERSION" section
-
 
1330
#                   The linker can handle a linker script with an EXTERN section
-
 
1331
#                   and a --version-script
-
 
1332
#                   
-
 
1333
#                   This workaround will take the linker script and break it into two
-
 
1334
#                   parts. This must be done at make-time in case the linker script is
-
 
1335
#                   generated.
-
 
1336
#                   
-
 
1337
#                   Use a feature of Pattern Rules. Handling of multiple targets
-
 
1338
#                   The pattern (%) is a '.'. 
-
 
1339
#                   It may be substituted as $* in the output.
-
 
1340
#                   
-
 
1341
#                   file1%out file2%out : infile
-
 
1342
#                       SomeProg file1$*out file2$*out      - Using pattern substitution
-
 
1343
#                       SomeProg file1.out file2.out        - Alternate command
-
 
1344
#                   
-
 
1345
# Inputs          : None 
-
 
1346
#
-
 
1347
# Returns         : Nothing
-
 
1348
#
-
 
1349
sub ToolsetGenLdScripts
-
 
1350
{
-
 
1351
    return unless @ldFixups;
-
 
1352
    Verbose('ToolsetGenLdScripts');
-
 
1353
 
-
 
1354
    my ($io) = ToolsetPrinter::New();
-
 
1355
    $io->PrtLn('# Broken Linker Support');
-
 
1356
    foreach my $entry (@ldFixups)
-
 
1357
    {
-
 
1358
        (my $ls = $entry->{ls}) =~ s~\.~%~;
-
 
1359
        (my $vs = $entry->{vs}) =~ s~\.~%~;
-
 
1360
 
-
 
1361
        $io->Newline();
-
 
1362
        $io->PrtLn("$vs $ls:  $entry->{src} \$(SCM_MAKEFILE)" );
-
 
1363
 
-
 
1364
        $io->PrtLn("\t\$(GBE_PERL) -Mjats_runtime_gcc -e splitscript -- --src=$entry->{src} --vs=$entry->{vs} --ls=$entry->{ls}" );
-
 
1365
        ToolsetGenerate ($entry->{vs} );
-
 
1366
        ToolsetGenerate ($entry->{ls} );
-
 
1367
    }
-
 
1368
}
1290
 
1369
 
1291
###############################################################################
1370
###############################################################################
1292
#   ToolsetARLINT( $name, \@args, \@objs )
1371
#   ToolsetARLINT( $name, \@args, \@objs )
1293
#       This subroutine takes the user options and builds the rules
1372
#       This subroutine takes the user options and builds the rules
1294
#       required to lint the static library 'name'.
1373
#       required to lint the static library 'name'.