Skip to content

Instantly share code, notes, and snippets.

@orip
Created November 23, 2020 11:22
Show Gist options
  • Save orip/00142a498cf6d0c536b5d38771ad6249 to your computer and use it in GitHub Desktop.
Save orip/00142a498cf6d0c536b5d38771ad6249 to your computer and use it in GitHub Desktop.
Patch for Python 3.4.x for macos, based on https://bugs.python.org/issue28676
diff --git a/Python/random.c b/Python/random.c
index 93d300d..396041d 100644
--- a/Python/random.c
+++ b/Python/random.c
@@ -3,6 +3,9 @@
#include <windows.h>
#else
#include <fcntl.h>
+#if defined(HAVE_GETRANDOM) || defined(HAVE_GETENTROPY)
+#include <sys/random.h>
+#endif
#ifdef HAVE_SYS_STAT_H
#include <sys/stat.h>
#endif
@oliviadawd
Copy link

Does this patch work for installing 2.7.11? Been running into some issue when I try to install using pyenv

❯❯❯ pyenv install --patch 2.7.11 < <(curl -sSL https://gist.githubusercontent.com/orip/00142a498cf6d0c536b5d38771ad6249/raw/8cd96db639a723803fb072d0b15697f9c95a19e4/Python-3.4.3-macos.patch)
python-build: use openssl from homebrew
python-build: use readline from homebrew
Downloading Python-2.7.11.tar.xz...
-> https://www.python.org/ftp/python/2.7.11/Python-2.7.11.tar.xz
Installing Python-2.7.11...
patching file Python/random.c
patch unexpectedly ends in middle of line
Hunk #1 FAILED at 3.
1 out of 1 hunk FAILED -- saving rejects to file Python/random.c.rej

BUILD FAILED (OS X 11.1 using python-build 20180424)

Inspect or clean up the working tree at /var/folders/cg/qygt2npn2y7brxh8x9bygpnc0000gn/T/python-build.20210107131231.32577
Results logged to /var/folders/cg/qygt2npn2y7brxh8x9bygpnc0000gn/T/python-build.20210107131231.32577.log

Last 10 log lines:
/var/folders/cg/qygt2npn2y7brxh8x9bygpnc0000gn/T/python-build.20210107131231.32577 ~/python-pkgs
/var/folders/cg/qygt2npn2y7brxh8x9bygpnc0000gn/T/python-build.20210107131231.32577/Python-2.7.11 /var/folders/cg/qygt2npn2y7brxh8x9bygpnc0000gn/T/python-build.20210107131231.32577 ~/python-pkgs

Any guidance would be much appreciated! For reference this is the error I was seeing when just trying to install 2.7.11 without the patch:

❯❯❯ pyenv install 2.7.11
python-build: use openssl from homebrew
python-build: use readline from homebrew
Downloading Python-2.7.11.tar.xz...
-> https://www.python.org/ftp/python/2.7.11/Python-2.7.11.tar.xz
Installing Python-2.7.11...
python-build: use readline from homebrew
python-build: use zlib from xcode sdk

BUILD FAILED (OS X 11.1 using python-build 20180424)

Inspect or clean up the working tree at /var/folders/cg/qygt2npn2y7brxh8x9bygpnc0000gn/T/python-build.20210107131750.35749
Results logged to /var/folders/cg/qygt2npn2y7brxh8x9bygpnc0000gn/T/python-build.20210107131750.35749.log

Last 10 log lines:
Python/random.c:114:19: note: did you mean 'py_getentropy'?
Python/random.c:106:1: note: 'py_getentropy' declared here
py_getentropy(unsigned char *buffer, Py_ssize_t size, int fatal)
^
Python/random.c:123:19: error: implicit declaration of function 'getentropy' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
            res = getentropy(buffer, len);
                  ^
2 errors generated.
make: *** [Python/random.o] Error 1
make: *** Waiting for unfinished jobs....

@gustavopergola
Copy link

Thank you. I will take a look at that.

@karthicraghupathi did u find the solution? Having a lot of trouble installing 3.4.3 here... the discussion linked refers to 3.7+ only

@ajay1mg
Copy link

ajay1mg commented Jan 28, 2021

I am on Big Sur 11.0.1 and facing this below issue while installing 3.4.3 using pyenv with the following command:
pyenv install 3.4.3 --patch < Python-3.4.3-macos.patch
@orip

python-build: use openssl from homebrew
python-build: use readline from homebrew
Installing Python-3.4.3...
patching file Python/random.c
python-build: use readline from homebrew
python-build: use zlib from xcode sdk

BUILD FAILED (OS X 11.0.1 using python-build 20180424)

Inspect or clean up the working tree at /var/folders/3v/7q2n62ds7y572drrb071xp4h0000gp/T/python-build.20210128200252.63497
Results logged to /var/folders/3v/7q2n62ds7y572drrb071xp4h0000gp/T/python-build.20210128200252.63497.log

Last 10 log lines:
#define UTIME_HAVE_FD (defined(HAVE_FUTIMES) || defined(HAVE_FUTIMENS))
                                                ^
./Modules/posixmodule.c:8301:11: error: implicit declaration of function 'sendfile' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
    ret = sendfile(in, out, offset, &sbytes, &sf, flags);
          ^
clang -Wno-unused-result -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include   -I/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include   -Werror=declaration-after-statement   -I. -IInclude -I./Include -I/usr/local/opt/readline/include -I/usr/local/opt/readline/include -I/usr/local/opt/[email protected]/include -I/Users/ajay/.pyenv/versions/3.4.3/include  -I/usr/local/opt/readline/include -I/usr/local/opt/readline/include -I/usr/local/opt/[email protected]/include -I/Users/ajay/.pyenv/versions/3.4.3/include   -DPy_BUILD_CORE  -c ./Modules/_functoolsmodule.c -o Modules/_functoolsmodule.o
clang -Wno-unused-result -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include   -I/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include   -Werror=declaration-after-statement   -I. -IInclude -I./Include -I/usr/local/opt/readline/include -I/usr/local/opt/readline/include -I/usr/local/opt/[email protected]/include -I/Users/ajay/.pyenv/versions/3.4.3/include  -I/usr/local/opt/readline/include -I/usr/local/opt/readline/include -I/usr/local/opt/[email protected]/include -I/Users/ajay/.pyenv/versions/3.4.3/include   -DPy_BUILD_CORE  -c ./Modules/_operator.c -o Modules/_operator.o
18 warnings and 1 error generated.
make: *** [Modules/posixmodule.o] Error 1
make: *** Waiting for unfinished jobs....

the patch, however, solved the entropy error I was getting earlier.

@karthicraghupathi
Copy link

@karthicraghupathi did u find the solution? Having a lot of trouble installing 3.4.3 here... the discussion linked refers to 3.7+ only

@gustavopergola No, I have not been able find a solution yet.

@orip
Copy link
Author

orip commented Feb 1, 2021

I would suggest looking at what people are doing at pyenv/pyenv#1643

It's for newer Python versions but the error is the same, making it likely that their solutions would work for 3.4.x as well.

@karthicraghupathi
Copy link

I would suggest looking at what people are doing at pyenv/pyenv#1643

It's for newer Python versions but the error is the same, making it likely that their solutions would work for 3.4.x as well.

@orip thanks. I was able to solve that issue but I ran into another hurdle. I'm going to detail my steps here for everyone. May be someone else can take this over the finish line. I've been trying to build and install Python 3.4.10. I've performed these steps on both macOS Catalina and Pop!_OS 20.04 LTS (based on Ubuntu).

I use asdf which uses pyenv's python-build underneath to build and install different versions of Python. I believe pyenv gives you the ability to provide a URL from which a patch can be applied prior to building and installing Python. asdf did not have this ability so I opened an issue and another user @donaldguy provided a solution to add that capability to asdf here: asdf-community/asdf-python#77 (comment).

Regardless of whether you use asdf or pyenv, you have the ability to only specify one patch URL. So I took the following patches:

I combined both these patches and made it available here karthicraghupathi/Python-3.4.x-macos.patch.

I then used the following command to perform the install:

ASDF_PYTHON_PATCH_URL="https://gist.githubusercontent.com/karthicraghupathi/da7bccec3bce904ad081d06efea4a607/raw/e1d81c611ea44bbca114495fbc6e8458417b8313/Python-3.4.3-macos.patch" \
asdf install python 3.4.10

I am able to get past both the original getentropy and sendfile issue. However, I'm running into an issue with OpenSSL now.

python-build --patch 3.4.10 /Users/karthicr/.asdf/installs/python/3.4.10
with patch file from: https://gist.githubusercontent.com/karthicraghupathi/da7bccec3bce904ad081d06efea4a607/raw/e1d81c611ea44bbca114495fbc6e8458417b8313/Python-3.4.3-macos.patch
python-build: use openssl from homebrew
python-build: use readline from homebrew
Downloading Python-3.4.10.tar.xz...
-> https://www.python.org/ftp/python/3.4.10/Python-3.4.10.tar.xz
Installing Python-3.4.10...
patching file Python/random.c
patching file Misc/NEWS.d/next/macOS/2020-06-24-13-51-57.bpo-41100.mcHdc5.rst
patching file configure
Hunk #1 succeeded at 3420 (offset -6 lines).
patching file configure.ac
Hunk #1 succeeded at 489 (offset -21 lines).
python-build: use readline from homebrew
python-build: use zlib from xcode sdk
ERROR: The Python ssl extension was not compiled. Missing the OpenSSL lib?

Please consult to the Wiki page to fix the problem.
https://github.com/pyenv/pyenv/wiki/Common-build-problems


BUILD FAILED (OS X 10.15.7 using python-build 1.2.22-47-g4c302a02)

Inspect or clean up the working tree at /var/folders/dy/1vzm3lbx1673twz_pmd8vcnmr40220/T/python-build.20210201165847.29817
Results logged to /var/folders/dy/1vzm3lbx1673twz_pmd8vcnmr40220/T/python-build.20210201165847.29817.log

Last 10 log lines:
(cd /Users/karthicr/.asdf/installs/python/3.4.10/share/man/man1; ln -s python3.4.1 python3.1)
if test "xupgrade" != "xno"  ; then \
		case upgrade in \
			upgrade) ensurepip="--upgrade" ;; \
			install|*) ensurepip="" ;; \
		esac; \
		 ./python.exe -E -m ensurepip \
			$ensurepip --root=/ ; \
	fi
