premake-core icon indicating copy to clipboard operation
premake-core copied to clipboard

Premake system toolset selection issue

Open tritao opened this issue 2 months ago • 5 comments

Problem

Lets take a simple of a Premake script with a library and toolset "gcc" and generate with gmake2 action.

The generated Makefile will generate with the default $(CC) and $(CXX) Make implicit variables.

From the Make documentation:

CC Program for compiling C programs; default cc. CXX Program for compiling C++ programs; default g++.

Notice is uses g++ instead of what I would expect `c++``.

On my system cc and c++ are mapped to Clang, so I end up with a weird build mixing both Clang for C and GCC for C++.

This also ends up being a problem with the premake-export-compile-commands extension. https://github.com/tritao/premake-export-compile-commands/commit/495800463587cc8fe817aefcae2d41a10c1e8b89

Even though it uses toolset.gettoolname, it ends up generating the JSON file as: command": "cxx -MD -MP

Which is wrong, since it will look for system includes with the cxx command which is Clang, while the build uses the implicit g++.

Proposed Solution

If I choose toolset "gcc", then gmake action should generate the Makefile with C = gcc and CXX = g++.

For the system compiler, a new toolset "system", can be added, default to C = ccandCXX = c++`.

Basically the gmake action should always generate explicit C and CXX rules or we may end up mixing toolsets.

@samsinsane Any thoughts on this?

tritao avatar Apr 29 '24 18:04 tritao