[cfe-dev] Targets.cpp enhancement for x86, Triple enhancement

John Thompson john.thompson.jtsoftware at gmail.com
Tue Sep 15 06:46:29 PDT 2009

I submitted something like this to cfe-commits a few weeks ago, but I guess
in the release crunch it got lost.  Here's another crack at it here, as I
stopped watching the commits traffic, as it got too heavy.

It's another pass at refining Targets.cpp for Windows targets, revised for
the current repository.  From my original email:


Unfortunately, it requires some LLVM enhancements, placed in the
separate llvm_triple_enhancement.patch file:

I extended the Triple class, supporting more explicitly the optional
environment field, adding an EnvironmentType enum for that with an
item for Visual Studio (-vc), and adding a Win64 OSType.  There are
probably more environments that can be added to the EnvironmentType

Changed the default triples from cmake to be i686-pc-win32-vc and if
64-bit is enabled, x86_64-pc-win64-vc.

The Targets.cpp changes, placed in clang_targets_enhancement.patch:
Added separate TargetInfo's for Visual Studio, MinGW, and Cygwin, as
illustrated by the following hierarchy:

          CygwinWindowsX86_32TargetInfo  (i686-pc-cygwin) (new)
          WindowsX86_32TargetInfo (i686-pc-win32)
              VisualStudioWindowsX86_32TargetInfo  (i686-pc-win32-vc) (new)
              MinGWX86_32TargetInfo  (i686-pc-mingw32) (new)
          WindowsX86_64TargetInfo  (x86_64-pc-win64) (new)
              VisualStudioWindowsX86_64TargetInfo  (x86_64-pc-win64-vc)
              MinGWX86_64TargetInfo  (x86_64-pc-mingw64) (new)

Messing with the triple was of some concern to me, so I also tried an
alternate approach without adding -vc to the triple, making the
default -win32 map to Visual Studio, and having MinGW and Cygwin be
separate as above, but then I figured you might want -winXX with no
environment field to be the native Clang target for Windows, mapping
to the generic Windows TargetInfo, assuming at some point Clang has
it's own runtime and headers.  But let me know if this would be the
more desired approach.

Note that though I've tested the Targets;cpp part in the debugger,
I've not yet been able to build, and therefore, run the LLVM tests.  I
don't expect the Triple class changes to change any existing behavior,
but I have a slight worry that the change of the default triple from
cmake might impact something, but being on the apparently less-used
cmake path, perhaps it's less of a concern.  I built and ran the Clang
tests on Linux successfully.

John Thompson
John.Thompson.JTSoftware at gmail.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20090915/8e7a4f39/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: clang_targets_enhancement.patch
Type: application/octet-stream
Size: 7022 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20090915/8e7a4f39/attachment.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: llvm_triple_enhancement.patch
Type: application/octet-stream
Size: 4967 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20090915/8e7a4f39/attachment-0001.obj>

More information about the cfe-dev mailing list