Ignoring ensurepip failure: pip 9.0.1 requires SSL/TLS

I know these issues are stemming from the fact that OpenSSL now available on most systems (brew on macOS and apt on Ubuntu) no longer have the OpenSSL 1.0.x version. They all now provide OpenSSL 1.1.x versions readily.

I have tried some suggestions from these following issues:

However I remain stuck at this point. Looking forward to seeing if anyone has solved this. I will continue to try and post if I have any further updates.

@orip
Copy link
Author

orip commented Feb 2, 2021

On Macos you can force the Python build to build openssl 1.0 by removing openssl 1.1 just for the build.

brew uninstall --ignore-dependencies [email protected]
pyenv install ...
brew reinstall [email protected]

@karthicraghupathi
Copy link

karthicraghupathi commented Feb 2, 2021

Thanks. I was hoping to avoid uninstalling OpenSSL as re-installing it would mean brew would update all dependent packages because the new OpenSSL version would be newer than what I'm uninstalling. But having come this far, I went ahead and tried it anyway just to see if I could successfully install Python 3.4.10 and guess what: IT WORKED.

The only thing I want to draw attention to is to use the --force option when uninstalling OpenSSL to ensure all versions are removed as indicated by brew.

$ brew uninstall --ignore-dependencies [email protected]
Uninstalling /usr/local/Cellar/[email protected]/1.1.1h... (8,067 files, 18.5MB)
[email protected] 1.1.1g is still installed.
To remove all versions, run:
  brew uninstall --force [email protected]

