Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OTP 24.0 unable to find crypto OpenSSL lib #4821

Closed
jj1bdx opened this issue May 12, 2021 · 81 comments · Fixed by #4835
Closed

OTP 24.0 unable to find crypto OpenSSL lib #4821

jj1bdx opened this issue May 12, 2021 · 81 comments · Fixed by #4835
Assignees
Labels
bug Issue is reported as a bug team:VM Assigned to OTP team VM

Comments

@jj1bdx
Copy link
Contributor

jj1bdx commented May 12, 2021

Describe the bug

lib/crypto/configure of OTP 24.0 on macOS 10.15.7 was unable to find the shared library /usr/local/opt/openssl/lib/libcrypto.a.

(Edited: This bug was first discovered when running under parallel configure execution. Using --disable-parallel-configure solves the issue in some cases but not the root cause.)

(Edited 2: a workaround for this bug is posted as a comment here)

(Edited 3: this issue is NOT specific to macOS, reproducible on Ubuntu 20.10 when using autoconf-2.71 instead of stock autoconf-2.69)

To Reproduce

Running the following script as script.sh 24.0

#!/bin/sh
# For macOS with HomeBrew OpenSSL
OTP_VERSION=$1
# SSL path is configured in standard path of lib/crypto/configure.in
#OPENSSL_LOCAL="/usr/local/opt/openssl"
INSTALL_DIR_PREFIX="/Users/kenji/otp/"
#
env \
    CC=/usr/local/opt/ccache/libexec/clang \
    CXX=/usr/local/opt/ccache/libexec/clang++ \
    CFLAGS="-O3 -fstack-protector-strong" LDFLAGS="-fstack-protector-strong" \
    MAKEFLAGS="-j12" \
    KERL_BUILD_PLT="yes" \
    # --disable-parallel-configure required to avoid malfunction of
    # lib/crypto/configure, failing to detect libcrypto.dylib
    KERL_CONFIGURE_OPTIONS="--enable-jit --enable-m64-build --enable-darwin-64bit --disable-vm-probes --disable-native-libs --enable-kernel-poll --enable-dirty-schedulers --enable-sharing-preserving --enable-lock-counter --enable-esock --disable-sctp --without-javac --without-odbc --enable-threads --enable-smp-support --with-wx --disable-silent-rules --with-ssl --disable-dynamic-ssl-lib" \
    KERL_BUILD_DOCS="yes" \
    sh -c "(kerl build git https://github.com/jj1bdx/otp/ OTP-${OTP_VERSION} ${OTP_VERSION} && kerl install ${OTP_VERSION} ${INSTALL_DIR_PREFIX}${OTP_VERSION})"

Causes the following output (note that repository jj1bdx/otp is identical fork as erlang/otp):

% script.sh 24.0
Checking out Erlang/OTP git repository from https://github.com/jj1bdx/otp/...
Building Erlang/OTP 24.0 from git, please wait...
Configure failed.
checking for compiler flags for loadable drivers... -Werror=undef -Werror=implicit -Werror=return-type  -Wdeclaration-after-statement -Wall -Wstrict-prototypes -Wmissing-prototypes  -D_THREAD_SAFE -D_REENTRANT -DPOSIX_THREADS -fno-common -m64 -O3 -fstack-protector-strong -fPIC -fno-common
checking for linker for loadable drivers... clang
checking for linker flags for loadable drivers... -m64 -bundle -bundle_loader /Users/kenji/.kerl/builds/24.0/otp_src_git/bin/x86_64-apple-darwin19.6.0/beam.smp
checking for 'runtime library path' linker flag... not found
checking for multiarch directory... not found
checking size of void *... 8
checking for static zlib... no
checking for OpenSSL header in /usr/local/Cellar/openssl@1.1/1.1.1k... yes
checking for OpenSSL in /usr/local/Cellar/openssl@1.1/1.1.1k... configure: error: static linking against crypto library disabled by user, but no dynamic library found in /usr/local/Cellar/openssl@1.1/1.1.1k
ERROR: /Users/kenji/.kerl/builds/24.0/otp_src_git/lib/crypto/configure failed!

Please see /Users/kenji/.kerl/builds/24.0/otp_build_git.log for full details.

Expected behavior
The build should have been ongoing properly without --disable-parallel-configure.

Affected versions
24.0

Additional context
Building without parallelism by make (without -j option) in the building directory did not cause this bug.

Even with this workaround, the build was failed as follows:

Checking out Erlang/OTP git repository from https://github.com/jj1bdx/otp/...
Building Erlang/OTP 24.0 from git, please wait...
APPLICATIONS DISABLED (See: /Users/kenji/.kerl/builds/24.0/otp_build_git.log)
 * jinterface     : Java compiler disabled by user
 * odbc           : User gave --without-odbc option

APPLICATIONS INFORMATION (See: /Users/kenji/.kerl/builds/24.0/otp_build_git.log)
 * wx             : wxWidgets was not compiled with --enable-webview or wxWebView developer package is not installed, wxWebView will NOT be available

DOCUMENTATION INFORMATION (See: /Users/kenji/.kerl/builds/24.0/otp_build_git.log)
 * documentation  :
 *                  fop is missing.
 *                  Using fakefop to generate placeholder PDF files.

