Browse Source

Enable cxx11 abi for GCC 4.9+ on linux.

GCC version is checked, if version is 4.8 or lower then cxx11 ABI is disabled. Added new `--no-cxx11-abi` option. It explicitly disables cxx11 ABI even on new compilers. This option is also taken into account when building LLVM.
pull/1019/head
Rokas Kupstys 8 years ago
parent
commit
1cac2e0d78
  1. 28
      build/Helpers.lua
  2. 8
      build/scripts/LLVM.lua
  3. 6
      src/CppParser/Bindings/CSharp/premake5.lua
  4. 9
      src/CppParser/premake5.lua

28
build/Helpers.lua

@ -9,6 +9,11 @@ newoption {
} }
} }
newoption {
trigger = "no-cxx11-abi",
description = "disable cxx11 abi on gcc 4.9+"
}
explicit_target_architecture = _OPTIONS["arch"] explicit_target_architecture = _OPTIONS["arch"]
function is_64_bits_mono_runtime() function is_64_bits_mono_runtime()
@ -95,6 +100,12 @@ function SetupNativeProject()
defines { "WIN32", "_WINDOWS" } defines { "WIN32", "_WINDOWS" }
filter {} filter {}
if os.istarget("linux") then
if not UseCxx11ABI() then
defines { "_GLIBCXX_USE_CXX11_ABI=0" }
end
end
end end
function SetupManagedProject() function SetupManagedProject()
@ -164,3 +175,20 @@ function StaticLinksOpt(libnames)
links(existing_libnames) links(existing_libnames)
end end
function GccVersion()
local compiler = os.getenv("CXX")
if compiler == nil then
compiler = "gcc"
end
local out = os.outputof(compiler.." -v")
local version = string.match(out, "gcc version [0-9\\.]+")
return string.sub(version, 13)
end
function UseCxx11ABI()
if os.istarget("linux") and GccVersion() >= '4.9.0' and _OPTIONS["no-cxx11-abi"] == nil then
return true
end
return false
end

8
build/scripts/LLVM.lua

@ -181,6 +181,14 @@ function cmake(gen, conf, builddir, options)
os.chdir(builddir) os.chdir(builddir)
local cmake = os.ishost("macosx") and "/Applications/CMake.app/Contents/bin/cmake" local cmake = os.ishost("macosx") and "/Applications/CMake.app/Contents/bin/cmake"
or "cmake" or "cmake"
if options == nil then
options = ""
end
if os.istarget("linux") and _OPTIONS["no-cxx11-abi"] ~= nil then
options = options.." -DCMAKE_CXX_FLAGS='-D_GLIBCXX_USE_CXX11_ABI=0'"
end
local cmd = cmake .. " -G " .. '"' .. gen .. '"' local cmd = cmake .. " -G " .. '"' .. gen .. '"'
.. ' -DLLVM_BUILD_TOOLS=false ' .. ' -DLLVM_BUILD_TOOLS=false '
.. ' -DLLVM_ENABLE_LIBEDIT=false' .. ' -DLLVM_ENABLE_LIBEDIT=false'

6
src/CppParser/Bindings/CSharp/premake5.lua

@ -25,7 +25,11 @@ project "CppSharp.Parser.CSharp"
end end
elseif os.istarget("linux") then elseif os.istarget("linux") then
files { "x86_64-linux-gnu/**.cs" } local abi = ""
if UseCxx11ABI() then
abi = "-cxx11abi"
end
files { "x86_64-linux-gnu"..abi.."/**.cs" }
else else
print "Unknown architecture" print "Unknown architecture"
end end

9
src/CppParser/premake5.lua

@ -22,9 +22,6 @@ project "CppSharp.CppParser"
linkoptions { "/ignore:4099" } -- LNK4099: linking object as if no debug info linkoptions { "/ignore:4099" } -- LNK4099: linking object as if no debug info
end end
filter "system:linux"
defines { "_GLIBCXX_USE_CXX11_ABI=0" }
filter {} filter {}
files files
@ -65,7 +62,11 @@ project "Std-symbols"
end end
elseif os.istarget("linux") then elseif os.istarget("linux") then
files { "Bindings/CSharp/x86_64-linux-gnu/Std-symbols.cpp" } local abi = ""
if UseCxx11ABI() then
abi = "-cxx11abi"
end
files { "Bindings/CSharp/x86_64-linux-gnu"..abi.."/Std-symbols.cpp" }
else else
print "Unknown architecture" print "Unknown architecture"
end end

Loading…
Cancel
Save