$ brew uninstall --ignore-dependencies --force [email protected]
Uninstalling [email protected]... (8,059 files, 18MB)

$ ASDF_PYTHON_PATCH_URL="https://gist.githubusercontent.com/karthicraghupathi/da7bccec3bce904ad081d06efea4a607/raw/e1d81c611ea44bbca114495fbc6e8458417b8313/Python-3.4.3-macos.patch" \
asdf install python 3.4.10
python-build --patch 3.4.10 /Users/karthicr/.asdf/installs/python/3.4.10
with patch file from: https://gist.githubusercontent.com/karthicraghupathi/da7bccec3bce904ad081d06efea4a607/raw/e1d81c611ea44bbca114495fbc6e8458417b8313/Python-3.4.3-macos.patch
Downloading openssl-1.0.2k.tar.gz...
-> https://pyenv.github.io/pythons/6b3977c61f2aedf0f96367dcfb5c6e578cf37e7b8d913b4ecb6643c3cb88d8c0
Installing openssl-1.0.2k...
Installed openssl-1.0.2k to /Users/karthicr/.asdf/installs/python/3.4.10

python-build: use readline from homebrew
Downloading Python-3.4.10.tar.xz...
-> https://www.python.org/ftp/python/3.4.10/Python-3.4.10.tar.xz
Installing Python-3.4.10...
patching file Python/random.c
patching file Misc/NEWS.d/next/macOS/2020-06-24-13-51-57.bpo-41100.mcHdc5.rst
patching file configure
Hunk #1 succeeded at 3420 (offset -6 lines).
patching file configure.ac
Hunk #1 succeeded at 489 (offset -21 lines).
python-build: use readline from homebrew
python-build: use zlib from xcode sdk
Installed Python-3.4.10 to /Users/karthicr/.asdf/installs/python/3.4.10

