Builds using different compiler versions on different user machines

44 views
Skip to first unread message

Satish K

unread,
Nov 1, 2022, 11:11:31 AM11/1/22
to tup-users
Hello,

I have several projects using different versions of the same compiler. Since Tup takes the PATH from system environment on windows, it will find the first one in the PATH that matches the name and uses it. I know that I can use different system environment variables specific to compiler version to get around this behavior.

 However, we have a simple practice of using batch files to set the Path before executing makefile. Is it possible to use batch files to set the compiler path before invoking Tup ? 

Thanks,
Satish K

Bitkicker

unread,
Mar 29, 2023, 11:28:18 PM3/29/23
to tup-users
I am using different environment variables for each compiler in my bash profile. I then import the respective variable in the respective tup variant and assign it to a variable I call COMPILER. That $(COMPILER) variable is then used in the rule. This way, each variant can create complete custom setups, including compiler options, etc. for each platform I am building.

So, for example, for OSX, it will look like this...
ifdef OSX
import PROJECT_OSX_COMPILER=gcc

COMPILER = $(PROJECT_OSX_COMPILER)

CFLAGS += -fdiagnostics-color=always
CFLAGS += -mmacosx-version-min=10.13
endif 

For Windows, for example, it will then look like this
ifdef WIN32
import PROJECT_WIN32_COMPILER=clang
import PROJECT_WIN32_SYSTEM_INCLUDE

COMPILER = $(PROJECT_WIN32_COMPILER)
OUTNAME = libogg.lib

CFLAGS += -target x86_64-pc-win32
CFLAGS += -fdeclspec
CFLAGS += -D_CRT_SECURE_NO_WARNINGS
CFLAGS += -D_CRT_NONSTDC_NO_DEPRECATE
CFLAGS += -DWIN32_LEAN_AND_MEAN

CFLAGS += -isystem "$(PROJECT_WIN32_SYSTEM_INCLUDE)"
endif

and so on...

This is not exactly what you're asking but, perhaps, it will give you an idea for a different approach.

Guido

Satish K

unread,
May 19, 2023, 11:56:01 AM5/19/23
to tup-users
This is no longer an issue once this behavior is understood. 
Running 'tup init' after removing .tup to takes the current PATH  value.

On Windows, If the PATH is set before 'tup init', it seems to find the right version of tools after that.
If the PATH is set after 'tup init', it doesn't seem to find the right version of tools.

Tup may be storing PATH in the database. I do have to mention that i run with '-no-environ-check' after 'tup init'.
It may be a side effect of not checking the environment.

Guillaume @layus Maudoux

unread,
May 19, 2023, 1:07:34 PM5/19/23
to Satish K, tup-users
I would say it is precisely the semantics of -no-environ-check: Reuse cached env vars to avoid invalidation due to changes. It also works for other end vars, but PATH is the only one that is used by default, and thus always used.
Reply all
Reply to author
Forward
0 new messages