openssl icon indicating copy to clipboard operation
openssl copied to clipboard

test/v3ext.c fails to compile on MacOS11 arm64

Open blackspherefollower opened this issue 3 years ago • 30 comments

Building using: ./Configure no-shared no-gost darwin64-arm64-cc -g -fPIC -isysroot/Library/Developer/CommandLineTools/SDKs/MacOSX11.1.sdk -mmacosx-version-min=11.1 fails with:

clang  -Iinclude -arch arm64 -O3 -Wall -g -fPIC -isysroot/Library/Developer/CommandLineTools/SDKs/MacOSX11.1.sdk -mmacosx-version-min=11.1 -D_REENTRANT -DNDEBUG  -MMD -MF test/v3ext.d.tmp -MT test/v3ext.o -c -o test/v3ext.o test/v3ext.c
test/v3ext.c:201:24: error: implicitly declaring library function 'memcmp' with type 'int (const void *, const void *, unsigned long)' [-Werror,-Wimplicit-function-declaration]
        if (!TEST_true(memcmp(ip1->data, ip2->data, ip1->length) <= 0))
                       ^
test/v3ext.c:201:24: note: include the header <string.h> or explicitly provide a declaration for 'memcmp'
1 error generated.
make[1]: *** [test/v3ext.o] Error 1

Adding #include <string.h> to test/v3ext.c resolves the error (other tests already explicitly include string.h)

blackspherefollower avatar Jul 05 '22 12:07 blackspherefollower

Also hit this bug. Further confirmed via CI: https://github.com/openssl/openssl/runs/7190875851?check_suite_focus=true

baentsch avatar Jul 05 '22 12:07 baentsch

I encountered this on NonStop also, but the case was open by the time I got to it. Worked around it in my case. Will deal with the conflict at 1.1.1r.

rsbeckerca avatar Jul 06 '22 12:07 rsbeckerca

I have stumbled across exactly this problem today as well. I am building openssl for iOS and its arm64 build (and I think the x64 build as well) fails with the exact same error. I am using XCode 12.5.1. The last version I have used before was 1.1.1.n and that worked without any problems.

skuskusku avatar Jul 08 '22 18:07 skuskusku

Yes, it is a genuine issue with 1.1.1q. A fix has already been committed to the OpenSSL_1_1_1-stable branch and should be in the next version of 1.1.1.

To fix is to add a line #include <string.h> at the top of test/v3ext.c, if you don't want to use the stable branch or wait for the next 1.1.1 release.

tom-cosgrove-arm avatar Jul 08 '22 19:07 tom-cosgrove-arm

How can I do, to install this patch ?

Tioneb12 avatar Jul 10 '22 21:07 Tioneb12

Waiting for the new release with the fix.

invinciible avatar Jul 11 '22 13:07 invinciible

My patch looks like this and I apply it in my build script with patch -u test/v3ext.c v3ext.c.patch in case this helps anybody:

diff -u bad/v3ext.c good/v3ext.c --- bad/v3ext.c 2022-07-05 11:08:33.000000000 +0200 +++ good/v3ext.c 2022-07-09 13:04:28.449762000 +0200 @@ -8,6 +8,7 @@ */

#include <stdio.h> +#include <string.h> #include <openssl/x509.h> #include <openssl/x509v3.h> #include <openssl/pem.h>

skuskusku avatar Jul 11 '22 13:07 skuskusku

