Skip to content

Commit

Permalink
consolidate special compiler options
Browse files Browse the repository at this point in the history
Signed-off-by: Stephan Mueller <[email protected]>
  • Loading branch information
smuellerDD committed Feb 2, 2024
1 parent 266f5e2 commit 7b45cd4
Show file tree
Hide file tree
Showing 10 changed files with 36 additions and 85 deletions.
18 changes: 3 additions & 15 deletions aead/src/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,7 @@ if get_option('hash_crypt').enabled()
'leancrypto_aead_avx2_lib',
[ 'cshake_crypt.c',
'kmac_crypt.c' ],
c_args: [
'-mavx2',
'-mbmi2',
'-mpopcnt',
],
c_args: cc_avx2_args,
include_directories: [ include_dirs,
include_internal_dirs ],
)
Expand All @@ -26,10 +22,7 @@ if get_option('hash_crypt').enabled()
'leancrypto_aead_neon_armv8_lib',
[ 'cshake_crypt.c',
'kmac_crypt.c' ],
c_args: [
'-march=armv8-a+simd',
'-Wno-unused-result',
],
c_args: cc_armv8_neon_simd_args,
include_directories: [ include_dirs,
include_internal_dirs ],
)
Expand All @@ -41,12 +34,7 @@ if get_option('hash_crypt').enabled()
'leancrypto_aead_neon_armv7_lib',
[ 'cshake_crypt.c',
'kmac_crypt.c' ],
c_args: [
'-mfpu=neon-vfpv4',
'-mthumb',
'-march=armv7-a+vfpv4',
'-funsafe-math-optimizations'
],
c_args: cc_armv7_neon_simd_args,
include_directories: [ include_dirs,
include_internal_dirs ],
)
Expand Down
6 changes: 1 addition & 5 deletions curve25519/src/avx/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,7 @@ leancrypto_curve25519_avx_lib = static_library(
'../',
include_internal_dirs
],
c_args: [
'-mavx2',
'-mpopcnt',
'-Wno-unused-command-line-argument'
]
c_args: cc_avx2_args
)

leancrypto_support_libs += leancrypto_curve25519_avx_lib
28 changes: 5 additions & 23 deletions hash/src/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,7 @@ if get_option('sha3').enabled()
'leancrypto_keccak_avx2_4x_lib',
[ 'shake_4x_avx2.c',
'asm/AVX2_4x/KeccakP-1600-times4-SIMD256.c' ],
c_args: [
'-mavx2',
'-mbmi2',
'-mpopcnt',
],
c_args: cc_avx2_args,
include_directories: [ include_dirs,
include_internal_dirs ],
)
Expand All @@ -52,12 +48,7 @@ if get_option('sha3').enabled()
'leancrypto_keccak_arm7a_neon_lib',
[ 'sha3_arm_neon.c',
'asm/ARMv7A-NEON/KeccakP-1600-armv7a-le-neon-gcc.S' ],
c_args: [
'-mfpu=neon-vfpv4',
'-mthumb',
'-march=armv7-a+vfpv4',
'-funsafe-math-optimizations'
],
c_args: cc_armv7_neon_simd_args,
include_directories: [
include_directories(['asm/ARMv7A-NEON/']),
include_dirs,
Expand All @@ -71,10 +62,7 @@ if get_option('sha3').enabled()
'leancrypto_keccak_arm8a_neon_lib',
[ 'sha3_arm_neon.c',
'asm/ARMv8A/KeccakP-1600-armv8a-neon.S' ],
c_args: [
'-march=armv8-a+simd',
'-funsafe-math-optimizations'
],
c_args: cc_armv8_neon_simd_args,
include_directories: [
include_directories(['asm/ARMv8A/']),
include_dirs,
Expand All @@ -94,10 +82,7 @@ if get_option('sha3').enabled()
leancrypto_keccak_armv8_2x_ce_lib = static_library(
'leancrypto_keccak_armv8_2x_ce_lib',
[ 'asm/ARMv8_2x/keccakx2_armce.S' ],
c_args: [
'-march=armv8-a+crypto',
'-Wno-unused-result',
],
c_args: cc_armv8_neon_simd_args,
include_directories: [ include_dirs,
include_internal_dirs ],
)
Expand All @@ -107,10 +92,7 @@ if get_option('sha3').enabled()
leancrypto_keccak_armv8_2x_c_lib = static_library(
'leancrypto_keccak_armv8_2x_c_lib',
[ 'shake_2x_armv8.c' ],
c_args: [
'-march=armv8-a+simd',
'-Wno-unused-result',
],
c_args: cc_armv8_neon_simd_args,
include_directories: [ include_dirs,
include_internal_dirs ],
)
Expand Down
5 changes: 1 addition & 4 deletions internal/src/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,7 @@ if (x86_64_asm)
include_dirs,
include_internal_dirs
],
c_args: [
'-mavx2',
'-Wno-unused-command-line-argument'
]
c_args: cc_avx2_args
)
leancrypto_support_libs += leancrypto_memcmp_secure_avx2_lib
else
Expand Down
7 changes: 1 addition & 6 deletions kem/src/armv7/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,7 @@ leancrypto_kyber_armv7_lib = static_library(
include_dirs,
include_internal_dirs
],
# c_args: [
# '-mfpu=neon-vfpv4',
# '-mthumb',
# '-march=armv7-a+vfpv4',
# '-funsafe-math-optimizations'
# ],
# c_args: cc_armv7_neon_simd_args,
)

