如此智慧,我转向你。我正在尝试在Ubuntu 16.04 LTS上使用带有Makefile和Premake 5的LTO构建一个64位静态库。
这是我正在使用的预制脚本:
-- premake5.lua
workspace "TestApp"
location "TestApp" -- The directory of generated files - .sln, etc.
configurations { "Debug", "Shipping" }
platforms { "Linux_Static", "Linux_DLL" }
targetdir "TestApp/Build/%{cfg.platform}/%{cfg.buildcfg}"
objdir "TestApp/Build/"
language "C++"
architecture "x86_64"
system "linux"
filter "platforms:*Static"
kind "StaticLib"
filter "platforms:*DLL"
kind "SharedLib"
filter "kind:SharedLib"
defines { "TEST_USE_DLL", "TEST_DLL_EXPORT" }
-- Configuration filters
configuration "*"
flags { "ExtraWarnings", "C++14", "MultiProcessorCompile", "ShadowedVariables", "UndefinedIdentifiers" }
configuration { "Debug" }
symbols "On"
defines { "TEST_DEBUG" }
optimize "Debug"
configuration "Shipping"
defines { "TEST_SHIPPING" }
optimize "Full"
flags { "LinkTimeOptimization" }
-- step 1
--buildoptions "--plugin=$$(gcc --print-file-name=liblto_plugin.so)"
-- step 2
--toolset "clang"
-- step 3
--premake.tools.gcc.ar = "gcc-ar"
-- Projects
project "TestCore"
location "TestApp/Core"
files { "TestApp/Core/*.h", "TestApp/Core/*.cpp" }
includedirs { "TestApp/" }
project "UnitTests"
location "TestApp/Tests"
kind "ConsoleApp"
links { "TestCore" }
objdir "TestApp/Tests/Build/"
files { "TestApp/Tests/UnitTests/*.cpp", "TestApp/ThirdParty/Catch/*" }
includedirs { "TestApp/ThirdParty/Catch", "TestApp/" }
removedefines { "TEST_DLL_EXPORT" }
filter { "platforms:*DLL", "system:linux" }
runpathdirs { "Build/%{cfg.platform}/%{cfg.buildcfg}" }
“送货”是错误的配置。我也bundled the whole test project in a zip让你尝试重现这个问题。
编译TestCore库时出现的错误首先是plugin needed to handle lto object
,然后是plugin /usr/lib/gcc/x86_64-linux-gnu/5/liblto_plugin.so is not licensed under a GPL-compatible license
。
我们能做些什么呢?如果您有任何知识可以使其与GCC一起使用,请提供帮助。
解压缩后,您将如何重现GCC错误:
更多系统信息:
我和Clang合作了。使用toolset clang
进行送货配置(使用LLVM 3.9),库似乎编译正常。 但是我又收到了一个错误:
error adding symbols: Archive has no index; run ranlib to add one
我设法通过调用ranlib Build/Linux_Static/Shipping/libTestCore.a --plugin /usr/lib/llvm-3.9/lib/LLVMgold.so
来解决此问题,然后重新制作。
因此使用Clang很痛苦。
我读到我可以create a specific premake toolset for this kind of thing,因为建议将所有gnu utils替换为gcc-
对应物(例如gcc-ar
而不是ar
),但要快速修改premake.tools.gcc.ar = "gcc-ar"
没有结果,我不确定它会有所帮助。