cluac99premake

Using clang and trying to generate a visual studio solution with premake doesn't compile with "llvm-lib.exe exited with code 1"


I have 2 premake files 1 for my renderer, and one for my engine but when I generate a vs2022 solution via the command premake5 vs2022 trying to build said solution hits me with a error

I would like to know why this behavior happens, as building on the command line (with gmake) works perfectly fine, and being able to build in VS would greatly increase the productivity of debugging

Here are the aforementioned solution files

workspace "Wrenderer"
configurations { "Debug", "Release"}
project "Wrenderer"
    language "C"
    targetname "Wrenderer"
    architecture "x64"
    kind "StaticLib"
    outputdir = "%{cfg.system}-%{cfg.architecture}/%{cfg.buildcfg}"

    toolset "clang"
    cdialect "C99"

    targetdir("%{wks.location}/Binaries/" .. outputdir .. "/%{prj.name}")
    objdir("%{wks.location}/Binaries/Intermediates/" .. outputdir .. "/%{prj.name}")
    files { "include/**.h", "src/**.c" }
    libdirs { "./libs/" }
    includedirs { "./include/" }
    includedirs { "./include/libs/" }
    includedirs { os.getenv("VULKAN_SDK") .. "/Include" }
    buildoptions { "-Wextra -Wall" }
    links { "vulkan-1", "glfw3" }
    removefiles { "test/**.**" }
    filter "configurations:Debug"
        defines { "DEBUG" }
        symbols "On"
    filter ""
    filter "configurations:Release"
        optimize "On"
    filter ""
    filter "system:windows"
        links { "user32", "msvcrt", "gdi32", "shell32", "libcmt" }
        defines { "VK_USE_PLATFORM_WIN32_KHR" }
    filter ""
    filter "system:linux"
        defines { "VK_USE_PLATFORM_XLIB_KHR" }
    filter ""
    filter "action:gmake"
        prebuildcommands {

            "mkdir -p" .. " %[%{wks.location}/Binaries/]",
            "mkdir -p" .. " %[%{wks.location}/Binaries/Intermediates/]",

            "mkdir -p" .. " %[%{wks.location}/Binaries/" .. outputdir .. "]",
            "mkdir -p" .. " %[%{wks.location}/Binaries/Intermediates/" .. outputdir .. "]",
        }
    filter ""
    filter "not action:gmake"
        prebuildcommands {

            "{MKDIR}" .. " %[%{wks.location}/Binaries/]",
            "{MKDIR}" .. " %[%{wks.location}/Binaries/Intermediates/]",

            "{MKDIR} %[%{wks.location}/Binaries/" .. outputdir .. "]",
            "{MKDIR} %[%{wks.location}/Binaries/Intermediates/" .. outputdir .. "]",
        }
    filter ""
    project "WrenTest"
        architecture "x64"
        kind "ConsoleApp"  
        language "C"   

        files { "**.h", "test/**.c" }
        outputdir = "%{cfg.system}-%{cfg.architecture}/%{cfg.buildcfg}"

        toolset "clang"
        cdialect "C99"
    
        targetdir("%{wks.location}/Binaries/" .. outputdir .. "/%{prj.name}")
        objdir("%{wks.location}/Binaries/Intermediates/" .. outputdir .. "/%{prj.name}")

        libdirs { "./libs/" }
        includedirs { "./include/" }
        includedirs { "./include/libs/" }
        includedirs { os.getenv("VULKAN_SDK") .. "/Include" }
        links { "Wrenderer" }
        buildoptions { "-Wextra -Wall" }
        links { "vulkan-1", "glfw3" }

        filter "configurations:Debug"
            defines { "DEBUG" }
            symbols "On"
            sanitize { "Address", "Fuzzer" }
        filter ""
        filter "configurations:Release"
            optimize "On"
        filter ""
        filter "system:windows"
            links { "user32", "msvcrt", "gdi32", "shell32", "libcmt" }
            defines { "VK_USE_PLATFORM_WIN32_KHR" }
        filter ""
        filter "system:linux"
            defines { "VK_USE_PLATFORM_XLIB_KHR" }
        filter ""
