Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 80905

Summary: Managed build assumes compiler is in PATH environment variable
Product: [Tools] CDT Reporter: Oyvind Harboe <oyvind.harboe>
Component: cdt-build-managedAssignee: Project Inbox <cdt-build-managed-inbox>
Status: RESOLVED FIXED QA Contact: Chris Recoskie <recoskie>
Severity: enhancement    
Priority: P3 CC: EclipseBug.Tracker, leh, Rekha.Deshmukh
Version: 3.0   
Target Milestone: ---   
Hardware: All   
OS: All   
Whiteboard:

Description Oyvind Harboe CLA 2004-12-14 03:31:14 EST
On machines with e.g. CygWin toolchains, the compiler isn't necessarily in the
path. This is especially true for embedded toolchains.

Also, CygWin itself isn't necessarily in the PATH environment variable(as that
can cause interoperability problems by CygWin adding thousands of new commands
that can conflict with other programs in the PATH). This makes it impossible to
add a fullpath reference to the compiler from the project(which is a terrible
idea anyway, if the project is shared with other developers via e.g. CVS). 

It occurs to me that how to invoke the compiler is not configuration information
that belongs in the project.


Øyvind
Comment 1 Doug Schaefer CLA 2004-12-14 07:35:17 EST
I'd like to see environment variables as part of the build settings. That'll let
you build for multiple environments in the same workspace without mucking with
your global environment variables. Something similar to the launcher would be great.
Comment 2 Oyvind Harboe CLA 2004-12-14 08:52:34 EST
>I'd like to see environment variables as part of the build settings. That'll let
>you build for multiple environments in the same workspace without mucking with
>your global environment variables. Something similar to the launcher would be 
>great.

Are build settings part of the project?

I.e. would they be committed to CVS and shared between developers?

Øyvind
Comment 3 Doug Schaefer CLA 2004-12-14 09:16:10 EST
Yes. They could take advantage of the path variable feature we are planning on
adding for 3.0 to make them work in team environments to deal with different
install locations.
Comment 4 PalmSource Eclipse Bug Tracker CLA 2005-04-26 17:22:00 EDT
Øyvind's comments about Cygwin's bin being in the PATH environment variable and
causing interoperability problems rings true for not just managed make but for
all Cygwin commands invoked by CDT, including standard make projects.  

Fortunately, there is a possible convenient solution to this.  All CDT
invocations of command line tools of any significance goes through the
ProcessFactory and Spawner classes.  One could patch the
ProcesFactory.addPathsToEnv() method to add paths from a defined extension
point.  The extension point could be defined for the configuration to apply to
all CDT.  A preferences page for CDT could be adding to allow the user to
add/remove/edit paths.  To make the path in the extension point portable and not
hard-coded, one could make an interface for the extension point that dynamically
provides the full path values.
Comment 5 Chris Recoskie CLA 2005-09-26 13:28:30 EDT
I would like to see this happen as part of expanded support for the MBS macros 
that were added in 3.0.  What I would like to do is create a workspace or 
project macro with my build command in it (incl full path), and then my 
command invocation uses the macro.  This way the project can remain portable 
between different folders, computers, etc.

Env var support would be nice for some people too, but in my case we actually 
have a rule that our product can't use environment variables, so I would 
definitely like to see the macro solution implmented as well.
Comment 6 Leo Treggiari CLA 2005-09-28 14:15:58 EDT
MBS 3.0 does have new functionality that can be used here.  A project or tool-
chain can provide an "environment supplier".  When it is called, it can define 
new environment variables or append/prepend/replace existing variables.  The 
scenario that led to its creation is for a tool integration to be abe to set up 
its own environment for the build.  This is particluarly important when you 
have projects that have configurations using different tool-chains or multiple 
versions of the same tool-chain.  

I agree with comment #4 that solving this issue in MBS alone is not enough.  
This is an example of why I think we need CDT-wide tool-chain definitions.  
This would provide all of the information about a tool-chain in one extension 
point, rather than inventing a new extension point every time there is a piece 
of information that multile parts of CDT need.
Comment 7 Chris Recoskie CLA 2009-05-07 13:33:57 EDT
You can do this with macros currently.  However, it's a bit of a pain because then every toolchain vendor has to create a UI to manage their own preferences so their users can specify the macro values.  See the XL C/C++ toolchain.

Things are further complicated because the user might use the same toolchain on several different machines and platforms, in which case the path will be different for potentially each project and each build configuration in it.  Heck, they may even want to specify different compilers to use from different paths on the individual file level (weird, but possible).

We need something better here.  Not sure this will be worked on any time soon though, so contributions would be welcomed.
Comment 8 Chris Recoskie CLA 2009-05-07 13:35:20 EDT
You can do this with macros currently.  However, it's a bit of a pain because then every toolchain vendor has to create a UI to manage their own preferences so their users can specify the macro values.  See the XL C/C++ toolchain.

Things are further complicated because the user might use the same toolchain on several different machines and platforms, in which case the path will be different for potentially each project and each build configuration in it.  Heck, they may even want to specify different compilers to use from different paths on the individual file level (weird, but possible).

We need something better here.  Not sure this will be worked on any time soon though, so contributions would be welcomed.
Comment 9 Leo Hippeläinen CLA 2010-02-10 13:39:19 EST
With CDT 6 I can provide compiler path from a build configuration. I do not add Cygwin or MinGW directory to the PATH but instead declare it as an environment variable, e.g., CYGWIN_PATH. Then I add to the appropriate CDT project > Properties > C/C++ Build > Environment dialogue environment variable PATH with value: ;${CYGWIN_PATH}. With this technique I can have separate build configurations for Cygwin and MinGW and invoke the correct GCC variant per build configuration. As the environment variables can be set separately in each computer, the paths need not be the same in every computer.
Comment 10 Andrew Gvozdev CLA 2013-06-30 23:49:52 EDT
(In reply to comment #9)
This technique was institutionalized in CDT 8.2 with introducing variables $CYGWIN_HOME and $MINGW_HOME by corresponding environment supplier.