Skip to content

Commit 96b2600

Browse files
committed
Meson: compile code only once if possible
By using both_libraries(), object files are compiled only once. Signed-off-by: Stephan Mueller <smueller@chronox.de>
1 parent 8881b3f commit 96b2600

File tree

2 files changed

+27
-21
lines changed

2 files changed

+27
-21
lines changed

meson.build

Lines changed: 26 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -629,19 +629,10 @@ endif
629629
build_shared = get_option('default_library') != 'static' and get_option('efi').disabled()
630630

631631
if (get_option('fips140').enabled())
632-
# Create the official static FIPS library
633-
leancrypto_static_lib_fips = static_library('leancrypto-fips',
634-
[ src_fips, internal_src ],
635-
include_directories: [ include_dirs, include_internal_dirs ],
636-
dependencies: [ leancrypto_link ],
637-
link_whole: [ leancrypto_support_libs_fips ],
638-
install: true
639-
)
640-
leancrypto_support_libs += leancrypto_static_lib_fips
641632

642633
if build_shared
643634
# Create the official shared FIPS library
644-
leancrypto_lib_fips = shared_library('leancrypto-fips',
635+
leancrypto_both_libs_fips = both_libraries('leancrypto-fips',
645636
[ src_fips, internal_src ],
646637
include_directories: [ include_dirs,
647638
include_internal_dirs ],
@@ -650,10 +641,23 @@ if (get_option('fips140').enabled())
650641
link_whole: [ leancrypto_support_libs_fips ],
651642
install: true
652643
)
644+
645+
leancrypto_lib_fips = leancrypto_both_libs_fips.get_shared_lib()
646+
leancrypto_static_lib_fips = leancrypto_both_libs_fips.get_static_lib()
653647
else
648+
# Create the official static FIPS library
649+
leancrypto_static_lib_fips = static_library('leancrypto-fips',
650+
[ src_fips, internal_src ],
651+
include_directories: [ include_dirs, include_internal_dirs ],
652+
dependencies: [ leancrypto_link ],
653+
link_whole: [ leancrypto_support_libs_fips ],
654+
install: true
655+
)
654656
leancrypto_lib_fips = leancrypto_static_lib_fips
655657
endif
656658

659+
leancrypto_support_libs += leancrypto_static_lib_fips
660+
657661
if get_option('efi').disabled()
658662
pkgconfig.generate(leancrypto_lib_fips,
659663
description: 'PQC-resistant cryptographic library with FIPS -140 compliance')
@@ -667,26 +671,28 @@ else
667671
leancrypto_support_libs += leancrypto_support_libs_fips
668672
endif
669673

670-
# Create the official static library
671-
leancrypto_static_lib = static_library('leancrypto',
672-
[ src ],
673-
include_directories: [ include_dirs, include_internal_dirs ],
674-
dependencies: [ leancrypto_link ],
675-
link_whole: [ leancrypto_support_libs ],
676-
install: true
677-
)
678-
679674
if build_shared
680675
# Create the official shared library
681-
leancrypto_lib = shared_library('leancrypto',
676+
leancrypto_both_libs = both_libraries('leancrypto',
682677
[ src ],
683678
include_directories: [ include_dirs, include_internal_dirs ],
684679
soversion: version_array[0],
685680
dependencies: [ leancrypto_link ],
686681
link_whole: [ leancrypto_support_libs ],
687682
install: true
688683
)
684+
685+
leancrypto_lib = leancrypto_both_libs.get_shared_lib()
686+
leancrypto_static_lib = leancrypto_both_libs.get_static_lib()
689687
else
688+
# Create the official static library
689+
leancrypto_static_lib = static_library('leancrypto',
690+
[ src ],
691+
include_directories: [ include_dirs, include_internal_dirs ],
692+
dependencies: [ leancrypto_link ],
693+
link_whole: [ leancrypto_support_libs ],
694+
install: true
695+
)
690696
leancrypto_lib = leancrypto_static_lib
691697
endif
692698

ml-kem/src/armv8/meson.build

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
# Files compiled only once
44
if (get_option('kyber_1024').enabled() or get_option('kyber_768').enabled())
5-
src += files([
5+
src_fips += files([
66
'kyber_ntt_armv8.c',
77
])
88
endif

0 commit comments

Comments
 (0)