leancrypto_support_libs += leancrypto_kyber_armv7_lib
7 changes: 1 addition & 6 deletions kem/src/avx2/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,6 @@ leancrypto_kyber_avx2_lib = static_library(
include_dirs,
include_internal_dirs
],
c_args: [
'-mavx2',
'-mbmi2',
'-mpopcnt',
'-Wno-unused-command-line-argument'
]
c_args: cc_avx2_args
)
leancrypto_support_libs += leancrypto_kyber_avx2_lib
19 changes: 19 additions & 0 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,13 @@ if (host_machine.cpu_family() == 'x86_64' and
# 64 bit AVX2 / AVX512 support
x86_64_asm = true
add_global_arguments([ '-DLC_HOST_X86_64' ], language: 'c')

cc_avx2_args = [
'-mavx2',
'-mbmi2',
'-mpopcnt',
'-Wno-unused-command-line-argument'
]
endif

if (host_machine.cpu_family() == 'arm' and
Expand All @@ -269,11 +276,23 @@ if (host_machine.cpu_family() == 'arm' and

add_global_arguments([ '-DLC_HOST_ARM32_NEON' ], language: 'c')

cc_armv7_neon_simd_args = [
'-mfpu=neon-vfpv4',
'-mthumb',
'-march=armv7-a+vfpv4',
'-funsafe-math-optimizations'
]

elif (host_machine.cpu_family() == 'aarch64')

arm64_asm = true
add_global_arguments([ '-DLC_HOST_AARCH64' ], language: 'c')

cc_armv8_neon_simd_args = [
'-march=armv8-a+simd',
'-Wno-unused-result',
]

if (cc.get_id() == 'gcc')

# 64 bit ARM processor and GCC
Expand Down
7 changes: 1 addition & 6 deletions signature/src/armv7/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,7 @@ leancrypto_dilithium_armv7_lib = static_library(
include_dirs,
include_internal_dirs
],
# c_args: [
# '-mfpu=neon-vfpv4',
# '-mthumb',
# '-march=armv7-a+vfpv4',
# '-funsafe-math-optimizations'
# ],
# c_args: cc_armv7_neon_simd_args,
)

leancrypto_support_libs += leancrypto_dilithium_armv7_lib
6 changes: 1 addition & 5 deletions signature/src/avx2/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,7 @@ leancrypto_dilithium_avx2_lib = static_library(
include_dirs,
include_internal_dirs
],
c_args: [
'-mavx2',
'-mpopcnt',
'-Wno-unused-command-line-argument'
]
c_args: cc_avx2_args
)

#-Wl,--whole-archive kem/src/avx2/libleancrypto_kyber_avx2_lib.a -Wl,--no-whole-archive
Expand Down
18 changes: 3 additions & 15 deletions sym/src/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,7 @@ if get_option('chacha20').enabled()
leancrypto_chacha20_avx2_lib = static_library(
'leancrypto_chacha20_avx2_lib',
[ 'chacha20.c' ],
c_args: [
'-mavx2',
'-mbmi2',
'-mpopcnt',
],
c_args: cc_avx2_args,
include_directories: [ include_dirs,
include_internal_dirs ],
)
Expand All @@ -28,10 +24,7 @@ if get_option('chacha20').enabled()
leancrypto_chacha20_neon_armv8_lib = static_library(
'leancrypto_chacha20_neon_armv8_lib',
[ 'chacha20.c' ],
c_args: [
'-march=armv8-a+simd',
'-Wno-unused-result',
],
c_args: cc_armv8_neon_simd_args,
include_directories: [ include_dirs,
include_internal_dirs ],
)
Expand All @@ -42,12 +35,7 @@ if get_option('chacha20').enabled()
leancrypto_chacha20_neon_armv7_lib = static_library(
'leancrypto_chacha20_neon_armv7_lib',
[ 'chacha20.c' ],
c_args: [
'-mfpu=neon-vfpv4',
'-mthumb',
'-march=armv7-a+vfpv4',
'-funsafe-math-optimizations'
],
c_args: cc_armv7_neon_simd_args,
include_directories: [ include_dirs,
include_internal_dirs ],
)
Expand Down

0 comments on commit 7b45cd4

Please sign in to comment.