Build failed.
gmake[4]: x86_64-apple-darwin19.6.0/Makefile: No such file or directory
gmake[4]: *** No rule to make target 'x86_64-apple-darwin19.6.0/Makefile'.  Stop.
gmake[4]: Leaving directory '/Users/kenji/.kerl/builds/24.0/otp_src_git/lib/crypto/c_src'
gmake[3]: *** [/Users/kenji/.kerl/builds/24.0/otp_src_git/make/run_make.mk:35: opt] Error 2
gmake[3]: Leaving directory '/Users/kenji/.kerl/builds/24.0/otp_src_git/lib/crypto/c_src'
gmake[2]: *** [/Users/kenji/.kerl/builds/24.0/otp_src_git/make/otp_subdir.mk:29: opt] Error 2
gmake[2]: Leaving directory '/Users/kenji/.kerl/builds/24.0/otp_src_git/lib/crypto'
gmake[1]: *** [/Users/kenji/.kerl/builds/24.0/otp_src_git/make/otp_subdir.mk:29: opt] Error 2
gmake[1]: Leaving directory '/Users/kenji/.kerl/builds/24.0/otp_src_git/lib'
gmake: *** [Makefile:498: libs] Error 2
@jj1bdx jj1bdx added the bug Issue is reported as a bug label May 12, 2021
@jj1bdx
Copy link
Contributor Author

jj1bdx commented May 12, 2021

The build was failed. I've edited the base article of this issue.

@jj1bdx
Copy link
Contributor Author

jj1bdx commented May 12, 2021

I've noticed there was a massive change in b354ab8 between 24.0-rc3 and 24.0. I couldn't figure out the details of the changes.

@LouisMT
Copy link

LouisMT commented May 12, 2021

Same issue using asdf-erlang:

$ asdf install erlang ref:OTP-24.0
asdf_OTP-24.0 is not a kerl-managed Erlang/OTP installation
No build named asdf_OTP-24.0
Checking out Erlang/OTP git repository from https://github.com/erlang/otp.git...
Building Erlang/OTP asdf_OTP-24.0 from git, please wait...
Configure failed.
checking for compiler flags for loadable drivers... -Werror=undef -Werror=implicit -Werror=return-type  -Wdeclaration-after-statement -Wall -Wstrict-prototypes -Wmissing-prototypes  -D_THREAD_SAFE -D_REENTRANT -DPOSIX_THREADS -fno-common -g -O2 -fPIC -fno-common
checking for linker for loadable drivers... gcc
checking for linker flags for loadable drivers... -m64 -bundle -bundle_loader /Users/louis/.asdf/plugins/erlang/kerl-home/builds/asdf_OTP-24.0/otp_src_git/bin/x86_64-apple-darwin20.4.0/beam.smp
checking for 'runtime library path' linker flag... not found
checking for multiarch directory... not found
checking size of void *... (cached) 8
checking for static zlib... no
checking for OpenSSL header in /usr/local/opt/openssl@1.1... yes
checking for OpenSSL in /usr/local/opt/openssl@1.1... configure: error: neither static nor dynamic crypto library found in /usr/local/opt/openssl@1.1
ERROR: /Users/louis/.asdf/plugins/erlang/kerl-home/builds/asdf_OTP-24.0/otp_src_git/lib/crypto/configure failed

I was able to build one of the RCs without any problems as well.

@jj1bdx
Copy link
Contributor Author

jj1bdx commented May 12, 2021

Yes, 24.0-rc3 was buildable.

@rickard-green
Copy link
Contributor

@jj1bdx I have no idea why --disable-parallel-configure behaved differently than without it. I'm not able to reproduce that. It seems like configure in crypto was not run when you passed --disable-parallel-configure, but lets look at the other scenario when you did not pass it.

Please attach the lib/crypto/config.log file, and also do an ls /usr/local/Cellar/openssl@1.1/1.1.1k/{lib,lib64,lib/64} and paste the result in a comment.

@rickard-green rickard-green self-assigned this May 12, 2021
@rickard-green
Copy link
Contributor

@LouisMT Please attach the lib/crypto/config.log file, and also do an ls /usr/local/opt/openssl@1.1/{lib,lib64,lib/64} and paste the result in a comment.

@wojtekmach
Copy link
Contributor

wojtekmach commented May 12, 2021

I'm running into the same problem, I'm on latest master:

lib/crypto/config.log

% ls -l /usr/local/opt/openssl@1.1/lib
total 15144
drwxr-xr-x  4 wojtek  staff      128 Mar 25 14:28 engines-1.1
-r--r--r--  1 wojtek  staff  2437024 Apr 10 21:22 libcrypto.1.1.dylib
-r--r--r--  1 wojtek  staff  4087176 Mar 25 14:28 libcrypto.a
lrwxr-xr-x  1 wojtek  staff       19 Mar 25 14:28 libcrypto.dylib -> libcrypto.1.1.dylib
-r--r--r--  1 wojtek  staff   502872 Apr 10 21:22 libssl.1.1.dylib
-r--r--r--  1 wojtek  staff   723992 Mar 25 14:28 libssl.a
lrwxr-xr-x  1 wojtek  staff       16 Mar 25 14:28 libssl.dylib -> libssl.1.1.dylib
drwxr-xr-x  5 wojtek  staff      160 Apr 10 21:22 pkgconfig
~/src/otp[master]%