newaction {
    trigger     = "clean",
    description = "clean the software",
    execute     = function ()
       print("Cleaning")
       os.rmdir("./Binaries")
       os.remove("./Lib/*.lib")
       os.remove("*.make")
       os.remove("Makefile")
       os.remove("*.vcxproj")
       os.remove("*.vcxproj.filters")
       os.remove("*.vcxproj.user")
       os.remove("*.sln")
       print("done.")
    end
}

and the one for the engine

workspace "Wrenderer"
project "Wrengine"
    language "C"
    targetname "Wrengine"
    architecture "x64"
    outputdir = "%{cfg.system}-%{cfg.architecture}/%{cfg.buildcfg}"
    kind "ConsoleApp"
    toolset "clang"
    cdialect "C99"

    targetdir("%{wks.location}/Binaries/" .. outputdir .. "/%{prj.name}")
    objdir("%{wks.location}/Binaries/Intermediates/" .. outputdir .. "/%{prj.name}")
    files { "include/**.h", "src/**.c" }
    libdirs { "./libs/" }
    includedirs { "./include/" }
    includedirs { "./Wrenderer/include/" }
    includedirs { "./include/libs/" }
    includedirs { os.getenv("VULKAN_SDK") .. "/Include" }
    libdirs { os.getenv("VULKAN_SDK") .. "/Lib" }
    buildoptions { "-Wextra -Wall" }
    links { "vulkan-1", "glfw3" }
    links { "Wrenderer" }

    filter "configurations:Debug"
        defines { "DEBUG" }
        symbols "On"
        sanitize {"Address"}
    filter ""
    filter "configurations:Release"
        optimize "On"
    filter ""
    filter "system:windows"
        links { "user32", "msvcrt", "gdi32", "shell32", "libcmt" }
        defines { "VK_USE_PLATFORM_WIN32_KHR" }
    filter ""
    filter "system:linux"
        defines { "VK_USE_PLATFORM_XLIB_KHR" }
    filter ""
    filter "action:gmake"
    filter ""

    prebuildcommands {
        "compileShaders.bat"
    }
include "Wrenderer/premake5.lua"

my file tree looks like so
file tree

from what I've been messing around with it sort of looks like its trying to force the msvc c standard on it, which might contribute to the issue, but still evades me


