Detect the need for libexecinfo in premake. This is mostly useful for musl Linux.

Patch By: nephele
Differential Revision: https://code.wildfiregames.com/D2671
This was SVN commit r23787.
This commit is contained in:
Nicolas Auvray 2020-06-23 15:06:57 +00:00
parent b437af833d
commit aabab15324
3 changed files with 31 additions and 10 deletions

View File

@ -168,6 +168,7 @@
{ "nick": "myconid" },
{ "nick": "nani", "name": "S. N." },
{ "nick": "nd3c3nt", "name": "Gavin Fowler" },
{ "nick": "nephele" },
{ "nick": "Nescio" },
{ "nick": "niektb", "name": "Niek ten Brinke" },
{ "nick": "njm" },

View File

@ -90,6 +90,19 @@ else
end
end
-- Test whether we need to link libexecinfo.
-- This is mostly the case on musl systems, as well as on BSD systems : only glibc provides the
-- backtrace symbols we require in the libc, for other libcs we use the libexecinfo library.
local link_execinfo = false
if os.istarget("bsd") then
link_execinfo = true
elseif os.istarget("linux") then
local _, link_errorCode = os.outputof(cc .. " ./tests/execinfo.c -o /dev/null")
if link_errorCode ~= 0 then
link_execinfo = true
end
end
-- Set up the Workspace
workspace "pyrogenesis"
targetdir(rootdir.."/binaries/system")
@ -1005,16 +1018,17 @@ function setup_main_exe ()
links { "log" }
end
if link_execinfo then
links {
"execinfo"
}
end
if os.istarget("linux") or os.getversion().description == "GNU/kFreeBSD" then
links {
-- Dynamic libraries (needed for linking for gold)
"dl",
}
elseif os.istarget("bsd") then
links {
-- Needed for backtrace* on BSDs
"execinfo",
}
end
-- Threading support
@ -1380,6 +1394,11 @@ function setup_tests()
elseif os.istarget("linux") or os.istarget("bsd") then
if link_execinfo then
links {
"execinfo"
}
end
if not _OPTIONS["android"] and not (os.getversion().description == "OpenBSD") then
links { "rt" }
end
@ -1394,11 +1413,6 @@ function setup_tests()
-- Dynamic libraries (needed for linking for gold)
"dl",
}
elseif os.istarget("bsd") then
links {
-- Needed for backtrace* on BSDs
"execinfo",
}
end
-- Threading support

View File

@ -0,0 +1,6 @@
#include <execinfo.h>
int main() {
backtrace(0, 0);
return 0;
}