@lukebakken
Copy link
Contributor

Thanks to @rickard-green 's help on the mailing list, I get to the point where I see the error reported here.

$ sw_vers 
ProductName:	macOS
ProductVersion:	11.3
BuildVersion:	20E232
$ ls -la "$(brew --prefix openssl)"/{lib,lib64,lib/64}
ls: /usr/local/opt/openssl/lib/64: No such file or directory
ls: /usr/local/opt/openssl/lib64: No such file or directory
/usr/local/opt/openssl/lib:
total 15144
drwxr-xr-x  10 lbakken  staff      320 Mar 25 06:28 .
drwxr-xr-x  14 lbakken  staff      448 Mar 31 14:22 ..
drwxr-xr-x   4 lbakken  staff      128 Mar 25 06:28 engines-1.1
-r--r--r--   1 lbakken  staff  2437024 Mar 31 14:22 libcrypto.1.1.dylib
-r--r--r--   1 lbakken  staff  4087176 Mar 25 06:28 libcrypto.a
lrwxr-xr-x   1 lbakken  staff       19 Mar 25 06:28 libcrypto.dylib -> libcrypto.1.1.dylib
-r--r--r--   1 lbakken  staff   502872 Mar 31 14:22 libssl.1.1.dylib
-r--r--r--   1 lbakken  staff   723992 Mar 25 06:28 libssl.a
lrwxr-xr-x   1 lbakken  staff       16 Mar 25 06:28 libssl.dylib -> libssl.1.1.dylib
drwxr-xr-x   5 lbakken  staff      160 Mar 31 14:22 pkgconfig

otp-24-crypto-config.log.txt

@DOBRO
Copy link

DOBRO commented May 12, 2021

same issue on macOS Big Sur 11.3.1 using kerl:

$ kerl build 24.0

Extracting source code
Building Erlang/OTP 24.0 (24.0), please wait...
Configure failed.
checking for compiler flags for loadable drivers... -Werror=undef -Werror=implicit -Werror=return-type  -Wdeclaration-after-statement -Wall -Wstrict-prototypes -Wmissing-prototypes  -D_THREAD_SAFE -D_REENTRANT -DPOSIX_THREADS -fno-common -g -O2 -fPIC -fno-common
checking for linker for loadable drivers... gcc
checking for linker flags for loadable drivers... -m64 -bundle -bundle_loader /Users/dobro/.kerl/builds/24.0/otp_src_24.0/bin/x86_64-apple-darwin20.4.0/beam.smp
checking for 'runtime library path' linker flag... not found
checking for multiarch directory... not found
checking size of void *... (cached) 8
checking for static zlib... no
checking for OpenSSL header in /usr/local/opt/openssl@1.1... yes
checking for OpenSSL in /usr/local/opt/openssl@1.1... configure: error: neither static nor dynamic crypto library found in /usr/local/opt/openssl@1.1
ERROR: /Users/dobro/.kerl/builds/24.0/otp_src_24.0/lib/crypto/configure failed!

Please see /Users/dobro/.kerl/builds/24.0/otp_build_24.0.log for full details.
$ ls -l /usr/local/opt/openssl@1.1/{lib,lib64,lib/64}
ls: /usr/local/opt/openssl@1.1/lib/64: No such file or directory
ls: /usr/local/opt/openssl@1.1/lib64: No such file or directory
/usr/local/opt/openssl@1.1/lib:
total 15144
drwxr-xr-x  4 dobro  staff      128 Mar 25 16:28 engines-1.1
-r--r--r--  1 dobro  staff  2437024 Mar 29 19:43 libcrypto.1.1.dylib
-r--r--r--  1 dobro  staff  4087176 Mar 25 16:28 libcrypto.a
lrwxr-xr-x  1 dobro  staff       19 Mar 25 16:28 libcrypto.dylib -> libcrypto.1.1.dylib
-r--r--r--  1 dobro  staff   502872 Mar 29 19:43 libssl.1.1.dylib
-r--r--r--  1 dobro  staff   723992 Mar 25 16:28 libssl.a
lrwxr-xr-x  1 dobro  staff       16 Mar 25 16:28 libssl.dylib -> libssl.1.1.dylib
drwxr-xr-x  5 dobro  staff      160 Mar 29 19:43 pkgconfig

config.log

otp_build_24.0.log

@rickard-green
Copy link
Contributor

It seems like a lot of the runs fail due to configure not knowing how to run the C preprocessor. I'm not sure this is the case for all of you. If you set CC to something, try also setting CPP="$CC -E". I haven't got more time to look at this right now, but I'll be back in a couple of hours and will look into it in more detail.

@wojtekmach
Copy link
Contributor

CC was empty for me:

% echo $CC

@essen
Copy link
Contributor

essen commented May 12, 2021

Getting the exact same output as #4821 (comment) but on Mojave. No particular environment/configuration.

@wojtekmach
Copy link
Contributor

wojtekmach commented May 12, 2021

./configure generated the following conftest.c:

