forked from 0ad/0ad
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:
parent
b437af833d
commit
aabab15324
@ -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" },
|
||||
|
@ -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
|
||||
|
6
build/premake/tests/execinfo.c
Normal file
6
build/premake/tests/execinfo.c
Normal file
@ -0,0 +1,6 @@
|
||||
#include <execinfo.h>
|
||||
|
||||
int main() {
|
||||
backtrace(0, 0);
|
||||
return 0;
|
||||
}
|
Loading…
Reference in New Issue
Block a user