Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gcc is not a valid toolset in "premake5 gmake" in dev #266

Open
jvburnes opened this issue Sep 10, 2015 · 10 comments · May be fixed by #1932
Open

gcc is not a valid toolset in "premake5 gmake" in dev #266

jvburnes opened this issue Sep 10, 2015 · 10 comments · May be fixed by #1932

Comments

@jvburnes
Copy link

A simple check of:

solution "xyzzy"
toolset "clang"

yields "CC=clang" in the generated makefiles, however:

solution "xyzzy"
toolset "gcc"

does not set CC= in the generated makefiles

This is on OSX, if it makes any difference.

@TurkeyMan
Copy link
Contributor

Is it not that GCC is the default in lieu of explicit statement?

@jvburnes
Copy link
Author

No. Some platforms (NetBSD being one) use 'clang' as their default C
compiler. They need the C compiler set to 'gcc' explicitly. That's why
you shouldn't make assumptions about that. If someone says 'toolset "gcc"'
just assume they have a good reason.

On Thu, Sep 10, 2015 at 6:27 AM, Manu Evans [email protected]
wrote:

Is it not that GCC is the default in lieu of explicit statement?


Reply to this email directly or view it on GitHub
#266 (comment)
.

@tvandijck
Copy link
Contributor

kind of goes with #248

which is essentially an incorrect fix too.... if we didn't assume any default, and simple don't set CC, my fix might not actually be needed either..

@starkos
Copy link
Member

starkos commented Sep 21, 2015

Open to suggestions on this. We'll have to store a default toolset somewhere? Or perhaps better to have a function that could be overridden?

@tvandijck
Copy link
Contributor

well, why don't we have an actual "toolset 'default'", that way the gmake backend can just not output the CC and LINK directives which basically will cause make to use whatever C compiler is active on the system.

@starkos
Copy link
Member

starkos commented Oct 6, 2015

What about a premake.config.toolset(cfg) function that returns what we think ought to be the default toolset adapter for the given configuration. It can check cfg.toolset, and then lookup the default by system or similar: Windows or Visual Studio is msc, Apple is clang…I guess this should be extensible for modules adding support for other environments?

@catb0t
Copy link
Contributor

catb0t commented Dec 26, 2017

has this been fixed?

@stefanocaronia
Copy link

as a workaround, I found this method:

makesettings [[
CC = gcc
]]

https://github.com/premake/premake-core/wiki/makesettings

@AeroSW
Copy link

AeroSW commented May 21, 2024

How do we specify makesettings in the premake5 lua file. I'm having issues getting the generated makefile to even use a "CC" argument. It keeps generating a CreateProcess that is attempting to use a command on a path that shouldn't have MinGW installed.

E:\home\Code\Czengine\CzenginePlusPlus>make CC="E:\utility\MinGW\mingw64\bin\g++.exe"
"==== Building CzenginePlusPlus (debug_win64) ===="
"czengine.cpp"
process_begin: CreateProcess(NULL, sh.exe -c "/d/Prog/winlibs64ucrt_stage/mingw64/bin/x86_64-w64-mingw32-g++.exe -MD -MP -DDEBUG -m64 -g -o obj/Win64/Debug/czengine.o -MF obj/Win64/Debug/czengine.d -c src/czengine.cpp", ...) failed.
make (e=2): The system cannot find the file specified.
make[1]: *** [CzenginePlusPlus.make:135: obj/Win64/Debug/czengine.o] Error 2
make: *** [makefile:30: CzenginePlusPlus] Error 2

It appears to think that /d/... is the path to my g++.exe, even when I specify the path manually in my make execution.
I'm using MinGW G++ compiler on Windows 11.

@AeroSW
Copy link

AeroSW commented May 21, 2024

So what I found as my problem just now is that the tool is specifying CC in the middle of the generated ${Project}.make file, but it isn't using this property anywhere. It is attempting to use a CXX variable that isn't defined in this file. I assume this "CXX" variable is what is producing the /d/Prog/winlibs64ucrt_stage/mingw64/bin/x86_64-w64-mingw32-g++.exe command above. I removed the usages of CXX from the file and replaced it with CC. This did not 100% correct the usage, but it make it such that specifying CC cmd line argument when executing make work:

Post CC Replacing CXX in ${Project}.make without specifying CC as CMD line argument

E:\home\Code\Czengine\CzenginePlusPlus>make
"==== Building CzenginePlusPlus (debug_win64) ===="
"czengine.cpp"
process_begin: CreateProcess(NULL, cc -MD -MP -DDEBUG -m64 -g -o obj/Win64/Debug/czengine.o -MF obj/Win64/Debug/czengine.d -c src/czengine.cpp, ...) failed.
make (e=2): The system cannot find the file specified.
make[1]: *** [CzenginePlusPlus.make:135: obj/Win64/Debug/czengine.o] Error 2
make: *** [makefile:30: CzenginePlusPlus] Error 2

Adding CC as CMD line argument after discovery that cc is now being printed in the CreateProcess function.

E:\home\Code\Czengine\CzenginePlusPlus>make CC="E:\utility\MinGW\mingw64\bin\g++.exe"
"==== Building CzenginePlusPlus (debug_win64) ===="
"czengine.cpp"
Creating bin/Win64/Debug
Linking CzenginePlusPlus

I see above at the top of this thread that there is a "May be fixed by #1932", but it appears that fix failed to merge due to conflicts that have yet to be resolved.

Last Update:
I dove a bit further into searching out the "CXX" issue, and came across Issue #78. It appears like a nice workaround while the default premake5 gmake2 on windows issue is unresolved. I added the listed conditional into my premake.lua file, and it worked like a charm.

.....
project "CzenginePlusPlus"
    kind "ConsoleApp"
    language "C++"
    system "Windows"
    architecture "x86_64"
    if os.execute("g++ -v") == 0 then -- <====
        toolset "g++"
    end
    files {"**.hpp","**.h","**.cpp"}
    buildcommands {
        "make %{cfg.buildcfg}"
    }
.....

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants