Skip to content
This repository has been archived by the owner on Jan 23, 2023. It is now read-only.
/ corefx Public archive

Commit

Permalink
[release/2.1] Fix build errors in some build configurations
Browse files Browse the repository at this point in the history
* Change #if NEED_OPENSSL_1_0 to #ifdef NEED_OPENSSL_1_0

This was a mistake in e4bcbd5 (#34443) made when backporting it to
the release branches. All other uses of NEED_OPENSSL_1_0 are guarded by
an #ifdef, not an #if. This one should be too.

The warning is seen when building corefx using source-build. I couldn't observe
it directly:

    source-build/src/corefx/src/Native/Unix/System.Security.Cryptography.Native/pal_asn1_print.cpp:34:5:
    error: 'NEED_OPENSSL_1_0' is not defined, evaluates to 0 [-Werror,-Wundef]
      #if NEED_OPENSSL_1_0
      ^

* Disable used-but-marked-unused warnings in System.Security.Cryptography.Native

When building in non-portable mode, some OpenSSL 1.1 function defnitions
that are marked as unused can be picked up by our build. When those
functions are called, clang reports a warning and fails the build:

    src/Native/Unix/System.Security.Cryptography.Native/openssl.cpp:432:12:
    error: 'sk_ASN1_OBJECT_num' was marked unused but was used [-Werror,-Wused-but-marked-unused]
          return sk_ASN1_OBJECT_num(eku);
                 ^

This 'unused' attribute was recently added to sk_* methods in OpenSSL
1.1: openssl/openssl#8246
  • Loading branch information
omajid authored and bartonjs committed Mar 7, 2019
1 parent a470e6e commit e713bb5
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ set(CMAKE_INCLUDE_CURRENT_DIR ON)

# These are happening inside of OpenSSL-defined macros out of our control
add_compile_options(-Wno-cast-align)
add_compile_options(-Wno-used-but-marked-unused)

add_definitions(-DPIC=1 -DOPENSSL_API_COMPAT=0x10100000L)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ static_assert(PAL_ASN1_STRFLGS_UTF8_CONVERT == ASN1_STRFLGS_UTF8_CONVERT, "");

extern "C" ASN1_STRING* CryptoNative_DecodeAsn1TypeBytes(const uint8_t* buf, int32_t len, Asn1StringTypeFlags type)
{
#if NEED_OPENSSL_1_0
#ifdef NEED_OPENSSL_1_0
if (!API_EXISTS(d2i_ASN1_type_bytes) || !buf || !len)
{
return nullptr;
Expand Down

0 comments on commit e713bb5

Please sign in to comment.