openssl: 1.1.1q test/v3ext.c fails to compile on MacOS (missing string.h include)

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)

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 33
  • Comments: 37 (11 by maintainers)

Commits related to this issue

Most upvoted comments

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

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))

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.

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)

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

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

Found a workaround here, helped me

How can I do, to install this patch ?

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.

Waiting for the new release with the fix.

@pplmx Yes, the issue is present in the 1.1.1q release, and the 1.1.1q release won’t be changed. It is fixed in the OpenSSL_1_1_1-stable branch, and the next 1.1.1 release won’t have the issue.

This is fixed in git repo, keeping it open until next release to avoid duplicate reports.

@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>

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

make test runs them. Doing this is recommended.

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