@@ -34,6 +34,10 @@ option(S2N_STACKTRACE "Enables stacktrace functionality in s2n-tls. Note that th
3434only available on platforms that support execinfo." ON )
3535option (S2N_OVERRIDE_LIBCRYPTO_RAND_ENGINE "Allow s2n-tls to override the libcrypto random implementation with the custom
3636s2n-tls implementation, when appropriate. Disabling this flag is not recommended. See docs/BUILD.md for details." ON )
37+ option (S2N_ENFORCE_PROPER_LIBCRYPTO_FEATURE_PROBE "Assert that the feature probes are able to link to the libcrypto and
38+ properly probe for feature support. If the feature probes are unable to properly probe for support, the build will
39+ fail. This option ensures that s2n-tls doesn't silently build without properly probing for the support of important
40+ features, such as TLS 1.3 support." OFF )
3741option (COVERAGE "Enable profiling collection for code coverage calculation" OFF )
3842option (BUILD_TESTING "Build tests for s2n-tls. By default only unit tests are built." ON )
3943option (S2N_INTEG_TESTS "Enable the integrationv2 tests" OFF )
@@ -352,6 +356,8 @@ function(feature_probe PROBE_NAME)
352356
353357 # Set the flags that we used for the probe
354358 set (${PROBE_NAME} _FLAGS ${PROBE_FLAGS} PARENT_SCOPE)
359+
360+ set (${PROBE_NAME} _OUTPUT "${TRY_COMPILE_OUTPUT} " PARENT_SCOPE)
355361endfunction ()
356362
357363# Iterate over all of the features and try to compile them
@@ -362,6 +368,13 @@ foreach(file ${FEATURE_SRCS})
362368 feature_probe(${feature_name} )
363369endforeach ()
364370
371+ # Ensure that the feature probes were able to properly link to the libcrypto.
372+ if (S2N_ENFORCE_PROPER_LIBCRYPTO_FEATURE_PROBE AND NOT S2N_LIBCRYPTO_SANITY_PROBE)
373+ message (FATAL_ERROR "A sanity-check libcrypto feature probe failed, which indicates that other
374+ feature probes were likely unable to probe the libcrypto for its supported features:
375+ ${S2N_LIBCRYPTO_SANITY_PROBE_OUTPUT} " )
376+ endif ()
377+
365378# FreeBSD might need to link to execinfo explicitly
366379if (NOT S2N_EXECINFO_AVAILABLE AND CMAKE_SYSTEM_NAME STREQUAL "FreeBSD" )
367380 feature_probe(S2N_EXECINFO_AVAILABLE LINK_LIBRARIES execinfo)
0 commit comments