diff options
author | Richard Levitte <levitte@openssl.org> | 2021-01-10 09:08:46 +0100 |
---|---|---|
committer | Richard Levitte <levitte@openssl.org> | 2021-01-12 11:25:54 +0100 |
commit | 507f83800fe9c85c6249e9baad4602075df2b5b7 (patch) | |
tree | 194452417dbb2794a9a317de0e151fc5f2c7999e /Configure | |
parent | v3_ocsp.c: fix indentation of include directives (diff) | |
download | openssl-507f83800fe9c85c6249e9baad4602075df2b5b7.tar.xz openssl-507f83800fe9c85c6249e9baad4602075df2b5b7.zip |
Configure: Check all SOURCE declarations, to ensure consistency
If the given sources are GENERATEd, we check those generators as well.
This ensures that the declarations in the diverse build.info files are
consistent with existing files.
Reviewed-by: Tomas Mraz <tmraz@fedoraproject.org>
(Merged from https://github.com/openssl/openssl/pull/13824)
Diffstat (limited to 'Configure')
-rwxr-xr-x | Configure | 74 |
1 files changed, 69 insertions, 5 deletions
@@ -1891,6 +1891,17 @@ if ($builder eq "unified") { $config{build_infos} = [ ]; + # We want to detect configdata.pm in the source tree, so we + # don't use it if the build tree is different. + my $src_configdata = cleanfile($srcdir, "configdata.pm", $blddir); + + # Any source file that we recognise is placed in this hash table, with + # the list of its intended destinations as value. When everything has + # been collected, there's a routine that checks that these source files + # exist, or if they are generated, that the generator exists. + my %check_exist = (); + my %check_generate = (); + my %ordinals = (); while (@build_dirs) { my @curd = @{shift @build_dirs}; @@ -2038,11 +2049,6 @@ if ($builder eq "unified") { } }; - # We want to detect configdata.pm in the source tree, so we - # don't use it if the build tree is different. - my $src_configdata = cleanfile($srcdir, "configdata.pm", $blddir); - - if ($buildinfo_debug) { print STDERR "DEBUG: Reading ",catfile($sourced, $f),"\n"; } @@ -2242,6 +2248,7 @@ EOF } # We recognise C++, C and asm files if ($s =~ /\.(cc|cpp|c|s|S)$/) { + push @{$check_exist{$s}}, $ddest; my $o = $_; $o =~ s/\.[csS]$/.o/; # C and assembler $o =~ s/\.(cc|cpp)$/_cc.o/; # C++ @@ -2250,12 +2257,14 @@ EOF $unified_info{sources}->{$o}->{$s} = -1; } elsif ($s =~ /\.rc$/) { # We also recognise resource files + push @{$check_exist{$s}}, $ddest; my $o = $_; $o =~ s/\.rc$/.res/; # Resource configuration my $o = cleanfile($buildd, $o, $blddir); $unified_info{sources}->{$ddest}->{$o} = -1; $unified_info{sources}->{$o}->{$s} = -1; } else { + push @{$check_exist{$s}}, $ddest; $unified_info{sources}->{$ddest}->{$s} = 1; } } @@ -2275,6 +2284,7 @@ EOF if ($s =~ /\.(cc|cpp|c|s|S)$/) { # We recognise C++, C and asm files + push @{$check_exist{$s}}, $ddest; my $o = $_; $o =~ s/\.[csS]$/.o/; # C and assembler $o =~ s/\.(cc|cpp)$/_cc.o/; # C++ @@ -2283,6 +2293,7 @@ EOF $unified_info{sources}->{$o}->{$s} = -1; } elsif ($s =~ /\.rc$/) { # We also recognise resource files + push @{$check_exist{$s}}, $ddest; my $o = $_; $o =~ s/\.rc$/.res/; # Resource configuration my $o = cleanfile($buildd, $o, $blddir); @@ -2291,6 +2302,7 @@ EOF } elsif ($s =~ /\.ld$/) { # We also recognise linker scripts (or corresponding) # We know they are generated files + push @{$check_exist{$s}}, $ddest; my $ld = cleanfile($buildd, $_, $blddir); $unified_info{shared_sources}->{$ddest}->{$ld} = 1; } else { @@ -2313,6 +2325,7 @@ EOF if ($generate{$gen}) { $generator[0] = cleanfile($buildd, $gen, $blddir); } + $check_generate{$ddest}->{$generator[0]} = 1; $unified_info{generate}->{$ddest} = [ @generator ]; } @@ -2417,6 +2430,57 @@ They are ignored and should be replaced with a combination of GENERATE, DEPEND and SHARED_SOURCE. EOF + # Check that each generated file is only generated once + my $ambiguous_generation = 0; + foreach (sort keys %check_generate) { + my @generators = sort keys %{$check_generate{$_}}; + my $generators_txt = join(', ', @generators); + if (scalar @generators > 1) { + warn "$_ is GENERATEd by more than one generator ($generators_txt)\n"; + $ambiguous_generation++; + } + } + die "There are ambiguous source file generations\n" + if $ambiguous_generation > 0; + + # All given source files should exist, or if generated, their + # generator should exist. This loop ensures this is true. + my $missing = 0; + foreach my $orig (sort keys %check_exist) { + foreach my $dest (@{$check_exist{$orig}}) { + if ($orig ne $src_configdata) { + if ($orig =~ /\.a$/) { + # Static library names may be used as sources, so we + # need to detect those and give them special treatment. + unless (grep { $_ eq $orig } + keys %{$unified_info{libraries}}) { + warn "$orig is given as source for $dest, but no such library is built\n"; + $missing++; + } + } else { + # A source may be generated, and its generator may be + # generated as well. We therefore loop to dig out the + # first generator. + my $gen = $orig; + + while (my @next = keys %{$check_generate{$gen}}) { + $gen = $next[0]; + } + + if (! -f $gen) { + if ($gen ne $orig) { + $missing++; + warn "$orig is given as source for $dest, but its generator (leading to $gen) is missing\n"; + } else { + $missing++; + warn "$orig is given as source for $dest, but is missing\n"; + } + } + } + } + } + } + die "There are files missing\n" if $missing > 0; # Go through the sources of all libraries and check that the same basename # doesn't appear more than once. Some static library archivers depend on |