$ asdf list python
  2.7.18
  3.4.10
  3.6.12

$ asdf python shell 3.4.10

$ python
Python 3.4.10 (default, Feb  2 2021, 13:24:58)
[GCC Apple LLVM 12.0.0 (clang-1200.0.32.29)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import ssl
>>> exit()

$ brew install [email protected]

==> Downloading https://homebrew.bintray.com/bottles/openssl%401.1-1.1.1i.catalina.bottle.tar.gz
==> Downloading from https://d29vzk4ow07wi7.cloudfront.net/066b9f114617872e77fa3d4afee2337daabc2c181d7564fe60a5b26d89d69742?response-content-disposition=attac
######################################################################## 100.0%
==> Pouring [email protected]
...
...
Omitted rest of the output for brevity.
...
==> Upgrading 34 dependents:
glib 2.66.1 -> 2.66.4_1, cairo 1.16.0_3 -> 1.16.0_4, erlang 23.1.1 -> 23.2.3, freetds 1.2.5 -> 1.2.18, gnupg 2.2.23 -> 2.2.27, gobject-introspection 1.66.1 -> 1.66.1_1, graphviz 2.44.1 -> 2.46.0, harfbuzz 2.7.2 -> 2.7.4, krb5 1.18.2 -> 1.18.3, libssh 0.9.5 -> 0.9.5_1, libxml2 2.9.10_1 -> 2.9.10_2, libxmlsec1 1.2.30 -> 1.2.31, macvim 8.2-166_1 -> 8.2-169_2, [email protected] 5.7.31 -> 5.7.32, xwmx/taps/nb 5.6.2 -> 5.7.8, nghttp2 1.41.0_1 -> 1.42.0_1, oath-toolkit 2.6.2_1 -> 2.6.6, pango 1.46.2 -> 1.48.1, plantuml 1.2020.19 -> 1.2021.0, postgresql 13.0 -> 13.1, postgresql@11 11.9 -> 11.10, pyenv 1.2.21 -> 1.2.22, pygments 2.7.1_1 -> 2.7.4, [email protected] 3.8.6 -> 3.8.7, [email protected] 3.9.0 -> 3.9.1_7, rabbitmq 3.8.9_1 -> 3.8.11, ruby 2.7.2 -> 3.0.0_1, sngrep 1.4.7 -> 1.4.8, socat 1.7.3.4 -> 1.7.4.1, termshark 2.1.1_1 -> 2.2.0, unbound 1.12.0 -> 1.13.0, w3m 0.5.3_6 -> 0.5.3_7, wget 1.20.3_2 -> 1.21.1, wireshark 3.4.3
...
Omitted rest of the output for brevity.
...
...

@benbenbuhben
Copy link

@karthicraghupathi Thanks! This helped immensely.

@srini-akhil
Copy link

@karthicraghupathi i am still getting same issue although i am trying to install on M1 architecture. Any fix for M1 big sur?

@karthicraghupathi
Copy link

@benbenbuhben You're welcome.

@srini-akhil Multiple issues have been described on this page. What exactly are you running into? Posting logs will help someone assist you.

@srini-akhil
Copy link

srini-akhil commented Jun 18, 2021

@benbenbuhben You're welcome.

@srini-akhil Multiple issues have been described on this page. What exactly are you running into? Posting logs will help someone assist you.

ASDF_PYTHON_PATCH_URL="https://gist.githubusercontent.com/karthicraghupathi/da7bccec3bce904ad081d06efea4a607/raw/e1d81c611ea44bbca114495fbc6e8458417b8313/Python-3.4.3-macos.patch" \
arch -x86_64 asdf install python 3.4.3
python-build --patch 3.4.3 /Users/srini/.asdf/installs/python/3.4.3
with patch file from: https://gist.githubusercontent.com/karthicraghupathi/da7bccec3bce904ad081d06efea4a607/raw/e1d81c611ea44bbca114495fbc6e8458417b8313/Python-3.4.3-macos.patch
Downloading openssl-1.0.2k.tar.gz...
-> https://pyenv.github.io/pythons/6b3977c61f2aedf0f96367dcfb5c6e578cf37e7b8d913b4ecb6643c3cb88d8c0
Installing openssl-1.0.2k...
Installed openssl-1.0.2k to /Users/srini/.asdf/installs/python/3.4.3

python-build: use readline from homebrew
Downloading Python-3.4.3.tar.xz...
-> https://www.python.org/ftp/python/3.4.3/Python-3.4.3.tar.xz
Installing Python-3.4.3...
patching file Python/random.c
patching file Misc/NEWS.d/next/macOS/2020-06-24-13-51-57.bpo-41100.mcHdc5.rst
patching file configure
Hunk #1 succeeded at 3419 (offset -7 lines).
patching file configure.ac
Hunk #1 succeeded at 489 (offset -21 lines).
python-build: use readline from homebrew
python-build: use zlib from xcode sdk
WARNING: The Python bz2 extension was not compiled. Missing the bzip2 lib?
WARNING: The Python readline extension was not compiled. Missing the GNU readline lib?
WARNING: The Python sqlite3 extension was not compiled. Missing the SQLite3 lib?
ERROR: The Python zlib extension was not compiled. Missing the zlib?

Please consult to the Wiki page to fix the problem.
https://github.com/pyenv/pyenv/wiki/Common-build-problems


BUILD FAILED (OS X 11.2.3 using python-build 2.0.1-5-gbbcecc75)

Inspect or clean up the working tree at /var/folders/wz/khb2wmws78131mb3nmx1hkph0000gp/T/python-build.20210618111355.15602
Results logged to /var/folders/wz/khb2wmws78131mb3nmx1hkph0000gp/T/python-build.20210618111355.15602.log

Last 10 log lines:
		 ./python.exe -E -m ensurepip \
			$ensurepip --root=/ ; \
	fi
Ignoring indexes: https://pypi.python.org/simple
Collecting setuptools
Collecting pip
Installing collected packages: pip, setuptools


Successfully installed pip-6.0.8 setuptools-12.0.5

although i have installed zlib library using brew and exported paths as per documentation as well but still i keep on getting this
Anyone installed python 3.4 on M1 Big sur can u pls help

@karthicraghupathi
Copy link

@srini-akhil The documentation suggest setting up CPPFLAGS and LDFLAGS to solve the problem of missing libraries. So if you have installed zlib and readline using brew, you might have to try something like this:

ASDF_PYTHON_PATCH_URL="https://gist.githubusercontent.com/karthicraghupathi/da7bccec3bce904ad081d06efea4a607/raw/e1d81c611ea44bbca114495fbc6e8458417b8313/Python-3.4.3-macos.patch" \
arch -x86_64 \
CPPFLAGS="-I$(brew --prefix zlib)/include -I$(brew --prefix readline)/include" \
LDFLAGS="-L$(brew --prefix readline)/lib" \
asdf install python 3.4.3

YMMV. Keep trying a bunch of things. All the best.

@kytta
Copy link

kytta commented Sep 7, 2021

For those, who happen to have aria2c installed: you have to uninstall it as well, since it requires OpenSSL 1.1 to function properly. I did that, then I ran pyenv install with Karthic's patch, and it worked flawlessly.

In the end, this is what I had to execute:

$ brew uninstall --ignore-dependencies --force [email protected]
Uninstalling [email protected]... (8,073 files, 18.5MB)

$ brew uninstall --ignore-dependencies --force aria2
Uninstalling aria2... (23 files, 4.0MB)

$ pyenv install 3.4.10 --patch < Python-3.4.3-macos.patch # this file I downloaded to my computer
Downloading openssl-1.0.2k.tar.gz...
# output omitted here
Installed Python-3.4.10 to [REDACTED]

$ pyenv versions
  system
* 2.7.18 (set by [REDACTED])
  3.4.10
  3.6.14
* 3.9.6 (set by [REDACTED])

$ brew install [email protected] aria2
Updating Homebrew...
# output omitted here
🍺  /usr/local/Cellar/[email protected]/1.1.1l: 8,073 files, 18.5MB
# output omitted here
🍺  /usr/local/Cellar/aria2/1.36.0: 23 files, 4.0MB

$ pyenv shell 3.4.10

$ python --version

Python 3.4.10

@DuncanTormey
Copy link

@srini-akhil Were you able to resolve? I have a similar issue and I tried what @karthicraghupathi suggested in this comment with no luck

python-build: use openssl from homebrew
python-build: use readline from homebrew
Installing Python-3.4.3...
patching file Python/random.c
patching file Misc/NEWS.d/next/macOS/2020-06-24-13-51-57.bpo-41100.mcHdc5.rst
patching file configure
Hunk #1 succeeded at 3419 (offset -7 lines).
patching file configure.ac
patch unexpectedly ends in middle of line
Hunk #1 succeeded at 489 with fuzz 1 (offset -21 lines).
python-build: use readline from homebrew
python-build: use zlib from xcode sdk
WARNING: The Python bz2 extension was not compiled. Missing the bzip2 lib?
ERROR: The Python ssl extension was not compiled. Missing the OpenSSL lib?

Please consult to the Wiki page to fix the problem.
https://github.com/pyenv/pyenv/wiki/Common-build-problems


BUILD FAILED (OS X 11.3.1 using python-build 20180424)

Inspect or clean up the working tree at /var/folders/qf/7_n2v5yn74789h69s0rv2mn40000gp/T/python-build.20211110174308.82264
Results logged to /var/folders/qf/7_n2v5yn74789h69s0rv2mn40000gp/T/python-build.20211110174308.82264.log

Last 10 log lines:
(cd /Users/duncan.tormey/.pyenv/versions/3.4.3/share/man/man1; ln -s python3.4.1 python3.1)
if test "xupgrade" != "xno"  ; then \
		case upgrade in \
			upgrade) ensurepip="--upgrade" ;; \
			install|*) ensurepip="" ;; \
		esac; \
		 ./python.exe -E -m ensurepip \
			$ensurepip --root=/ ; \
	fi
