jiffy 1.1.2 double-conversion error on mac os when compiling
System: MacOS Sequoia 15.5 (24F74) Erlang Version: Erlang/OTP 26 installed via homebrew. I cannot use v 27 or 28 as amqp_client dep uses rabbit_common which only runs under OTP 26 at the moment.
I'm getting the following compiler error (in doubles.cc) when trying to run rebar3 compile for my erlang app:
In file included from c_src/double-conversion/double-conversion.h:31:
c_src/double-conversion/utils.h:31:10: fatal error: 'cstdlib' file not found
31 | #include <cstdlib>
| ^~~~~~~~~
1 error generated.
It managed to compile other c binaries:
===> Compiling c_src/decoder.c
===> Compiling c_src/encoder.c
===> Compiling c_src/jiffy.c
===> Compiling c_src/termstack.c
===> Compiling c_src/utf8.c
===> Compiling c_src/util.c
I have tried installed gcc via homebrew thinking that I may have a problem finding the cstdlib file but the error persists. When I run gcc --version I get:
Apple clang version 17.0.0 (clang-1700.0.13.5)
Target: arm64-apple-darwin24.5.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin
My rebar.config looks like this:
{erl_opts, [debug_info]}.
{deps, [
{cowboy, "2.12.0"},
{amqp_client, "4.0.3"},
{hackney, "1.24.1"},
{uuid, {git, "https://github.com/okeuday/uuid.git", {tag,"v2.0.7"}}},
{jsx, "3.1.0"},
{jiffy, "1.1.2"}
]}.
{relx, [{release, {dev, "0.3.0"},
[testapp]},
{mode, prod},
{dev_mode, false},
{include_erts, true},
{extended_start_script, true}]}.
{shell, [
% {config, "config/sys.config"},
{apps, [testapp]}
]}.
I'm at a loss as to how to compile jiffy. Any help much appreciated.
That's an odd error. I don't have a MacOS Sequoia to reproduce it, but it does compile for me on 14.7.6 (Sonoma) with Intel.
I can run a make check after git clean -xffd
I don't have gcc installed. I believe clang from CommandLineTools just aliases to gcc.
gcc --version
Apple clang version 16.0.0 (clang-1600.0.26.6)
Target: x86_64-apple-darwin23.6.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin
Maybe if you recently updated your OS, try to reinstall CommandLineTools I had to do that a few times in the past.
jiffy reads the CC variable for the compiler, I didn't have it set, so it picks up the default cc (same as gcc same i.e. clang basically). See if you set CC, or maybe some other projects or dependencies alter or update any pc (port compiler) flags and it affects jiffy?
https://github.com/davisp/jiffy/blob/50daa80a62a97ffb6dd46ea9cb8ccb4930cbf1ae/rebar.config.script#L22-L24
Thanks for the quick reply. I'll try reinstalling command line tools; I'll also try and compile an app that only has jiffy as a dependency and see if I get the same error. I have managed to get the app running in a docker container on Erlang/OTP 26 so I can use that for now.
I removed the homebrew version of gcc and re-installed xcode command line tools. I also removed all other deps and tried to recompile but am still getting the same error.
Thanks for trying it out @cliveyg, much appreciated. I'll have to find or ask someone with an arm-based mac machine to reproduce it.
In then meantime I wonder if just cloning jiffy by itself and running make check would work? You may need to also have rebar installed for it.
If that works but your project doesn't, would you be able to create a simple example project using jiffy as a single dependency so it easy enough to point someone with an arm mac machine at to give it a try.