1
0
mirror of https://github.com/pgbackrest/pgbackrest.git synced 2025-09-16 09:06:18 +02:00

Build libc using links rather than referencing the C files in src directly.

The C library builds with different options which should not be reused for the C binary or vice versa.
This commit is contained in:
David Steele
2018-05-17 17:09:06 -04:00
parent 91be372e6a
commit bce3d0fe1c
5 changed files with 29 additions and 6 deletions

View File

@@ -23,6 +23,12 @@
<p>Use <code>time_t</code> instead of <code>__time_t</code> for better portability.</p>
</release-item>
</release-improvement-list>
<release-development-list>
<release-item>
<p>Build <path>libc</path> using links rather than referencing the C files in <path>src</path> directly. The C library builds with different options which should not be reused for the C binary or vice versa.</p>
</release-item>
</release-development-list>
</release-core-list>
<release-test-list>

View File

@@ -13,7 +13,6 @@ $SIG{__DIE__} = sub { Carp::confess @_ };
use Cwd qw(abs_path);
use ExtUtils::MakeMaker;
use File::Basename qw(dirname);
use File::Copy qw(copy);
use lib dirname($0) . '/lib';
use pgBackRest::LibCAuto;
@@ -112,10 +111,28 @@ my @stryCFile =
'storage/storage.c',
);
# Add ../src for files that are outside libc
# Link source files to build the C library. The library has different build options and we don't want the bin build to reuse any of
# them. Also, this makes the output of the __FILE__ macro prettier.
for (my $iFileIdx = 1; $iFileIdx < @stryCFile; $iFileIdx++)
{
$stryCFile[$iFileIdx] = '../src/' . $stryCFile[$iFileIdx];
# Make directory
system("mkdir -p " . dirname($stryCFile[$iFileIdx])) == 0
or die('unable to mkdir ' . dirname($stryCFile[$iFileIdx]));
# Link the file to the source directory
my @stryLink = split('/', $stryCFile[$iFileIdx]);
my $strLink;
for (my $iLinkIdx = 0; $iLinkIdx < @stryLink; $iLinkIdx++)
{
$strLink .= (defined($strLink) ? '/' : '') . '..';
}
if (!-l $stryCFile[$iFileIdx])
{
system("ln -s ${strLink}/src/$stryCFile[$iFileIdx] $stryCFile[$iFileIdx]") == 0
or die("unable to link ../src/$stryCFile[$iFileIdx] to $stryCFile[$iFileIdx]");
}
}
# Write the makefile

View File

@@ -69,7 +69,7 @@ typedef struct ConfigOptionData
/***********************************************************************************************************************************
Include the automatically generated configuration data
***********************************************************************************************************************************/
#include "config.auto.c"
#include "config/config.auto.c"
/***********************************************************************************************************************************
Debug Asserts

View File

@@ -170,7 +170,7 @@ typedef enum
/***********************************************************************************************************************************
Include the automatically generated configuration data.
***********************************************************************************************************************************/
#include "define.auto.c"
#include "config/define.auto.c"
/***********************************************************************************************************************************
Find optional data for a command and option.

View File

@@ -47,7 +47,7 @@ Parse option flags
/***********************************************************************************************************************************
Include automatically generated data structure for getopt_long()
***********************************************************************************************************************************/
#include "parse.auto.c"
#include "config/parse.auto.c"
/***********************************************************************************************************************************
Struct to hold options parsed from the command line