/* confdefs.h */
#define PACKAGE_NAME ""
#define PACKAGE_TARNAME ""
#define PACKAGE_VERSION ""
#define PACKAGE_STRING ""
#define PACKAGE_BUGREPORT ""
#define PACKAGE_URL ""
#define HAVE_STDIO_H 1
#define HAVE_STDLIB_H 1
#define HAVE_STRING_H 1
#define HAVE_INTTYPES_H 1
#define HAVE_STDINT_H 1
#define HAVE_STRINGS_H 1
#define HAVE_SYS_STAT_H 1
#define HAVE_SYS_TYPES_H 1
#define HAVE_UNISTD_H 1
#define STDC_HEADERS 1
#define HAVE_PTHREAD_H 1
#define SIZEOF_VOID_P 8
#define SIZEOF_VOID_P 8
/* end confdefs.h.  */

#include <openssl/opensslv.h>
#if OPENSSL_VERSION_NUMBER >= 0x0090803fL
yes
#endif

and it produced the following errors:

clang: warning: treating 'c' input as 'c++' when in C++ mode, this behavior is deprecated [-Wdeprecated]
conftest.c:25:1: error: unknown type name 'yes'
yes
^
conftest.c:27:1: error: expected unqualified-id
^
2 errors generated.

@bitwalker
Copy link
Contributor

@wojtekmach Those errors are expected if you don't pass -E to just run the preprocessor, which is what AC_EGREP_CPP does under the covers I believe (which is what is driving the configuration test being performed here). Interestingly, if I just run clang -I/path/to/openssl/include -E conftest.c independently, it works just fine, I get the expected output, but its failing during the configure run, which would seem to vibe with @rickard-green's thought that this is an issue with how the preprocessor is being invoked.

@bitwalker
Copy link
Contributor

