Skip to content
Snippets Groups Projects
Commit 22368531 authored by Shengjing Zhu's avatar Shengjing Zhu Committed by Guillem Jover
Browse files

test: Add unit tests for lto build flags handling in Ubuntu

[guillem@debian.org: Fix typos in comments. ]

Ref: https://bugs.launchpad.net/bugs/2002582


Signed-off-by: default avatarGuillem Jover <guillem@debian.org>
parent c5e6822d
No related branches found
No related tags found
1 merge request!4Update crimson to version from bookworm
......@@ -16,7 +16,7 @@
use strict;
use warnings;
use Test::More tests => 18;
use Test::More tests => 21;
BEGIN {
use_ok('Dpkg::BuildFlags');
......@@ -42,6 +42,15 @@ sub test_ltoflag
"LDFLAGS contains LTO flags on $ENV{DEB_HOST_ARCH}");
}
sub test_no_ltoflag
{
my $bf = shift;
# Test the LTO flags not being enabled.
ok($bf->get('LDFLAGS') !~ m/-flto=auto -ffat-lto-objects/,
"LDFLAGS does not contain LTO flags on $ENV{DEB_HOST_ARCH}");
}
my $bf;
# Force loading the Dpkg::Vendor::Ubuntu module.
......@@ -65,4 +74,21 @@ $bf = Dpkg::BuildFlags->new();
test_optflag($bf, '-O3');
test_ltoflag($bf);
# Test the optimization flag not enabled for riscv64.
$ENV{DEB_HOST_ARCH} = 'riscv64';
$bf = Dpkg::BuildFlags->new();
test_no_ltoflag($bf);
# Test the optimization flag override by DEB_BUILD_MAINT_OPTIONS.
$ENV{DEB_BUILD_MAINT_OPTIONS} = 'optimize=+lto';
$bf = Dpkg::BuildFlags->new();
test_ltoflag($bf);
$ENV{DEB_HOST_ARCH} = 'amd64';
$ENV{DEB_BUILD_MAINT_OPTIONS} = 'optimize=-lto';
$bf = Dpkg::BuildFlags->new();
test_no_ltoflag($bf);
1;
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment