diff options
author | Jonathan Peyton <jonathan.l.peyton@intel.com> | 2015-09-14 17:20:30 +0000 |
---|---|---|
committer | Jonathan Peyton <jonathan.l.peyton@intel.com> | 2015-09-14 17:20:30 +0000 |
commit | 8aa5b7d1461247f0ab90a02c08c53fc9c9c5f702 (patch) | |
tree | cf54345b08a109e67473a6921768dc63a3e2e1d3 /runtime/tools | |
parent | 34260e3af776e0303994e5d7e3b11b29e392e712 (diff) |
Removing the Makefile/Perl build system.
This change deletes the Makefile+Perl build system and all files used by it
which aren't used by the CMake build system. This included many Perl files,
*.mk files, iomp* files. This change also updates the README's and
index.html to instruct the user to use the CMake build system. All mentioning
of the Perl+Makefile based system are removed.
Differential Revision: http://reviews.llvm.org/D12331
git-svn-id: https://llvm.org/svn/llvm-project/openmp/trunk@247583 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'runtime/tools')
-rwxr-xr-x | runtime/tools/build.pl | 756 | ||||
-rwxr-xr-x | runtime/tools/check-openmp-test.pl | 18 | ||||
-rwxr-xr-x | runtime/tools/check-openmp.pl | 18 | ||||
-rwxr-xr-x | runtime/tools/check-tools.pl | 605 | ||||
-rw-r--r-- | runtime/tools/common.inc | 109 | ||||
-rwxr-xr-x | runtime/tools/expand-vars.pl | 306 | ||||
-rwxr-xr-x | runtime/tools/extract-objects.pl | 258 | ||||
-rw-r--r-- | runtime/tools/freebsd.inc | 12 | ||||
-rw-r--r-- | runtime/tools/linux.inc | 35 | ||||
-rw-r--r-- | runtime/tools/macos.inc | 37 | ||||
-rwxr-xr-x | runtime/tools/make-fat-binaries.pl | 234 | ||||
-rw-r--r-- | runtime/tools/objcopy.cpp | 520 | ||||
-rwxr-xr-x | runtime/tools/required-objects.pl | 642 | ||||
-rw-r--r-- | runtime/tools/src/common-checks.mk | 95 | ||||
-rw-r--r-- | runtime/tools/src/common-defs.mk | 232 | ||||
-rw-r--r-- | runtime/tools/src/common-rules.mk | 200 | ||||
-rw-r--r-- | runtime/tools/src/common-tools.mk | 487 | ||||
-rw-r--r-- | runtime/tools/windows.inc | 27 | ||||
-rwxr-xr-x | runtime/tools/wipe-string.pl | 183 |
19 files changed, 0 insertions, 4774 deletions
diff --git a/runtime/tools/build.pl b/runtime/tools/build.pl deleted file mode 100755 index 53027a5..0000000 --- a/runtime/tools/build.pl +++ /dev/null @@ -1,756 +0,0 @@ -#!/usr/bin/perl - -# -#//===----------------------------------------------------------------------===// -#// -#// The LLVM Compiler Infrastructure -#// -#// This file is dual licensed under the MIT and the University of Illinois Open -#// Source Licenses. See LICENSE.txt for details. -#// -#//===----------------------------------------------------------------------===// -# - -# Pragmas. -use strict; -use warnings; - -# Standard modules. -use Data::Dumper; # Not actually used, but useful for debugging dumps. - -# Enable `libomp/tools/lib/' module directory. -use FindBin; -use lib "$FindBin::Bin/lib"; - -# LIBOMP modules. -use Build; -use LibOMP; -use Platform ":vars"; -use Uname; -use tools; - -our $VERSION = "0.017"; - -# -------------------------------------------------------------------------------------------------- -# Important variables. -# -------------------------------------------------------------------------------------------------- - -my $root_dir = $ENV{ LIBOMP_WORK }; - -my %makefiles = ( - rtl => cat_file( $root_dir, "src", "makefile.mk" ), - timelimit => cat_file( $root_dir, "tools", "src", "timelimit", "makefile.mk" ), -); - -# -------------------------------------------------------------------------------------------------- -# Parse command line. -# -------------------------------------------------------------------------------------------------- - -# Possible options. -# * targets: comma separated list of targets the option has meaning for. For example, -# "version" option (4 or 5) has a meaning only for "rtl" target, while "mode" option has -# meaning for all targets. -# * base: If base is true this is a base option. All the possible values of base options are -# iterated if "--all" option is specified. If base is 0, this is an extra option. -# * params: A hash of possible option values. "*" denotes default option value. For example, -# if "versio" option is not specified, "--version=5" will be used implicitly. -# * suffux: Only for extra options. Subroutine returning suffix for build and output -# directories. ** When you do not want an option to be part of the suffix, set its base=2 -my $opts = { - "target" => { targets => "", base => 1, parms => { map( ( $_ => "" ), keys( %makefiles ) ), rtl => "*" }, }, - "version" => { targets => "rtl", base => 1, parms => { 5 => "*", 4 => "" }, }, - "lib-type" => { targets => "rtl", base => 1, parms => { normal => "*", stubs => "" }, }, - "link-type" => { targets => "rtl", base => 1, parms => { dynamic => "*", static => "" }, }, - "mode" => { targets => "rtl,dsl,timelimit", base => 0, parms => { release => "*", diag => "", debug => "" }, suffix => sub { substr( $_[ 0 ], 0, 3 ); } }, - "omp-version" => { targets => "rtl", base => 0, parms => { 40 => "", 30 => "", 41 => "*" }, suffix => sub { $_[ 0 ]; } }, - "coverage" => { targets => "rtl", base => 0, parms => { off => "*", on => "" }, suffix => sub { $_[ 0 ] eq "on" ? "c1" : "c0"; } }, - "stats" => { targets => "rtl", base => 0, parms => { off => "*", on => "" }, suffix => sub { $_[ 0 ] eq "on" ? "s1" : "s0"; } }, - "ompt-support" => { targets => "rtl", base => 0, parms => { off => "*", on => "" }, suffix => sub { $_[ 0 ] eq "on" ? "ompt" : "" } }, - "ompt-blame" => { targets => "rtl", base => 0, parms => { off => "", on => "*" }, suffix => sub { $_[ 0 ] eq "on" ? "" : "no-ompt-blame" } }, - "ompt-trace" => { targets => "rtl", base => 0, parms => { off => "", on => "*" }, suffix => sub { $_[ 0 ] eq "on" ? "" : "no-ompt-trace" } }, -}; -my $synonyms = { - "debug" => [ qw{ dbg debg } ], -}; -# This array specifies order of options to process, so it cannot be initialized with keys( %$opts ). -my @all_opts = qw{ target version lib-type link-type mode omp-version coverage stats ompt-support ompt-blame ompt-trace }; -# This is the list of base options. -my @base_opts = grep( $opts->{ $_ }->{ base } == 1, @all_opts ); -# This is the list of extra options. -my @extra_opts = grep( $opts->{ $_ }->{ base } == 0, @all_opts ); - -sub suffix($$$) { - my ( $opt, $value, $skip_if_default ) = @_; - my $suffix = ""; - if ( not $skip_if_default or $value ne $opts->{ $opt }->{ dflt } ) { - $suffix = $opts->{ $opt }->{ suffix }->( $value ); - }; # if - return $suffix; -}; # sub suffix - -my $scuts = {}; # Shortcuts. Will help to locate proper item in $opts. -foreach my $opt ( keys( %$opts ) ) { - foreach my $parm ( keys( %{ $opts->{ $opt }->{ parms } } ) ) { - if ( $parm !~ m{\A(?:[012]|on|off)\z} ) { - $scuts->{ $parm } = $opts->{ $opt }; - }; # if - if ( $opts->{ $opt }->{ parms }->{ $parm } eq "*" ) { - $opts->{ $opt }->{ dflt } = $parm; - }; # if - }; # foreach $parm -}; # foreach $opt - -sub parse_option(@) { - # This function is called to process every option. $name is option name, $value is option value. - # For boolean options $value is either 1 or 0, - my ( $name, $value ) = @_; - if ( $name eq "all" or $name eq "ALL" ) { - foreach my $opt ( keys( %$opts ) ) { - if ( $opts->{ $opt }->{ base } or $name eq "ALL" ) { - foreach my $parm ( keys( %{ $opts->{ $opt }->{ parms } } ) ) { - $opts->{ $opt }->{ parms }->{ $parm } = 1; - }; # foreach $parm - }; # if - }; # foreach $opt - return; - }; # if - if ( exists( $opts->{ $name } ) ) { - # Suppose it is option with explicit value, like "target=normal". - if ( $value eq "all" ) { - foreach my $parm ( keys( %{ $opts->{ $name }->{ parms } } ) ) { - $opts->{ $name }->{ parms }->{ $parm } = 1; - }; # foreach - return; - } elsif ( exists( $opts->{ $name }->{ parms }->{ $value } ) ) { - $opts->{ $name }->{ parms }->{ $value } = 1; - return; - } elsif ( $value eq "" and exists( $opts->{ $name }->{ parms }->{ on } ) ) { - $opts->{ $name }->{ parms }->{ on } = 1; - return; - } else { - cmdline_error( "Illegal value of \"$name\" option: \"$value\"" ); - }; # if - }; # if - # Ok, it is not an option with explicit value. Try to treat is as a boolean option. - if ( exists( $scuts->{ $name } ) ) { - ( $value eq "1" or $value eq "0" ) or die "Internal error; stopped"; - $scuts->{ $name }->{ parms }->{ $name } = $value; - return; - }; # if - # No, it is not a valid option at all. - cmdline_error( "Illegal option: \"$name\"" ); -}; # sub parse_option - -my $clean = 0; -my $clean_common = 0; -my $clobber = 0; -my $test_deps = 1; -my $test_touch = 1; -my @goals; - -sub synonyms($) { - my ( $opt ) = @_; - return exists( $synonyms->{ $opt } ) ? "|" . join( "|", @{ $synonyms->{ $opt } } ) : ""; -}; # sub synonyms - -my @specs = ( - map( ( "$_" . synonyms( $_ ) . "=s" => \&parse_option ), keys( %$opts ) ), - map( ( "$_" . synonyms( $_ ) . "!" => \&parse_option ), keys( %$scuts ) ), -); -my $answer; -get_options( - @specs, - Platform::target_options(), - "all" => \&parse_option, - "ALL" => \&parse_option, - "answer=s" => \$answer, - "test-deps!" => \$test_deps, - "test-touch!" => \$test_touch, - "version|ver:s" => - sub { - # It is a tricky option. It specifies library version to build and it is also a standard - # option to request tool version. - if ( $_[ 1 ] eq "" ) { - # No arguments => version request. - print( "$tool version $VERSION\n" ); - exit( 0 ); - } else { - # Arguments => version to build. - parse_option( @_ ) - }; - }, -); -@goals = @ARGV; -if ( grep( $_ eq "clobber", @goals ) ) { - $clobber = 1; -}; # if -if ( grep( $_ eq "clean", @goals ) ) { - $clean = 1; -}; # if - -# Ok, now $opts is fulfilled with 0, 1 (explicitly set by the user) and "" and "*" (original -# values). In each option at least one 1 should be present (otherwise there is nothing to build). -foreach my $opt ( keys( %$opts ) ) { - if ( not grep( $_ eq "1", values( %{ $opts->{ $opt }->{ parms } } ) ) ) { - # No explicit "1" found. Enable default choice by replacing "*" with "1". - foreach my $parm ( keys( %{ $opts->{ $opt }->{ parms } } ) ) { - if ( $opts->{ $opt }->{ parms }->{ $parm } eq "*" ) { - $opts->{ $opt }->{ parms }->{ $parm } = 1; - }; # if - }; # foreach $parm - }; # if -}; # foreach $opt - -# Clear $opts. Leave only "1". -foreach my $opt ( keys( %$opts ) ) { - foreach my $parm ( keys( %{ $opts->{ $opt }->{ parms } } ) ) { - if ( $opts->{ $opt }->{ parms }->{ $parm } ne "1" ) { - delete( $opts->{ $opt }->{ parms }->{ $parm } ); - }; # if - }; # foreach $parm -}; # foreach $opt - -# -------------------------------------------------------------------------------------------------- -# Fill job queue. -# -------------------------------------------------------------------------------------------------- - -sub enqueue_jobs($$@); -sub enqueue_jobs($$@) { - my ( $jobs, $set, @rest ) = @_; - if ( @rest ) { - my $opt = shift( @rest ); - if ( - exists( $set->{ target } ) - and - $opts->{ $opt }->{ targets } !~ m{(?:\A|,)$set->{ target }(?:,|\z)} - ) { - # This option does not have meananing for the target, - # do not iterate, just use default value. - enqueue_jobs( $jobs, { $opt => $opts->{ $opt }->{ dflt }, %$set }, @rest ); - } else { - foreach my $parm ( sort( keys( %{ $opts->{ $opt }->{ parms } } ) ) ) { - enqueue_jobs( $jobs, { $opt => $parm, %$set }, @rest ); - }; # foreach $parm - }; # if - } else { - my $makefile = $makefiles{ $set->{ target } }; - my @base = map( substr( $set->{ $_ }, 0, 3 ), @base_opts ); - my @extra = map( suffix( $_, $set->{ $_ }, 0 ), @extra_opts ); - my @ex = grep( $_ ne "", map( suffix( $_, $set->{ $_ }, 1 ), @extra_opts ) ); - # Shortened version of @extra -- only non-default values. - my $suffix = ( @extra ? "." . join( ".", @extra ) : "" ); - my $knights = index( $suffix, "kn" ) - 1; - if ( $target_arch !~ "mic" and $knights > 0 ) { - $suffix = substr( $suffix, 0, $knights ); - } - my $suf = ( @ex ? "." . join( ".", @ex ) : "" ); - # Shortened version of $siffix -- only non-default values. - my $build_dir = join( "-", $target_platform, join( "_", @base ) . $suffix, Uname::host_name() ); - my $out_arch_dir = cat_dir( $ENV{ LIBOMP_EXPORTS }, $target_platform . $suf ); - my $out_cmn_dir = cat_dir( $ENV{ LIBOMP_EXPORTS }, "common" ); - push( - @$jobs, - { - makefile => $makefile, - make_args => [ - "os=" . $target_os, - "arch=" . $target_arch, - "MIC_ARCH=" . $target_mic_arch, - "date=" . Build::tstr( $Build::start ), - "TEST_DEPS=" . ( $test_deps ? "on" : "off" ), - "TEST_TOUCH=" . ( $test_touch ? "on" : "off" ), - "CPLUSPLUS=on", - "COVERAGE=" . $set->{ coverage }, - # Option "mode" controls 3 make flags: - # debug => Full debugging : diagnostics, debug info, no optimization. - # diag => Only diagnostics : diagnostics, debug info, optimization. - # release => Production build : no diagnostics, no debug info, optimization. - "DEBUG_INFO=" . ( $set->{ mode } ne "release" ? "on" : "off" ), - "DIAG=" . ( $set->{ mode } ne "release" ? "on" : "off" ), - "OPTIMIZATION=" . ( $set->{ mode } ne "debug" ? "on" : "off" ), - "LIB_TYPE=" . substr( $set->{ "lib-type" }, 0, 4 ), - "LINK_TYPE=" . substr( $set->{ "link-type" }, 0, 4 ), - "OMP_VERSION=" . $set->{ "omp-version" }, - "VERSION=" . $set->{ version }, - "suffix=" . $suf, - "stats=" . $set->{ stats }, - "OMPT_SUPPORT=" . $set->{ "ompt-support" }, - "OMPT_BLAME=" . $set->{ "ompt-blame" }, - "OMPT_TRACE=" . $set->{ "ompt-trace" }, - @goals, - ], - build_dir => $build_dir - } - ); # push - }; # if -}; # sub enqueue_jobs - -my @jobs; -enqueue_jobs( \@jobs, {}, @all_opts ); - -# -------------------------------------------------------------------------------------------------- -# Do the work. -# -------------------------------------------------------------------------------------------------- - -my $exit = 0; - -Build::init(); - -if ( $clobber ) { - my @dirs = ( $ENV{ LIBOMP_TMP }, $ENV{ LIBOMP_EXPORTS }, cat_dir( $root_dir, "tools", "bin" ) ); - my $rc = 0; - question( - "Clobber " . join( ", ", map( "\"" . Build::shorter( $_ ) . "\"", @dirs ) ) . " dirs? ", - $answer, - qr{\A(y|yes|n|no)\z}i - ); - if ( $answer =~ m{\Ay}i ) { - info( "Clobbering..." ); - $rc = Build::clean( @dirs ); - info( Build::rstr( $rc ) ); - }; # if - if ( $rc != 0 ) { - $exit = 3; - }; # if -} else { # Build or clean. - if ( @jobs ) { - my $total = @jobs; # Total number of jobs. - my $n = 0; # Current job number. - Build::progress( "", "" ); # Output empty line to log file. - my $goals = join( " ", @goals ); - Build::progress( "Goals", $goals eq "" ? "(all)" : $goals ); - Build::progress( "Configurations", scalar( @jobs ) ); - foreach my $job ( @jobs ) { - ++ $n; - my $base = get_file( $job->{ build_dir } ); - Build::progress( "Making", "%3d of %3d : %s", $n, $total, $base ); - $job->{ rc } = Build::make( $job, $clean, sprintf( "%d/%d", $n, $total ) ); - }; # my $job - my $failures = Build::summary(); - if ( $failures > 0 ) { - $exit = 3; - }; # if - } else { - info( "Nothing to do." ); - }; # if -}; # if - -# And exit. -exit( $exit ); - -__END__ - -=pod - -=head1 NAME - - -B<build.pl> -- Build one or more configurations of OMP RTL libraries. - -=head1 SYNOPSIS - -B<build.pl> I<option>... [B<-->] I<make-option>... I<variable>... I<goal>... - -=head1 OPTIONS - -=over - -=item B<--all> - -Build all base configurations. - -=item B<--ALL> - -Build really all configurations, including extra ones. - -=item B<--answer=>I<str> - -Use specified string as default answer to all questions. - -=item B<--architecture=>I<arch> - -Specify target architecture to build. Default is architecture of host machine. I<arch> can be C<32>, -C<32e>, C<mic>, or one of known aliases like C<IA32>. - -If architecture is not specified explicitly, value of LIBOMP_ARCH environment variable is used. -If LIBOMP_ARCH is not defined, host architecture detected. - -=item B<--os=>I<os> - -Specify target OS. Default is OS of host machine. I<os> can be C<lin>, C<mac>, C<win>, -or one of known aliases like C<Linux>, C<WinNT>, etc. - -=item B<--mic-arch=>I<arch> - -Specify architecture of Intel(R) Many Integrated Core Architecture card. Default is C<knf>. I<arch> can be C<knf>, C<knc>, C<knl>. - -=item B<-->[B<no->]B<test-deps> - -Enable or disable C<test-deps>. The test runs in any case, but result of disabled test is ignored. -By default, test is enabled. - -=item B<-->[B<no->]B<test-touch> - -Enable or disable C<test-touch>. The test runs in any case, but result of disabled test is ignored. -By default, test is enabled. - -=item Base Configuration Selection Options - -=over - -=item B<--target=>I<target> - -Build specified target, either C<rtl> (OMP Runtime Library; default), -or C<timelimit> (program used in testing), or C<all>. - -=item B<--lib-type=>I<lib> - -Build specified library, either C<normal> (default), or C<stubs>, or C<all>. - -=item B<--link-type=>I<type> - -Build specified link type, either C<dynamic> (default) or C<all>. - -=back - -=item Extra Configuration Selection Options - -=over - -=item B<--cover=>I<switch> - -Build for code coverage data collection. I<switch> can be C<off> (default), C<on> -or C<all>. - -=item B<--mode=>I<mode> - -Build library of specified I<mode>, either C<debug>, C<diag>, C<release> (default), or C<all>. -Mode controls 3 features: - - --------------------------------------------------- - feature/mode debug diag release - --------------------------------------------------- - debug info o o - diagnostics (asserts, traces) o o - code optimization o o - --------------------------------------------------- - -=back - -=item Shortcuts - -If option with C<no> prefix is used, corresponding configuration will B<not> be built. -Useful for excluding some configurations if one or more other options specified with C<all> -value (see Examples). - -=over - -=item B<-->[B<no>]B<11> - -Build files for compiler C<11>. - -=item B<-->[B<no>]B<12> - -Build files for compiler C<12>. - -=item B<-->[B<no>]B<debug> - -=item B<-->[B<no>]B<debg> - -=item B<-->[B<no>]B<dbg> - -Build debuggable library. - -=item B<-->[B<no>]B<diag> - -Build library with diagnostics enabled. - -=item B<-->[B<no>]B<dynamic> - -Build dynamic library (default). - -=item B<-->[B<no>]B<normal> - -Build normal library (default). - -=item B<-->[B<no>]B<release> - -Build release library (default). - -=item B<-->[B<no>]B<rtl> - -Build OMP RTL (default). - -=item B<-->[B<no>]B<stubs> - -Build stubs library. - -=item B<-->[B<no>]B<timelimit> - -Build timelimit utility program. - -=back - -=item Standard Options - -=over - -=item B<--doc> - -=item B<--manual> - -Print full help message and exit. - -=item B<--help> - -Print short help message and exit. - -=item B<--usage> - -Print very short usage message and exit. - -=item B<--verbose> - -Do print informational messages. - -=item B<--version> - -Print program version and exit. - -=item B<--quiet> - -Work quiet, do not print informational messages. - -=back - -=back - -=head1 ARGUMENTS - -=over - -=item I<make-option> - -Any option for makefile, for example C<-k> or C<-n>. If you pass some options to makefile, C<--> -delimiter is mandatory, otherwise C<build.pl> processes all the options internally. - -=item I<variable> - -Define makefile variable in form I<name>B<=>I<value>. Most makefile capabilities are -accessible through C<build.pl> options, so there is no need in defining make variables in command -line. - -=item I<goal> - -Makefile goal to build (or clean). - -=over - -=item B<all> - -Build C<lib>, C<tests>, C<inc>. - -=item B<common> - -Build common (architecture-independent) files. Common files are not configuration-dependent, so -there is no point in building it for more than one configuration (thought it is harmless). -However, do not build common files on many machines simultaneously. - -=item B<clean> - -Delete the export files and clean build directory of configuration(s) specified by options. Note -that C<clean> goal cannot be mixed with other goals (except for C<clean-common>). - -=item B<clean-common> - -Delete the common files in F<exports/> directory. - -=item B<clobber> - -Clean F<export/> and F<tmp/> directories. If C<clobber> is specified, other goals and/or options -do not matter. - -Note: Clobbering is potentialy dangerous operation, because it deletes content of directory -pointed by If C<LIBOMP_TMP> environment variable, so C<build.pl> asks a confirmation before -clobbering. To suppress the question, use option C<--answer=yes>. - -=item B<fat> - -C<mac_32e> only: Build fat libraries for both mac_32 and mac_32e. Should be run when C<lib> -goal is built on both C<mac_32> and C<mac_32e>. - -=item I<file.o> - -(Windows* OS: I<file.obj>) Build specified object file only. - -=item I<file.i> - -Create preprocessed source file. - -=item B<force-tests> - -Force performing tests. - -=item B<force-test-deps> - -Force performing test-deps. - -=item B<force-test-instr> - -Force performing test-instr. - -=item B<force-test-relo> - -Force performing test-relo. - -=item B<force-test-touch> - -Force performing test-touch. - -=item B<inc> - -Build Fortran include files, omp_lib.h, omp_lib.mod and omp_lib_kinds.mod. - -=item B<lib> - -Build library (on Windows* OS in case of dynamic linking, it also builds import library). - -=item B<tests> - -Perform tests: C<test-deps>, C<test-instr>, C<test-relo>, and C<test-touch>. - -=item B<test-deps> - -Check the library dependencies. - -=item B<test-instr> - -Intel(R) Many Integrated Core Architecture only: check the library does not contain undesired instructions. - -=item B<test-relo> - -Linux* OS with dynamic linking only: check the library does not contain position-dependent -code. - -=item B<test-touch> - -Build a very simple application with native compiler (GNU on Linux* OS and OS X*, MS -on Windows* OS), check it does not depend on C<libirc> library, and run it. - -=back - -=back - -=head1 DESCRIPTION - -C<build.pl> constructs the name of a build directory, creates the directory if it -does not exist, changes to it, and runs make to build the goals in specified configuration. -If more than one configuration are specified in command line C<build.pl> builds them all. - -Being run with C<clean> goal, C<build.pl> does not build but deletes export files and -cleans build directories of configuration specified by other options. For example, -C<build.pl --all clean> means "clean build directories for all configurations", -it does B<not> mean "clean then build all". - -C<clear-common> goal deletes common files in F<exports/> directory. -Since common files are really common and not architecture and/or configuration dependent, -there are no much meaning in combining C<clear-common> with configuration selection options. -For example, C<build.pl --all clean-common> deletes the same files 13 times. -However, it does not hurt and can be used in conjunction with C<clear> goal. - -C<clobber> goal instructs C<build.pl> to clean exports and all build -directories, e. g. clean everything under F<exports/> and F<tmp/> directories. - -Logs are saved automatically, there is no need in explicit output redirection. -Log file for each particular configuration is named F<build.log> and located in build directory. -Summary log file (just result of each configuration) is saved in F<tmp/> directory. - -Log files are never overwritten. C<build.pl> always appends output to log files. -However (obviously), C<clear> deletes log file for cleared configurations, -and C<clobber> deletes all summary log files. - -=head2 Environment Variables - -=over - -=item B<LIBOMP_ARCH> - -Specifies target architecture. If not present, host architecture is used. Environment variable may -be overriden by C<--architecture> command line option. - -=item B<LIBOMP_EXPORTS> - -Specifies directory for output files. If not set, C<$LIBOMP_WORK/exports/> used by default. - -=item B<LIBOMP_OS> - -Specifies target OS. If not present, host OS is used. Environment variable may -be overriden by C<--os> command line option. - -=item B<LIBOMP_TMP> - -Directory for temporary files. C<build.pl> creates build directories there. If not set, -C<$LIBOMP_WORK/tmp/> used by default. - -On Windows* OS F<tmp/> directory on local drive speeds up the build process. - -=item B<LIBOMP_WORK> - -Root of libomp directory tree, contains F<src/>, F<tools/>, and F<exports/> subdirs. -If not set, C<build.pl> guesses the root dir (it is a parent of dir containing C<build.pl>). - -Note: Guessing it not reliable. Please set C<LIBOMP_WORK> environment variable appropriately. - -=back - -=head1 EXAMPLES - -=head2 Development - -Build normal (performance) dynamic library for debugging: - - $ build.pl --debug - -Build all libraries (normal, stub; dynamic RTL) for debugging: - - $ build.pl --all --debug - -Do a clean build for all: - - $ build.pl --all --debug clean && build.pl --all --debug - -Debugging libraries are saved in F<exports/I<platform>.deb/>. - -=head2 Promotion - -=over - -=item 1 - -Clobber everything; on one machine: - - $ build.pl clobber - -=item 2 - -Build common headers, on one machine: - - $ build.pl common - -=item 3 - -Build all platform-dependent files, on all machines: - - $ build.pl --all - -=item 4 - -Build OS X* universal (fat) libraries, on C<mac_32e>: - - $ build.pl fat - -=back - -=cut - -# end of file # diff --git a/runtime/tools/check-openmp-test.pl b/runtime/tools/check-openmp-test.pl deleted file mode 100755 index 2e64a74..0000000 --- a/runtime/tools/check-openmp-test.pl +++ /dev/null @@ -1,18 +0,0 @@ -#!/usr/bin/perl - -use strict; -use warnings; - -use FindBin; -use lib "$FindBin::Bin/lib"; - -# LIBOMP modules. -use Build; -use LibOMP; -use Platform ":vars"; -use Uname; -use tools; - -my $root_dir = $ENV{ LIBOMP_WORK }; -print join('', $target_platform, "/"); - diff --git a/runtime/tools/check-openmp.pl b/runtime/tools/check-openmp.pl deleted file mode 100755 index 60334d7..0000000 --- a/runtime/tools/check-openmp.pl +++ /dev/null @@ -1,18 +0,0 @@ -#!/usr/bin/perl - -use strict; -use warnings; - -use FindBin; -use lib "$FindBin::Bin/lib"; - -# LIBOMP modules. -use Build; -use LibOMP; -use Platform ":vars"; -use Uname; -use tools; - -my $root_dir = $ENV{ LIBOMP_WORK }; -print join('', $root_dir, "/", "exports", "/", $target_platform, "/", "lib"); - diff --git a/runtime/tools/check-tools.pl b/runtime/tools/check-tools.pl deleted file mode 100755 index 5f6e53a..0000000 --- a/runtime/tools/check-tools.pl +++ /dev/null @@ -1,605 +0,0 @@ -#!/usr/bin/perl - -# -#//===----------------------------------------------------------------------===// -#// -#// The LLVM Compiler Infrastructure -#// -#// This file is dual licensed under the MIT and the University of Illinois Open -#// Source Licenses. See LICENSE.txt for details. -#// -#//===----------------------------------------------------------------------===// -# - -# Pragmas. -use strict; -use warnings; - -use FindBin; -use lib "$FindBin::Bin/lib"; - -# LIBOMP modules. -use Platform ":vars"; -use tools; - -our $VERSION = "0.015"; - -my $pedantic; - -# -------------------------------------------------------------------------------------------------- -# Helper functions -# -------------------------------------------------------------------------------------------------- - - -sub run($\$\$;\$) { - my ( $cmd, $stdout, $stderr, $path ) = @_; - my ( @path, $rc ); - @path = which( $cmd->[ 0 ], -all => 1 ); - if ( @path > 0 ) { - if ( @path > 1 and $pedantic ) { - warning( "More than one \"$cmd->[ 0 ]\" found in PATH:", map( " $_", @path ) ); - }; # if - debug( "\"$cmd->[ 0 ]\" full path is \"$path[ 0 ]\"." ); - if ( defined( $path ) ) { - $$path = $path[ 0 ]; - }; # if - debug( "Executing command: \"" . join ( " ", @$cmd ) . "\"." ); - $rc = - execute( - $cmd, - -ignore_signal => 1, -ignore_status => 1, - -stdout => $stdout, -stderr => $stderr, -stdin => undef - ); - if ( $rc < 0 ) { - warning( "Cannot run \"$cmd->[ 0 ]\": $@" ); - }; # if - debug( "stdout:", $$stdout, "(eof)", "stderr:", $$stderr, "(eof)" ); - } else { - warning( "No \"$cmd->[ 0 ]\" found in PATH." ); - $rc = -1; - }; # if - return $rc; -}; # sub run - - -sub get_arch($$$) { - my ( $name, $str, $exps ) = @_; - my ( $arch, $count ); - $count = 0; - foreach my $re ( keys( %$exps ) ) { - if ( $str =~ $re ) { - $arch = $exps->{ $re }; - ++ $count; - }; # if - }; # for - if ( $count != 1 or not Platform::canon_arch( $arch ) ) { - warning( "Cannot detect $name architecture: $str" ); - return undef; - }; # if - return $arch; -}; # sub get_arch - -sub encode($) { - my ( $str ) = @_; - $str =~ s{ }{_}g; - return $str; -}; # sub encode - - -# -------------------------------------------------------------------------------------------------- -# get_xxx_version subroutines. -# -------------------------------------------------------------------------------------------------- -# -# Some of get_xxx_version() subroutines accept an argument -- a tool name. For example, -# get_intel_compiler_version() can report version of C, C++, or Fortran compiler. The tool for -# report should be specified by argument, for example: get_intel_compiler_version( "ifort" ). -# -# get_xxx_version() subroutines returns list of one or two elements: -# 1. The first element is short tool name (like "gcc", "g++", "icl", etc). -# 2. The second element is version string. -# If returned list contain just one element, it means there is a problem with the tool. -# - -sub get_perl_version() { - my ( $rc, $stdout, $stderr, $version ); - my $tool = "perl"; - my ( @ret ) = ( $tool ); - $rc = run( [ $tool, "--version" ], $stdout, $stderr ); - if ( $rc >= 0 ) { - # Typical perl output: - # This is perl, v5.10.0 built for x86_64-linux-thread-multi - # This is perl, v5.8.8 built for MSWin32-x64-multi-thread - # This is perl, v5.10.1 (*) built for x86_64-linux-thread-multi - if ( $stdout !~ m{^This is perl.*v(\d+\.\d+(?:\.\d+)).*built for}m ) { - warning( "Cannot parse perl output:", $stdout, "(oef)" ); - }; # if - $version = $1; - if ( $target_os eq "win" ) { - if ( $stdout !~ m{Binary build (.*) provided by ActiveState } ) { - warning( "Perl is not ActiveState one" ); - }; # if - }; # if - }; # if - push( @ret, $version ); - return @ret; -}; # sub get_perl_version - - -sub get_gnu_make_version() { - my ( $rc, $stdout, $stderr, $version ); - my $tool = "make"; - my ( @ret ) = ( $tool ); - my ( $path ); - $rc = run( [ $tool, "--version" ], $stdout, $stderr, $path ); - if ( $rc >= 0 ) { - # Typical make output: - # GNU Make version 3.79.1, by Richard Stallman and Roland McGrath. - # GNU Make 3.81 - if ( $stdout =~ m{^GNU Make (?:version )?(\d+\.\d+(?:\.\d+)?)(?:,|\s)} ) { - $version = $1; - }; # if - if ( $target_os eq "win" and $stdout =~ m{built for ([a-z0-9-]+)} ) { - my $built_for = $1; - debug( "GNU Make built for: \"$built_for\"." ); - if ( $built_for =~ m{cygwin}i ) { - warning( "\"$path\" is a Cygwin make, it is *not* suitable." ); - return @ret; - }; # if - }; # if - }; # if - push( @ret, $version ); - return @ret; -}; # sub get_gnu_make_version - - -sub get_intel_compiler_version($) { - my ( $tool ) = @_; # Tool name, like "icc", "icpc", "icl", or "ifort". - my ( @ret ) = ( $tool ); - my ( $rc, $stdout, $stderr, $tool_re ); - my $version; - my $ic_archs = { - qr{32-bit|IA-32} => "32", - qr{Intel\(R\) 64} => "32e", - qr{Intel\(R\) [M][I][C] Architecture} => "32e", - }; - $tool_re = quotemeta( $tool ); - $rc = run( [ $tool, ( $target_os eq "win" ? () : ( "-V" ) ) ], $stdout, $stderr ); - if ( $rc < 0 ) { - return @ret; - }; # if - # Intel compiler version string is in the first line of stderr. Get it. - #$stderr =~ m{\A(.*\n?)}; - # AC: Let's look for version string in the first line which contains "Intel" string. - # This allows to use 11.1 and 12.0 compilers on new MAC machines by ignoring - # huge number of warnings issued by old compilers. - $stderr =~ m{^(Intel.*)$}m; - my $vstr = $1; - my ( $apl, $ver, $bld, $pkg ); - if ( 0 ) { - } elsif ( $vstr =~ m{^Intel.*?Compiler\s+(.*?),?\s+Version\s+(.*?)\s+Build\s+(\S+)(?:\s+Package ID: (\S+))?} ) { - # 9.x, 10.x, 11.0. - ( $apl, $ver, $bld, $pkg ) = ( $1, $2, $3, $4 ); - } elsif ( $vstr =~ m{^Intel's (.*?) Compiler,?\s+Version\s+(.*?)\s+Build\s+(\S+)} ) { - # 11.1 - ( $apl, $ver, $bld ) = ( $1, $2, $3 ); - } else { - warning( "Cannot parse ${tool}'s stderr:", $stderr, "(eof)" ); - return @ret; - }; # if - my $ic_arch = get_arch( "Intel compiler", $apl, $ic_archs ); - if ( not defined( $ic_arch ) ) { - return @ret; - }; # if - if ( Platform::canon_arch( $ic_arch ) ne $target_arch and not (Platform::canon_arch($ic_arch) eq "32e" and $target_arch eq "mic" )) { - warning( "Target architecture is $target_arch, $tool for $ic_arch found." ); - return @ret; - }; # if - # Normalize version. - my $stage; - $ver =~ s{\s+}{ }g; - $ver = lc( $ver ); - if ( $ver =~ m{\A(\d+\.\d+(?:\.\d+)?) ([a-z]+)\a}i ) { - ( $version, $stage ) = ( $1, $2 ); - } else { - ( $version, $stage ) = ( $ver, "" ); - }; # if - # Parse package. - if ( defined( $pkg ) ) { - if ( $pkg !~ m{\A[lwm]_[a-z]+_[a-z]_(\d+\.\d+\.\d+)\z}i ) { - warning( "Cannot parse Intel compiler package: $pkg" ); - return @ret; - }; # if - $pkg = $1; - $version = $pkg; - }; # if - push( @ret, "$version " . ( $stage ? "$stage " : "" ) . "($bld) for $ic_arch" ); - # Ok, version of Intel compiler found successfully. Now look at config file. - # Installer of Intel compiler tends to add a path to MS linker into compiler config file. - # It leads to troubles. For example, all the environment set up for MS VS 2005, but Intel - # compiler uses lnker from MS VS 2003 because it is specified in config file. - # To avoid such troubles, make sure: - # ICLCFG/IFORTCFG environment variable exists or - # compiler config file does not exist, or - # compiler config file does not specify linker. - if ( $target_os eq "win" ) { - if ( not exists( $ENV{ uc( $tool . "cfg" ) } ) ) { - # If ICLCFG/IFORTCFG environment varianle exists, everything is ok. - # Otherwise check compiler's config file. - my $path = which( $tool ); - $path =~ s{\.exe\z}{}i; # Drop ".exe" suffix. - $path .= ".cfg"; # And add ".cfg" one. - if ( -f $path ) { - # If no config file exists, it is ok. - # Otherwise analyze its content. - my $bulk = read_file( $path ); - $bulk =~ s{#.*\n}{}g; # Remove comments. - my @options = ( "Qvc", "Qlocation,link," ); - foreach my $opt ( @options ) { - if ( $bulk =~ m{[-/]$opt} ) { - warning( "Compiler config file \"$path\" contains \"-$opt\" option." ); - }; # if - }; # foreach - }; # if - }; # if - }; # if - return @ret; -}; # sub get_intel_compiler_version - - -sub get_gnu_compiler_version($) { - my ( $tool ) = @_; - my ( @ret ) = ( $tool ); - my ( $rc, $stdout, $stderr, $version ); - $rc = run( [ $tool, "--version" ], $stdout, $stderr ); - if ( $rc >= 0 ) { - my ( $ver, $bld ); - if ( $target_os eq "mac" ) { - # i686-apple-darwin8-gcc-4.0.1 (GCC) 4.0.1 (Apple Computer, Inc. build 5367) - # i686-apple-darwin9-gcc-4.0.1 (GCC) 4.0.1 (Apple Inc. build 5484) - # i686-apple-darwin11-llvm-gcc-4.2 (GCC) 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2336.9.00) - $stdout =~ m{^.*? \(GCC\) (\d+\.\d+\.\d+) \(.*Apple.*?Inc\. build (\d+)\)}m; - ( $ver, $bld ) = ( $1, $2 ); - } else { - if ( 0 ) { - } elsif ( $stdout =~ m{^.*? \(GCC\) (\d+\.\d+\.\d+)(?: (\d+))?}m ) { - # g++ (GCC) 3.2.3 20030502 (Red Hat Linux 3.2.3-20) - # GNU Fortran (GCC) 4.3.2 20081105 (Red Hat 4.3.2-7) - ( $ver, $bld ) = ( $1, $2 ); - } elsif ( $stdout =~ m{^.*? \(SUSE Linux\) (\d+\.\d+\.\d+)\s+\[.*? (\d+)\]}m ) { - # gcc (SUSE Linux) 4.3.2 [gcc-4_3-branch revision 141291] - ( $ver, $bld ) = ( $1, $2 ); - } elsif ( $stdout =~ m{^.*? \(SUSE Linux\) (\d+\.\d+\.\d+)\s+\d+\s+\[.*? (\d+)\]}m ) { - # gcc (SUSE Linux) 4.7.2 20130108 [gcc-4_7-branch revision 195012] - ( $ver, $bld ) = ( $1, $2 ); - } elsif ( $stdout =~ m{^.*? \((Debian|Ubuntu).*?\) (\d+\.\d+\.\d+)}m ) { - # gcc (Debian 4.7.2-22) 4.7.2 - # Debian support from Sylvestre Ledru - # Thanks! - $ver = $2; - }; # if - }; # if - if ( defined( $ver ) ) { - $version = $ver . ( defined( $bld ) ? " ($bld)" : "" ); - } else { - warning( "Cannot parse GNU compiler version:", $stdout, "(eof)" ); - }; # if - }; # if - push( @ret, $version ); - return @ret; -}; # sub get_gnu_compiler_version - - -sub get_clang_compiler_version($) { - my ( $tool ) = @_; - my ( @ret ) = ( $tool ); - my ( $rc, $stdout, $stderr, $version ); - $rc = run( [ $tool, "--version" ], $stdout, $stderr ); - if ( $rc >= 0 ) { - my ( $ver, $bld ); - if ( $target_os eq "mac" ) { - # Apple LLVM version 4.2 (clang-425.0.28) (based on LLVM 3.2svn) - $stdout =~ m{^.*? (\d+\.\d+) \(.*-(\d+\.\d+\.\d+)\)}m; - ( $ver, $bld ) = ( $1, $2 ); - # For custom clang versions. - if ( not defined($ver) and $stdout =~ m{^.*? (\d+\.\d+)( \((.*)\))?}m ) { - ( $ver, $bld ) = ( $1, $3 ); - } - } else { - if ( 0 ) { - } elsif ( $stdout =~ m{^.*? (\d+\.\d+)( \((.*)\))?}m ) { - # clang version 3.3 (tags/RELEASE_33/final) - ( $ver, $bld ) = ( $1, $3 ); - } - }; # if - if ( defined( $ver ) ) { - $version = $ver . ( defined( $bld ) ? " ($bld)" : "" ); - } else { - warning( "Cannot parse Clang compiler version:", $stdout, "(eof)" ); - }; # if - }; # if - push( @ret, $version ); - return @ret; -}; # sub get_gnu_compiler_version - - -sub get_ms_compiler_version() { - my ( $rc, $stdout, $stderr, $version ); - my $tool = "cl"; - my ( @ret ) = ( $tool ); - my $mc_archs = { - qr{80x86|x86} => "IA-32 architecture", - qr{AMD64|x64} => "Intel(R) 64", - }; - $rc = run( [ $tool ], $stdout, $stderr ); - if ( $rc < 0 ) { - return @ret; - }; # if - if ( $stderr !~ m{^Microsoft .* Compiler Version (.*?) for (.*)\s*$}m ) { - warning( "Cannot parse MS compiler output:", $stderr, "(eof)" ); - return @ret; - }; # if - my ( $ver, $apl ) = ( $1, $2 ); - if ( $ver !~ m{\A\d+(?:\.\d+)+\z} ) { - warning( "Cannot parse MS compiler version: $ver" ); - return @ret; - }; # if - my $mc_arch = get_arch( "MS compiler", $apl, $mc_archs ); - if ( not defined( $mc_arch ) ) { - return @ret; - }; # if - if ( Platform::canon_arch( $mc_arch ) ne $target_arch ) { - warning( "Target architecture is $target_arch, $tool for $mc_arch found" ); - return @ret; - }; # if - $version = "$ver for $target_arch"; - push( @ret, $version ); - return @ret; -}; # sub get_ms_compiler_version - - -sub get_ms_linker_version() { - my ( $rc, $stdout, $stderr, $version ); - my $tool = "link"; - my ( @ret ) = ( $tool ); - my ( $path ); - $rc = run( [ $tool ], $stdout, $stderr, $path ); - if ( $rc < 0 ) { - return @ret; - }; # if - if ( $stdout !~ m{^Microsoft \(R\) Incremental Linker Version (\d+(?:\.\d+)+)\s*$}m ) { - warning( "Cannot parse MS linker output:", $stdout, "(eof)" ); - if ( $stderr =~ m{^link: missing operand} ) { - warning( "Seems \"$path\" is a Unix-like \"link\" program, not MS linker." ); - }; # if - return @ret; - }; # if - $version = ( $1 ); - push( @ret, $version ); - return @ret; -}; # sub get_ms_linker_version - - -# -------------------------------------------------------------------------------------------------- -# "main" program. -# -------------------------------------------------------------------------------------------------- - -my $make; -my $intel = 1; # Check Intel compilers. -my $fortran = 0; # Check for corresponding Fortran compiler, ifort for intel - # gfortran for gnu - # gfortran for clang -my $clang = 0; # Check Clang Compilers. -my $intel_compilers = { - "lin" => { c => "icc", cpp => "icpc", f => "ifort" }, - "mac" => { c => "icc", cpp => "icpc", f => "ifort" }, - "win" => { c => "icl", cpp => undef, f => "ifort" }, -}; -my $gnu_compilers = { - "lin" => { c => "gcc", cpp => "g++", f => "gfortran" }, - "mac" => { c => "gcc", cpp => "g++", f => "gfortran" }, -}; -my $clang_compilers = { - "lin" => { c => "clang", cpp => "clang++" }, - "mac" => { c => "clang", cpp => "clang++" }, -}; - -get_options( - Platform::target_options(), - "intel!" => \$intel, - "fortran" => \$fortran, - "clang" => \$clang, - "make" => \$make, - "pedantic" => \$pedantic, -); - -my @versions; -push( @versions, [ "Perl", get_perl_version() ] ); -push( @versions, [ "GNU Make", get_gnu_make_version() ] ); -if ( $intel ) { - my $ic = $intel_compilers->{ $target_os }; - push( @versions, [ "Intel C Compiler", get_intel_compiler_version( $ic->{ c } ) ] ); - if ( defined( $ic->{ cpp } ) ) { - # If Intel C++ compiler has a name different from C compiler, check it as well. - push( @versions, [ "Intel C++ Compiler", get_intel_compiler_version( $ic->{ cpp } ) ] ); - }; # if - # fortran check must be explicitly specified on command line with --fortran - if ( $fortran ) { - if ( defined( $ic->{ f } ) ) { - push( @versions, [ "Intel Fortran Compiler", get_intel_compiler_version( $ic->{ f } ) ] ); - }; # if - }; -}; # if -if ( $target_os eq "lin" or $target_os eq "mac" ) { - # check for clang/gnu tools because touch-test.c is compiled with them. - if ( $clang or $target_os eq "mac" ) { # OS X* >= 10.9 discarded GNU compilers. - push( @versions, [ "Clang C Compiler", get_clang_compiler_version( $clang_compilers->{ $target_os }->{ c } ) ] ); - push( @versions, [ "Clang C++ Compiler", get_clang_compiler_version( $clang_compilers->{ $target_os }->{ cpp } ) ] ); - } else { - push( @versions, [ "GNU C Compiler", get_gnu_compiler_version( $gnu_compilers->{ $target_os }->{ c } ) ] ); - push( @versions, [ "GNU C++ Compiler", get_gnu_compiler_version( $gnu_compilers->{ $target_os }->{ cpp } ) ] ); - }; - # if intel fortran has been checked then gnu fortran is unnecessary - # also, if user specifies clang as build compiler, then gfortran is assumed fortran compiler - if ( $fortran and not $intel ) { - push( @versions, [ "GNU Fortran Compiler", get_gnu_compiler_version( $gnu_compilers->{ $target_os }->{ f } ) ] ); - }; -}; -if ( $target_os eq "win" ) { - push( @versions, [ "MS C/C++ Compiler", get_ms_compiler_version() ] ); - push( @versions, [ "MS Linker", get_ms_linker_version() ] ); -}; # if - -my $count = 0; -foreach my $item ( @versions ) { - my ( $title, $tool, $version ) = @$item; - if ( not defined( $version ) ) { - $version = "--- N/A ---"; - ++ $count; - }; # if - if ( $make ) { - printf( "%s=%s\n", encode( $tool ), encode( $version ) ); - } else { - printf( "%-25s: %s\n", $title, $version ); - }; # if -}; # foreach - -exit( $count == 0 ? 0 : 1 ); - -__END__ - -=pod - -=head1 NAME - -B<check-tools.pl> -- Check development tools availability and versions. - -=head1 SYNOPSIS - -B<check-tools.pl> I<OPTION>... - -=head1 OPTIONS - -=over - -=item B<--make> - -Produce output suitable for using in makefile: short tool names (e. g. "icc" instead of "Intel C -Compiler"), spaces in version strings replaced with underscores. - -=item Tools selection - -=over - -=item B<-->[B<no->]B<-gnu-fortran> - -Check GNU Fortran compiler. By default, it is not checked. - -=item B<-->[B<no->]B<intel> - -Check Intel C, C++ and Fortran compilers. This is default. - -=back - -=item Platform selection - -=over - -=item B<--architecture=>I<str> - -Specify target architecture. Used in cross-builds, for example when building 32-bit applications on -Intel(R) 64 machine. - -If architecture is not specified explicitly, value of LIBOMP_ARCH environment variable is used. -If LIBOMP_ARCH is not defined, host architecture detected. - -=item B<--os=>I<str> - -Specify target OS name. Used in cross-builds, for example when building Intel(R) Many Integrated Core Architecture applications on -Windows* OS. - -If OS is not specified explicitly, value of LIBOMP_OS environment variable is used. -If LIBOMP_OS is not defined, host OS detected. - -=back - -=back - -=head2 Standard Options - -=over - -=item B<--doc> - -=item B<--manual> - -Print full help message and exit. - -=item B<--help> - -Print short help message and exit. - -=item B<--usage> - -Print very short usage message and exit. - -=item B<--verbose> - -Do print informational messages. - -=item B<--version> - -Print version and exit. - -=item B<--quiet> - -Work quiet, do not print informational messages. - -=back - -=head1 DESCRIPTION - -This script checks availability and versions of development tools. By default, the script checks: -Perl, GNU Make, Intel compilers, GNU C and C++ compilers (Linux* OS and OS X*), -Microsoft C/C++ compiler and linker (Windows* OS). - -The sript prints nice looking table or machine-readable strings. - -=head2 EXIT - -=over - -=item * - -0 -- All programs found. - -=item * - -1 -- Some of tools are not found. - -=back - -=head1 EXAMPLES - - $ check-tools.pl - Perl : 5.8.0 - GNU Make : 3.79.1 - Intel C Compiler : 11.0 (20080930) for 32e - Intel C++ Compiler : 11.0 (20080930) for 32e - Intel Fortran Compiler : 10.1.008 (20070913) for 32e - GNU C Compiler : 3.2.3 (20030502) - GNU C++ Compiler : 3.2.3 (20030502) - - > check-tools.pl --make - perl=5.8.8 - make=3.81 - icl=10.1_(20070913)_for_32e - ifort=10.1_(20070913)_for_32e - cl=14.00.40310.41_for_32e - link=8.00.40310.39 - -=back - -=cut - -# end of file # - diff --git a/runtime/tools/common.inc b/runtime/tools/common.inc deleted file mode 100644 index 2e51a69..0000000 --- a/runtime/tools/common.inc +++ /dev/null @@ -1,109 +0,0 @@ -# -#//===----------------------------------------------------------------------===// -#// -#// The LLVM Compiler Infrastructure -#// -#// This file is dual licensed under the MIT and the University of Illinois Open -#// Source Licenses. See LICENSE.txt for details. -#// -#//===----------------------------------------------------------------------===// -# - -ifndef omp_os - - # Windows sets environment variable OS; for other systems, ask uname - ifeq ($(OS),) - OS:=$(shell uname) - ifeq ($(OS),) - $(error "Cannot detect operating system") - endif - export omp_os=$(OS) - endif - - ifeq ($(OS), Windows_NT) - export omp_os=windows - endif - ifeq ($(OS), Linux) - export omp_os=linux - endif - ifeq ($(OS), FreeBSD) - export omp_os=freebsd - endif - ifeq ($(OS), Darwin) - export omp_os=macos - endif - -endif # !omp_os - -# Compiling for the Intel(R) Many Integrated Core architecture is non-trivial at the next layer -# of script down, but we can make it consistent here. -ifneq "$(filter knf knc knl, $(arch))" "" - # I really do mean this... - # have top-level arch=mic and then mic_arch = flavor of mic - override mic_arch:=$(arch) - override arch:=mic - override mic:=yes -else - ifeq "$(arch)" "mic" - # default flavor of mic is knc - mic_arch?=knc - override mic:=yes - else - override mic:=no - endif -endif - -ifeq (,$(wildcard $(omp_root)/tools/$(omp_os).inc)) - $(error "$(omp_os)" is not supported. Add tools/$(omp_os).inc file with os-specific settings ) -endif - -# detect arch and runtime versions, provide common host-specific definitions -include $(omp_root)/tools/$(omp_os).inc - -ifeq ($(arch),) - $(error Architecture not detected) -endif - -# Setting defaults -mode?=release - -ifeq "$(filter 32 32e 64 mic,$(arch))" "" - compiler?=gcc -else - ifeq "$(omp_os)" "windows" - compiler?=icl - else - compiler?=icc - endif -endif - -ifneq "$(mic)" "no" - ifeq "$(compiler)" "gcc" - $(error Compiling the runtime with gcc is not supported on Intel(R) Many Integrated Core Architecture) - endif - - # Add Intel(R) Many Integrated Core Architecture kind (knf, knc, knl, etc.) - build_args += --mic-arch=$(mic_arch) - - # Check that the binutils for Intel(R) Many Integrated Core Architecture are available - # First we see whether the objdump on the user's path supports the k1om architecture. - hask1om = $(shell if (x86_64-k1om-linux-objdump --help | grep -s k1om); then echo OK; else echo KO; fi) - ifneq "$(hask1om)" "OK" - # Appropriate binutils are not already set up, so try to add them from the default place. - micBinPath = /usr/linux-k1om-4.7/bin - micBinPresent = $(shell if test -d $(micBinPath); then echo OK; else echo KO; fi) - ifneq "$(micBinPresent)" "OK" - # We can't find them in the normal place, so complain. - $(error Compiling for Intel(R) Many Integrated Core Architecture requires that the cross-hosted binutils are available in $(micBinPath).\ -See the Tools tab at http://software.intel.com/mic-developer) - endif - export PATH := $(micBinPath):${PATH} - endif -endif - -# number of parallel build jobs -jobs?=1 - -export BUILD_COMPILER := $(compiler) - - diff --git a/runtime/tools/expand-vars.pl b/runtime/tools/expand-vars.pl deleted file mode 100755 index 40a6490..0000000 --- a/runtime/tools/expand-vars.pl +++ /dev/null @@ -1,306 +0,0 @@ -#!/usr/bin/perl - -# -#//===----------------------------------------------------------------------===// -#// -#// The LLVM Compiler Infrastructure -#// -#// This file is dual licensed under the MIT and the University of Illinois Open -#// Source Licenses. See LICENSE.txt for details. -#// -#//===----------------------------------------------------------------------===// -# - -use strict; -use warnings; - -use FindBin; -use lib "$FindBin::Bin/lib"; - -use tools; - -our $VERSION = "0.005"; - -my $name_rexp = qr{[A-Za-z_]+[A-Za-z0-9_]*}; -my $keyword_rexp = qr{if|else|end|omp}; - -sub error($$$) { - my ( $input, $msg, $bulk ) = @_; - my $pos = pos( $$bulk ); - $$bulk =~ m{^(.*?)\G(.*?)$}m or die "Internal error"; - my ( $pre, $post ) = ( $1, $2 ); - my $n = scalar( @{ [ substr( $$bulk, 0, $pos ) =~ m{\n}g ] } ) + 1; - runtime_error( "\"$input\" line $n: $msg:", ">>> " . $pre . "--[HERE]-->" . $post ); -}; # sub error - -sub evaluate($$$\$) { - my ( $expr, $strict, $input, $bulk ) = @_; - my $value; - { # Signal handler will be restored on exit from this block. - # In case of "use strict; use warnings" eval issues warnings to stderr. This direct - # output may confuse user, so we need to catch it and prepend with our info. - local $SIG{ __WARN__ } = sub { die @_; }; - $value = - eval( - "package __EXPAND_VARS__;\n" . - ( $strict ? "use strict; use warnings;\n" : "no strict; no warnings;\n" ) . - $expr - ); - }; - if ( $@ ) { - # Drop location information -- increasing eval number and constant "line 3" - # is useless for the user. - $@ =~ s{ at \(eval \d+\) line \d+}{}g; - $@ =~ s{\s*\z}{}; - error( $input, "Cannot evaluate expression \"\${{$expr}}\": $@", $bulk ); - }; # if - if ( $strict and not defined( $value ) ) { - error( $input, "Substitution value is undefined", $bulk ); - }; # if - return $value; -}; # sub evaluate - -# -# Parse command line. -# - -my ( @defines, $input, $output, $strict ); -get_options( - "D|define=s" => \@defines, - "strict!" => \$strict, -); -if ( @ARGV < 2 ) { - cmdline_error( "Not enough argument" ); -}; # if -if ( @ARGV > 2 ) { - cmdline_error( "Too many argument(s)" ); -}; # if -( $input, $output ) = @ARGV; - -foreach my $define ( @defines ) { - my ( $equal, $name, $value ); - $equal = index( $define, "=" ); - if ( $equal < 0 ) { - $name = $define; - $value = ""; - } else { - $name = substr( $define, 0, $equal ); - $value = substr( $define, $equal + 1 ); - }; # if - if ( $name eq "" ) { - cmdline_error( "Illegal definition: \"$define\": variable name should not be empty." ); - }; # if - if ( $name !~ m{\A$name_rexp\z} ) { - cmdline_error( - "Illegal definition: \"$define\": " . - "variable name should consist of alphanumeric characters." - ); - }; # if - eval( "\$__EXPAND_VARS__::$name = \$value;" ); - if ( $@ ) { - die( "Internal error: $@" ); - }; # if -}; # foreach $define - -# -# Do the work. -# - -my $bulk; - -# Read input file. -$bulk = read_file( $input ); - -# Do the replacements. -$bulk =~ - s{(?:\$($keyword_rexp)|\$($name_rexp)|\${{(.*?)}})} - { - my $value; - if ( defined( $1 ) ) { - # Keyword. Leave it as is. - $value = "\$$1"; - } elsif ( defined( $2 ) ) { - # Variable to expand. - my $name = $2; - $value = eval( "\$__EXPAND_VARS__::$name" ); - if ( $@ ) { - die( "Internal error" ); - }; # if - if ( $strict and not defined( $value ) ) { - error( $input, "Variable \"\$$name\" not defined", \$bulk ); - }; # if - } else { - # Perl code to evaluate. - my $expr = $3; - $value = evaluate( $expr, $strict, $input, $bulk ); - }; # if - $value; - }ges; - -# Process conditionals. -# Dirty patch! Nested conditionals not supported! -# TODO: Implement nested constructs. -$bulk =~ - s{^\$if +([^\n]*) *\n(.*\n)\$else *\n(.*\n)\$end *\n} - { - my ( $expr, $then_part, $else_part ) = ( $1, $2, $3 ); - my $value = evaluate( $expr, $strict, $input, $bulk ); - if ( $value ) { - $value = $then_part; - } else { - $value = $else_part; - }; # if - }gesm; - -# Write output. -write_file( $output, \$bulk ); - -exit( 0 ); - -__END__ - -=pod - -=head1 NAME - -B<expand-vars.pl> -- Simple text preprocessor. - -=head1 SYNOPSIS - -B<expand-vars.pl> I<OPTION>... I<input> I<output> - -=head1 OPTIONS - -=over - -=item B<-D> I<name>[B<=>I<value>] - -=item B<--define=>I<name>[B<=>I<value>] - -Define variable. - -=item B<--strict> - -In strict mode, the script issues error on using undefined variables and executes Perl code -with C<use strict; use warnings;> pragmas. - -=back - -=head2 Standard Options - -=over - -=item B<--doc> - -=item B<--manual> - -Print full help message and exit. - -=item B<--help> - -Print short help message and exit. - -=item B<--usage> - -Print very short usage message and exit. - -=item B<--verbose> - -Do print informational messages. - -=item B<--version> - -Print version and exit. - -=item B<--quiet> - -Work quiet, do not print informational messages. - -=back - -=head1 ARGUMENTS - -=over - -=item I<input> - -Input file name. - -=item I<output> - -Output file name. - -=back - -=head1 DESCRIPTION - -This script reads input file, makes substitutes and writes output file. - -There are two form of substitutes: - -=over - -=item Variables - -Variables are referenced in input file in form: - - $name - -Name of variable should consist of alphanumeric characters (Latin letters, digits, and underscores). -Variables are defined in command line with C<-D> or C<--define> options. - -=item Perl Code - -Perl code is specified in input file in form: - - ${{ ...code... }} - -The code is evaluated, and is replaced with its result. Note: in strict mode, you should declare -variable before use. See examples. - -=back - -=head1 EXAMPLES - -Replace occurrences of C<$year>, C<$month>, and C<$day> in C<input.txt> file with C<2007>, C<09>, C<01> -respectively and write result to C<output.txt> file: - - $ cat input.var - Today is $year-$month-$day. - $ expand-vars.pl -D year=2007 -D month=09 -D day=01 input.var output.txt && cat output.txt - Today is 2007-09-01. - -Using Perl code: - - $ cat input.var - ${{ localtime(); }} - $ expand-vars.pl -D year=2007 -D month=09 -D day=01 input.var output.txt && cat output.txt - Now Tue May 5 20:54:13 2009 - -Using strict mode for catching bugs: - - $ cat input.var - ${{ "year : " . substr( $date, 0, 4 ); }} - $ expand-vars.pl input.var output.txt && cat output.txt - year : - -Oops, why it does not print year? Let us use strict mode: - - $ expand-vars.pl --strict input.var output.txt && cat output.txt - expand-vars.pl: (x) "test.var": Cannot evaluate expression "${{ "year : " . substr( $date, 0, 4 ); }}": Global symbol "$date" requires explicit package name - -Ok, variable is not defined. Let us define it: - - $ expand-vars.pl --strict -D date=20090501 input.var output.txt && cat output.txt - expand-vars.pl: (x) "test.var": Cannot evaluate expression "${{ "year : " . substr( $date, 0, 4 ); }}": Variable "$date" is not imported - -What is wrong? Variable should be declared: - - $ cat input.var - ${{ our $date; "year : " . substr( $date, 0, 4 ); }} - $ expand-vars.pl --strict -D date=20090501 input.var output.txt && cat output.txt - year : 2009 - -=cut - -# end of file # diff --git a/runtime/tools/extract-objects.pl b/runtime/tools/extract-objects.pl deleted file mode 100755 index e9eaa3d..0000000 --- a/runtime/tools/extract-objects.pl +++ /dev/null @@ -1,258 +0,0 @@ -#!/usr/bin/env perl - -# -#//===----------------------------------------------------------------------===// -#// -#// The LLVM Compiler Infrastructure -#// -#// This file is dual licensed under the MIT and the University of Illinois Open -#// Source Licenses. See LICENSE.txt for details. -#// -#//===----------------------------------------------------------------------===// -# - -use strict; -use warnings; - -use File::Glob ":glob"; -use File::Temp; -use Cwd; - -use FindBin; -use lib "$FindBin::Bin/lib"; - -use tools; -use Uname; -use Platform ":vars"; - -our $VERSION = "0.005"; - -# -------------------------------------------------------------------------------------------------- -# Subroutines. -# -------------------------------------------------------------------------------------------------- - -sub windows { - my ( $arch, $output, @args ) = @_; - my %files; - # TODO: Check the archives are of specified architecture. - foreach my $arg ( @args ) { - foreach my $archive ( bsd_glob( $arg ) ) { - info( "Processing \"$archive\"..." ); - my $bulk; - execute( [ "lib.exe", "/nologo", "/list", $archive ], -stdout => \$bulk ); - my @members = split( "\n", $bulk ); - foreach my $member ( @members ) { - my $file = get_file( $member ); - my $path = cat_file( $output, $file ); - if ( exists( $files{ $file } ) ) { - runtime_error( - "Extraction \"$file\" member from \"$archive\" archive failed:", - "\"$file\" member has already been extracted from \"$files{ $file }\" archive" - ); - }; # if - $files{ $file } = $archive; - info( " Writing \"$path\"..." ); - execute( [ "lib.exe", "/nologo", "/extract:" . $member, "/out:" . $path, $archive ] ); - }; # foreach $member - }; # foreach $archive - }; # foreach $arg -}; # sub windows - -sub linux { - my ( $arch, $output, @archives ) = @_; - # TODO: Check the archives are of specified architecture. - my $cwd = Cwd::cwd(); - change_dir( $output ); - foreach my $archive ( @archives ) { - info( "Processing \"$archive\"..." ); - my $path = abs_path( $archive, $cwd ); - execute( [ "ar", "xo", $path ] ); - }; # foreach $archive - change_dir( $cwd ); -}; # sub linux - -my %mac_arch = ( - "32" => "i386", - "32e" => "x86_64" -); - -sub darwin { - my ( $arch, $output, @archives ) = @_; - my $cwd = getcwd(); - change_dir( $output ); - if ( defined( $arch ) ) { - if ( not defined( $mac_arch{ $arch } ) ) { - runtime_error( "Architecture \"$arch\" is not a valid one for OS X*" ); - }; # if - $arch = $mac_arch{ $arch }; - }; # if - foreach my $archive ( @archives ) { - info( "Processing \"$archive\"..." ); - my $path = abs_path( $archive, $cwd ); - my $temp; - # Whether archive is a fat or thin? - my $bulk; - execute( [ "file", $path ], -stdout => \$bulk ); - if ( $bulk =~ m{Mach-O universal binary} ) { - # Archive is fat, extracy thin archive first. - if ( not defined( $arch ) ) { - runtime_error( - "\"$archive\" archive is universal binary, " . - "please specify architecture to work with" - ); - }; # if - ( undef, $temp ) = File::Temp::tempfile(); - execute( [ "libtool", "-static", "-arch_only", $arch, "-o", $temp, $path ] ); - $path = $temp; - }; # if - execute( [ "ar", "xo", $path ] ); # Extract members. - if ( defined( $temp ) ) { # Delete temp file, if any. - del_file( $temp ); - }; # if - }; # foreach $archive - change_dir( $cwd ); -}; # sub darwin - - -# -------------------------------------------------------------------------------------------------- -# Main. -# -------------------------------------------------------------------------------------------------- - -# Parse command line. - -my $output = "."; -my @args; - -get_options( - Platform::target_options(), - "o|output-directory=s" => \$output, -); -@args = @ARGV; - -if ( not -e $output ) { - runtime_error( "Output directory \"$output\" does not exist" ); -}; # if -if ( not -d $output ) { - runtime_error( "\"$output\" is not a directory" ); -}; # if -if ( not -w $output ) { - runtime_error( "Output directory \"$output\" is not writable" ); -}; # if - -if ( $target_os eq "win" ) { - *process = \&windows; -} elsif ( $target_os eq "lin") { - *process = \&linux; -} elsif ( $target_os eq "mac" ) { - *process = \&darwin; -} else { - runtime_error( "OS \"$target_os\" not supported" ); -}; # if - - -# Do the work. -process( $target_arch, $output, @args ); -exit( 0 ); - -__END__ - -=pod - -=head1 NAME - -B<extract-objects.pl> -- Extract all object files from static library. - -=head1 SYNOPSIS - -B<extract-objects.pl> I<option>... I<archive>... - -=head1 OPTIONS - -=over - -=item B<--architecture=>I<arch> - -Specify architecture to work with. The option is mandatory on OS X* in case of universal archive. -In other cases the option should not be used. I<arch> may be one of C<32> or C<32e>. - -=item B<--os=>I<str> - -Specify OS name. By default OS is autodetected. - -Depending on OS, B<extract-objects.pl> uses different external tools for handling static -libraries: F<ar> (in case of "lin" and "mac") or F<lib.exe> (in case of "win"). - -=item B<--output-directory=>I<dir> - -Specify directory to write extracted members to. Current directory is used by default. - -=item B<--help> - -Print short help message and exit. - -=item B<--doc> - -=item B<--manual> - -Print full documentation and exit. - -=item B<--quiet> - -Do not print information messages. - -=item B<--version> - -Print version and exit. - -=back - -=head1 ARGUMENTS - -=over - -=item I<archive> - -A name of archive file (static library). Multiple archives may be specified. - -=back - -=head1 DESCRIPTION - -The script extracts all the members (object files) from archive (static library) to specified -directory. Commands to perform this action differ on different OSes. On Linux* OS, simple command - - ar xo libfile.a - -is enough (in case of extracting files to current directory). - -On OS X*, it is a bit compilicated with universal ("fat") binaries -- C<ar> cannot -operate on fat archives, so "thin" archive should be extracted from the universal binary first. - -On Windows* OS, library manager (C<lib.exe>) can extract only one object file, so operation should be -repeated for every object file in the library. - -B<extract-objects.pl> detects OS automatically. But detection can be overrided with B<--os> option. -It may be helpful in cross-build environments. - -B<extract-objects.pl> effectively encapsulates all these details and provides uniform way for -extracting object files from static libraries, which helps to keep makefiles simple and clean. - -=head1 EXAMPLES - -Extract object files from library F<libirc.lib>, and put them into F<obj/> directory: - - $ extract-objects.pl --output=obj libirc.lib - -Extract object files from library F<libirc.a>. Use Linux* OS tools (F<ar>), even if run on another OS: - - $ extract-objects.pl --os=lin libirc.a - -Extract object files from library F<libirc.a>, if it is a OS X* universal binary, use i386 -architecture. Be quiet: - - $ extract-objects.pl --quiet --arch=i386 libirc.a - -=cut - -# end of file # - diff --git a/runtime/tools/freebsd.inc b/runtime/tools/freebsd.inc deleted file mode 100644 index 7b60eec..0000000 --- a/runtime/tools/freebsd.inc +++ /dev/null @@ -1,12 +0,0 @@ -# -#//===----------------------------------------------------------------------===// -#// -#// The LLVM Compiler Infrastructure -#// -#// This file is dual licensed under the MIT and the University of Illinois Open -#// Source Licenses. See LICENSE.txt for details. -#// -#//===----------------------------------------------------------------------===// -# - -include tools/linux.inc diff --git a/runtime/tools/linux.inc b/runtime/tools/linux.inc deleted file mode 100644 index 7ad2512..0000000 --- a/runtime/tools/linux.inc +++ /dev/null @@ -1,35 +0,0 @@ -# -#//===----------------------------------------------------------------------===// -#// -#// The LLVM Compiler Infrastructure -#// -#// This file is dual licensed under the MIT and the University of Illinois Open -#// Source Licenses. See LICENSE.txt for details. -#// -#//===----------------------------------------------------------------------===// -# - -####### Detections and Commands ############################################### - -ifndef arch - uname_m:=$(shell uname -m) - ifeq ($(uname_m),i686) - export arch:=32 - endif - ifeq ($(uname_m),x86_64) - export arch:=32e - endif - ifndef arch - export arch:=$(uname_m) - endif -endif - -CMD=sh -c -CWD=$(shell pwd) -CP=cp -RM?=rm -f -RMR?=rm -rf -RD?=rmdir -MD?=mkdir -p -NUL= /dev/null -SLASH=/ diff --git a/runtime/tools/macos.inc b/runtime/tools/macos.inc deleted file mode 100644 index 38f86b1..0000000 --- a/runtime/tools/macos.inc +++ /dev/null @@ -1,37 +0,0 @@ -# -#//===----------------------------------------------------------------------===// -#// -#// The LLVM Compiler Infrastructure -#// -#// This file is dual licensed under the MIT and the University of Illinois Open -#// Source Licenses. See LICENSE.txt for details. -#// -#//===----------------------------------------------------------------------===// -# - -####### Detections and Commands ############################################### - -ifndef arch - ifeq ($(shell /usr/sbin/sysctl -n hw.machine),Power Macintosh) - ifeq ($(shell /usr/sbin/sysctl -n hw.optional.64bitops),1) - export arch:=ppc64 - else - export arch:=ppc32 - endif - else - ifeq ($(shell /usr/sbin/sysctl -n hw.optional.x86_64 2>/dev/null),1) - export arch:=intel64 - else - export arch:=ia32 - endif - endif -endif - -CMD=$(SHELL) -c -CWD=$(shell pwd) -RM?=rm -f -RMR?=rm -rf -RD?=rmdir -MD?=mkdir -p -NUL= /dev/null -SLASH=/ diff --git a/runtime/tools/make-fat-binaries.pl b/runtime/tools/make-fat-binaries.pl deleted file mode 100755 index b297e31..0000000 --- a/runtime/tools/make-fat-binaries.pl +++ /dev/null @@ -1,234 +0,0 @@ -#!/usr/bin/env perl - -# -#//===----------------------------------------------------------------------===// -#// -#// The LLVM Compiler Infrastructure -#// -#// This file is dual licensed under the MIT and the University of Illinois Open -#// Source Licenses. See LICENSE.txt for details. -#// -#//===----------------------------------------------------------------------===// -# - -use strict; -use warnings; - -use IO::Dir; - -use FindBin; -use lib "$FindBin::Bin/lib"; - - -use tools; - -our $VERSION = "0.003"; - -# -# Subroutines. -# - -sub check_dir($$) { - - # Make sure a directory is a readable directory. - - my ( $dir, $type ) = @_; - - -e $dir or runtime_error( "Directory \"$dir\" does not exist" ); - -d $dir or runtime_error( "\"$dir\" is not a directory" ); - -r $dir or runtime_error( "Directory \"$dir\" is not readable" ); - -}; # sub check_dir - -sub read_dir($) { - - # Return list of files (not subdirectories) of specified directory. - - my ( $dir ) = @_; - my $handle; - my $entry; - my @files; - - $handle = IO::Dir->new( $dir ) or runtime_error( "Cannot open \"$dir\" directory: $!" ); - while ( $entry = $handle->read() ) { - my $path = "$dir/$entry"; - if ( $entry !~ m{\A\.} and -f $path ) { - push( @files, $entry ); - }; # if - }; # while - $handle->close(); - - @files = sort( @files ); - return @files; - -}; # sub read_dir - -# -------------------------------------------------------------------------------------------------- -# Main program. -# -------------------------------------------------------------------------------------------------- - -# -# Parse command line. -# -my @dirs; # List of input directories. -my @files; # List of files. -my $output; # Output directory. - -get_options( - "output=s" => \$output -); - -@ARGV == 0 and cmdline_error( "No input directories specified" ); - -# -# Check input and output directories. -# - -# Make shure there is no duplicated directories. -my %dirs; -$dirs{ $output } = ""; -foreach my $dir ( @ARGV ) { - if ( exists( $dirs{ $dir } ) ) { - cmdline_error( "Directory \"$dir\" has already been specified" ); - }; # if - $dirs{ $dir } = ""; - push( @dirs, $dir ); -}; # foreach $dir -undef( %dirs ); - -# Make sure all dirs are exist, dirs, and readable. -check_dir( $output, "output" ); -foreach my $dir ( @dirs ) { - check_dir( $dir, "input" ); -}; # foreach $dir - -# All input dirs should contain exactly the same list of files. -my @errors; -@files = read_dir( $dirs[ 0 ] ); -foreach my $dir ( @dirs ) { - my %files = map( ( $_ => 0 ), @files ); - foreach my $file ( read_dir( $dir ) ) { - if ( not exists( $files{ $file } ) ) { - push( @errors, "Extra file: `" . cat_file( $dir, $file ) . "'." ); - }; # if - $files{ $file } = 1; - }; # foreach $file - foreach my $file ( keys( %files ) ) { - if ( $files{ $file } == 0 ) { - push( @errors, "Missed file: `" . cat_file( $dir, $file ) . "'." ); - }; # if - }; # foreach $file -}; # foreach $dir -if ( @errors ) { - runtime_error( @errors ); -}; # if - -# -# Make fat binaries. -# - -foreach my $file ( sort( @files ) ) { - info( "Making \"$file\"..." ); - my $output_file = cat_file( $output, $file ); - del_file( $output_file ); - execute( - [ - "lipo", - "-create", - "-output", $output_file, - map( cat_file( $_, $file ), @dirs ) - ] - ); -}; # foreach $entry - -exit( 0 ); - -__END__ - -=pod - -=head1 NAME - -B<make-fat-binaries.pl> -- Make set of fat (universal) binaries. - -=head1 SYNOPSIS - -B<make-fat-binaries.pl> I<OPTION>... I<INPUT_DIR>... - -=head1 OPTIONS - -=over - -=item B<--output=>I<DIR> - -Name of output directory to place fat binaries to. Directory must exist and be writable. - -=item Standard Options - -=over - -=item B<--doc> - -=item B<--manual> - -Print full help message and exit. - -=item B<--help> - -Print short help message and exit. - -=item B<--usage> - -Print very short usage message and exit. - -=item B<--verbose> - -Do print informational messages. - -=item B<--version> - -Print program version and exit. - -=item B<--quiet> - -Work quiet, do not print informational messages. - -=back - -=back - -=head1 ARGUMENTS - -=over - -=item I<INPUT_DIR> - -Name of input directory to get thin files from. Directory must exist and be readable. At least one -directory required. - -=back - -=head1 DESCRIPTION - -The script creates set of Mac-O fat (universal, multi-architecture) binaries from set of thin -(single-architecture) files. - -The scripts reads files from input directory (or directoriers). It is assumed that one input -directory keeps files for one architecture (e. g. i386), another directory contains files for -another architecture (e. g. x86_64), etc. All input directories must contain the same set of files. -The script issues an error if sets of files in input directories differ. - -If the script finishes successfully, output directory will contain the set universal binaries -built from files with the same name in input directories. - -=head1 EXAMPLES - -Get thin binaries from C<mac_32.thin/> and C<mac_32e.thin/> directories, and put fat binaries to -C<mac.fat/> directory: - - $ make-fat-binaries.pl --output=mac.fat mac_32.thin mac_32e.thin - - -=cut - -# end of file # diff --git a/runtime/tools/objcopy.cpp b/runtime/tools/objcopy.cpp deleted file mode 100644 index a2811c6..0000000 --- a/runtime/tools/objcopy.cpp +++ /dev/null @@ -1,520 +0,0 @@ -/* - */ - - -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.txt for details. -// -//===----------------------------------------------------------------------===// - - -#include <stdlib.h> -#include <iostream> -#include <strstream> -#include <fstream> -#include <string> -#include <set> -#include <map> -#include <vector> -#include <cstring> - -using namespace std; - -typedef std::string string_t; -typedef std::vector< string_t > strings_t; -typedef std::map< string_t, string_t > str_hash_t; -typedef std::pair< string_t, string_t > str_pair_t; -#ifdef _WIN32 - typedef long long int64_t; -#endif - -string_t -shift( strings_t & strs ) { - string_t first = strs.front(); - strs.erase( strs.begin() ); - return first; -} // shift - -string_t -find( - str_hash_t const & hash, - string_t const & key -) { - string_t value; - str_hash_t::const_iterator it = hash.find( key ); - if ( it != hash.end() ) { - value = it->second; - }; // if - return value; -} // find - -void die( string_t const & message ) { - std::cerr << message << std::endl; - exit( 1 ); -} // die - -void stop( string_t const & message ) { - printf( "%s\n", message.c_str() ); - exit( 1 ); -} - -// An entry in the symbol table of a .obj file. -struct symbol_t { - long long name; - unsigned value; - unsigned short section_num; - unsigned short type; - char storage_class; - char nAux; -}; // struct symbol_t - - -class _rstream_t : public std::istrstream { - - private: - - const char * buf; - - protected: - - _rstream_t( pair< const char *, streamsize > p ) - : istrstream( p.first, p.second ), buf( p.first ) - { - } - - ~_rstream_t() { - delete [] buf; - } - -}; // class _rstream_t - -/* A stream encapuslating the content of a file or the content of a string, overriding the - >> operator to read various integer types in binary form, as well as a symbol table - entry. -*/ -class rstream_t : public _rstream_t { -private: - - template< typename type_t > - inline rstream_t & do_read( type_t & x ) { - read( (char*) & x, sizeof( type_t ) ); - return * this; - } - - static pair<const char*, streamsize> getBuf(const char *fileName) { - ifstream raw(fileName,ios::binary | ios::in); - if(!raw.is_open()) - stop("rstream.getBuf: Error opening file"); - raw.seekg(0,ios::end); - streampos fileSize = raw.tellg(); - if(fileSize < 0) - stop("rstream.getBuf: Error reading file"); - char *buf = new char[fileSize]; - raw.seekg(0,ios::beg); - raw.read(buf, fileSize); - return pair<const char*, streamsize>(buf,fileSize); - } -public: - // construct from a string - rstream_t( const char * buf, streamsize size ) : - _rstream_t( pair< const char *, streamsize >( buf, size ) ) - {} - /* construct from a file whole content is fully read once to initialize the content of - this stream - */ - rstream_t( string_t const & fileName ) - : _rstream_t( getBuf( fileName.c_str() ) ) - { - } - - rstream_t & operator >>( int & x ) { - return do_read(x); - } - rstream_t & operator >>(unsigned &x) { - return do_read(x); - } - rstream_t & operator>>(short &x) { - return do_read(x); - } - rstream_t & operator>>(unsigned short &x) { - return do_read(x); - } - rstream_t & operator>>( symbol_t & e ) { - read((char*)&e, 18); - return *this; - } -}; // class rstream_t - -// string table in a .OBJ file -class StringTable { -private: - map<string, unsigned> directory; - size_t length; - char *data; - - // make <directory> from <length> bytes in <data> - void makeDirectory(void) { - unsigned i = 4; - while(i < length) { - string s = string(data + i); - directory.insert(make_pair(s, i)); - i += s.size() + 1; - } - } - // initialize <length> and <data> with contents specified by the arguments - void init(const char *_data) { - unsigned _length = *(unsigned*)_data; - - if(_length < sizeof(unsigned) || _length != *(unsigned*)_data) - stop("StringTable.init: Invalid symbol table"); - if(_data[_length - 1]) { - // to prevent runaway strings, make sure the data ends with a zero - data = new char[length = _length + 1]; - data[_length] = 0; - } else { - data = new char[length = _length]; - } - *(unsigned*)data = length; - memcpy( data + sizeof(unsigned), _data + sizeof(unsigned), length - sizeof(unsigned) ); - makeDirectory(); - } -public: - StringTable( rstream_t & f ) { - /* Construct string table by reading from f. - */ - streampos s; - unsigned strSize; - char *strData; - - s = f.tellg(); - f>>strSize; - if(strSize < sizeof(unsigned)) - stop("StringTable: Invalid string table"); - strData = new char[strSize]; - *(unsigned*)strData = strSize; - // read the raw data into <strData> - f.read(strData + sizeof(unsigned), strSize - sizeof(unsigned)); - s = f.tellg() - s; - if(s < strSize) - stop("StringTable: Unexpected EOF"); - init(strData); - delete[]strData; - } - StringTable(const set<string> &strings) { - /* Construct string table from given strings. - */ - char *p; - set<string>::const_iterator it; - size_t s; - - // count required size for data - for(length = sizeof(unsigned), it = strings.begin(); it != strings.end(); ++it) { - size_t l = (*it).size(); - - if(l > (unsigned) 0xFFFFFFFF) - stop("StringTable: String too long"); - if(l > 8) { - length += l + 1; - if(length > (unsigned) 0xFFFFFFFF) - stop("StringTable: Symbol table too long"); - } - } - data = new char[length]; - *(unsigned*)data = length; - // populate data and directory - for(p = data + sizeof(unsigned), it = strings.begin(); it != strings.end(); ++it) { - const string &str = *it; - size_t l = str.size(); - if(l > 8) { - directory.insert(make_pair(str, p - data)); - memcpy(p, str.c_str(), l); - p[l] = 0; - p += l + 1; - } - } - } - ~StringTable() { - delete[] data; - } - /* Returns encoding for given string based on this string table. - Error if string length is greater than 8 but string is not in - the string table--returns 0. - */ - int64_t encode(const string &str) { - int64_t r; - - if(str.size() <= 8) { - // encoded directly - ((char*)&r)[7] = 0; - strncpy((char*)&r, str.c_str(), 8); - return r; - } else { - // represented as index into table - map<string,unsigned>::const_iterator it = directory.find(str); - if(it == directory.end()) - stop("StringTable::encode: String now found in string table"); - ((unsigned*)&r)[0] = 0; - ((unsigned*)&r)[1] = (*it).second; - return r; - } - } - /* Returns string represented by x based on this string table. - Error if x references an invalid position in the table--returns - the empty string. - */ - string decode(int64_t x) const { - if(*(unsigned*)&x == 0) { - // represented as index into table - unsigned &p = ((unsigned*)&x)[1]; - if(p >= length) - stop("StringTable::decode: Invalid string table lookup"); - return string(data + p); - } else { - // encoded directly - char *p = (char*)&x; - int i; - - for(i = 0; i < 8 && p[i]; ++i); - return string(p, i); - } - } - void write(ostream &os) { - os.write(data, length); - } -}; - - -void -obj_copy( - string_t const & src, // Name of source file. - string_t const & dst, // Name of destination file. - str_hash_t const & redefs // List of redefinititions. -) { - - set< string > strings; // set of all occurring symbols, appropriately prefixed - streampos fileSize; - size_t strTabStart; - unsigned symTabStart; - unsigned symNEntries; - int i; - - - string const error_reading = "Error reading \"" + src + "\" file: "; - - rstream_t in( src ); - - in.seekg( 0, ios::end ); - fileSize = in.tellg(); - - in.seekg( 8 ); - in >> symTabStart >> symNEntries; - strTabStart = symTabStart + 18 * size_t( symNEntries ); - in.seekg( strTabStart ); - if ( in.eof() ) { - stop( error_reading + "Unexpected end of file" ); - } - StringTable stringTableOld( in ); // Read original string table. - - if ( in.tellg() != fileSize ) { - stop( error_reading + "Unexpected data after string table" ); - } - - // compute set of occurring strings with prefix added - for ( i = 0; i < symNEntries; ++ i ) { - - symbol_t e; - - in.seekg( symTabStart + i * 18 ); - if ( in.eof() ) { - stop("hideSymbols: Unexpected EOF"); - } - in >> e; - if ( in.fail() ) { - stop("hideSymbols: File read error"); - } - if ( e.nAux ) { - i += e.nAux; - } - const string & s = stringTableOld.decode( e.name ); - // if symbol is extern and found in <hide>, prefix and insert into strings, - // otherwise, just insert into strings without prefix - string_t name = find( redefs, s ); - strings.insert( name != "" && e.storage_class == 2 ? name : s ); - } - - ofstream out( dst.c_str(), ios::trunc | ios::out | ios::binary ); - if ( ! out.is_open() ) { - stop("hideSymbols: Error opening output file"); - } - - // make new string table from string set - StringTable stringTableNew = StringTable( strings ); - - // copy input file to output file up to just before the symbol table - in.seekg( 0 ); - char * buf = new char[ symTabStart ]; - in.read( buf, symTabStart ); - out.write( buf, symTabStart ); - delete [] buf; - - // copy input symbol table to output symbol table with name translation - for ( i = 0; i < symNEntries; ++ i ) { - symbol_t e; - - in.seekg( symTabStart + i * 18 ); - if ( in.eof() ) { - stop("hideSymbols: Unexpected EOF"); - } - in >> e; - if ( in.fail() ) { - stop("hideSymbols: File read error"); - } - const string & s = stringTableOld.decode( e.name ); - out.seekp( symTabStart + i * 18 ); - string_t name = find( redefs, s ); - e.name = stringTableNew.encode( ( e.storage_class == 2 && name != "" ) ? name : s ); - out.write( (char*) & e, 18 ); - if ( out.fail() ) { - stop( "hideSymbols: File write error" ); - } - if ( e.nAux ) { - // copy auxiliary symbol table entries - int nAux = e.nAux; - for (int j = 1; j <= nAux; ++j ) { - in >> e; - out.seekp( symTabStart + ( i + j ) * 18 ); - out.write( (char*) & e, 18 ); - } - i += nAux; - } - } - // output string table - stringTableNew.write( out ); -} - - -void -split( string_t const & str, char ch, string_t & head, string_t & tail ) { - string_t::size_type pos = str.find( ch ); - if ( pos == string_t::npos ) { - head = str; - tail = ""; - } else { - head = str.substr( 0, pos ); - tail = str.substr( pos + 1 ); - }; // if -} // split - - -void help() { - std::cout - << "NAME\n" - << " objcopy -- copy and translate object files\n" - << "\n" - << "SYNOPSIS\n" - << " objcopy options... source destination\n" - << "\n" - << "OPTIONS\n" - << " --help Print this help and exit.\n" - << " --redefine-sym old=new\n" - << " Rename \"old\" symbol in source object file to \"new\" symbol in\n" - << " destination object file.\n" - << " --redefine-syms sym_file\n" - << " For each pair \"old new\" in sym_file rename \"old\" symbol in \n" - << " source object file to \"new\" symbol in destination object file.\n" - << "\n" - << "ARGUMENTS\n" - << " source The name of source object file.\n" - << " destination\n" - << " The name of destination object file.\n" - << "\n" - << "DESCRIPTION\n" - << " This program implements a minor bit of Linux* OS's objcopy utility on Windows* OS.\n" - << " It can copy object files and edit its symbol table.\n" - << "\n" - << "EXAMPLES\n" - << " \n" - << " > objcopy --redefine-sym fastcpy=__xxx_fastcpy a.obj b.obj\n" - << "\n"; -} // help - - -int -main( int argc, char const * argv[] ) { - - strings_t args( argc - 1 ); - str_hash_t redefs; - strings_t files; - - std::copy( argv + 1, argv + argc, args.begin() ); - - while ( args.size() > 0 ) { - string_t arg = shift( args ); - if ( arg.substr( 0, 2 ) == "--" ) { - // An option. - if ( 0 ) { - } else if ( arg == "--help" ) { - help(); - return 0; - } else if ( arg == "--redefine-sym" ) { - if ( args.size() == 0 ) { - die( "\"" + arg + "\" option requires an argument" ); - }; // if - // read list of symbol pairs "old new" from command line. - string_t redef = shift( args ); - string_t old_sym; - string_t new_sym; - split( redef, '=', old_sym, new_sym ); - if ( old_sym.length() == 0 || new_sym.length() == 0 ) { - die( "Illegal redefinition: \"" + redef + "\"; neither old symbol nor new symbol may be empty" ); - }; // if - redefs.insert( str_pair_t( old_sym, new_sym ) ); - } else if ( arg == "--redefine-syms" ) { - if ( args.size() == 0 ) { - die( "\"" + arg + "\" option requires an argument" ); - }; // if - // read list of symbol pairs "old new" from file. - string_t fname = shift( args ); - string_t redef; - ifstream ifs( fname.c_str() ); - while ( ifs.good() ) { - getline( ifs, redef );// get pair of old/new symbols separated by space - string_t old_sym; - string_t new_sym; - // AC: gcount() does not work here (always return 0), so comment it - //if ( ifs.gcount() ) { // skip empty lines - split( redef, ' ', old_sym, new_sym ); - if ( old_sym.length() == 0 || new_sym.length() == 0 ) { - break; // end of file reached (last empty line) - //die( "Illegal redefinition: \"" + redef + "\"; neither old symbol nor new symbol may be empty" ); - }; // if - redefs.insert( str_pair_t( old_sym, new_sym ) ); - //} - } - } else { - die( "Illegal option: \"" + arg + "\"" ); - }; // if - } else { - // Not an option, a file name. - if ( files.size() >= 2 ) { - die( "Too many files specified; two files required (use --help option for help)" ); - }; // if - files.push_back( arg ); - }; // if - }; // while - if ( files.size() < 2 ) { - die( "Not enough files specified; two files required (use --help option for help)" ); - }; // if - - obj_copy( files[ 0 ], files[ 1 ], redefs ); - - return 0; - -} // main - - -// end of file // diff --git a/runtime/tools/required-objects.pl b/runtime/tools/required-objects.pl deleted file mode 100755 index 6102a62..0000000 --- a/runtime/tools/required-objects.pl +++ /dev/null @@ -1,642 +0,0 @@ -#!/usr/bin/perl - -# -#//===----------------------------------------------------------------------===// -#// -#// The LLVM Compiler Infrastructure -#// -#// This file is dual licensed under the MIT and the University of Illinois Open -#// Source Licenses. See LICENSE.txt for details. -#// -#//===----------------------------------------------------------------------===// -# - -use strict; -use warnings; - -use File::Glob ":glob"; -use Data::Dumper; - -use FindBin; -use lib "$FindBin::Bin/lib"; - -use tools; -use Platform ":vars"; - -our $VERSION = "0.004"; - -# -------------------------------------------------------------------------------------------------- -# Set of objects: # Ref to hash, keys are names of objects. -# object0: # Ref to hash of two elements with keys "defined" and "undefined". -# defined: # Ref to array of symbols defined in object0. -# - symbol0 # Symbol name. -# - ... -# undefined: # Ref to array of symbols referenced in object0. -# - symbol0 -# - ... -# object1: -# ... -# ... -# -------------------------------------------------------------------------------------------------- - -# -------------------------------------------------------------------------------------------------- -# Set of symbols: # Ref to hash, keys are names of symbols. -# symbol0: # Ref to array of object names where the symbol0 is defined. -# - object0 # Object file name. -# - ... -# symbol1: -# ... -# ... -# -------------------------------------------------------------------------------------------------- - -sub dump_objects($$$) { - - my ( $title, $objects, $dump ) = @_; - - if ( $dump > 0 ) { - STDERR->print( $title, "\n" ); - foreach my $object ( sort( keys( %$objects ) ) ) { - STDERR->print( " $object\n" ); - if ( $dump > 1 ) { - STDERR->print( " Defined symbols:\n" ); - foreach my $symbol ( sort( @{ $objects->{ $object }->{ defined } } ) ) { - STDERR->print( " $symbol\n" ); - }; # foreach $symbol - STDERR->print( " Undefined symbols:\n" ); - foreach my $symbol ( sort( @{ $objects->{ $object }->{ undefined } } ) ) { - STDERR->print( " $symbol\n" ); - }; # foreach $symbol - }; # if - }; # foreach $object - }; # if - -}; # sub dump_objects - -sub dump_symbols($$$) { - - my ( $title, $symbols, $dump ) = @_; - - if ( $dump > 0 ) { - STDERR->print( $title, "\n" ); - foreach my $symbol ( sort( keys( %$symbols ) ) ) { - STDERR->print( " $symbol\n" ); - if ( $dump > 1 ) { - foreach my $object ( sort( @{ $symbols->{ $symbol } } ) ) { - STDERR->print( " $object\n" ); - }; # foreach - }; # if - }; # foreach $object - }; # if - -}; # sub dump_symbols - -# -------------------------------------------------------------------------------------------------- -# Name: -# load_symbols -- Fulfill objects data structure with symbol names. -# Synopsis: -# load_symbols( $objects ); -# Arguments: -# $objects (in/out) -- Set of objects. On enter, it is expected that top-level hash has filled -# with object names only. On exit, it is completely fulfilled with lists of symbols -# defined or referenced in each object file. -# Returns: -# Nothing. -# Example: -# my $objects = { foo.o => {} }; -# load_symbols( $objects ); -# # Now $objects is { goo.o => { defined => [ ... ], undefined => [ ... ] } }. -# -# -------------------------------------------------------------------------------------------------- -# This version of load_symbols parses output of nm command and works on Linux* OS and OS X*. -# -sub _load_symbols_nm($) { - - my $objects = shift( @_ ); - # It is a ref to hash. Keys are object names, values are empty hashes (for now). - my @bulk; - - if ( %$objects ) { - # Do not run nm if a set of objects is empty -- nm will try to open a.out in this case. - my $tool; - if($target_arch eq "mic") { - $tool = "x86_64-k1om-linux-nm" - } else { - $tool = "nm" - } - execute( - [ - $tool, - "-g", # Display only external (global) symbols. - "-o", # Precede each symbol by the name of the input file. - keys( %$objects ) - # Running nm once (rather than once per object) improves performance - # drastically. - ], - -stdout => \@bulk - ); - }; # if - - foreach my $line ( @bulk ) { - if ( $line !~ m{^(.*):(?: ?[0-9a-f]*| *) ([A-Za-z]) (.*)$} ) { - die "Cannot parse nm output, line:\n $line\n"; - }; # if - my ( $file, $tag, $symbol ) = ( $1, $2, $3 ); - if ( not exists( $objects->{ $file } ) ) { - die "nm reported unknown object file:\n $line\n"; - }; # if - # AC: exclude some libc symbols from renaming, otherwise we have problems - # in tests for gfortran + static libomp on Lin_32. - # These symbols came from libtbbmalloc.a - if ( $target_os eq "lin" ) { - if ( $symbol =~ m{__i686} ) { - next; - } - } - # AC: added "w" to tags of undefined symbols, e.g. malloc is weak in libirc v12.1. - if ( $tag eq "U" or $tag eq "w" ) { # Symbol not defined. - push( @{ $objects->{ $file }->{ undefined } }, $symbol ); - } else { # Symbol defined. - push( @{ $objects->{ $file }->{ defined } }, $symbol ); - }; # if - }; # foreach - - return undef; - -}; # sub _load_symbols_nm - -# -------------------------------------------------------------------------------------------------- -# This version of load_symbols parses output of link command and works on Windows* OS. -# -sub _load_symbols_link($) { - - my $objects = shift( @_ ); - # It is a ref to hash. Keys are object names, values are empty hashes (for now). - my @bulk; - - if ( %$objects ) { - # Do not run nm if a set of objects is empty -- nm will try to open a.out in this case. - execute( - [ - "link", - "/dump", - "/symbols", - keys( %$objects ) - # Running nm once (rather than once per object) improves performance - # drastically. - ], - -stdout => \@bulk - ); - }; # if - - my $num_re = qr{[0-9A-F]{3,4}}; - my $addr_re = qr{[0-9A-F]{8}}; - my $tag_re = qr{DEBUG|ABS|UNDEF|SECT[0-9A-F]+}; - my $class_re = qr{Static|External|Filename|Label|BeginFunction|EndFunction|WeakExternal|\.bf or\.ef}; - - my $file; - foreach my $line ( @bulk ) { - if ( $line =~ m{\ADump of file (.*?)\n\z} ) { - $file = $1; - if ( not exists( $objects->{ $file } ) ) { - die "link reported unknown object file:\n $line\n"; - }; # if - } elsif ( $line =~ m{\A$num_re } ) { - if ( not defined( $file ) ) { - die "link reported symbol of unknown object file:\n $line\n"; - }; # if - if ( $line !~ m{\A$num_re $addr_re ($tag_re)\s+notype(?: \(\))?\s+($class_re)\s+\| (.*?)\n\z} ) { - die "Cannot parse link output, line:\n $line\n"; - }; # if - my ( $tag, $class, $symbol ) = ( $1, $2, $3 ); - # link.exe /dump sometimes prints comments for symbols, e. g.: - # ".?0_memcopyA ([Entry] ?0_memcopyA)", or "??_C@_01A@r?$AA@ (`string')". - # Strip these comments. - $symbol =~ s{ \(.*\)\z}{}; - if ( $class eq "External" ) { - if ( $tag eq "UNDEF" ) { # Symbol not defined. - push( @{ $objects->{ $file }->{ undefined } }, $symbol ); - } else { # Symbol defined. - push( @{ $objects->{ $file }->{ defined } }, $symbol ); - }; # if - }; # if - } else { - # Ignore all other lines. - }; # if - }; # foreach - - return undef; - -}; # sub _load_symbols_link - -# -------------------------------------------------------------------------------------------------- -# Name: -# symbols -- Construct set of symbols with specified tag in the specified set of objects. -# Synopsis: -# my $symbols = defined_symbols( $objects, $tag ); -# Arguments: -# $objects (in) -- Set of objects. -# $tag (in) -- A tag, "defined" or "undefined". -# Returns: -# Set of symbols with the specified tag. -# -sub symbols($$) { - - my $objects = shift( @_ ); - my $tag = shift( @_ ); - - my $symbols = {}; - - foreach my $object ( keys( %$objects ) ) { - foreach my $symbol ( @{ $objects->{ $object }->{ $tag } } ) { - push( @{ $symbols->{ $symbol } }, $object ); - }; # foreach $symbol - }; # foreach $object - - return $symbols; - -}; # sub symbols - -sub defined_symbols($) { - - my $objects = shift( @_ ); - my $defined = symbols( $objects, "defined" ); - return $defined; - -}; # sub defined_symbols - -sub undefined_symbols($) { - - my $objects = shift( @_ ); - my $defined = symbols( $objects, "defined" ); - my $undefined = symbols( $objects, "undefined" ); - foreach my $symbol ( keys( %$defined ) ) { - delete( $undefined->{ $symbol } ); - }; # foreach symbol - return $undefined; - -}; # sub undefined_symbols - -# -------------------------------------------------------------------------------------------------- -# Name: -# _required_extra_objects -- Select a subset of extra objects required to resolve undefined -# symbols in a set of objects. It is a helper sub for required_extra_objects(). -# Synopsis: -# my $required = _required_extra_objects( $objects, $extra, $symbols ); -# Arguments: -# $objects (in) -- A set of objects to be searched for undefined symbols. -# $extra (in) -- A set of extra objects to be searched for defined symbols to resolve undefined -# symbols in objects. -# $symbols (in/out) -- Set of symbols defined in the set of external objects. At the first call -# it should consist of all the symbols defined in all the extra objects. Symbols defined in -# the selected subset of extra objects are removed from set of defined symbols, because -# they are out of interest for subsequent calls. -# Returns: -# A subset of extra objects required by the specified set of objects. -# -sub _required_extra_objects($$$$) { - - my $objects = shift( @_ ); - my $extra = shift( @_ ); - my $symbols = shift( @_ ); - my $dump = shift( @_ ); - - my $required = {}; - - if ( $dump > 0 ) { - STDERR->print( "Required extra objects:\n" ); - }; # if - foreach my $object ( keys( %$objects ) ) { - foreach my $symbol ( @{ $objects->{ $object }->{ undefined } } ) { - if ( exists( $symbols->{ $symbol } ) ) { - # Add all objects where the symbol is defined to the required objects. - foreach my $req_obj ( @{ $symbols->{ $symbol } } ) { - if ( $dump > 0 ) { - STDERR->print( " $req_obj\n" ); - if ( $dump > 1 ) { - STDERR->print( " by $object\n" ); - STDERR->print( " due to $symbol\n" ); - }; # if - }; # if - $required->{ $req_obj } = $extra->{ $req_obj }; - }; # foreach $req_obj - # Delete the symbol from list of defined symbols. - delete( $symbols->{ $symbol } ); - }; # if - }; # foreach $symbol - }; # foreach $object - - return $required; - -}; # sub _required_extra_objects - - -# -------------------------------------------------------------------------------------------------- -# Name: -# required_extra_objects -- Select a subset of extra objects required to resolve undefined -# symbols in a set of base objects and selected extra objects. -# Synopsis: -# my $required = required_extra_objects( $base, $extra ); -# Arguments: -# $base (in/out) -- A set of base objects to be searched for undefined symbols. On enter, it is -# expected that top-level hash has filled with object names only. On exit, it is completely -# fulfilled with lists of symbols defined and/or referenced in each object file. -# $extra (in/out) -- A set of extra objects to be searched for defined symbols required to -# resolve undefined symbols in a set of base objects. Usage is similar to base objects. -# Returns: -# A subset of extra object files. -# -sub required_extra_objects($$$) { - - my $base = shift( @_ ); - my $extra = shift( @_ ); - my $dump = shift( @_ ); - - # Load symbols for each object. - load_symbols( $base ); - load_symbols( $extra ); - if ( $dump ) { - dump_objects( "Base objects:", $base, $dump ); - dump_objects( "Extra objects:", $extra, $dump ); - }; # if - - # Collect symbols defined in extra objects. - my $symbols = defined_symbols( $extra ); - - my $required = {}; - # Select extra objects required by base objects. - my $delta = _required_extra_objects( $base, $extra, $symbols, $dump ); - while ( %$delta ) { - %$required = ( %$required, %$delta ); - # Probably, just selected objects require some more objects. - $delta = _required_extra_objects( $delta, $extra, $symbols, $dump ); - }; # while - - if ( $dump ) { - my $base_undefined = undefined_symbols( $base ); - my $req_undefined = undefined_symbols( $required ); - dump_symbols( "Symbols undefined in base objects:", $base_undefined, $dump ); - dump_symbols( "Symbols undefined in required objects:", $req_undefined, $dump ); - }; # if - - return $required; - -}; # sub required_extra_objects - - -# -------------------------------------------------------------------------------------------------- -# Name: -# copy_objects -- Copy (and optionally edit) object files to specified directory. -# Synopsis: -# copy_objects( $objects, $target, $prefix, @symbols ); -# Arguments: -# $objects (in) -- A set of object files. -# $target (in) -- A name of target directory. Directory must exist. -# $prefix (in) -- A prefix to add to all the symbols listed in @symbols. If prefix is undefined, -# object files are just copied. -# @symbols (in) -- List of symbol names to be renamed. -# Returns: -# None. -# -sub copy_objects($$;$\@) { - - my $objects = shift( @_ ); - my $target = shift( @_ ); - my $prefix = shift( @_ ); - my $symbols = shift( @_ ); - my $tool; - my @redefine; - my @redefine_; - my $syms_file = "__kmp_sym_pairs.log"; - - if ( $target_arch eq "mic" ) { - $tool = "x86_64-k1om-linux-objcopy" - } else { - $tool = "objcopy" - } - - if ( not -e $target ) { - die "\"$target\" directory does not exist\n"; - }; # if - if ( not -d $target ) { - die "\"$target\" is not a directory\n"; - }; # if - - if ( defined( $prefix ) and @$symbols ) { - my %a = map ( ( "$_ $prefix$_" => 1 ), @$symbols ); - @redefine_ = keys( %a ); - }; # if - foreach my $line ( @redefine_ ) { - $line =~ s{$prefix(\W+)}{$1$prefix}; - push( @redefine, $line ); - } - write_file( $syms_file, \@redefine ); - foreach my $src ( sort( keys( %$objects ) ) ) { - my $dst = cat_file( $target, get_file( $src ) ); - if ( @redefine ) { - execute( [ $tool, "--redefine-syms", $syms_file, $src, $dst ] ); - } else { - copy_file( $src, $dst, -overwrite => 1 ); - }; # if - }; # foreach $object - -}; # sub copy_objects - - -# -------------------------------------------------------------------------------------------------- -# Main. -# -------------------------------------------------------------------------------------------------- - -my $base = {}; -my $extra = {}; -my $switcher = $base; -my $dump = 0; -my $print_base; -my $print_extra; -my $copy_base; -my $copy_extra; -my $prefix; - -# Parse command line. - -Getopt::Long::Configure( "permute" ); -get_options( - Platform::target_options(), - "base" => sub { $switcher = $base; }, - "extra" => sub { $switcher = $extra; }, - "print-base" => \$print_base, - "print-extra" => \$print_extra, - "print-all" => sub { $print_base = 1; $print_extra = 1; }, - "copy-base=s" => \$copy_base, - "copy-extra=s" => \$copy_extra, - "copy-all=s" => sub { $copy_base = $_[ 1 ]; $copy_extra = $_[ 1 ]; }, - "dump" => sub { ++ $dump; }, - "prefix=s" => \$prefix, - "<>" => - sub { - my $arg = $_[ 0 ]; - my @args; - if ( $^O eq "MSWin32" ) { - # Windows* OS does not expand wildcards. Do it... - @args = bsd_glob( $arg ); - } else { - @args = ( $arg ); - }; # if - foreach my $object ( @args ) { - if ( exists( $base->{ $object } ) or exists( $extra->{ $object } ) ) { - die "Object \"$object\" has already been specified.\n"; - }; # if - $switcher->{ $object } = { defined => [], undefined => [] }; - }; # foreach - }, -); -if ( not %$base ) { - cmdline_error( "No base objects specified" ); -}; # if - -if ( $target_os eq "win" ) { - *load_symbols = \&_load_symbols_link; -} elsif ( $target_os eq "lin" ) { - *load_symbols = \&_load_symbols_nm; -} elsif ( $target_os eq "mac" ) { - *load_symbols = \&_load_symbols_nm; -} else { - runtime_error( "OS \"$target_os\" not supported" ); -}; # if - -# Do the work. - -my $required = required_extra_objects( $base, $extra, $dump ); -if ( $print_base ) { - print( map( "$_\n", sort( keys( %$base ) ) ) ); -}; # if -if ( $print_extra ) { - print( map( "$_\n", sort( keys( %$required ) ) ) ); -}; # if -my @symbols; -if ( defined( $prefix ) ) { - foreach my $object ( sort( keys( %$required ) ) ) { - push( @symbols, @{ $required->{ $object }->{ defined } } ); - }; # foreach $objects -}; # if -if ( $copy_base ) { - copy_objects( $base, $copy_base, $prefix, @symbols ); -}; # if -if ( $copy_extra ) { - copy_objects( $required, $copy_extra, $prefix, @symbols ); -}; # if - -exit( 0 ); - -__END__ - -=pod - -=head1 NAME - -B<required-objects.pl> -- Select a required extra object files. - -=head1 SYNOPSIS - -B<required-objects.pl> I<option>... [--base] I<file>... --extra I<file>... - -=head1 DESCRIPTION - -B<required-objects.pl> works with two sets of object files -- a set of I<base> objects -and a set of I<extra> objects, and selects those extra objects which are required for resolving -undefined symbols in base objects I<and> selected extra objects. - -Selected object files may be copied to specified location or their names may be printed to stdout, -a name per line. Additionally, symbols defined in selected extra objects may be renamed. - -Depending on OS, different external tools may be used. For example, B<required-objects.pl> uses -F<link.exe> on "win" and F<nm> on "lin" and "mac" OSes. Normally OS is autodetected, but -detection can be overrided with B<--os> option. It may be helpful in cross-build environments. - -=head1 OPTIONS - -=over - -=item B<--base> - -The list of base objects follows this option. - -=item B<--extra> - -List of extra objects follows this option. - -=item B<--print-all> - -Print list of base objects and list of required extra objects. - -=item B<--print-base> - -Print list of base objects. - -=item B<--print-extra> - -Print list of selected extra objects. - -=item B<--copy-all=>I<dir> - -Copy all base and selected extra objects to specified directory. The directory must exist. Existing -files are overwritten. - -=item B<--copy-base=>I<dir> - -Copy all base objects to specified directory. - -=item B<--copy-extra=>I<dir> - -Copy selected extra objects to specified directory. - -=item B<--prefix=>I<str> - -If prefix is specified, copied object files are edited -- symbols defined in selected extra -object files are renamed (in all the copied object files) by adding this prefix. - -F<objcopy> program should be available for performing this operation. - -=item B<--os=>I<str> - -Specify OS name. By default OS is autodetected. - -Depending on OS, B<required-objects.pl> uses different external tools. - -=item B<--help> - -Print short help message and exit. - -=item B<--doc> - -=item B<--manual> - -Print full documentation and exit. - -=item B<--version> - -Print version and exit. - -=back - -=head1 ARGUMENTS - -=over - -=item I<file> - -A name of object file. - -=back - -=head1 EXAMPLES - - $ required-objects.pl --base obj/*.o --extra ../lib/obj/*.o --print-extra > required.lst - $ ar cr libx.a obj/*.o $(cat required.lst) - - $ required-objects.pl --base internal/*.o --extra external/*.o --prefix=__xyz_ --copy-all=obj - $ ar cr xyz.a obj/*.o - -=cut - -# end of file # - diff --git a/runtime/tools/src/common-checks.mk b/runtime/tools/src/common-checks.mk deleted file mode 100644 index 250eaed..0000000 --- a/runtime/tools/src/common-checks.mk +++ /dev/null @@ -1,95 +0,0 @@ -# common-checks.mk # - -# -#//===----------------------------------------------------------------------===// -#// -#// The LLVM Compiler Infrastructure -#// -#// This file is dual licensed under the MIT and the University of Illinois Open -#// Source Licenses. See LICENSE.txt for details. -#// -#//===----------------------------------------------------------------------===// -# - -# -------------------------------------------------------------------------------------------------- -# This file contains really common definitions used by multiple makefiles. Modify it carefully! -# -------------------------------------------------------------------------------------------------- - -# -# Check tools versions. -# -ifeq "$(clean)" "" # Do not check tools if clean goal specified. - - check_tools_flags = --make - - # determine if fortran check is required from goals - # MAKECMDGOALS is like argv for gnu make - ifneq "$(filter mod all,$(MAKECMDGOALS))" "" - check_tools_flags += --fortran - else - ifeq "$(MAKECMDGOALS)" "" # will default to all if no goals specified on command line - check_tools_flags += --fortran - endif - endif - ifneq "$(filter gcc clang,$(c))" "" # if build compiler is gcc or clang - check_tools_flags += --nointel - endif - ifeq "$(c)" "clang" - check_tools_flags += --clang - endif - - curr_tools := $(strip $(shell $(perl) $(tools_dir)check-tools.pl $(oa-opts) $(check_tools_flags))) - - ifeq "$(curr_tools)" "" - $(error check-tools.pl failed) - endif - ifneq "$(findstring N/A,$(curr_tools))" "" - missed_tools := $(filter %---_N/A_---,$(curr_tools)) - missed_tools := $(subst =---_N/A_---,,$(missed_tools)) - missed_tools := $(subst $(space),$(comma)$(space),$(missed_tools)) - $(error Development tools not found: $(missed_tools)) - endif - prev_tools := $(strip $(shell [ -e tools.cfg ] && cat tools.cfg)) - $(call say,Tools : $(curr_tools)) - ifeq "$(prev_tools)" "" - # No saved config file, let us create it. - dummy := $(shell echo "$(curr_tools)" > tools.cfg) - else - # Check the saved config file matches current configuration. - ifneq "$(curr_tools)" "$(prev_tools)" - # Show the differtence between previous and current tools. - $(call say,Old tools : $(filter-out $(curr_tools),$(prev_tools))) - $(call say,New tools : $(filter-out $(prev_tools),$(curr_tools))) - # And initiate rebuild. - $(call say,Tools changed$(comma) rebuilding...) - dummy := $(shell $(rm) .rebuild && echo "$(curr_tools)" > tools.cfg) - endif - endif -endif - -# Check config. -ifeq "$(curr_config)" "" - $(error makefile must define `curr_config' variable) -endif -prev_config := $(shell [ -e build.cfg ] && cat build.cfg) -curr_config := $(strip $(curr_config)) -ifeq "$(clean)" "" # Do not check config if clean goal specified. - $(call say,Config : $(curr_config)) - ifeq "$(prev_config)" "" - # No saved config file, let us create it. - dummy := $(shell echo "$(curr_config)" > build.cfg) - else - # Check saved config file matches current configuration. - ifneq "$(curr_config)" "$(prev_config)" - # Show the differtence between previous and current configurations. - $(call say,Old config : $(filter-out $(curr_config),$(prev_config))) - $(call say,New config : $(filter-out $(prev_config),$(curr_config))) - # And initiate rebuild. - $(call say,Configuration changed$(comma) rebuilding...) - dummy := $(shell $(rm) .rebuild && echo "$(curr_config)" > build.cfg) - endif - endif -endif - -# end of file # - diff --git a/runtime/tools/src/common-defs.mk b/runtime/tools/src/common-defs.mk deleted file mode 100644 index 4a059d0..0000000 --- a/runtime/tools/src/common-defs.mk +++ /dev/null @@ -1,232 +0,0 @@ -# common-defs.mk # - -# -#//===----------------------------------------------------------------------===// -#// -#// The LLVM Compiler Infrastructure -#// -#// This file is dual licensed under the MIT and the University of Illinois Open -#// Source Licenses. See LICENSE.txt for details. -#// -#//===----------------------------------------------------------------------===// -# - -# -------------------------------------------------------------------------------------------------- -# This file contains really common definitions used by multiple makefiles. Modify it carefully! -# -------------------------------------------------------------------------------------------------- - -# -------------------------------------------------------------------------------------------------- -# Some tricky variables. -# -------------------------------------------------------------------------------------------------- -empty := -space := $(empty) $(empty) -comma := , -ifeq "$(date)" "" - $(error Caller should specify "date" variable.) -endif - -# -------------------------------------------------------------------------------------------------- -# Helper finctions. -# -------------------------------------------------------------------------------------------------- - -# Synopsis: -# $(call say,text-to-print-to-the-screen) -# Description: -# The function prints its argument to the screen. In case of older makes it is analog of -# $(warning), starting from make 3.81 is is analog of $(info). -# -say = $(warning $(1)) -ifneq "$(filter 3.81,$(MAKE_VERSION))" "" - say = $(info $(1)) -endif - -# Synopsis: -# architecture = $(call legal_arch,32) -# Description: -# The function return printable name of specified architecture, IA-32 architecture or Intel(R) 64. -# -legal_arch = $(if $(filter 32,$(1)),IA-32,$(if $(filter 32e,$(1)),Intel(R) 64,$(if $(filter l1,$(1)),L1OM,$(if $(filter arm,$(1)),ARM,$(if $(filter ppc64,$(1)),PPC64,$(if $(filter ppc64le,$(1)),PPC64LE,$(if $(filter aarch64,$(1)),AArch64,$(if $(filter mic,$(1)),Intel(R) Many Integrated Core Architecture,$(error Bad architecture specified: $(1)))))))))) - -# Synopsis: -# var_name = $(call check_variable,var,list) -# Description: -# The function verifies the value of var varibale. If it is empty, the first word from the list -# is assigned to var as default value. Otherwise the var value must match one of words in the -# list, or error is issued. -# Example: -# LINK_TYPE = $(call check_variable,LINK_TYPE,static dynamic) -# -check_variable = $(call _check_variable_words,$(1))$(call _check_variable_value,$(1),$(2)) - -# Synopsis: -# $(call _check_variable_words,var) -# Description: -# Checks that variable var is empty or single word. In case of multiple words an error is -# issued. It is helper function for check_variable. -# -_check_variable_words = $(if $(filter 0 1,$(words $($(1)))),,\ - $(error Illegal value of $(1): "$($(1))")) - -# Synopsis: -# $(call _check_variable_value,var) -# Description: -# If variable var is empty, the function returns the first word from the list. If variable is -# not empty and match one of words in the list, variable's value returned. Otherwise, error is -# issued. It is helper function for check_variable. -# -_check_variable_value = $(if $($(1)),$(if $(filter $(2),$($(1))),$($(1)),\ - $(error Illegal value of $(1): "$($(1))")),$(firstword $(2))) - -# Synopsis: -# $(call debug,var) -# Description: -# If LIBOMP_MAKE_DEBUG is not empty, var name and value printed. Use this for debug purpose. -# -ifeq "$(LIBOMP_MAKE_DEBUG)" "" - debug = -else - debug = $(call say,debug: $(1)="$($(1))") -endif - -# Synopsis: -# $(call header,target) -# Description: -# Returns a string to print to show build progress. -# -header = ----- $(marker) --- $(1) ----- - -# -------------------------------------------------------------------------------------------------- -# Global make settings. -# -------------------------------------------------------------------------------------------------- - -# Non-empty CDPATH may lead to problems on some platforms: simple "cd dir" (where "dir" is an -# existing directory in current one) fails. Clearing CDPATH solves the problem. -CDPATH = -.SUFFIXES : # Clean default list of suffixes. -.DELETE_ON_ERROR : # Delete target file in case of error. - -$(call say,$(call header,making $(if $(MAKECMDGOALS),$(MAKECMDGOALS),all))) - -# -------------------------------------------------------------------------------------------------- -# Check clean and clobber goals. -# -------------------------------------------------------------------------------------------------- - -# "clean" goal must be specified alone, otherwise we have troubles with dependency files. -clean := $(filter clean%,$(MAKECMDGOALS)) -ifneq "$(clean)" "" # "clean" goal is present in command line. - ifneq "$(filter-out clean%,$(MAKECMDGOALS))" "" # there are non-clean goals. - $(error "clean" goals must not be mixed with other goals) - endif -endif -# Issue error on "clobber" target. -ifneq "$(filter clobber,$(MAKECMDGOALS))" "" - $(error There is no clobber goal in makefile) -endif - -# -------------------------------------------------------------------------------------------------- -# Mandatory variables passed from build.pl. -# -------------------------------------------------------------------------------------------------- - -os := $(call check_variable,os,lin mac win) -arch := $(call check_variable,arch,32 32e 64 arm ppc64 ppc64le aarch64 mic) -ifeq "$(arch)" "mic" # We want the flavor of mic (knf, knc, knl, etc.) - platform := $(os)_$(MIC_ARCH) -else - platform := $(os)_$(arch) -endif -platform := $(call check_variable,platform,lin_32 lin_32e lin_64 lin_arm lin_knc lin_knf mac_32 mac_32e win_32 win_32e win_64 lin_ppc64 lin_ppc64le lin_aarch64) -# oa-opts means "os and arch options". They are passed to almost all perl scripts. -oa-opts := --os=$(os) --arch=$(arch) - -# -------------------------------------------------------------------------------------------------- -# Directories. -# -------------------------------------------------------------------------------------------------- - -ifeq "$(LIBOMP_WORK)" "" - $(error Internal error: LIBOMP_WORK variable must be set in makefile.mk) -endif -tools_dir = $(LIBOMP_WORK)tools/ -# We do not define src/ and other directories here because they depends on target (RTL, DSL, tools). - -# -------------------------------------------------------------------------------------------------- -# File suffixes. -# -------------------------------------------------------------------------------------------------- - -ifeq "$(os)" "win" # win - asm = .asm - obj = .obj - lib = .lib - dll = .dll - exe = .exe - cat = $(dll) -else # lin, mic or mac - asm = .s - obj = .o - lib = .a - ifeq "$(os)" "mac" - dll = .dylib - else - dll = .so - endif - exe = $(empty) - cat = .cat -endif - -# -------------------------------------------------------------------------------------------------- -# File manipulation and misc commands. -# -------------------------------------------------------------------------------------------------- - -target = @echo "$(call header,$@)" -ifeq "$(os)" "win" - cp = cp -f - rm = rm -f - mkdir = mkdir -p - touch = touch - perl = perl - slash = \\ -else # lin, mic or mac - cp = cp -f - rm = rm -f - mkdir = mkdir -p - touch = touch - perl = perl - slash = / -endif - -# -------------------------------------------------------------------------------------------------- -# Common non-configuration options. -# -------------------------------------------------------------------------------------------------- -# They may affect build process but does not affect result. - -# If TEST_DEPS is "off", test deps is still performed, but its result is ignored. -TEST_DEPS := $(call check_variable,TEST_DEPS,on off) -# The same for test touch. -TEST_TOUCH := $(call check_variable,TEST_TOUCH,on off) -td-i = $(if $(filter off,$(TEST_DEPS)),-) -tt-i = $(if $(filter off,$(TEST_TOUCH)),-) - -# -------------------------------------------------------------------------------------------------- -# Common targets. -# -------------------------------------------------------------------------------------------------- - -# All common targets are defined as phony. It allows "buil.pl --all test-xxx". -# Makefile can define actions for a particiular test or leave it no-op. - -# all, the default target, should be the first one. -.PHONY : all -all : - -.PHONY : common clean clean-common fat inc l10n lib - -.PHONY : force-tests tests -.PHONY : force-test-touch test-touch -.PHONY : force-test-relo test-relo -.PHONY : force-test-execstack test-execstack -.PHONY : force-test-instr test-instr -.PHONY : force-test-deps test-deps - -tests = touch relo execstack instr deps -tests : $(addprefix test-,$(tests)) -force-tests : $(addprefix force-test-,$(tests)) - -# end of file # diff --git a/runtime/tools/src/common-rules.mk b/runtime/tools/src/common-rules.mk deleted file mode 100644 index 44f97c2..0000000 --- a/runtime/tools/src/common-rules.mk +++ /dev/null @@ -1,200 +0,0 @@ -# common-rules.mk # - -# -#//===----------------------------------------------------------------------===// -#// -#// The LLVM Compiler Infrastructure -#// -#// This file is dual licensed under the MIT and the University of Illinois Open -#// Source Licenses. See LICENSE.txt for details. -#// -#//===----------------------------------------------------------------------===// -# - -# -------------------------------------------------------------------------------------------------- -# This file contains really common definitions used by multiple makefiles. Modify it carefully! -# -------------------------------------------------------------------------------------------------- - -# --- Creating a directory --- -# A directory cannot be a target, because in Linux* OS directory's timestamp is updated each time a -# file is created or deleted in the directory. We use ".dir" file in place of directory. If such -# file exists, it means directory exists also. - -.PRECIOUS : %/.dir # Do not delete automatically created files. - -%/.dir : - $(target) - $(mkdir) $(dir $@) - $(touch) $@ - -# --- Rebuilding --- -# Removing or touching .rebuild file causes rebuild. -# To let it work, .rebuild should be added as prerequisite to every rule (dependency with commands) -# except clean* and force*, in this and other makefiles. -.rebuild : - $(target) - $(touch) $@ - -# -- Creating dependency file for C/C++ --- - -%.d : %.c .rebuild - $(target) - $(c) $(cpp-flags) $(c-flags) $(c-flags-m) $< > $@ - -%.d : %.cpp .rebuild - $(target) - $(cxx) $(cpp-flags) $(cxx-flags) $(cxx-flags-m) $< > $@ - -# -- Creating preprocessed file for C/C++ --- - -%.i : %.c .rebuild - $(target) - $(c) $(cpp-flags) $(c-flags) -P $(c-out)$@ $< - -%.i : %.cpp .rebuild - $(target) - $(cxx) $(cpp-flags) $(cxx-flags) -P $(cxx-out)$@ $< - -# -- Compiling C/C++ files --- - -%$(obj) : %.c .rebuild - $(target) - $(c) $(cpp-flags) $(c-flags) $(c-out)$@ $< - -%$(obj) : %.cpp .rebuild - $(target) - $(cxx) $(cpp-flags) $(cxx-flags) $(cxx-out)$@ $< - -# -- Generate assembly files --- - -%$(asm) : %.c .rebuild - $(target) - $(c) $(cpp-flags) $(c-flags) -S $(c-out)$@ $< - -%$(asm) : %.cpp .rebuild - $(target) - $(cxx) $(cpp-flags) $(cxx-flags) -S $(cxx-out)$@ $< - -# -- Compiling asm files --- - -%$(obj) : %$(asm) .rebuild - $(target) - # There is a bug on mic: icc does not work with "-x assembler-with-cpp" option, so we have - # to preprocess file manually and then assembly it. - ifeq "$(arch)" "mic" - $(c) -E $(cpp-flags) $< > $@.tmp - $(as) $(as-flags) -x assembler $(as-out)$@ $@.tmp - else - $(as) $(as-flags) $(as-out)$@ $< - endif - -# -- Expanding variables in template files --- - -# General rule "% : %.var" does not work good, so we have to write more specific rules: -# "%.h : %.h.var", etc. - -.PRECIOUS : %.h %.f %.rc # Do not delete automatically created files. - -expand-vars = $(perl) $(tools_dir)expand-vars.pl --strict $(ev-flags) $< $@ - -# Any generated file depends on kmp_version.c, because we extract build number from that file. - -%.h : %.h.var \ - kmp_version.c $(tools_dir)expand-vars.pl .rebuild - $(target) - $(expand-vars) - -%.f : %.f.var \ - kmp_version.c $(tools_dir)expand-vars.pl .rebuild - $(target) - $(expand-vars) - -%.f90 : %.f90.var \ - kmp_version.c $(tools_dir)expand-vars.pl .rebuild - $(target) - $(expand-vars) - -%.rc : %.rc.var \ - kmp_version.c $(tools_dir)expand-vars.pl .rebuild - $(target) - $(expand-vars) - -# -- Making static library --- - -.PRECIOUS : %$(lib) # Do not delete automatically created files. - -%$(lib) : %$(lib).lst .rebuild - $(target) - $(rm) $@ - $(ar) $(ar-flags) $(ar-out)$@ $$(cat $<) - # strip debug info in case it is requested (works for Linux* OS only) - ifneq "$(dbg_strip)" "" - ifeq "$(DEBUG_INFO)" "off" - ifeq "$(arch)" "mic" - x86_64-k1om-linux-objcopy --strip-debug $@ - else - objcopy --strip-debug $@ - endif - endif - endif - -# -- Making dynamic library --- - -.PRECIOUS : %$(dll) # Do not delete automatically created files. - -# makefile.mk should properly define imp_file, def_file, res_file, and pdb_file: -# lin and mac: def_file and res_file should be empty, imp_file and pdb_file do not matter. -# win: all the variabe may be empty; if a variable specified, it affects ld-flags. -# Note: imp_file and pdb_file are side effect of building this target. -# Note: to workaround CQ215229 $ld-flags-extra introduced to keep options be placed after objects -%$(dll) : %$(dll).lst $(def_file) $(res_file) .rebuild - $(target) - $(ld) $(ld-flags-dll) $(ld-flags) $(ld-out)$@ $$(cat $<) $(ld-flags-extra) $(res_file) - # If stripped pdb exist, rename it to normal pdb name. See devtools.mk for explanation. - ifneq "$(pdb_file)" "" - ifeq "$(DEBUG_INFO)" "off" - mv $(pdb_file) $(pdb_file).nonstripped - mv $(pdb_file).stripped $(pdb_file) - endif - endif - -ifneq "$(pdb_file)" "" -$(pdb_file) : $(lib_file) -endif - -%.dbg : %$(dll) .rebuild - $(target) - ifeq "$(arch)" "mic" - x86_64-k1om-linux-objcopy --only-keep-debug $< $@ - else - objcopy --only-keep-debug $< $@ - endif - - -.PRECIOUS: %.res # Do not delete automatically created files. - -%.res : %.rc .rebuild - $(target) - rc -fo$@ $< - -# --- Building helper tools from sources --- - -.PRECIOUS: %$(exe) # Do not delete automatically created files. - -%$(exe) : $(tools_dir)%.cpp .rebuild - $(target) - $(cxx) $(cxx-out)$@ $< - -# --- Forcing a test --- - -test-%/.force : test-%/.dir - $(target) - $(rm) $(dir $@).{test,force} - -# --- Removing a file in build directory --- - -rm-% : - $(target) - $(rm) $(patsubst rm-%,%,$@) - -# end of file # diff --git a/runtime/tools/src/common-tools.mk b/runtime/tools/src/common-tools.mk deleted file mode 100644 index 38614d2..0000000 --- a/runtime/tools/src/common-tools.mk +++ /dev/null @@ -1,487 +0,0 @@ -# common-tools.mk # - -# -#//===----------------------------------------------------------------------===// -#// -#// The LLVM Compiler Infrastructure -#// -#// This file is dual licensed under the MIT and the University of Illinois Open -#// Source Licenses. See LICENSE.txt for details. -#// -#//===----------------------------------------------------------------------===// -# - -# -------------------------------------------------------------------------------------------------- -# Dev tools and general options (like -fpic, -O2 or -g). -# -------------------------------------------------------------------------------------------------- - -# c -- C compiler. -# cxx -- C++ compiler. -# cpp -- C preprocessor. -# fort -- Fortran compiler. -# as -- Assembler. -# ar -- Librarian (static library maker). -# ld -- Linker (dynamic library maker). -# *-out -- Flag denoting output file. If space between flag and file name required, add explicit -# space to variable, e. g.: "c-out = -o$(space)". -# *-flags -- Flags to appropriate program, e. g. c-flags -- flags for C compiler, etc. - -# --- Common definitions --- - -# Add current directory (it contains generated files). -# Note: It is important to specify current dir as "./" (not just "."). Otherwise Intel compiler -# on Windows* OS generates such a dependency: "kmp_runtime.obj: .\kmp_i18n.inc", and make complains -# "No rule to build .\kmp_i18n.inc". Using "./" solves the problem. -cpp-flags += -I ./ -# For non-x86 architecture -ifeq "$(filter 32 32e 64 mic,$(arch))" "" - cpp-flags += $(shell pkg-config --cflags libffi) -endif -# Add all VPATH directories to path for searching include files. -cpp-flags += $(foreach i,$(VPATH),-I $(i)) - - -cpp-flags += -D USE_DEBUGGER=1 - -# Shouldn't this be being set from the command line somehow? -cpp-flags += -D USE_ITT_BUILD - -ifeq "$(OPTIMIZATION)" "on" - cpp-flags += -D NDEBUG -else - cpp-flags += -D _DEBUG -D BUILD_DEBUG - ifeq "$(os)" "win" - # This is forced since VS2010 tool produces inconsistent directives - # between objects, resulting in a link failure. - cpp-flags += -D _ITERATOR_DEBUG_LEVEL=0 - endif -endif - -# --- Linux* OS, Intel(R) Many Integrated Core Architecture and OS X* definitions --- - -ifneq "$(filter lin mac,$(os))" "" - # --- C/C++ --- - ifeq "$(c)" "" - c = icc - endif - # C++ compiler is a complement to C compiler. - ifeq "$(c)" "icc" - cxx = icpc - endif - ifeq "$(c)" "gcc" - cxx = g++ - endif - ifeq "$(c)" "clang" - cxx = clang++ - endif - # Output file flag. - c-out = -o$(space) - cxx-out = -o$(space) - # Compile only, no link. - c-flags += -c - cxx-flags += -c - # Generating dependecy file. - c-flags-m += -M -MG - cxx-flags-m += -M -MG - # Enable C99 language. - ifneq "$(CPLUSPLUS)" "on" - c-flags += -std=gnu99 - endif - # Generate position-independent code (SDL requirements). - c-flags += -fPIC - cxx-flags += -fPIC - # Emit debugging information. - ifeq "$(DEBUG_INFO)" "on" - c-flags += -g - cxx-flags += -g - endif - # Instrument program for profiling, gather extra information. - ifeq "$(COVERAGE)" "on" - ifeq "$(c)" "icc" - c-flags += -prof_genx - endif - ifeq "$(cxx)" "icpc" - cxx-flags += -prof_genx - endif - endif - # Turn optimization on or off. - ifeq "$(OPTIMIZATION)" "on" - # -inline-min-size=1 improves performance of PARALLEL EPCC up to 10% on fxi64lin01, - # doesn't change performance on fxe64lin01. - # Presence of the -inline-min-size=1 switch should only help - # to promote performance stability between changes, - # even if it has no observable impact right now. - ifneq "$(filter icl icl.exe,$(c))" "" - c-flags += -O2 -inline-min-size=1 - else - c-flags += -O2 - endif - ifneq "$(filter icl icl.exe,$(cxx))" "" - cxx-flags += -O2 -inline-min-size=1 - else - cxx-flags += -O2 - endif - else - c-flags += -O0 - cxx-flags += -O0 - endif - # --- Assembler --- - ifeq "$(c)" "icc" - as = icc - endif - ifeq "$(c)" "gcc" - as = gcc - endif - ifeq "$(c)" "clang" - as = clang - endif - as-out = -o$(space) - as-flags += $(cpp-flags) - # Compile only, no link. - as-flags += -c - as-flags += -x assembler-with-cpp - # --- Fortran --- - ifeq "$(c)" "icc" - fort = ifort - endif - ifeq "$(c)" "gcc" - fort = gfortran - endif - ifeq "$(c)" "clang" - fort = gfortran - endif - ifeq "$(fort)" "" - fort = ifort - endif - fort-out = -o$(space) - fort-flags += -c -endif - -# --- Linux* OS definitions --- - -ifeq "$(os)" "lin" -ifneq "$(arch)" "mic" - # --- C/C++ --- - # On lin_32, we want to maintain stack alignment to be compatible with GNU binaries built with - # compiler. - ifeq "$(c)" "icc" - ifeq "$(arch)" "32" - c-flags += -falign-stack=maintain-16-byte - cxx-flags += -falign-stack=maintain-16-byte - endif - # Generate code that will run on any Pentium or later processor. - ifeq "$(arch)" "32" - c-flags += -mia32 - cxx-flags += -mia32 - endif - endif - ifeq "$(c)" "gcc" - ifeq "$(arch)" "arm" - c-flags += -marm - endif - endif - # --- Librarian --- - ar = ar - ar-out = $(empty) - ar-flags += cr - # --- Linker --- - # Use ld by default, however, makefile may specify ld=$(c) before including devtools.mk. - ifeq "$(ld)" "" - ld = $(c) - endif - ld-flags-dll += -shared - ifeq "$(ld)" "ld" - ld-out = -o$(space) - ifeq "$(arch)" "32" - ld-flags += -m elf_i386 - endif - ifeq "$(arch)" "32e" - ld-flags += -m elf_x86_64 - endif - ld-flags += -x -lc -ldl - # SDL (Security Development Lifecycle) flags: - # -z noexecstack - Stack execution protection. - # -z relro -z now - Data relocation and protection. - ld-flags += -z relro -z now - ld-flags += -z noexecstack - ld-flags-dll += -soname=$(@F) - endif - ifeq "$(ld)" "$(c)" - ld-out = $(c-out) - # SDL (Security Development Lifecycle) flags: - # -z noexecstack - Stack execution protection. - # -z relro -z now - Data relocation and protection. - ld-flags += -Wl,-z,relro -Wl,-z,now - ld-flags += -Wl,-z,noexecstack - ld-flags-dll += -Wl,-soname=$(@F) - endif - ifeq "$(ld)" "$(cxx)" - ld-out = $(cxx-out) - # SDL (Security Development Lifecycle) flags: - # -z noexecstack - Stack execution protection. - # -z relro -z now - Data relocation and protection. - ld-flags += -Wl,-z,relro -Wl,-z,now - ld-flags += -Wl,-z,noexecstack - ld-flags-dll += -Wl,-soname=$(@F) - endif -endif -endif - -# --- Intel(R) Many Integrated Core Architecture definitions --- - -ifeq "$(arch)" "mic" - # --- C/C++ --- - # Intel(R) Many Integrated Core Architecture specific options, need clarification for purpose: - #c-flags += -mmic -mP2OPT_intrin_disable_name=memcpy -mP2OPT_intrin_disable_name=memset -mGLOB_freestanding -mGLOB_nonstandard_lib -nostdlib -fno-builtin - #cxx-flags += -mmic -mP2OPT_intrin_disable_name=memcpy -mP2OPT_intrin_disable_name=memset -mGLOB_freestanding -mGLOB_nonstandard_lib -nostdlib -fno-builtin - # icc for mic has a bug: it generates dependencies for target like file.obj, while real object - # files are named file.o. -MT is a workaround for the problem. - c-flags-m += -MT $(basename $@).o - cxx-flags-m += -MT $(basename $@).o - # --- Librarian --- - ar = ar - ar-out = $(empty) - ar-flags += cr - # --- Linker --- - # Use $(c) by default, however, makefile may specify another linker (e.g. ld=ld) before including devtools.mk. - ifeq "$(ld)" "" - ld = $(c) - endif - ifeq "$(ld)" "ld" - ld-out = -o$(space) - ld-flags += -m elf_l1om_fbsd - ld-flags-dll += -shared -x -lc - # SDL (Security Development Lifecycle) flags: - # -z noexecstack - Stack execution protection. - # -z relro -z now - Data relocation and protection. - ld-flags += -z noexecstack - ld-flags += -z relro -z now - ld-flags-dll += -soname=$(@F) - # Now find out path to libraries. - ld-flags-L := $(shell $(c) -Wl,-v -\# 2>&1 | grep -e "-L") - $(call debug,ld-flags-L) - # Remove continuation characters; first add a space to the end (" -Lpath1 /" -> "-Lpath1 / ") - ld-flags-L := $(filter-out \,$(ld-flags-L)) - $(call debug,ld-flags-L) - # Linker treats backslash ('\') as an escape symbol, so replace it with forward slash. - ld-flags-L := $(subst \,/,$(ld-flags-L)) - $(call debug,ld-flags-L) - ld-flags += $(ld-flags-L) - endif - ifeq "$(ld)" "$(c)" - ld-out = $(c-out) - ld-flags-dll += -shared -Wl,-x -Wl,-soname=$(@F) - # SDL (Security Development Lifecycle) flags: - # -z noexecstack - Stack execution protection. - # -z relro -z now - Data relocation and protection. - ld-flags += -Wl,-z,noexecstack - ld-flags += -Wl,-z,relro -Wl,-z,now - endif - ifeq "$(ld)" "$(cxx)" - ld-out = $(cxx-out) - ld-flags-dll += -shared -Wl,-x -Wl,-soname=$(@F) - # SDL (Security Development Lifecycle) flags: - # -z noexecstack - Stack execution protection. - # -z relro -z now - Data relocation and protection. - ld-flags += -Wl,-z,noexecstack - ld-flags += -Wl,-z,relro -Wl,-z,now - endif -endif - -# --- OS X* definitions --- - -ifeq "$(os)" "mac" - # --- Librarian --- - ar = libtool - ar-out = -o$(space) - ar-flags += -static - # --- Linker --- - # Use C compiler as linker by default, however, makefile may specify ld=$(libtool) before - # including devtools.mk. - ifeq "$(ld)" "" - ld = $(c) - endif - ifeq "$(ld)" "libtool" - ld-out = -o$(space) - ld-flags-dll += -dynamic - ld-flags += -lc -ldl - endif - ifeq "$(ld)" "$(c)" - ld-out = $(c-out) - ld-flags-dll += -dynamiclib - endif - ifeq "$(ld)" "$(cxx)" - ld-out = $(cxx-out) - ld-flags-dll += -dynamiclib - endif - # These options suitable for any linker, either C compiler or libtool. - ld-flags-dll += -headerpad_max_install_names - ld-flags-dll += -install_name $(@F) -endif - -# --- Windows* OS definitions --- - -ifeq "$(os)" "win" - # Disable warning "function "..." (declared at line ... of ...) was declared deprecated...". - cpp-flags += -D_CRT_SECURE_NO_WARNINGS -D_CRT_SECURE_NO_DEPRECATE - # --- C/C++ --- - ifeq "$(c)" "" - c = icl.exe - endif - cxx = $(c) - # Often default icl.cfg file in compiler bin/ directory contains options -Qvc and - # -Qlocation,link. Setting ICLCFG (and IFORTCFG) to specially prepared empty config file - # overrides default config. - ICLCFG = $(tools_dir)icc.cfg - IFORTCFG = $(tools_dir)icc.cfg - export ICLCFG - export IFORTCFG - # Output file. - c-out = -o$(space) - cxx-out = -o$(space) - # Disable annoying compiler logo. - c-flags += -nologo - cxx-flags += -nologo - # Generate code that will run on any Pentium or later processor. - ifeq "$(arch)" "32" - c-flags += -arch:ia32 - cxx-flags += -arch:ia32 - endif - # Compile only, no link. - c-flags += -c - cxx-flags += -c - # -QM -- Generate dependency file. - # -QMM -- do not include system headers. On Windows* OS, system headers may be located in - # "C:\Program Files\...", but path with space confuses make, so we exclude system - # headers. - # -QMG -- Treat missed headers as generated. We do have some generated include files. - c-flags-m += -QM -QMM -QMG - cxx-flags-m += -QM -QMM -QMG - # Enable C99 language. - ifneq "$(CPLUSPLUS)" "on" - c-flags += -Qstd=gnu99 - endif - # Enable C++ exception handling. - # ??? Why we disable it on Linux* OS? - cxx-flags += -EHsc - ifeq "$(arch)" "32" - ifneq "$(filter icl icl.exe,$(c))" "" - c-flags += -Qsafeseh - endif - ifneq "$(filter icl icl.exe,$(cxx))" "" - cxx-flags += -Qsafeseh - endif - endif - # Emit debugging information. - ifeq "$(DEBUG_INFO)" "on" - c-flags += -Zi - cxx-flags += -Zi - endif - # Instrument program for profiling, gather extra information. - ifeq "$(COVERAGE)" "on" - c-flags += -Qprof_genx - cxx-flags += -Qprof_genx - endif - # Turn optimization on or off. - ifeq "$(OPTIMIZATION)" "on" - # Presence of the -inline-min-size=1 switch should only help - # to promote performance stability between changes, - # even if it has no observable impact right now. - # See the Linux* OS section above. - ifneq "$(filter icl icl.exe,$(c))" "" - c-flags += -O2 -Qinline-min-size=1 - else - c-flags += -O2 - endif - ifneq "$(filter icl icl.exe,$(cxx))" "" - cxx-flags += -O2 -Qinline-min-size=1 - else - cxx-flags += -O2 - endif - else - c-flags += -Od - cxx-flags += -Od - # Enable stack frame runtime error checking. - # !!! 0Obsolete option. Should use /RTC instead. - c-flags += -RTC1 - cxx-flags += -RTC1 - endif - # SDL (Security Development Lifecycle) flags: - # GS - Stack-based Buffer Overrun Detection - # DynamicBase - Image Randomization - c-flags += -GS -DynamicBase - cxx-flags += -GS -DynamicBase - # --- Assembler --- - ifeq "$(arch)" "32" - as = ml - endif - ifeq "$(arch)" "32e" - as = ml64 - endif - ifeq "$(as)" "ias" - as-out = -o$(space) - endif - ifneq "$(filter ml ml64,$(as))" "" - as-out = -Fo - as-flags += -nologo -c - # SDL (Security Development Lifecycle) flags: - # DynamicBase - Image Randomization - as-flags += -DynamicBase - endif - # --- Fortran --- - fort = ifort - fort-out = -o$(space) - fort-flags += -nologo - fort-flags += -c - # SDL (Security Development Lifecycle) flags: - # GS - Stack-based Buffer Overrun Detection - # DynamicBase - Image Randomization - fort-flags += -GS -DynamicBase - # --- Librarian --- - ar = link.exe - ar-out = -out: - # Generate static library. Must be the first option. - ar-flags += -lib - # Turn off tool banner. - ar-flags += -nologo - # --- Linker --- - ld = link.exe - ld-out = -out: - # Generate dynamic library. - ld-flags-dll += -dll - # Turn off tool banner. - ld-flags += -nologo - # Generate pdb (Program DataBase, debug information) file. - # If DEBUG_INFO is on, generate normal (full-featured) pdb file. Otherwise, we need only - # stripped pdb. But stripped pdb cannot be generated alone, we have to generate normal *and* - # stripped pdb. After generating both pdb files we rename stripped pdb to normal pdb name (see - # rules.mk). - ifeq "$(DEBUG_INFO)" "on" - ld-flags += $(if $(pdb_file),-debug -pdb:$(pdb_file)) - else - ld-flags += $(if $(pdb_file),-debug -pdb:$(pdb_file) -pdbstripped:$(pdb_file).stripped) - endif - # Use def file, if $(def_file) is specified. - ld-flags += $(if $(def_file),-def:$(def_file)) - # Generate import library, if $(imp_file) is specified. - ld-flags += $(if $(imp_file),-implib:$(imp_file)) - # Specify architecture. - ifeq "$(arch)" "32" - ar-flags += -machine:i386 - ld-flags += -machine:i386 - endif - ifeq "$(arch)" "32e" - ar-flags += -machine:amd64 - ld-flags += -machine:amd64 - endif - # SAFESEH - ifeq "$(arch)" "32" - as-flags += -safeseh - ld-flags += -safeseh - endif - # SDL (Security Development Lifecycle) flags: - # NXCompat - Data Execution Prevention - ld-flags += -NXCompat -DynamicBase -endif - -# end of file # diff --git a/runtime/tools/windows.inc b/runtime/tools/windows.inc deleted file mode 100644 index 3d2e070..0000000 --- a/runtime/tools/windows.inc +++ /dev/null @@ -1,27 +0,0 @@ -# -#//===----------------------------------------------------------------------===// -#// -#// The LLVM Compiler Infrastructure -#// -#// This file is dual licensed under the MIT and the University of Illinois Open -#// Source Licenses. See LICENSE.txt for details. -#// -#//===----------------------------------------------------------------------===// -# - -export SHELL = cmd - -# TODO give an error if archs doesn't match -ifndef arch - $(error Could not detect arch: please specify on command line.) -endif - - -CMD=cmd /C -CWD=$(shell cmd /C echo %CD%) -RM=cmd /C del /Q /F -RD=cmd /C rmdir -MD=cmd /c mkdir -SLASH=\\ -NUL = nul - diff --git a/runtime/tools/wipe-string.pl b/runtime/tools/wipe-string.pl deleted file mode 100755 index deab95f..0000000 --- a/runtime/tools/wipe-string.pl +++ /dev/null @@ -1,183 +0,0 @@ -#!/usr/bin/perl - -# -#//===----------------------------------------------------------------------===// -#// -#// The LLVM Compiler Infrastructure -#// -#// This file is dual licensed under the MIT and the University of Illinois Open -#// Source Licenses. See LICENSE.txt for details. -#// -#//===----------------------------------------------------------------------===// -# - -use strict; -use warnings; - -use File::Glob ":glob"; - -use FindBin; -use lib "$FindBin::Bin/lib"; - -use tools; - -our $VERSION = "0.02"; - -sub wipe($$$) { - - my ( $input, $output, $wipe ) = @_; - my $bulk = read_file( $input, -binary => 1 ); - $bulk =~ s{($wipe)}{ " " x length( $1 ) }ge; - write_file( $output, \$bulk, -binary => 1 ); - return undef; - -}; # sub wipe - -my @wipe; -my $target = "."; -get_options( - "wipe-literal=s" => - sub { my $arg = $_[ 1 ]; push( @wipe, qr{@{ [ quotemeta( $arg ) ] }} ); }, - "wipe-regexp=s" => - sub { my $arg = $_[ 1 ]; push( @wipe, qr{$arg} ); }, - "target-directory=s" => \$target, -); - -# Convert strings to regular expression. -my $wipe = qr{@{ [ join( "|", @wipe ) ] }}; - -my %jobs; - -# Collect files to process. -# jobs: output -> input. -foreach my $arg ( @ARGV ) { - my @inputs = ( $^O eq "MSWin32" ? bsd_glob( $arg ) : ( $arg ) ); - foreach my $input ( @inputs ) { - my $file = get_file( $input ); - my $output = cat_file( $target, $file ); - if ( exists( $jobs{ $output } ) ) { - runtime_error( - "\"$jobs{ $output }\" and \"$input\" input files tend to be written " . - "to the same output file \"$output\"" - ); - }; # if - $jobs{ $output } = $input; - }; # foreach -}; # foreach $file - -# Process files. -%jobs = reverse( %jobs ); # jobs: input -> output. -foreach my $input ( sort( keys( %jobs ) ) ) { - my $output = $jobs{ $input }; - info( "\"$input\" -> \"$output\"" ); - wipe( $input, $output, $wipe ); -}; # foreach $input - -exit( 0 ); - -__END__ - -# -# Embedded documentation. -# - -=pod - -=head1 NAME - -B<wipe-string.pl> -- Wipe string in text or binary files. - -=head1 SYNOPSIS - -B<wipe-string.pl> I<OPTION>... I<FILE>... - -=head1 OPTIONS - -=over - -=item B<--doc> - -=item B<--manual> - -Print full help message and exit. - -=item B<--help> - -Print short help message and exit. - -=item B<--target-directory=>I<dir> - -Directory to put result files to. By default result files are written in the current working -directory. - -=item B<--usage> - -Print very short usage message and exit. - -=item B<--version> - -Print version and exit. - -=item B<--wipe-literal=>I<str> - -Specify literal string to wipe. Multiple literals are allowed. - -=item B<--wipe-regexp=>I<str> - -Specify Perl regular expression to wipe. Multiple regular expressions may be specified. - -Be careful. Protect special characters from beign interpreted by shell. - -=back - -=head1 ARGUMENTS - -=over - -=item I<file> - -File name to wipe string in. - -=back - -=head1 DESCRIPTION - -The script wipes strings in files. String may be specified literally or by Perl regular expression. -Strings are wiped by replacing characters with spaces, so size of file remains the same. The script -may be applied to both text and binary files. - -Result files are written by default to current directory, or to directory specified by -B<--target-directory> option, if any. If multiple input files tend to be written to the same output -file (e. g. identically named input files located in different directories), the script generates an -error. - -The script reads entire file, process it, and the writes to disk. Therefore it is (almost) safe to -update files in-place (see examples). - -=head1 EXAMPLES - -Wipe "Copyright" word in all the files with "txt" suffix in current directory, overwrite original -files (update them in-place): - - wipe-string.pl --wipe-literal="Copyright" *.txt - -Wipe "Copyright" and "Copyleft" words in all the files with "txt" suffix in current directory, -write result files to ../wiped directory: - - wipe-string.pl --wipe-literal=Copyright --wipe-literal=Copyleft --target-dir=../wiped *.txt - -Wipe "Copyright" and "Copyleft" words in files from "doc" directory, write result files to current -directory; - - wipe-string.pl --wipe-regexp="Copyright|Copyleft" doc/* - -Wipe "defaultlib" directive in all the library files: - - wipe-string.pl --wipe-regexp="-defaultlib:[A-Za-z0-9_.]+" *.lib - -(Be careful: the script does not analyze structure of library and object files, it just wipes -U<strings>, so it wipes all the occurrences of strings matching to specified regular expression.) - -=cut - -# end of file # |