mirror of
https://github.com/correl/rebar.git
synced 2024-12-18 03:00:17 +00:00
Use external wordsize to get emulator build arch
Calling erlang:system_info(wordsize) yields the internal word size of the Erlang emulator. But due to the halfword emulator, need to pass {wordsize, external} instead to get the word size, or pointer size, as seen by external code such as NIFs. The halfword emulator has 4 byte internal words but 8 byte external words due to 64-bit compilation, which means NIFs for the halfword emulator also have to be compiled 64-bit. But just passing wordsize is equivalent to passing {wordsize, internal}, which does not indicate the pointer size for the halfword emulator. Older versions of Erlang do not support {wordsize, external}, though, so continue to pass just wordsize for those versions.
This commit is contained in:
parent
aef6c70f59
commit
0bbb2985f0
3 changed files with 17 additions and 3 deletions
|
@ -52,7 +52,8 @@
|
||||||
%%
|
%%
|
||||||
%% OtpRelease = erlang:system_info(otp_release).
|
%% OtpRelease = erlang:system_info(otp_release).
|
||||||
%% SysArch = erlang:system_info(system_architecture).
|
%% SysArch = erlang:system_info(system_architecture).
|
||||||
%% Words = integer_to_list(8 * erlang:system_info(wordsize)).
|
%% Words = integer_to_list(8 *
|
||||||
|
%% erlang:system_info({wordsize, external})).
|
||||||
%%
|
%%
|
||||||
%% E.g. to define HAVE_SENDFILE only on systems with
|
%% E.g. to define HAVE_SENDFILE only on systems with
|
||||||
%% sendfile(), to define BACKLOG on Linux/FreeBSD as 128,
|
%% sendfile(), to define BACKLOG on Linux/FreeBSD as 128,
|
||||||
|
|
|
@ -398,7 +398,14 @@ default_env() ->
|
||||||
{"DRV_LDFLAGS", "-shared $ERL_LDFLAGS"},
|
{"DRV_LDFLAGS", "-shared $ERL_LDFLAGS"},
|
||||||
{"darwin", "DRV_LDFLAGS",
|
{"darwin", "DRV_LDFLAGS",
|
||||||
"-bundle -flat_namespace -undefined suppress $ERL_LDFLAGS"},
|
"-bundle -flat_namespace -undefined suppress $ERL_LDFLAGS"},
|
||||||
{"ERLANG_ARCH", integer_to_list(8 * erlang:system_info(wordsize))},
|
{"ERLANG_ARCH",
|
||||||
|
try erlang:system_info({wordsize, external}) of
|
||||||
|
Val ->
|
||||||
|
integer_to_list(8 * Val)
|
||||||
|
catch
|
||||||
|
error:badarg ->
|
||||||
|
integer_to_list(8 * erlang:system_info(wordsize))
|
||||||
|
end},
|
||||||
{"ERLANG_TARGET", rebar_utils:get_arch()},
|
{"ERLANG_TARGET", rebar_utils:get_arch()},
|
||||||
|
|
||||||
%% Solaris specific flags
|
%% Solaris specific flags
|
||||||
|
|
|
@ -62,7 +62,13 @@ is_arch(ArchRegex) ->
|
||||||
end.
|
end.
|
||||||
|
|
||||||
get_arch() ->
|
get_arch() ->
|
||||||
Words = integer_to_list(8 * erlang:system_info(wordsize)),
|
Words = try erlang:system_info({wordsize, external}) of
|
||||||
|
Val ->
|
||||||
|
integer_to_list(8 * Val)
|
||||||
|
catch
|
||||||
|
error:badarg ->
|
||||||
|
integer_to_list(8 * erlang:system_info(wordsize))
|
||||||
|
end,
|
||||||
erlang:system_info(otp_release) ++ "-"
|
erlang:system_info(otp_release) ++ "-"
|
||||||
++ erlang:system_info(system_architecture) ++ "-" ++ Words.
|
++ erlang:system_info(system_architecture) ++ "-" ++ Words.
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue