mirror of
https://github.com/wolfSSL/wolfssl.git
synced 2025-07-31 11:17:29 +02:00
Generate an assembler-safe user_settings.h in configure.ac and CMakeLists.txt.
For user_settings.h builds, .S assembly files need to include user_settings.h in order to get the defines used by the build. However, a user_settings.h may contain code only understood by a C compiler and not the assembler (e.g. a typedef). This commit makes it so our autotools and CMake builds produce a file user_settings_asm.h when doing a user_settings.h build. This generated header contains only the preprocessor directives from the user_settings.h. As a result, it can be safely included by our assembly code files.
This commit is contained in:
3
.gitignore
vendored
3
.gitignore
vendored
@ -401,3 +401,6 @@ XXX-fips-test
|
|||||||
|
|
||||||
# ASYNC
|
# ASYNC
|
||||||
async
|
async
|
||||||
|
|
||||||
|
# Generated user_settings_asm.h.
|
||||||
|
user_settings_asm.h
|
||||||
|
@ -1768,6 +1768,14 @@ generate_build_flags()
|
|||||||
if(WOLFSSL_USER_SETTINGS)
|
if(WOLFSSL_USER_SETTINGS)
|
||||||
# Replace all options and just use WOLFSSL_USER_SETTINGS
|
# Replace all options and just use WOLFSSL_USER_SETTINGS
|
||||||
set(WOLFSSL_DEFINITIONS "-DWOLFSSL_USER_SETTINGS")
|
set(WOLFSSL_DEFINITIONS "-DWOLFSSL_USER_SETTINGS")
|
||||||
|
|
||||||
|
# Create user_settings_asm.h for use in assembly files (e.g. .S files).
|
||||||
|
execute_process(COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/scripts/user_settings_asm.sh
|
||||||
|
"${CMAKE_C_FLAGS} ${CMAKE_CXX_FLAGS}"
|
||||||
|
RESULT_VARIABLE USER_SETTINGS_ASM_RET)
|
||||||
|
if (NOT USER_SETTINGS_ASM_RET EQUAL 0)
|
||||||
|
message(FATAL_ERROR "${CMAKE_CURRENT_SOURCE_DIR}/scripts/user_settings_asm.sh failed.")
|
||||||
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# TODO: Applying definitions to everything like this, rather than
|
# TODO: Applying definitions to everything like this, rather than
|
||||||
@ -1790,7 +1798,6 @@ endif()
|
|||||||
|
|
||||||
# Suppress some warnings about separate compilation, inlining
|
# Suppress some warnings about separate compilation, inlining
|
||||||
add_definitions("-DWOLFSSL_IGNORE_FILE_WARN")
|
add_definitions("-DWOLFSSL_IGNORE_FILE_WARN")
|
||||||
|
|
||||||
# Generate user options header
|
# Generate user options header
|
||||||
message("Generating user options header...")
|
message("Generating user options header...")
|
||||||
if (${CMAKE_DISABLE_SOURCE_CHANGES})
|
if (${CMAKE_DISABLE_SOURCE_CHANGES})
|
||||||
|
@ -8393,6 +8393,13 @@ esac
|
|||||||
|
|
||||||
rm cyassl/options.h.bak
|
rm cyassl/options.h.bak
|
||||||
|
|
||||||
|
if test "x$ENABLED_USERSETTINGS" = "xyes"; then
|
||||||
|
$srcdir/scripts/user_settings_asm.sh "$CPPFLAGS $CFLAGS $CXXFLAGS"
|
||||||
|
if test $? -ne 0; then
|
||||||
|
AC_MSG_ERROR([$srcdir/scripts/user_settings_asm.sh failed.])
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
if test "$silent" != "yes"; then
|
if test "$silent" != "yes"; then
|
||||||
|
|
||||||
# output config summary
|
# output config summary
|
||||||
|
@ -120,3 +120,5 @@ EXTRA_DIST += scripts/dtlscid.test
|
|||||||
endif
|
endif
|
||||||
|
|
||||||
EXTRA_DIST += scripts/bench/bench_functions.sh
|
EXTRA_DIST += scripts/bench/bench_functions.sh
|
||||||
|
|
||||||
|
EXTRA_DIST += scripts/user_settings_asm.sh
|
||||||
|
48
scripts/user_settings_asm.sh
Executable file
48
scripts/user_settings_asm.sh
Executable file
@ -0,0 +1,48 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
if test $# -eq 0; then
|
||||||
|
echo "user_settings_asm.sh requires one argument specifying compiler flags to pull include directories from."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
user_settings_path=""
|
||||||
|
user_settings_dir="./"
|
||||||
|
|
||||||
|
# First, see if user_settings.h is in the current directory.
|
||||||
|
if test -e "user_settings.h"; then
|
||||||
|
user_settings_path="user_settings.h"
|
||||||
|
else
|
||||||
|
search_string="$1"
|
||||||
|
# Compress multiple spaces to single spaces, then replace instances of
|
||||||
|
# "-I " with "-I" (i.e. remove spaces between -I and the include path).
|
||||||
|
search_string=$(echo "$search_string" | sed -e 's/ */ /g' -e 's/-I /-I/g')
|
||||||
|
|
||||||
|
for token in $search_string
|
||||||
|
do
|
||||||
|
case "$token" in
|
||||||
|
-I*)
|
||||||
|
# Trim off the leading "-I".
|
||||||
|
path=$(echo "$token" | cut -c 3-)
|
||||||
|
if test -e "$path/user_settings.h"; then
|
||||||
|
user_settings_dir="$path"
|
||||||
|
user_settings_path="$path/user_settings.h"
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
|
||||||
|
if test -z "$user_settings_path"; then
|
||||||
|
echo "Unable to find user_settings.h."
|
||||||
|
exit 1
|
||||||
|
else
|
||||||
|
# Strip out anything from user_settings.h that isn't a preprocessor
|
||||||
|
# directive (i.e. any lines not starting with #). Put the result in
|
||||||
|
# user_settings_asm.h in the same directory as user_settings.h.
|
||||||
|
# user_settings_asm.h is safe to include in assembly files (e.g. .S
|
||||||
|
# files).
|
||||||
|
sed -e '/^ *#/!d' -e :a -e '$!N;s/\\\n/ /;ta' -e 'P;D' < "$user_settings_path" > "$user_settings_dir/user_settings_asm.h"
|
||||||
|
fi
|
@ -20,7 +20,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#ifdef WOLFSSL_USER_SETTINGS
|
#ifdef WOLFSSL_USER_SETTINGS
|
||||||
#include "wolfssl/wolfcrypt/settings.h"
|
#include "user_settings_asm.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef HAVE_INTEL_AVX1
|
#ifndef HAVE_INTEL_AVX1
|
||||||
|
@ -20,7 +20,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#ifdef WOLFSSL_USER_SETTINGS
|
#ifdef WOLFSSL_USER_SETTINGS
|
||||||
#include "wolfssl/wolfcrypt/settings.h"
|
#include "user_settings_asm.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef HAVE_INTEL_AVX1
|
#ifndef HAVE_INTEL_AVX1
|
||||||
|
@ -20,7 +20,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#ifdef WOLFSSL_USER_SETTINGS
|
#ifdef WOLFSSL_USER_SETTINGS
|
||||||
#include "wolfssl/wolfcrypt/settings.h"
|
#include "user_settings_asm.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef HAVE_INTEL_AVX1
|
#ifndef HAVE_INTEL_AVX1
|
||||||
|
@ -20,7 +20,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#ifdef WOLFSSL_USER_SETTINGS
|
#ifdef WOLFSSL_USER_SETTINGS
|
||||||
#include "wolfssl/wolfcrypt/settings.h"
|
#include "user_settings_asm.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef HAVE_INTEL_AVX1
|
#ifndef HAVE_INTEL_AVX1
|
||||||
|
@ -20,7 +20,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#ifdef WOLFSSL_USER_SETTINGS
|
#ifdef WOLFSSL_USER_SETTINGS
|
||||||
#include "wolfssl/wolfcrypt/settings.h"
|
#include "user_settings_asm.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef HAVE_INTEL_AVX1
|
#ifndef HAVE_INTEL_AVX1
|
||||||
|
@ -20,7 +20,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#ifdef WOLFSSL_USER_SETTINGS
|
#ifdef WOLFSSL_USER_SETTINGS
|
||||||
#include "wolfssl/wolfcrypt/settings.h"
|
#include "user_settings_asm.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef HAVE_INTEL_AVX1
|
#ifndef HAVE_INTEL_AVX1
|
||||||
|
@ -20,7 +20,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#ifdef WOLFSSL_USER_SETTINGS
|
#ifdef WOLFSSL_USER_SETTINGS
|
||||||
#include "wolfssl/wolfcrypt/settings.h"
|
#include "user_settings_asm.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef HAVE_INTEL_AVX1
|
#ifndef HAVE_INTEL_AVX1
|
||||||
|
@ -20,7 +20,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#ifdef WOLFSSL_USER_SETTINGS
|
#ifdef WOLFSSL_USER_SETTINGS
|
||||||
#include "wolfssl/wolfcrypt/settings.h"
|
#include "user_settings_asm.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef HAVE_INTEL_AVX1
|
#ifndef HAVE_INTEL_AVX1
|
||||||
|
Reference in New Issue
Block a user