Solution

  • The answer was just to suck it up and switch to msvc for the vs2022 profile

    workspace "Wrenderer"
    configurations { "Debug", "Release"}
    project "Wrenderer"
        language "C"
        targetname "Wrenderer"
        architecture "x64"
        kind "StaticLib"
        outputdir = "%{cfg.system}-%{cfg.architecture}/%{cfg.buildcfg}"
    
        cdialect "C99"
    
        targetdir("%{wks.location}/Binaries/" .. outputdir .. "/%{prj.name}")
        objdir("%{wks.location}/Binaries/Intermediates/" .. outputdir .. "/%{prj.name}")
        files { "include/**.h", "src/**.c" }
        libdirs { "./libs/" }
        includedirs { "./include/" }
        includedirs { "./include/libs/" }
        includedirs { os.getenv("VULKAN_SDK") .. "/Include" }
        links { "vulkan-1", "glfw3" }
        removefiles { "test/**.**" }
        filter "configurations:Debug"
            defines { "DEBUG" }
            symbols "On"
        filter ""
        filter "configurations:Release"
            optimize "On"
        filter ""
        filter "system:windows"
            defines { "VK_USE_PLATFORM_WIN32_KHR" }
        filter ""
        filter "system:linux"
            defines { "VK_USE_PLATFORM_XLIB_KHR" }
        filter ""
        filter "action:gmake"
        prebuildcommands {
    
            "mkdir -p" .. " %[%{wks.location}/Binaries/]",
            "mkdir -p" .. " %[%{wks.location}/Binaries/Intermediates/]",
    
            "mkdir -p" .. " %[%{wks.location}/Binaries/" .. outputdir .. "]",
            "mkdir -p" .. " %[%{wks.location}/Binaries/Intermediates/" .. outputdir .. "]",
        }
        filter "not action:gmake"
            prebuildcommands {
    
                "{MKDIR}" .. " %[%{wks.location}/Binaries/]",
                "{MKDIR}" .. " %[%{wks.location}/Binaries/Intermediates/]",
    
                "{MKDIR} %[%{wks.location}/Binaries/" .. outputdir .. "]",
                "{MKDIR} %[%{wks.location}/Binaries/Intermediates/" .. outputdir .. "]",
            }
        filter ""
        filter "action:gmake"
        toolset "clang"
        buildoptions {"-Wextra", "-Wall"}
    
        filter "not action:gmake"
        toolset "msc"
        filter""
    
    project "WrenTest"
            architecture "x64"
            kind "ConsoleApp"  
            language "C"   
    
            files { "**.h", "test/**.c" }
            outputdir = "%{cfg.system}-%{cfg.architecture}/%{cfg.buildcfg}"
    
            cdialect "C99"
        
            targetdir("%{wks.location}/Binaries/" .. outputdir .. "/%{prj.name}")
            objdir("%{wks.location}/Binaries/Intermediates/" .. outputdir .. "/%{prj.name}")
    
            libdirs { "./libs/" }
            includedirs { "./include/" }
            includedirs { "./include/libs/" }
            includedirs { os.getenv("VULKAN_SDK") .. "/Include" }
            links { "Wrenderer" }
            links { "vulkan-1", "glfw3" }
    
            filter "configurations:Debug"
                defines { "DEBUG" }
                symbols "On"
            filter ""
            filter "configurations:Release"
                optimize "On"
            filter ""
            filter "system:windows"
                defines { "VK_USE_PLATFORM_WIN32_KHR" }
            filter ""
            filter "system:linux"
                defines { "VK_USE_PLATFORM_XLIB_KHR" }
            filter ""
    
            filter "action:gmake"
            toolset "clang"
            buildoptions {"-Wextra", "-Wall"}
            links { "user32", "msvcrt", "gdi32", "shell32", "libcmt" }
            filter "not action:gmake"
            toolset "msc"
            filter ""
    newaction {
        trigger     = "clean",
        description = "clean the software",
        execute     = function ()
           print("Cleaning")
           os.rmdir("./Binaries")
           os.remove("./Lib/*.lib")
           os.remove("*.make")
           os.remove("Makefile")
           os.remove("*.vcxproj")
           os.remove("*.vcxproj.filters")
           os.remove("*.vcxproj.user")
           os.remove("*.sln")
           print("done.")
        end
    }
    
    workspace "Wrenderer"
    project "Wrengine"
        language "C"
        targetname "Wrengine"
        architecture "x64"
        outputdir = "%{cfg.system}-%{cfg.architecture}/%{cfg.buildcfg}"
        kind "ConsoleApp"
        cdialect "C99"
    
        targetdir("%{wks.location}/Binaries/" .. outputdir .. "/%{prj.name}")
        objdir("%{wks.location}/Binaries/Intermediates/" .. outputdir .. "/%{prj.name}")
        files { "include/**.h", "src/**.c" }
        libdirs { "./libs/" }
        includedirs { "./include/" }
        includedirs { "./Wrenderer/include/" }
        includedirs { "./include/libs/" }
        includedirs { os.getenv("VULKAN_SDK") .. "/Include" }
        libdirs { os.getenv("VULKAN_SDK") .. "/Lib" }
        links { "vulkan-1", "glfw3" }
        links { "Wrenderer" }
    
        filter "configurations:Debug"
            defines { "DEBUG" }
            symbols "On"
        filter ""
        filter "configurations:Release"
            optimize "On"
        filter ""
        filter "system:windows"
            defines { "VK_USE_PLATFORM_WIN32_KHR" }
        filter ""
        filter "system:linux"
            defines { "VK_USE_PLATFORM_XLIB_KHR" }
        filter ""
    
        prebuildcommands {
            "compileShaders.bat"
        }
    
        filter "action:gmake"
        toolset "clang"
        links { "user32", "msvcrt", "gdi32", "shell32", "libcmt" }
        buildoptions {"-Wextra", "-Wall"}
        filter "not action:gmake"
        toolset "msc"
        filter ""
    
    include "Wrenderer/premake5.lua"