libressl / portable

LibreSSL Portable itself. This includes the build scaffold and compatibility layer that builds portable LibreSSL from the OpenBSD source code. Pull requests or patches sent to tech@openbsd.org are welcome.
https://www.libressl.org
1.36k stars 267 forks source link

Building 3.9.0 on windows, with cmake+visual studio #1017

Open d3x0r opened 7 months ago

d3x0r commented 7 months ago

There are some basic warnings that maybe can be fixed...

Visual studio issues a warning about libressl\3.9.0\crypto\empty.c(1,1): warning C4206: nonstandard extension used: translation unit is empty. There are 3 files in 5 targets called 'empty.c' which are compiled, in crypto, tls, and ssl for compat.obj tls_compat.obj, crypto, ssl, and tls targets.

(Github doesn't have this code? even under tag 3.9.0?) crypto/pkcs7/pk7_doit.c line 657 has 'unreachable code' which is the final 'return NULL' after the forever loop for(;;).

static BIO *
PKCS7_find_digest(EVP_MD_CTX **pmd, BIO *bio, int nid)
{
    for (;;) {
        bio = BIO_find_type(bio, BIO_TYPE_MD);
        if (bio == NULL) {
            PKCS7error(PKCS7_R_UNABLE_TO_FIND_MESSAGE_DIGEST);
            return NULL;
        }
        BIO_get_md_ctx(bio, pmd);
        if (*pmd == NULL) {
            PKCS7error(ERR_R_INTERNAL_ERROR);
            return NULL;
        }
        if (EVP_MD_CTX_type(*pmd) == nid)
            return bio;
        bio = BIO_next(bio);
    }
    return NULL;
}

There are other 'unreachable code' warnings, but they are actually reachable if the object is invalid and contains an enum value that's not actually part of the enum. So some of these warnings are compiler false positives. Issue filed to MS Any switch without default:, that even covers all values defined in an enum that is the switch condition should actually be the warning, because there are various ways to get values into enum variables that can be not one of the choices in the enum. Actually there's an assert(0) that makes it unreachable in debug build.

mostly libressl does compile cleanly.

https://github.com/libressl/portable/issues/1004 I think should still be implemented - don't generate uninstall if LIBRESSL_SKIP_INSTALL is enabled in CMake.

botovq commented 7 months ago

Visual studio issues a warning about libressl\3.9.0\crypto\empty.c(1,1): warning C4206: nonstandard extension used: translation unit is empty. There are 3 files in 5 targets called 'empty.c' which are compiled, in crypto, tls, and ssl for compat.obj tls_compat.obj, crypto, ssl, and tls targets.

This is a weird hack that is apparently still needed for xcode. I don't know cmake well enough to figure out how to do this properly. See #996

The PKCS#7 code is here: https://github.com/libressl/openbsd/blob/master/src/lib/libcrypto/pkcs7/pk7_doit.c#L640 I need to think about this a bit. I would not be surprised if removing the offending line resulted in whining by another compiler with bad warnings (looking at you gcc)...

I have made a triage of most of the windows warnings a few months back https://github.com/libressl/portable/issues/966#issuecomment-1852994213 I might fix one or the other remaining issues, but this is mostly just busywork with no clear benefit.

I'm not entirely sure I understand what #1004 accomplishes, but I think we would be happy to take a PR.