[cfe-dev] Compiling a simple Win32 program
Nikola Smiljanic
popizdeh at gmail.com
Wed Jun 13 05:09:56 PDT 2012
I think there is more than one issue here.
These things are still unclear to me:
1. If both VS and MinGW are installed, which toolchain should Clang use and
how to decide?
2. How to obtain the target triple once we've selected the toolchain? Right
now Clang selects the toolchain based on the default target triple (comming
from config.h when Clang is compiled).
3. How to decide what the target platform is when using either mingw-w64 or
multiple mingw installations? For VS, toolchains for different targets are
in different directories and this is easy to detect, but I don't know how
this exactly works for MinGW/MinGW-W64. I think they have an executable for
every target?
Things I do know, at least partially:
- If multiple versions of VS are installed, Clang will select the first one
in the PATH.
- Same logic should apply for multiple MinGW/MSYS versions. "which gcc"
should give back the active toolchain. The question about the target still
remains.
- In the case of VS the target is decided based on the toolchain's
directory (the one in VC\bin targets x86, etc.)
A bit unrelated issue is the one about MinGW toolchain support inside Clang
codebase, or the lack thereof. This is why the hardcoded paths are still
needed in InitHeaderSearch. This is something that needs to be done, I had
a look into it but never found enough time to do something useful. I think
this is the first thing to work on If you're interested in better MinGW
support. For more info look here
http://lists.cs.uiuc.edu/pipermail/cfe-dev/2012-March/020235.html (see
reply from Chandler).
As for the external text files, I don't think a feature like that could be
implemented without discussing it first with larger community. Just
something to take into account if you had any plans to work on something
like this. This is just my personal impression after following the list for
some time :)
On Wed, Jun 13, 2012 at 10:15 AM, Mikael Lyngvig <mikael at lyngvig.org> wrote:
> I suggest that you don't hardwire the info into the tool but rather make
> an external text file with a list of places to search or something. Once I
> get around to it, I was planning to look into eliminating the hardwired
> paths from Clang because they are only marginally useful on Windows and are
> very likely to cause all sorts of unexpected behavior - if, for instance,
> the user has multiple version of Mingw installed (I have both Mingw32 and
> Mingw64 installed). Luckily, I decided to name my Mingw32 installation
> that: C:\Mingw32. Otherwise, Clang would have made use of Mingw32 features
> even though it was built as a 64-bit compiler that should only make use of
> Mingw64. Perhaps a new option, "-basedir" or something, should be added so
> the user can explicitly specify what directory to use as the base directory
> for include file and library searches.
>
>
> 2012/6/13 Nikola Smiljanic <popizdeh at gmail.com>
>
>> MinGW users should be in the clear since GnuWin32 only collides with
>> link.exe from VS, or so I think. The question is how to decide whether to
>> search for msvc or mingw, but this is where the default triple comes into
>> play?
>>
>>
>> On Wed, Jun 13, 2012 at 9:59 AM, Mikael Lyngvig <mikael at lyngvig.org>wrote:
>>
>>> Hehe, what if the user prepends the GnuWin32 tools or MSYS to the path
>>> AFTER having run vcvarsall.bat? Anyway, I figure that most LLVM users are
>>> bright enough that they'll figure it out quickly.
>>>
>>>
>>> 2012/6/13 Michael Spencer <bigcheesegs at gmail.com>
>>>
>>>> On Tue, Jun 12, 2012 at 8:09 PM, Mikael Lyngvig <mikael at lyngvig.org>
>>>> wrote:
>>>> > Just be aware that GnuWin32 includes a link.exe command, which creates
>>>> > symbolic or hard links (not sure which). It is part of GNU
>>>> coreutils. So
>>>> > if the user sets up an environment to use GnuWin32 and Mingw32, so as
>>>> to be
>>>> > able to run the llvm test suite, you'll bug into this one.
>>>>
>>>> vcvars prepends it's paths to PATH, so it will not find gnuwin32 or
>>>> mingw/msys link.
>>>>
>>>> - Michael Spencer
>>>>
>>>> > 2012/6/12 Nikola Smiljanic <popizdeh at gmail.com>
>>>> >>
>>>> >> It will search the path to find the first link.exe. The one from
>>>> Visual
>>>> >> Studio should be first if Command prompt or vcvars.bat are used.
>>>> >>
>>>> >>
>>>> >> On Tue, Jun 12, 2012 at 2:23 PM, Kim Gräsman <kim.grasman at gmail.com>
>>>> >> wrote:
>>>> >>>
>>>> >>>
>>>> >>> That sounds like it would match my expectations for behavior, good
>>>> idea!
>>>> >>>
>>>> >>> Can you have it fall back on %PATH% if no VS environment variables
>>>> are
>>>> >>> found?
>>>> >>>
>>>> >>> Thanks,
>>>> >>> - Kim
>>>>
>>>
>>
>
>
> --
> -- Love Thy Frog!
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20120613/ea74444a/attachment.html>
More information about the cfe-dev
mailing list