From ae6c7b479816bd441aa9a3c4b2dd1905195d94e0 Mon Sep 17 00:00:00 2001 From: Michael Baentsch Date: Mon, 13 Dec 2021 15:33:19 +0100 Subject: [PATCH] Output documented build options (#1155) * explaining all config options in system_info output --- src/oqsconfig.h.cmake | 5 ++++ tests/system_info.c | 60 ++++++++++++++++++++++++++++++++++++++++--- 2 files changed, 61 insertions(+), 4 deletions(-) diff --git a/src/oqsconfig.h.cmake b/src/oqsconfig.h.cmake index e78659fe2..df1de3c63 100644 --- a/src/oqsconfig.h.cmake +++ b/src/oqsconfig.h.cmake @@ -12,6 +12,11 @@ #cmakedefine ARCH_X86_64 1 #cmakedefine ARCH_ARM64v8 1 #cmakedefine ARCH_ARM32v7 1 +#cmakedefine BUILD_SHARED_LIBS 1 +#cmakedefine OQS_BUILD_ONLY_LIB 1 +#cmakedefine OQS_OPT_TARGET "@OQS_OPT_TARGET@" +#cmakedefine USE_SANITIZER "@USE_SANITIZER@" +#cmakedefine CMAKE_BUILD_TYPE "@CMAKE_BUILD_TYPE@" #cmakedefine OQS_USE_OPENSSL 1 #cmakedefine OQS_USE_AES_OPENSSL 1 diff --git a/tests/system_info.c b/tests/system_info.c index 1568f6b1b..0cec5e61e 100644 --- a/tests/system_info.c +++ b/tests/system_info.c @@ -28,14 +28,18 @@ static void print_compiler_info(void) { // based on macros in https://sourceforge.net/p/predef/wiki/Architectures/ static void print_platform_info(void) { #if defined(OQS_COMPILE_BUILD_TARGET) - printf("Target platform: %s\n", OQS_COMPILE_BUILD_TARGET); + printf("Target platform: %s", OQS_COMPILE_BUILD_TARGET); #elif defined(_WIN64) - printf("Target platform: Windows (64-bit)\n"); + printf("Target platform: Windows (64-bit)"); #elif defined(_WIN32) - printf("Target platform: Windows (32-bit)\n"); + printf("Target platform: Windows (32-bit)"); #else - printf("Target platform: Unknown\n"); + printf("Target platform: Unknown"); #endif +#if defined(OQS_SPEED_USE_ARM_PMU) + printf(" - ARM PMU options enabled"); +#endif + printf("\n"); } #if defined(OQS_USE_OPENSSL) @@ -170,6 +174,23 @@ static void print_cpu_extensions(void) { } static void print_oqs_configuration(void) { + /* Display all options as per https://github.com/open-quantum-safe/liboqs/wiki/Customizing-liboqs: + * BUILD_SHARED_LIBS: Performance relevance small/improbable + * CMAKE_BUILD_TYPE: If Debug, -g compiler option will be shown; + * -O3 for Release build + * CMAKE_INSTALL_PREFIX: Not performance relevant + * OQS_ENABLE_KEM|SIG: alg absence/presence detected on run; can be output + * by not passing an alg name to the test programs + * OQS_BUILD_ONLY_LIB: Not performance relevant + * OQS_DIST_BUILD: Set if output "CPU exts active" present; + * otherwise, "CPU exts compile-time:" output + * OQS_USE_OPENSSL: Explicitly output + * OQS_OPT_TARGET: Visible by looking at compile options (-march or -mcpu): + * 'auto' -> "-march|cpu=native" + * OQS_SPEED_USE_ARM_PMU: Output with Target platform + * USE_SANITIZER: -fsanitize= option present in compile options + * OQS_ENABLE_TEST_CONSTANT_TIME: only shown below + */ printf("OQS version: %s\n", OQS_VERSION_TEXT); #if defined(OQS_COMPILE_GIT_COMMIT) printf("Git commit: %s\n", OQS_COMPILE_GIT_COMMIT); @@ -200,6 +221,37 @@ static void print_oqs_configuration(void) { #else printf("SHA-3: C\n"); #endif + printf("OQS build flags: "); +#ifdef BUILD_SHARED_LIBS + printf("BUILD_SHARED_LIBS "); +#endif +#ifdef OQS_ENABLE_TEST_CONSTANT_TIME + printf("OQS_ENABLE_TEST_CONSTANT_TIME "); +#endif +#ifdef OQS_SPEED_USE_ARM_PMU + printf("OQS_SPEED_USE_ARM_PMU "); +#endif +#ifdef OQS_DIST_BUILD + printf("OQS_DIST_BUILD "); +#endif +#ifdef OQS_BUILD_ONLY_LIB + printf("OQS_BUILD_ONLY_LIB "); // pretty much impossible to appear but added for completeness +#endif +#ifdef USE_SANITIZER + printf("USE_SANITIZER=%s ", USE_SANITIZER); +#endif +#ifdef OQS_OPT_TARGET + printf("OQS_OPT_TARGET=%s ", OQS_OPT_TARGET); +#endif +#ifdef CMAKE_BUILD_TYPE + printf("CMAKE_BUILD_TYPE=%s ", CMAKE_BUILD_TYPE); +#else +#ifdef OQS_DEBUG_BUILD + guard against impossible configuration (no CMAKE_BUILD_TYPE but DEBUG_BUILD) +#endif + printf("CMAKE_BUILD_TYPE=Release "); +#endif + printf("\n"); } static void print_system_info(void) {