Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmake: fix generation of options.h #7546

Merged
merged 4 commits into from
Jun 6, 2024
Merged

cmake: fix generation of options.h #7546

merged 4 commits into from
Jun 6, 2024

Conversation

oltolm
Copy link
Contributor

@oltolm oltolm commented May 16, 2024

Description

I fixed the way options.h is generated. It is now being generated properly using configure_file. Fixes #4489.

Testing

I built wolfssl with CMake.

@wolfSSL-Bot
Copy link

Can one of the admins verify this patch?

@dgarske
Copy link
Contributor

dgarske commented May 16, 2024

Thank you @oltolm , I will review. Contributor agreement on file. Okay to test.

Copy link
Contributor

@dgarske dgarske left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a really nice change. Can you help understand the future maintenance of this?

wolfssl/options.h.in Outdated Show resolved Hide resolved
@dgarske
Copy link
Contributor

dgarske commented May 28, 2024

Hi @oltolm,

What is this PR actually fixing? It seems to just change the way options.h is generated to use configure_file and adds additional maintenance. I checked and the current method for generating options.h works fine and doesn't require maintaining a list of macros.

Are there benefits to using configure_file?

Thanks,
David Garske, wolfSSL

@oltolm
Copy link
Contributor Author

oltolm commented May 28, 2024

Yes. This is from the official documentation:

If the input file is modified the build system will re-run CMake to re-configure the file and generate the build system again. The generated file is modified and its timestamp updated on subsequent cmake runs only if its content is changed.

If the options.h does not change, you don't have to rebuild your project. Also using configure_file is the standard way of doing things in CMake.

@dgarske
Copy link
Contributor

dgarske commented May 29, 2024

Hi @oltolm ,

Thank you for the feedback. I'll review this with the engineering team tomorrow and made a decision.

Thanks,
David Garske, wolfSSL

wolfssl/options.h.in Outdated Show resolved Hide resolved
CMakeLists.txt Outdated
endif()
endforeach()

configure_file(${CMAKE_CURRENT_SOURCE_DIR}/wolfssl/options.h.in ${OPTION_FILE})
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add a comment here about needing to update the file for new options. Also add a comment in cmake/README.md.

@dgarske
Copy link
Contributor

dgarske commented May 30, 2024

Hi @oltolm ,

We discussed this internally provided a few items to adjust. Then this PR should be acceptable. Thank you again for your work on this improvement.

Thank you,
David Garske, wolfSSL

dgarske
dgarske previously approved these changes Jun 3, 2024
Copy link
Contributor

@dgarske dgarske left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dgarske dgarske assigned wolfSSL-Bot and unassigned oltolm and dgarske Jun 3, 2024
tests/api.c Outdated
@@ -146,6 +146,7 @@
#endif
#include <wolfssl/error-ssl.h>

#include <stdint.h>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this needed here?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good question. I was not able to reproduce.
@oltolm says : "fix compilation of tests with GCC".
@oltolm can you please describe how to reproduce this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Without the fix I get this on Windows with GCC 14.1.

FAILED: CMakeFiles/unit_test.dir/tests/api.c.obj 
C:\msys64\mingw64\bin\gcc.exe -DECC_SHAMIR -DECC_TIMING_RESISTANT -DGCM_TABLE_4BIT -DHAVE_AESGCM -DHAVE_CHACHA -DHAVE_CONFIG_H -DHAVE_DH_DEFAULT_PARAMS -DHAVE_ECC -DHAVE_ENCRYPT_THEN_MAC -DHAVE_EXTENDED_MASTER -DHAVE_FFDHE_2048 -DHAVE_HASHDRBG -DHAVE_HKDF -DHAVE_ONE_TIME_AUTH -DHAVE_POLY1305 -DHAVE_PTHREAD -DHAVE_SNI -DHAVE_SUPPORTED_CURVES -DHAVE_THREAD_LS -DHAVE_TLS_EXTENSIONS -DHAVE___UINT128_T -DNO_DES3 -DNO_DES3_TLS_SUITES -DNO_DSA -DNO_MD4 -DNO_PSK -DNO_RC4 -DTFM_ECC256 -DTFM_TIMING_RESISTANT -DWC_NO_ASYNC_THREADING -DWC_RSA_BLINDING -DWC_RSA_PSS -DWOLFSSL_BASE64_ENCODE -DWOLFSSL_DLL -DWOLFSSL_IGNORE_FILE_WARN -DWOLFSSL_NO_SHAKE128 -DWOLFSSL_NO_SHAKE256 -DWOLFSSL_PSS_LONG_SALT -DWOLFSSL_SHA224 -DWOLFSSL_SHA3 -DWOLFSSL_SHA384 -DWOLFSSL_SHA512 -DWOLFSSL_SYS_CA_CERTS -DWOLFSSL_TLS13 -DWOLFSSL_USE_ALIGN -DWOLFSSL_X86_64_BUILD -D_POSIX_THREADS -IC:/src/wolfssl/build -IC:/src/wolfssl -Wall  -g -DNO_MAIN_DRIVER -MD -MT CMakeFiles/unit_test.dir/tests/api.c.obj -MF CMakeFiles\unit_test.dir\tests\api.c.obj.d -o CMakeFiles/unit_test.dir/tests/api.c.obj -c C:/src/wolfssl/tests/api.c
C:/src/wolfssl/tests/api.c: In function 'test_read_write_hs':
C:/src/wolfssl/tests/api.c:71565:5: error: unknown type name 'uint8_t'
71565 |     uint8_t test_buffer[16];
      |     ^~~~~~~
C:/src/wolfssl/tests/api.c:5519:1: note: 'uint8_t' is defined in header '<stdint.h>'; this is probably fixable by adding '#include <stdint.h>'
 5518 | #include <wolfssl/openssl/pem.h>
  +++ |+#include <stdint.h>
 5519 | /*----------------------------------------------------------------------------*

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @oltolm . I went ahead and removed the uses of uint8_t. The reason we weren't seeing this is because configure sets HAVE_UINT_PTR that includes stdint.h.

tests/api.c Outdated
@@ -146,6 +146,7 @@
#endif
#include <wolfssl/error-ssl.h>

#include <stdint.h>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @oltolm . I went ahead and removed the uses of uint8_t. The reason we weren't seeing this is because configure sets HAVE_UINT_PTR that includes stdint.h.

@dgarske dgarske requested a review from SparkiDev June 6, 2024 17:59
@dgarske dgarske assigned SparkiDev and unassigned oltolm Jun 6, 2024
@SparkiDev SparkiDev merged commit c822303 into wolfSSL:master Jun 6, 2024
111 checks passed
@oltolm oltolm deleted the cmake branch June 7, 2024 13:57
jefferyq2 pushed a commit to jefferyq2/wolfssl that referenced this pull request Jun 9, 2024
cmake: fix generation of options.h
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
5 participants