Digging further, it looks to me like the use of $EGREP, e.g. if (eval $ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "^yes.?$" 2>&1 is what is causing this. For me at least, $EGREP is empty, so when I remove the redirections that silence output, I see ./configure: line 6152: ^yes.?$: command not found. This is causing the checks using it to fail.

@bitwalker
Copy link
Contributor

For those who just want something working, this worked for me:

EGREP=egrep CC=clang CPP="clang -E" KERL_USE_AUTOCONF=0 KERL_CONFIGURE_OPTIONS="--disable-hipe --disable-sctp --enable-darwin-64bit --enable-kernel-poll --enable-shared-zlib --enable-smp-support --enable-threads --enable-wx --with-ssl=$(brew --prefix openssl) --without-docs --without-javac --without-jinterface --without-odbc" asdf install erlang 24.0

You can probably get away with dropping KERL_CONFIGURE_OPTIONS, but I haven't tested that. It does seem to be necessary to disable KERL_USE_AUTOCONF, but that might've just been a fluke.

@wojtekmach
Copy link
Contributor

wojtekmach commented May 12, 2021

yup, I can also confirm the following worked for me:

% KERL_CONFIGURE_OPTIONS="--with-ssl=$(brew --prefix openssl)" EGREP=egrep CPP="clang++ -E " asdf install erlang 24.0

@nickva
Copy link
Contributor

nickva commented May 12, 2021

This worked for me:

EGREP=egrep CC=clang CPP="clang -E" asdf install erlang 24.0

@rickard-green
Copy link
Contributor

Thanks all for logs and other info!

I can reproduce this issue when using autoconf version 2.70 and 2.71. When using these autoconf versions, crypto's configure script doesn't check for how to run the preprocessor nor does it check for a usable egrep. Since these aren't available when checking for libcrypto, this check fails. I don't know if this is due to a bug in autoconf 2.70/2.71, or if one of our usages of macros that are obsolete in autoconf 2.70/2.71 cause this issue (there are quite a lot of warnings about usage of obsolete macros when running the ./otp_build autoconf step when using autoconf 2.70/2.71). We'll have to go over all our configure files to ensure that these are compatible with autoconf 2.70/2.71, but this is may take some time... The reason why this did not fail before OTP 24.0 is that crypto's configure test was kind of sloppy when testing and you didn't always get what you requested. For example, you could get dynamic linking even though you had disabled dynamic linking. The configure tests in crypo are as of OTP 24 much more thorough.

We have not detected this issue with autoconf 2.70/2.71, since all our machines in our lab use autoconf 2.69 (and in some cases even older autoconf versions). All our machines successfully performs the check for libcrypto (including MacOS Mojave, Catalina, and Big Sur on M1 as well as x86_64).

Since the results got this weird when using autoconf 2.70/2.71 with crypto's configure, I would not trust a build of OTP that has been made using autoconf 2.70/2.71 for now. There might be other issues with other configure tests as well with results that are not as obvious as in this case. I would recommend rebuilding using autoconf 2.69.

Please, report if you get any issues with autoconf 2.69.

@lpgauth
Copy link
Contributor

lpgauth commented May 12, 2021

@richcarl I have autoconf 2.69 and I'm getting the same error.

autoconf --version
autoconf (GNU Autoconf) 2.69

@rickard-green
Copy link
Contributor

rickard-green commented May 12, 2021

@lpgauth It would be interesting to see the lib/crypto/config.log file and listing of files under the lib directory where you expect that libcrypto resides.

@lpgauth
Copy link
Contributor

lpgauth commented May 12, 2021

ls -l /usr/local/opt/openssl@1.1/lib
total 15144
drwxr-xr-x  4 lp.gauthier  CORP\Domain Users      128 25 Mar 09:28 engines-1.1
-r--r--r--  1 lp.gauthier  CORP\Domain Users  2437024 16 Apr 15:59 libcrypto.1.1.dylib
-r--r--r--  1 lp.gauthier  CORP\Domain Users  4087072 25 Mar 09:28 libcrypto.a
lrwxr-xr-x  1 lp.gauthier  CORP\Domain Users       19 25 Mar 09:28 libcrypto.dylib -> libcrypto.1.1.dylib
-r--r--r--  1 lp.gauthier  CORP\Domain Users   502872 16 Apr 15:59 libssl.1.1.dylib
-r--r--r--  1 lp.gauthier  CORP\Domain Users   723992 25 Mar 09:28 libssl.a
lrwxr-xr-x  1 lp.gauthier  CORP\Domain Users       16 25 Mar 09:28 libssl.dylib -> libssl.1.1.dylib
drwxr-xr-x  5 lp.gauthier  CORP\Domain Users      160 16 Apr 15:59 pkgconfig

otp_build_24.0.log
config.log

@rickard-green
Copy link
Contributor

This is not the same error.

It looks like you are passing your own DED_LD and DED_LDFLAGS:

./configure CC=clang DED_LD=clang DED_LDFLAGS=-m64 -bundle -bundle_loader /Users/lp.gauthier/.kerl/builds/24.0/otp_src_24.0/bin/x86_64-apple-darwin19.6.0/beam.smp --enable-darwin-64bit --with-ssl=/usr/local/opt/openssl@1.1 --disable-option-checking --cache-file=/dev/null --srcdir=/Users/lp.gauthier/.kerl/builds/24.0/otp_src_24.0/lib/crypto

Since these are passed, these will be used when checking if it is possible to link against libcrypto. This will fail since beam.smp has not been built yet. Try building without setting any DED_LD* stuff. Configure will (or at least should) figure this out itself.

Also why do you set CC to clang? If you leave it unset, it will (should) find it under the pseudonym gcc. Or am I missing something since you all seem to do that?

@rickard-green
Copy link
Contributor

BTW the --enable-darwin-64bit argument should also not be needed although I don't think it will do any harm

@jj1bdx
Copy link
Contributor Author

jj1bdx commented May 13, 2021

Thanks for all the analysis and efforts.

About setting CC to clang: I've been using clang compilers explicitly on my macOS environment since I've installed three compiler stacks: Xcode-based clang/LLVM, gcc 11 from Homebrew, and the latest clang/LLVM from Homebrew. I explicitly specify clang to avoid confusion. In short: gcc is ambiguous on my compiler stack environment.

@zacky1972
Copy link

zacky1972 commented May 13, 2021

Hi,

I also install OTP 24.0 from otp_src_24.0on macOS Catalina 10.15.7 with OpenSSL 1.1 installed by Homebrew but I did it, successfully.

I tried it as follows:

./configure --with-ssl=/usr/local/opt/openssl@1.1

Autoconf is here:

% autoconf --version
autoconf (GNU Autoconf) 2.71
Copyright (C) 2021 Free Software Foundation, Inc.
License GPLv3+/Autoconf: GNU GPL version 3 or later
<https://gnu.org/licenses/gpl.html>, <https://gnu.org/licenses/exceptions.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Written by David J. MacKenzie and Akim Demaille.

@rickard-green
Copy link
Contributor

Regarding the autoconf 2.70/2.71 issue. From autoconf 2.70 release note:

*** Many macros no longer AC_REQUIRE as many other macros as they used to.

The above is most likely the reason why autoconf 2.70/2.71 do not play well with our configure scripts. It seems like we need to explicitly ensure that various prerequisite macros have been called before other macros are used in order to play well with 2.70/2.71. The documentation of what is prerequisite macros for, e.g., AC_EGREP_CPP, wasn't that great though, although it isn't that hard to guess egrep and preprocessor...

@APB9785
Copy link

APB9785 commented May 20, 2021

@rickard-green what is the solution to the above issue?

@rickard-green
Copy link
Contributor

@APB9785

The solution should be to not set any DED_* variables on MacOS. It should work out of the box. If it is not you setting the variables, you need to talk to the maintainer of asdf about this.

It is possible to set DED_* variables also on MacOS, but then you also need to set the DED_LDFLAGS_CONFTEST variable which will be used in the link configure tests. See the important variables inspected by configure section of HOWTO/INSTALL.md.

@deepankar-j
Copy link

Thanks @rickard-green! I'm not setting any value for DED_LDFLAGS. So, I guess it must be coming from elsewhere.

@rickard-green
Copy link
Contributor

@deepankar-j @APB9785

In both your cases one can find a directory called kerl-home in the path to the Erlang source tree, so it is very likely that both your builds use kerl underneath.

In this comment under point (2) @jj1bdx describes how to patch kerl to make it work (point (1) is not necessary for OTP 24.0.1).

@zacky1972
Copy link

zacky1972 commented May 20, 2021

Hi,

I tried to build 24.0.1 by the following command:

DED_LDFLAGS="-m64 -bundle -bundle_loader ~/.asdf/plugins/erlang/kerl-home/builds/asdf_24.0.1/otp_src_24.0.1/bin/x86_64-apple-darwin19.6.0/beam.smp" asdf install erlang 24.0.1

But I still got the following error:

ERROR: /Users/zacky/.asdf/plugins/erlang/kerl-home/builds/asdf_24.0.1/otp_src_24.0.1/lib/crypto/configure failed!

I found the directory ~/.asdf/plugins/erlang/kerl-home/builds/asdf_24.0.1/otp_src_24.0.1/bin/x86_64-apple-darwin19.6.0 is empty.

I attached the log.

otp_build_24.0.1.log

@rickard-green
Copy link
Contributor

@zacky1972 Adding that DED_LDFLAGS variable to the build wont help, quite the opposite. In this comment under point (2) @jj1bdx describes how to patch kerl to make it work (point (1) is not necessary for OTP 24.0.1).

@zacky1972
Copy link

I did it! Thank you!

@ferd
Copy link
Contributor

ferd commented May 20, 2021

I'm still getting failures as well. I ended up changing the OpenSSL path to a custom one downloaded by homebrew to bypass error: neither static nor dynamic crypto library found in /usr/local/opt/openssl@1.1 issues (went for --with-ssl=/usr/local/Cellar/openssl@1.1/1.1.1k/) but now I'm getting

=== Entering application crypto
rm -f ../ebin/crypto.beam ../ebin/crypto_ec_curves.beam ../ebin/crypto.app ../ebin/crypto.appup
rm -f errs core *~
 MAKE	clean
make[4]: x86_64-apple-darwin19.6.0/Makefile: No such file or directory
make[4]: *** No rule to make target `x86_64-apple-darwin19.6.0/Makefile'.  Stop.
make[3]: *** [clean] Error 2
make[2]: *** [clean] Error 2
make[1]: *** [clean] Error 2
make: *** [clean] Error 2
/Users/ferd/.kerl/builds/24.0.1/otp_src_24.0.1/configure  --cache-file=/dev/null CC=clang DED_LD=clang DED_LDFLAGS=-m64\ -bundle\ -bundle_loader\ /Users/ferd/\.kerl/builds/24\.0\.1/otp_src_24\.0\.1/bin/x86_64-apple-darwin19\.6\.0/beam\.smp --without-javac --with-ssl=/usr/local/Cellar/openssl@1.1/1.1.1k/ --disable-saved-compile-time --with-dynamic-trace=dtrace --enable-darwin-64bit
./otp_build: line 303: ./configure: No such file or directory

I've tried the same variation with and without the --with-ssl flag, and with and without Kenji's fix at #4821 (comment) and still can't get 24.0.1 to build on OSX.

At this point I'm mostly just giving up and developing on Linux only for my hobby stuff.

@bitwalker
Copy link
Contributor

@ferd Looks like kerl is still setting DED_* flags for you, as you can still see them in your paste. Since it's kerl setting these, it'll need to be fixed by the kerl maintainer, otherwise you'll have to patch your kerl shell scripts to omit those flags. I'm on my phone, so I'm not sure if an issue has already been opened in the kerl repo, but I'll open a PR later if there isn't one already.

@rickard-green
Copy link
Contributor

@ferd Until kerl stops passing these DED_* flags you wont be able to build OTP 24 using kerl on MacOS. Changing to another openssl installation wont help. I haven't tested Kenji's kerl fix myself, but it looks right and it seems to work for others. I don't know what is going on with your build, but I guess it tries to clean up the source tree in preparation for a new build, but fails since all makefiles aren't there due to a previous configure run that failed. I don't know how kerl handles these things, but in order to be sure that you aren't effected by old stuff from a previous build, you typically want to clean the repo with git clean -dfx (or extract the tar file from scratch) before trying again after a failed build.

@ferd
Copy link
Contributor

ferd commented May 21, 2021

yeah, I expected the fix to clear the DED_* flags. I guess something else is setting them.

@paulo-ferraz-oliveira
Copy link
Contributor

paulo-ferraz-oliveira commented May 21, 2021

I haven't tested Kenji's kerl fix myself, but it looks right and it seems to work for others.

I've updated info on the kerl issue related to this and do mention Kenji's "patch". Not sure it's the correct way forward (just disabling the whole thing), as there might be backward compatibility implications, but FWIW it's working for OTP 24.0.1 (compiling "with" kerl), even with autoconf 2.71.

@rickard-green, if we were to continue using DED_* flags, in kerl, what would be the appropriate content for DED_LDFLAGS_CONFTEST? (I'm testing with "", actually)

@rickard-green
Copy link
Contributor

rickard-green commented May 21, 2021

@paulo-ferraz-oliveira

I haven't tested Kenji's kerl fix myself, but it looks right and it seems to work for others.

I've updated info on the kerl issue related to this and do mention Kenji's "patch". Not sure it's the correct way forward (just disabling the whole thing), as there might be backward compatibility implications, but FWIW it's working for OTP 24.0.1 (compiling "with" kerl),

If I read the git history correct, you need to set these flags, as kerl does, if you build an OTP version prior to OTP 20.1. After that, setting these flags is not necessary.

even with autoconf 2.71.

It will work even without autoconf installed, since the configure scripts are present in git.

@rickard-green, if we were to continue using DED_* flags, in kerl, what would be the appropriate content for DED_LDFLAGS_CONFTEST? (I'm testing with "", actually)

You typically do not want to set these for other OTP versions than those having issues with our defaults. If you do, our changes will be overridden by yours, and you get issues like this one with kerl and OTP 24 when we make changes.

DED_LDFLAGS_CONFTEST was introduced in OTP 24, so it will have no effect prior to that.

OTPs configure will use the following on MacOS:

	darwin*)
		# Mach-O linker: a shared lib and a loadable
		# object file is not the same thing.
		DED_LDFLAGS="-bundle -bundle_loader ${ERL_TOP}/bin/$host/beam.smp"
		# DED_LDFLAGS_CONFTEST is for use in configure tests only. We
		# cannot use DED_LDFLAGS in configure tests since beam.smp has not
		# been built yet...
		DED_LDFLAGS_CONFTEST="-bundle"
		if test X${enable_m64_build} = Xyes; then
		  DED_LDFLAGS="-m64 $DED_LDFLAGS"
		else
		  if test X${enable_m32_build} = Xyes; then
		    DED_LDFLAGS="-m32 $DED_LDFLAGS"
		  else
		    AC_CHECK_SIZEOF(void *)
		    case "$ac_cv_sizeof_void_p" in
		      8)
			DED_LDFLAGS="-m64 $DED_LDFLAGS";;
		      *)
		        ;;
		    esac
		  fi
		fi
		DED_LD="$CC"
		DED_LD_FLAG_RUNTIME_LIBRARY_PATH="$CFLAG_RUNTIME_LIBRARY_PATH"

DavideSilva added a commit to subvisual/secrets.finiam.com that referenced this issue Jun 16, 2021
Why:
* Due to an issue with the installation of Erlang 24.0 in MacOS
* erlang/otp#4821

How:
* Changing the Erlang version from `24.0` to `24.0.2`
DavideSilva added a commit to subvisual/secrets.finiam.com that referenced this issue Jun 16, 2021
Why:
* Due to an issue with the installation of Erlang 24.0 in MacOS
* erlang/otp#4821

How:
* Changing the Erlang version from `24.0` to `24.0.2`
@nicnilov
Copy link

nicnilov commented Jul 6, 2021

As this also reproduces with 24.0.3 under macOS Catalina, here is the command (derived from the above), which worked for me:

DED_LDFLAGS_CONFTEST="-bundle" asdf install erlang 24.0.3

It appears, the "-bundle" part can instead be anything, just using the value from this comment.

joaohf added a commit to meta-erlang/meta-erlang that referenced this issue Aug 30, 2021
YP/OE hardknott uses autoconf 2.71 while Erlang/OTP still uses autoconf
2.69 leading to some potential problems. One of then is about the macro
AC_EGREP_CPP which expects the EGREP variable be filled.

The issue [1] has more details about the problem. For while the
erlang.inc exports the EGREP variable to fix the problem when compiling
erlang-native that was not able to find the correct Openssl libraries in
the sysroot-native folder.

Moreover, this commit also introduce the use of '--with-ssl-zlib' to fix
a potential host contamination when building for native and native-sdk.

1: erlang/otp#4821
zonque pushed a commit to zonque/meta-erlang that referenced this issue Aug 30, 2021
YP/OE hardknott uses autoconf 2.71 while Erlang/OTP still uses autoconf
2.69 leading to some potential problems. One of then is about the macro
AC_EGREP_CPP which expects the EGREP variable be filled.

The issue [1] has more details about the problem. For while the
erlang.inc exports the EGREP variable to fix the problem when compiling
erlang-native that was not able to find the correct Openssl libraries in
the sysroot-native folder.

Moreover, this commit also introduce the use of '--with-ssl-zlib' to fix
a potential host contamination when building for native and native-sdk.

1: erlang/otp#4821
joaohf added a commit to meta-erlang/meta-erlang that referenced this issue Sep 3, 2021
YP/OE hardknott uses autoconf 2.71 while Erlang/OTP still uses autoconf
2.69 leading to some potential problems. One of then is about the macro
AC_EGREP_CPP which expects the EGREP variable be filled.

The issue [1] has more details about the problem. For while the
erlang.inc exports the EGREP variable to fix the problem when compiling
erlang-native that was not able to find the correct Openssl libraries in
the sysroot-native folder.

Moreover, this commit also introduce the use of '--with-ssl-zlib' to fix
a potential host contamination when building for native and native-sdk.

1: erlang/otp#4821
joaohf added a commit to meta-erlang/meta-erlang that referenced this issue Sep 4, 2021
YP/OE hardknott uses autoconf 2.71 while Erlang/OTP still uses autoconf
2.69 leading to some potential problems. One of then is about the macro
AC_EGREP_CPP which expects the EGREP variable be filled.

The issue [1] has more details about the problem. For while the
erlang.inc exports the EGREP variable to fix the problem when compiling
erlang-native that was not able to find the correct Openssl libraries in
the sysroot-native folder.

Moreover, this commit also introduce the use of '--with-ssl-zlib' to fix
a potential host contamination when building for native and native-sdk.

1: erlang/otp#4821
joaohf added a commit to meta-erlang/meta-erlang that referenced this issue Oct 5, 2021
YP/OE hardknott uses autoconf 2.71 while Erlang/OTP still uses autoconf
2.69 leading to some potential problems. One of then is about the macro
AC_EGREP_CPP which expects the EGREP variable be filled.

The issue [1] has more details about the problem. For while the
erlang.inc exports the EGREP variable to fix the problem when compiling
erlang-native that was not able to find the correct Openssl libraries in
the sysroot-native folder.

Moreover, this commit also introduce the use of '--with-ssl-zlib' to fix
a potential host contamination when building for native and native-sdk.

1: erlang/otp#4821
@elbow-jason
Copy link

System: macOS Big Sur version 11.6 (20G165)
OTP version: 24.0
Is it Apple silicon / an M1 mac?: Yes

When attempting to install any erlang version 24.0 or above with asdf I was getting ambiguous error messages and an exit 2 after seeing many deprecation messages around openssl and RSA.

I finally found something that worked. I use this command from bitwalker's comment above, but changed the --with-ssl=$(brew --prefix openssl) to --with-ssl=$(brew --prefix openssl@1.1).

The command I used:

EGREP=egrep CC=clang CPP="clang -E" KERL_USE_AUTOCONF=0 KERL_CONFIGURE_OPTIONS="--disable-hipe --disable-sctp --enable-darwin-64bit --enable-kernel-poll --enable-shared-zlib --enable-smp-support --enable-threads --enable-wx --with-ssl=$(brew --prefix openssl@1.1) --without-docs --without-javac --without-jinterface --without-odbc" asdf install erlang 24.0

@HansN
Copy link
Contributor

HansN commented Nov 5, 2021

@elbow-jason

... many deprecation messages around openssl and RSA.

It seems as you use it with OpenSSL 3.0 which is the latest OpenSSL. OTP does not support that one yet. Since "-prefix openssl@1.1" made it work, you probably swithched to OpenSSL 1.1.1 which is the version preceeding 3.0. 1.1.1 is supported by OTP.

The OTP branches maint and master has a fix that simply removes the deprecation warnings. See issue #4577 for more information.

@jordanelbaite
Copy link

jordanelbaite commented Jan 7, 2022

Spending the last day and a half trying to install OTP v 24.1.7 to no avail, I've tried most if not all of the workarounds outline here in this thread, as well as here, here, here and here.

brew config:
HOMEBREW_VERSION: 3.3.9
ORIGIN: https://github.com/Homebrew/brew
HEAD: 96137bc19e68398ebbb7033379df288cd8b9a3f9
Last commit: 3 weeks ago
Core tap ORIGIN: https://github.com/Homebrew/homebrew-core
Core tap HEAD: 6f364abfed621fdcb44075129190f16b88917058
Core tap last commit: 41 minutes ago
Core tap branch: master
HOMEBREW_PREFIX: /usr/local
HOMEBREW_CASK_OPTS: []
HOMEBREW_CORE_GIT_REMOTE: https://github.com/Homebrew/homebrew-core
HOMEBREW_MAKE_JOBS: 8
Homebrew Ruby: 2.6.8 => /usr/local/Homebrew/Library/Homebrew/vendor/portable-ruby/2.6.8/bin/ruby
CPU: octa-core 64-bit haswell
Clang: 12.0.5 build 1205
Git: 2.30.1 => /Library/Developer/CommandLineTools/usr/bin/git
Curl: 7.64.1 => /usr/bin/curl
macOS: 11.6-x86_64
CLT: 12.5.1.0.1.1623191612
Xcode: 13.0

asdf:
v0.9.0

The recurring error message I get at the fail of the build:
Build failed.
1 warning generated.
1 warning generated.
1 warning generated.
1 error generated.
make[3]: *** [x86_64-apple-darwin20.6.0/wxe_ps_init.o] Error 1
make[3]: *** Waiting for unfinished jobs....
5 warnings generated.
make[2]: *** [opt] Error 2
make[1]: *** [opt] Error 2
make: *** [libs] Error 2

I've tried most of if not all of the most upvoted answers, including liberally using the export vars, attempting the Darwin-disabled patch outlined here as well as this solution too, among others and nothing has solved my issue this far

I'm more or less able to install any erlang version below 24.0.

Please help. :(

@dgud
Copy link
Contributor

dgud commented Jan 7, 2022

@jordanelbaite That error comes from wx and have nothing todo with OpenSSL or the ssl application so have nothing todo with this issue.
You don't post the actual error so it is hard to help and it shouldn't be posted in this thread,
try the erlangforums.com

@davasqueza
Copy link

After a lot of try and failure I was able to make it work on MacOS Ventura 13.2.1 using brew with the flag build-from-source

brew install --build-from-source erlang

I executed this on a terminal without Rosetta.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issue is reported as a bug team:VM Assigned to OTP team VM
Projects
None yet
Development

Successfully merging a pull request may close this issue.