I was trying to install rbenv install 2.7.6. Having this issue now:(

rbenv install 2.7.6                        
Downloading openssl-1.1.1q.tar.gz...
-> https://dqw8nmjcqpjn7.cloudfront.net/d7939ce614029cdff0b6c20f0e2e5703158a489a72b2507b8bd51bf8c8fd10ca
Installing openssl-1.1.1q...

BUILD FAILED (macOS 12.0.1 using ruby-build 20220710)
...

test/v3ext.c:201:24: error: implicitly declaring library function 'memcmp' with type 'int (const void *, const void *, unsigned long)' [-Werror,-Wimplicit-function-declaration]
        if (!TEST_true(memcmp(ip1->data, ip2->data, ip1->length) <= 0))

nrjshka avatar Jul 11 '22 13:07 nrjshka

Still facing this issue.. What can we do to fix this?

valentinoPereira avatar Jul 11 '22 14:07 valentinoPereira

Still facing this issue.. What can we do to fix this?

Either wait until 1.1.1r is out or apply the patch yourself, it is not that hard.

skuskusku avatar Jul 11 '22 14:07 skuskusku

I think for rbenv users all we can do is wait, since it attempts to download a new version everytime you run a install command. Correct me if I'm wrong but that's what I've noticed at least.

Four downloads of the same version, once for each attempt.

ruby-build.20220711152759.90203.iUixfj/openssl-1.1.1q/test/v3ext.c
ruby-build.20220711152259.75171.IpsEZO/openssl-1.1.1q/test/v3ext.c
ruby-build.20220711151859.60116.1Coe7H/openssl-1.1.1q/test/v3ext.c
ruby-build.20220711151540.44657.nTmFzb/openssl-1.1.1q/test/v3ext.c

MiralDesai avatar Jul 11 '22 14:07 MiralDesai

Found a workaround here, helped me

NSIbragim avatar Jul 11 '22 15:07 NSIbragim

I was trying to install rbenv install 2.7.6. Having this issue now:(

rbenv install 2.7.6                        
Downloading openssl-1.1.1q.tar.gz...
-> https://dqw8nmjcqpjn7.cloudfront.net/d7939ce614029cdff0b6c20f0e2e5703158a489a72b2507b8bd51bf8c8fd10ca
Installing openssl-1.1.1q...

BUILD FAILED (macOS 12.0.1 using ruby-build 20220710)
...

test/v3ext.c:201:24: error: implicitly declaring library function 'memcmp' with type 'int (const void *, const void *, unsigned long)' [-Werror,-Wimplicit-function-declaration]
        if (!TEST_true(memcmp(ip1->data, ip2->data, ip1->length) <= 0))

I'm facing the same issue unfortunatelly, is there any workaround for rbenv? Or the only option is to wait until the release?

MaxiUstria avatar Jul 11 '22 16:07 MaxiUstria

OPENSSL_CFLAGS=-Wno-error=implicit-function-declaration should help for rbenv / ruby-build. (https://github.com/rbenv/ruby-build/issues/1998)

eregon avatar Jul 11 '22 17:07 eregon

I was trying to install rbenv install 2.7.6. Having this issue now:(

rbenv install 2.7.6                        
Downloading openssl-1.1.1q.tar.gz...
-> https://dqw8nmjcqpjn7.cloudfront.net/d7939ce614029cdff0b6c20f0e2e5703158a489a72b2507b8bd51bf8c8fd10ca
Installing openssl-1.1.1q...

BUILD FAILED (macOS 12.0.1 using ruby-build 20220710)
...

test/v3ext.c:201:24: error: implicitly declaring library function 'memcmp' with type 'int (const void *, const void *, unsigned long)' [-Werror,-Wimplicit-function-declaration]
        if (!TEST_true(memcmp(ip1->data, ip2->data, ip1->length) <= 0))

I'm facing the same issue unfortunatelly, is there any workaround for rbenv? Or the only option is to wait until the release?

This tutorial helped me get past the issue, https://dev.to/yasuhiron777/install-2x-3x-version-of-ruby-via-rbenv-on-m1-mac-3okn

just add this at the end of your .zshrc file after installing openssl-1.1.1

export PATH="/opt/homebrew/opt/[email protected]/bin:$PATH"

austinsmithsprockets avatar Jul 11 '22 19:07 austinsmithsprockets

I was trying to install rbenv install 2.7.6. Having this issue now:(

rbenv install 2.7.6                        
Downloading openssl-1.1.1q.tar.gz...
-> https://dqw8nmjcqpjn7.cloudfront.net/d7939ce614029cdff0b6c20f0e2e5703158a489a72b2507b8bd51bf8c8fd10ca
Installing openssl-1.1.1q...

BUILD FAILED (macOS 12.0.1 using ruby-build 20220710)
...

test/v3ext.c:201:24: error: implicitly declaring library function 'memcmp' with type 'int (const void *, const void *, unsigned long)' [-Werror,-Wimplicit-function-declaration]
        if (!TEST_true(memcmp(ip1->data, ip2->data, ip1->length) <= 0))

I'm facing the same issue unfortunatelly, is there any workaround for rbenv? Or the only option is to wait until the release?

you can download older version from git (v20220630) or use asdf ASDF_RUBY_BUILD_VERSION=v20220630 asdf install ruby 2.7.6

frozen92 avatar Jul 12 '22 10:07 frozen92

Installing previous version and linking it for ruby install helped me https://github.com/rbenv/ruby-build/discussions/1940#discussioncomment-2663209

rumnatsf avatar Jul 12 '22 12:07 rumnatsf

Hit this issue as well. What I am also curious about is why is the test/ code built during the normal (rbenv in my case) build? Do we even care about test code? Do these tests actually run and check anything or are they just built and forgotten?..

software-artificer avatar Jul 14 '22 01:07 software-artificer

make test runs them. Doing this is recommended.

paulidale avatar Jul 14 '22 01:07 paulidale

is there a param to skip that step?

rumnatsf avatar Jul 14 '22 01:07 rumnatsf

make apps/openssl might be enough.

paulidale avatar Jul 14 '22 02:07 paulidale

Sorry for a bit offtopic, I want to disable the unit tests compilation because of this problem, I tried with perl Configure no-unit-test but this problematic file still compiles and I got error. Tried also no-acvp-tests and that option is not recognized. Thanks

tawmoto avatar Jul 14 '22 08:07 tawmoto

Sorry for a bit offtopic, I want to disable the unit tests compilation because of this problem, I tried with perl Configure no-unit-test but this problematic file still compiles and I got error. Tried also no-acvp-tests and that option is not recognized. Thanks

None of these would help. Does adding -Wno-error=implicit-function-declaration to the Configure line help you?

t8m avatar Jul 14 '22 11:07 t8m

Sorry for a bit offtopic, I want to disable the unit tests compilation because of this problem, I tried with perl Configure no-unit-test but this problematic file still compiles and I got error. Tried also no-acvp-tests and that option is not recognized. Thanks

None of these would help. Does adding -Wno-error=implicit-function-declaration to the Configure line help you?

Seems that no-tests worked. :) Thanks

tawmoto avatar Jul 14 '22 12:07 tawmoto

Where can you find test/v3ext.c ?

medhatnar avatar Jul 14 '22 13:07 medhatnar

mac asdf peeps that have ended up in this thread: (openssl 1.1.1q preventing install)

Intel:

ASDF_RUBY_BUILD_VERSION=v20220630 asdf install ruby SOME_VERSION

M1:

optflags=-Wno-error=implicit-function-declaration ASDF_RUBY_BUILD_VERSION=v20220630 asdf install ruby SOME_VERSION

(thank you @frozen92) (thank you @captain-enjoyable for digging into this and finding this thread)

edmangimelli avatar Jul 15 '22 21:07 edmangimelli

OPENSSL_CFLAGS=-Wno-error=implicit-function-declaration rbenv install 2.7.6 worked for me

chille1987 avatar Jul 21 '22 07:07 chille1987

Hi I also kept running into this on 'Mac OS X 10.15.7 using ruby-build' I had to set both of the following variables at the same time before the rbenv install 3.0.1 command:

OPENSSL_CFLAGS=-Wno-error=implicit-function-declaration RUBY_CONFIGURE_OPTS=--with-readline-dir="$(brew --prefix readline)" rbenv install 3.0.1

Teqshark avatar Jul 22 '22 00:07 Teqshark

This is happening with a generic build on MacOS11 x86_64 (darwin64-x86_64-cc) architecture as well (not just arm64):

${LDCMD:-cc} -arch x86_64 -O3 -Wall -L. -Wl,-search_paths_first  \
		-o test/uitest test/uitest.o \
		 apps/libapps.a -lssl test/libtestutil.a -lcrypto  
cc  -Iinclude -arch x86_64 -O3 -Wall -D_REENTRANT -DNDEBUG  -MMD -MF test/v3ext.d.tmp -MT test/v3ext.o -c -o test/v3ext.o test/v3ext.c
test/v3ext.c:201:24: error: implicitly declaring library function 'memcmp' with type 'int (const void *, const void *, unsigned long)' [-Werror,-Wimplicit-function-declaration]
        if (!TEST_true(memcmp(ip1->data, ip2->data, ip1->length) <= 0))
                       ^
test/v3ext.c:201:24: note: include the header <string.h> or explicitly provide a declaration for 'memcmp'
1 error generated.
make[1]: *** [test/v3ext.o] Error 1
make: *** [all] Error 2

jasonacox avatar Aug 10 '22 03:08 jasonacox

@jasonacox Yes, it is a "generic" bug and not related to the architecture you build for. It causes a build error only on macOS because the clang on macOS implicitly adds -Wimplicit-function-declaration in -Wall, which it doesn't on Linux. The fix is in the OpenSSL_1_1_1-stable branch and will be in the next release of 1.1.1 - in the file test/v3ext.c, after the line #include <stdio.h> near the top, add a line that says

#include <string.h>

tom-cosgrove-arm avatar Aug 10 '22 07:08 tom-cosgrove-arm