Ignoring ensurepip failure: pip 6.0.8 requires SSL/TLS```

@DuncanTormey
Copy link

I got it to work. I had to do this, notice the lack of a version stamp

brew uninstall --ignore-dependencies --force openssl

Then...

brew reinstall zlib

and finally.

CPPFLAGS="-I/usr/local/opt/zlib/include -I$(brew --prefix readline)/include" LDFLAGS="-L$(brew --prefix readline)/lib -L/usr/local/opt/zlib/lib" pyenv install 3.4.3 --patch < Python-3.4.3-macos.patch

Where Python-3.4.3-macos.path is @karthicraghupathi version (thank you so much).

diff --git a/Python/random.c b/Python/random.c
index 93d300d..396041d 100644
--- a/Python/random.c
+++ b/Python/random.c
@@ -3,6 +3,9 @@
 #include <windows.h>
 #else
 #include <fcntl.h>
+#if defined(HAVE_GETRANDOM) || defined(HAVE_GETENTROPY)
+#include <sys/random.h>
+#endif
 #ifdef HAVE_SYS_STAT_H
 #include <sys/stat.h>
 #endif
 diff --git a/Misc/NEWS.d/next/macOS/2020-06-24-13-51-57.bpo-41100.mcHdc5.rst b/Misc/NEWS.d/next/macOS/2020-06-24-13-51-57.bpo-41100.mcHdc5.rst
new file mode 100644
index 0000000000000..ded66b567a92d
--- /dev/null
+++ b/Misc/NEWS.d/next/macOS/2020-06-24-13-51-57.bpo-41100.mcHdc5.rst
@@ -0,0 +1 @@
+Support macOS 11 when building.
diff --git a/configure b/configure
index c51f396824b63..5024860ca4395 100755
--- a/configure
+++ b/configure
@@ -3426,7 +3426,7 @@ $as_echo "#define _BSD_SOURCE 1" >>confdefs.h
   # has no effect, don't bother defining them
   Darwin/[6789].*)
     define_xopen_source=no;;
-  Darwin/1[0-9].*)
+  Darwin/[12][0-9].*)
     define_xopen_source=no;;
   # On AIX 4 and 5.1, mbstate_t is defined only when _XOPEN_SOURCE == 500 but
   # used in wcsnrtombs() and mbsnrtowcs() even if _XOPEN_SOURCE is not defined
diff --git a/configure.ac b/configure.ac
index 70deefb6b9aea..5a3e340aa3e72 100644
--- a/configure.ac
+++ b/configure.ac
@@ -510,7 +510,7 @@ case $ac_sys_system/$ac_sys_release in
   # has no effect, don't bother defining them
   Darwin/@<:@6789@:>@.*)
     define_xopen_source=no;;
-  Darwin/1@<:@0-9@:>@.*)
+  Darwin/@<:@[12]@:>@@<:@0-9@:>@.*)
     define_xopen_source=no;;
   # On AIX 4 and 5.1, mbstate_t is defined only when _XOPEN_SOURCE == 500 but
   # used in wcsnrtombs() and mbsnrtowcs() even if _XOPEN_SOURCE is not defined

Thanks everyone! I would have been lost without this page. Afterwords i reinstalled openssl.

@wickkidd
Copy link

@DuncanTormey your solution was the only one that worked for me (I did it with 3.4.10 btw). Thank you 💪

@minjikarin
Copy link

@DuncanTormey, your solution was the only one that worked for me too..... thank you so much!!

@huwaizatahir2
Copy link

@DuncanTormey your solution was only one that worked for me too.... thank you sooooo much

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment