Skip to content

Commit 8b01bb5

Browse files
uenosmuellerDD
authored andcommitted
Compile FIPS 140 integrity check only when building shared library
When leancrypto is compiled as a static library with -Ddefault_library=static, it fails with: ``` ../internal/src/fips_integrity_checker_elf.c:77:10: fatal error: fips_integrity_checker_values.h: No such file or directory 77 | #include "fips_integrity_checker_values.h" | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ``` Given the FIPS 140 integrity check only works with shared library, as it utilizes the ELF sections, this adds an extra check on build_shared to avoid the compilation error. Signed-off-by: Daiki Ueno <dueno@redhat.com> Signed-off-by: Stephan Mueller <smueller@chronox.de>
1 parent 54dd21d commit 8b01bb5

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

internal/src/meson.build

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ else
3333
endif
3434

3535
# FIPS 140 Integrity check: The integrity checker is adopted for ELF.
36-
if (host_machine.system() == 'linux' and get_option('efi').disabled())
36+
if (host_machine.system() == 'linux' and get_option('efi').disabled() and build_shared)
3737
src_fips_wrapper += files([
3838
'fips_integrity_checker_elf.c'
3939
])

meson.build

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -631,6 +631,10 @@ leancrypto_support_libs_fips = [ ]
631631
# External libraries leancrypto should link to
632632
leancrypto_link = [ ]
633633

634+
# Whether to build the shared library alongside the static library
635+
build_shared = (get_option('default_library') != 'static' and
636+
get_option('efi').disabled())
637+
634638
foreach n : subdirs
635639
subdir(n)
636640
endforeach
@@ -650,10 +654,6 @@ if (host_machine.system() != 'windows')
650654
check: true)
651655
endif
652656

653-
# Whether to build the shared library alongside the static library
654-
build_shared = (get_option('default_library') != 'static' and
655-
get_option('efi').disabled())
656-
657657
# Compile the "raw" FIPS 140 library part which can be linked into
658658
# the libleancrypto-fips.[so|a] with the integrity test as well as
659659
# non-FIPS libleancrypto.[so|a] without the integrity test.
@@ -671,7 +671,7 @@ fips_integrity_checker_values_h = []
671671
link_args_fips140 = []
672672

673673
# FIPS 140 Integrity check: The integrity checker is adopted for ELF.
674-
if (host_machine.system() == 'linux' and get_option('efi').disabled())
674+
if (host_machine.system() == 'linux' and get_option('efi').disabled() and build_shared)
675675
link_args_fips140 = [
676676
'-T' + meson.project_source_root() + '/internal/src/fips_integrity_check.ld'
677677
]

0 commit comments

Comments
 (0)