Commit Graph

1743 Commits

Author SHA1 Message Date
Chad Rosier 9c76d24f9c [frontend] Fix how the frontend handles -fno-inline. AFAIK clang now matches
the behavior of gcc with respect to the -fno-inline and -fno-inline-functions
flags.

llvm-svn: 152861
2012-03-15 22:31:42 +00:00
David Blaikie ebcbe4b6aa Reapply r152745 (reverted in 152765) now that compiler-rt is fixed.
Original commit message:

Provide -Wnull-conversion separately from -Wconversion.

Like GCC, provide a NULL conversion to non-pointer conversion as a separate
flag, on by default. GCC's flag is "conversion-null" which we provide for
cross compatibility, but in the interests of consistency (with
-Wint-conversion, -Wbool-conversion, etc) the canonical Clang flag is called
-Wnull-conversion.

Patch by Lubos Lunak.
Review feedback by myself, Chandler Carruth, and Chad Rosier.

llvm-svn: 152774
2012-03-15 04:50:32 +00:00
Chad Rosier 2860fbb747 Revert r152745 as it's breaking the internal buildbots.
Abbreviated commit message:
Provide -Wnull-conversion separately from -Wconversion.

llvm-svn: 152765
2012-03-15 01:00:38 +00:00
David Blaikie 1ce8dbb93f Provide -Wnull-conversion separately from -Wconversion.
Like GCC, provide a NULL conversion to non-pointer conversion as a separate
flag, on by default. GCC's flag is "conversion-null" which we provide for
cross compatibility, but in the interests of consistency (with
-Wint-conversion, -Wbool-conversion, etc) the canonical Clang flag is called
-Wnull-conversion.

Patch by Lubos Lunak.
Review feedback by myself, Chandler Carruth, and Chad Rosier.

llvm-svn: 152745
2012-03-14 22:28:22 +00:00
Chad Rosier 864dfe11bd [driver] Clang should report an error for -faltivec on non-ppc.
rdar://10963572

llvm-svn: 152684
2012-03-13 23:45:51 +00:00
Chad Rosier d6f716ab2a [driver] Parse diagnostic args in the driver.
Previously, only diagnostics thrown by the cc1 process were
actually honoring the diagnostic options given on the command line,
like -Werror.

Reuse the existing code in Frontend currently used for cc1,
adjusting it to not interpret -Wl, linker flags as warnings.

Also fix a faulty test exposed by this change.
It wasn't actually testing anything, and was giving this warning:

clang-3: warning: argument unused during compilation: '-verify'

Which -Werror didn't turn into an error because it was output
by the driver, not the cc1 process, and diagnostic options
weren't parsed by the driver. And you couldn't see the warning
when running the test suite.

Fixes PR12181.
Patch by Dylan Noblesmith <nobled@dreamwidth.org>.

llvm-svn: 152660
2012-03-13 20:09:56 +00:00
David Chisnall ddc4c9d0a7 Tweak linkage order for solaris.
llvm-svn: 152627
2012-03-13 14:14:54 +00:00
NAKAMURA Takumi b5ee8a6deb [msvc] Honor %INCLUDE%. It should know essential search paths with vcvarsall.bat.
FYI,

On VS10, %INCLUDE% contains;
(VS10)\VC\INCLUDE
(VS10)\VC\ATLMFC\INCLUDE
(SDK70A)\include

On VS11,
(VS11)\VC\INCLUDE
(VS11)\VC\ATLMFC\INCLUDE
(SDK80)\include\shared
(SDK80)\include\um
(SDK80)\include\winrt

FIXME: It may be enabled also on mingw.
llvm-svn: 152589
2012-03-13 00:02:21 +00:00
Bill Wendling c0938f3fdb Address some of the concerns by Chandler.
* s/AddDirectoryList/addDirectoryList/
* Move the call to ::getenv into the function.
* FileCheck-ize the testcase.

llvm-svn: 152583
2012-03-12 22:10:06 +00:00
Bill Wendling adbeb9f38d Update FIXME.
llvm-svn: 152579
2012-03-12 21:24:57 +00:00
Bill Wendling 281ca2917b Have clang pay attention to the LIBRARY_PATH environment variable.
The LIBRARY_PATH environment variable should be honored by clang. Have the
driver pass the directories to the linker.
<rdar://problem/9743567> and PR10296.

llvm-svn: 152578
2012-03-12 21:22:35 +00:00
Benjamin Kramer ddefa6d925 Use VersionTuple to manage macosx versions in the driver. No functionality change.
llvm-svn: 152504
2012-03-10 20:55:36 +00:00
Nico Weber 97bd94bd98 Update comment after r152140. Clarify a bit too.
llvm-svn: 152441
2012-03-09 21:19:44 +00:00
Anna Zaks 0af3e06ff6 [analyzer] Rework inlining related command line options.
- Remove -analyzer-inline-call.
 - Add -analyzer-ipa=[none|inlining]
 - Add -analyzer-inlining-mode to allow experimentation for
different performance tuning methods.

llvm-svn: 152351
2012-03-08 23:16:35 +00:00
Rafael Espindola c41db927f3 Implement -fno-dwarf2-cfi-asm on linux too.
llvm-svn: 152316
2012-03-08 14:39:55 +00:00
Chad Rosier bee5a1df03 [driver] Don't try to generate diagnostic information for linker crashes.
rdar://10993648

llvm-svn: 152180
2012-03-07 00:30:40 +00:00
Chad Rosier 1aeb15adf5 Whitespace.
llvm-svn: 152159
2012-03-06 23:14:35 +00:00
Chad Rosier 64d6be979f [driver] What was implemented in r152130 was actually -fno-inline-functions, not
-fno-inline.
Part of rdar://10972766

llvm-svn: 152145
2012-03-06 21:17:19 +00:00
Ted Kremenek f7639e1b4a Add new code migrator support for migrating existing Objective-C code to use
the new Objective-C NSArray/NSDictionary/NSNumber literal syntax.

This introduces a new library, libEdit, which provides a new way to support
migration of code that improves on the original ARC migrator.  We now believe
that most of its functionality can be refactored into the existing libraries,
and thus this new library may shortly disappear.

llvm-svn: 152141
2012-03-06 20:06:33 +00:00
Ted Kremenek d151dde0e6 Enable default @synthesize by default.
llvm-svn: 152140
2012-03-06 20:06:15 +00:00
Ted Kremenek e65b086e07 Add clang support for new Objective-C literal syntax for NSDictionary, NSArray,
NSNumber, and boolean literals.  This includes both Sema and Codegen support.
Included is also support for new Objective-C container subscripting.

My apologies for the large patch.  It was very difficult to break apart.
The patch introduces changes to the driver as well to cause clang to link
in additional runtime support when needed to support the new language features.

Docs are forthcoming to document the implementation and behavior of these features.

llvm-svn: 152137
2012-03-06 20:05:56 +00:00
Chad Rosier 806031896d [driver] Add support for -fno-inline.
rdar://10972766

llvm-svn: 152130
2012-03-06 18:49:20 +00:00
Anna Zaks d5c3027473 [analyzer] Turn inlining on by default for better testing exposure.
Fix a test, which was most likely an unintended recursive call.

llvm-svn: 151848
2012-03-01 22:37:46 +00:00
Kostya Serebryany 28a7a1198b Add a flag -fthread-sanitizer.
This flag enables ThreadSanitizer instrumentation committed to llvm as r150423.
The patch includes one test for -fthread-sanitizer and one similar test for -faddress-sanitizer.
This patch does not modify the linker flags (as we do it for -faddress-sanitizer) because the run-time library is not yet
committed and it's structure in compiler-rt is not 100% clear.
The users manual wil be changed in a separate commit.

llvm-svn: 151846
2012-03-01 22:27:08 +00:00
David Chisnall 272a071d65 Add -C when linking on Solaris so that the error messages are understandable by actual humans.
llvm-svn: 151726
2012-02-29 15:06:12 +00:00
Argyrios Kyrtzidis 3dbeb55874 [driver] Emit an error when trying to use ARC on macosx earlier than 10.6
rdar://10459258

llvm-svn: 151706
2012-02-29 03:43:52 +00:00
David Chisnall c73fb894af Add -lm by default on Solaris.
llvm-svn: 151653
2012-02-28 20:06:45 +00:00
David Chisnall e0a7c28627 It turns out -fno-cxa-atexit just produces broken code, so disable it on Solaris and we'll ship a __cxa_atexit implementation...
llvm-svn: 151648
2012-02-28 19:15:06 +00:00
David Chisnall 0c52c0f0fd Some more Solaris fixes. Now successfully building libc++ on Solaris with clang (and linking clang against it).
llvm-svn: 151632
2012-02-28 17:10:04 +00:00
Jim Grosbach 2e16624291 Re-enable the Darwin ARM integrated assembler.
All known nightly-test failures are fixed.

llvm-svn: 151595
2012-02-27 23:55:25 +00:00
Chandler Carruth 2e9d731761 A follow-up to r151482 which added support for powerpc and powerpc64
Debian multiarch libraries, this should in theory add support for those
platform's header search rules. I don't have a system to check this
with, so review appreciated. I've added the corresponding tests
referring to the debian multiarch tree.

We are starting to have a relatively completely tested Linux platform
for header search and library search, with several interesting
peculiarities. We should point people at the debian_multiarch_tree when
suggesting new tests. Folks with Debian systems that can check this for
correctness, it would be much appreciated. The missing chunks I know of
are testing bi-arch peudo-cross-compiling toolchains betwen 32-bit and
64-bit variants of platforms, and the MIPS and ARM Debian toolchains.

llvm-svn: 151484
2012-02-26 09:21:43 +00:00
Chandler Carruth af3c2090b4 Add support for PPC and PPC64 multiarch toolchains on Debain.
Patch from Michel Dänzer, sent our way via Jeremy Huddleston who added
64-bit support. I just added one other place where powerpc64-linux-gnu
was missing (we only had powerpc64-unknown-linux-gnu).

I've also added a tree to test out the debian multiarch stuff. I don't
use debian regularly, so I'm not certain this is entirely accurate. If
anyone wants to check it against a debian system and fix any
inaccuracies, fire away. This way at least folks can see how this is
*supposed* to be tested.

It'd be particularly good to get the Debian MIPS toolchains tested in
this way.

llvm-svn: 151482
2012-02-26 09:03:21 +00:00
Chad Rosier 4c5c8ccf40 Temporarily revert r151288:
ARM: enable the integrated assembler by default for Darwin. 

llvm-svn: 151454
2012-02-25 20:32:43 +00:00
Jim Grosbach 1d43ca99e2 ARM: enable the integrated assembler by default for Darwin.
llvm-svn: 151288
2012-02-23 21:55:04 +00:00
Joerg Sonnenberger 17d7551e73 Revert part of r148839 and keep DefaultTargetTriple in the form adjusted
by -target and similar options. As discussed in PR 12026, the change
broke support for target-prefixed tools, i.e. calling x86_64--linux-ld
when compiling for x86_64--linux. Improve the test cases added
originally in r149083 to not require execution, just executable files.
Document the hack with appropiate FIXME comments.

llvm-svn: 151185
2012-02-22 19:15:16 +00:00
Chad Rosier ce975d9997 [driver] Add a warning for when -mcpu= is specified without an argument. There
are likely many other OPT_xxxx_EQ options that could/should be added here.
rdar://10704648

llvm-svn: 151174
2012-02-22 17:55:22 +00:00
Chad Rosier 877c0a27f8 Provide a way to disable auto-generation of preprocessed files during clang
crash.  This can speedup the process of generating a delta reduced test case.
rdar://10905465

llvm-svn: 151109
2012-02-22 00:30:39 +00:00
Aaron Ballman 232c4f50ba Fixing the working-directory option so that it stores the proper directory.
llvm-svn: 150960
2012-02-20 14:13:25 +00:00
Rafael Espindola 1af7c219c7 Implement a -gcc-toolchain command line option that does the same as
configure's --with-gcc-toolchain. The configure option is now just a default
value for the command line one.

llvm-svn: 150898
2012-02-19 01:38:32 +00:00
David Chisnall c616e95162 Default to not using __cxa_atexit on Solaris.
llvm-svn: 150883
2012-02-18 17:00:56 +00:00
David Chisnall 96de9933fb Tweak link order on Solaris so that global ctors work.
llvm-svn: 150696
2012-02-16 16:00:47 +00:00
David Blaikie 040a3a28f1 Remove the unuseful -fdiagnostics-show-name
This option was added in r129614 and doesn't have any use case that I'm aware
of. It's possible that external tools are using these names - and if that's
the case we can certainly reassess the functionality, but for now it lets us
shave out a few unneeded bits from clang.

Move the "StaticDiagNameIndex" table into the only remaining consumer, diagtool.
This removes the actual diagnostic name strings from clang entirely.

Reviewed by Chris Lattner & Ted Kremenek.

llvm-svn: 150612
2012-02-15 19:45:34 +00:00
David Chisnall 1026fb0797 Add some Solaris include paths and fix a -lgcc_eh that apparently should be -lgcc_s.
llvm-svn: 150602
2012-02-15 18:24:31 +00:00
David Chisnall a9ed5d76b4 Fix copy-and-paste error in comment
llvm-svn: 150587
2012-02-15 16:25:46 +00:00
David Chisnall f571cde869 First pass at Solaris toolchain support. This version compiles and links hello
world on Solaris 11 for both x86 and x86-64 using the built-in assembler and
Solaris (not GNU) ld, however it currently relies on a hard-coded GCC location
to find crtbegin.o and crtend.o, as well as libgcc and libgcc_eh.  

llvm-svn: 150580
2012-02-15 13:39:01 +00:00
Dylan Noblesmith 4d9cbffbe2 include clang's config.h unconditionally (v2)
And remove HAVE_CLANG_CONFIG_H, now that the header is generated
in the autoconf build, too.

Reverts r149571/restores r149504, now that config.h is generated
correctly by LLVM's configure in all build configurations.

llvm-svn: 150487
2012-02-14 15:54:49 +00:00
Chad Rosier 636d283202 When generating diagnostic information due to a clang failure, allow multiple
-arch options if the're all the same.

Patch by Jeremy Huddleston.
rdar://10849701

llvm-svn: 150403
2012-02-13 18:16:28 +00:00
Chandler Carruth 779579b332 Delete a simplistic helper function now that llvm::Triple can provide
this functionality.

llvm-svn: 150358
2012-02-13 02:02:09 +00:00
Chandler Carruth 9b5f8ddcf8 Begin refactoring to use the newly added triple predicates for
simplicity. Also addresses a FIXME, although not one that could be
observed.

llvm-svn: 150294
2012-02-11 03:31:12 +00:00
Jim Grosbach 576452b830 Have the driver pass CPU and target feature information to cc1as.
When creating the MCSubtargetInfo, the assembler driver uses the CPU and
feature string to construct a more accurate model of what instructions
are and are not legal.

rdar://10840476

llvm-svn: 150273
2012-02-10 20:37:10 +00:00
David Blaikie c8233cb740 Correct comment Clang C++ use in production.
This was from way-back-when (r82583) when Clang's C++ support wasn't prime-time
yet. Production quality C++ was tested experimentally from r100119 and turned
on by default in r141063.

Patch by Justin Bogner.

llvm-svn: 150148
2012-02-09 03:57:02 +00:00
Bob Wilson 7ecbd32e4e Filter a few more options not recognized by gcc. <rdar://problem/10814020>
These are new options that gcc doesn't recognize so the clang driver needs
to remove them when it falls back to invoking gcc.

llvm-svn: 149951
2012-02-07 01:17:55 +00:00
Eric Christopher 65c05fa79c Rewrite the debug action handling to take -verify into account.
Add a quiet option for dwarfdump and move it out of NDEBUG only.
Still requires an option as we don't want this on by default.

llvm-svn: 149894
2012-02-06 19:43:51 +00:00
Eric Christopher 3622221c87 Update the command line here and update the comment, we're just going
to leave this as a debug only option for now.

llvm-svn: 149890
2012-02-06 19:13:09 +00:00
Benjamin Kramer 3bb42f38f4 - Turn the other distribution checks into range compares.
- Turn openSUSE version parsing into a StringSwitch
- Add an entry for Fedora release 16 (Verne)

llvm-svn: 149872
2012-02-06 15:33:06 +00:00
Benjamin Kramer 7c3f09d416 Consolidate the ubuntu detection logic a bit, add an entry for Ubuntu 12.04 aka precise pangolin.
llvm-svn: 149869
2012-02-06 14:36:09 +00:00
Dylan Noblesmith 2c1dd2716a Basic: import SmallString<> into clang namespace
(I was going to fix the TODO about DenseMap too, but
that would break self-host right now. See PR11922.)

llvm-svn: 149799
2012-02-05 02:13:05 +00:00
Dylan Noblesmith e27789991d Basic: import OwningPtr<> into clang namespace
llvm-svn: 149798
2012-02-05 02:12:40 +00:00
Bob Wilson 14adb360a7 Fix -ftrap-function fallout from llvm r145714. <rdar://problem/10799325>
That llvm change removed the -trap-func backend option, so that using
-ftrap-function with clang would cause the backend to complain.  Fix it
by adding the trap function name to the CodeGenOptions and passing it through
to the TargetOptions.

llvm-svn: 149679
2012-02-03 06:27:22 +00:00
Rafael Espindola c29af947d6 Replace the old --with-cxx-* configure options with a single --with-gcc-toolchain
that just uses the new toolchain probing logic. This fixes linking with -m32 on
64 bit systems (the /32 dir was not being added to the search).

llvm-svn: 149652
2012-02-03 01:01:20 +00:00
Dylan Noblesmith 4f4e745725 back out r149504
Too many weird build failures.

llvm-svn: 149571
2012-02-02 00:40:14 +00:00
Dylan Noblesmith 86780e906b include clang's config.h unconditionally
And remove HAVE_CLANG_CONFIG_H, now that the header is generated
in the autoconf build, too. (clang r149497 / llvm r149498)

Also include the config.h header after all other headers, per
the LLVM coding standards.

It also turns out WindowsToolChain.cpp wasn't using the config
header at all, so that include's just deleted now.

llvm-svn: 149504
2012-02-01 14:25:28 +00:00
Bob Wilson a223401498 Use new Triple::getMacOSXVersion function.
llvm-svn: 149439
2012-01-31 22:43:59 +00:00
Bob Wilson 9d3f7af8c3 Fix more fallout from the introduction of "macosx" and "ios" triples.
The Darwin toolchain constructor was assuming that all Darwin triples would
have an OS string starting with "darwin".  Triples starting with "macosx"
would misinterpret the version number, and "ios" triples would completely
miss the version number (or worse) because the OS name is not 6 characters
long.  We lose some sanity checking of triple strings here, since the
Triple.getOSVersion function doesn't do all the checking that the previous
code did, but this still seems like a step in the right direction.

llvm-svn: 149422
2012-01-31 21:30:03 +00:00
Chandler Carruth d7fa2e04f6 Revert r149083 which is not the direction we're going in the Clang
driver based on discussions with Doug Gregor. There are several issues:
1) The patch was not reviewed prior to commit and there were review comments.
2) The design of the functionality (triple-prefixed tool invocation)
   isn't the design we want for Clang going forward: it focuses on the
   "user triple" rather than on the "toolchain triple", and forces that
   bit of state into the API of every single toolchain instead of
   handling it automatically in the common base classes.
3) The tests provided are not stable. They fail on a few Linux variants
   (Gentoo among them) and on mingw32 and some other environments.

I *am* interested in the Clang driver being able to invoke
triple-prefixed tools, but we need to design that feature the right way.
This patch just extends the previous hack without fixing the underlying
problems with it. I'm working on a new design for this that I will mail
for review by tomorrow.

I am aware that this removes functionality that NetBSD relies on, but
this is ToT, not a release. This functionality hasn't been properly
designed, implemented, and tested yet. We can't "regress" until we get
something that really works, both with the immediate use cases and with
long term maintenance of the Clang driver.

For reference, the original commit log:
Keep track of the original target the user specified before
normalization. This used to be captured in DefaultTargetTriple and is
used for the (optional) $triple-$tool lookup for cross-compilation.
Do this properly by making it an attribute of the toolchain and use it
in combination with the computed triple as index for the toolchain
lookup.

llvm-svn: 149337
2012-01-31 02:21:20 +00:00
Anna Zaks 58cc6cabe5 [analyzer] Rename the checker as per Ted's comment. Remove the reference
from the driver.

llvm-svn: 149276
2012-01-30 21:14:16 +00:00
Joerg Sonnenberger d64c60e534 Remove the ToolTriple logic in NetBSD, which was completely broken by
the recent refactoring. All interesting NetBSD release have a GNU as
version on i386 that supports --32, so don't bother with the conditional
setting of it.

llvm-svn: 149087
2012-01-26 22:27:52 +00:00
Joerg Sonnenberger f8ce8575aa Remove obviously incorrect branch.
llvm-svn: 149084
2012-01-26 21:58:37 +00:00
Joerg Sonnenberger 91960f4abb Keep track of the original target the user specified before
normalization. This used to be captured in DefaultTargetTriple and is
used for the (optional) $triple-$tool lookup for cross-compilation.
Do this properly by making it an attribute of the toolchain and use it
in combination with the computed triple as index for the toolchain
lookup.

llvm-svn: 149083
2012-01-26 21:56:28 +00:00
Bob Wilson 269e6377dd Revert r148249: "Make the auto-detection hack for the iOS simulator set the target triple correctly."
There were some problems with this, so I'm backing it out for now.

llvm-svn: 149040
2012-01-26 03:37:03 +00:00
Ted Kremenek 37e965221c Enable several checkers under --analyze for general testing.
llvm-svn: 149016
2012-01-26 02:27:38 +00:00
Chandler Carruth 0b1756b880 Reintroduce r148981 with significantly improved regression test. Now it
both actually tests what it wants to, doesn't have bogus and broken
assertions in it, and is also formatted much more cleanly and
consistently. Probably still some more that can be improved here, but
its much better.

Original commit message:
----
Try to unbreak the FreeBSD toolchain's detection of 32-bit targets
inside a 64-bit freebsd machine with the 32-bit compatibility layer
installed. The FreeBSD image always has the /usr/lib32 directory, so
test for the more concrete existence of crt1.o. Also enhance the tests
for freebsd to clarify what these trees look like and exercise the new
code.

Thanks to all the FreeBSD folks for helping me understand what caused
the failure and how we might fix it. =] That helps a lot. Also, yay
build bots.

llvm-svn: 149011
2012-01-26 01:35:15 +00:00
Argyrios Kyrtzidis e8be6652ce Revert r148981 because it fails test/Driver/freebsd.c
Original log:

Author: chandlerc <chandlerc@91177308-0d34-0410-b5e6-96231b3b80d8>
Date:   Wed Jan 25 21:32:31 2012 +0000

    Try to unbreak the FreeBSD toolchain's detection of 32-bit targets
    inside a 64-bit freebsd machine with the 32-bit compatibility layer
    installed. The FreeBSD image always has the /usr/lib32 directory, so
    test for the more concrete existence of crt1.o. Also enhance the tests
    for freebsd to clarify what these trees look like and exercise the new
    code.

    Thanks to all the FreeBSD folks for helping me understand what caused
    the failure and how we might fix it. =] That helps a lot. Also, yay
    build bots.

llvm-svn: 148993
2012-01-25 22:55:16 +00:00
Chandler Carruth 143f2f6e37 Try to unbreak the FreeBSD toolchain's detection of 32-bit targets
inside a 64-bit freebsd machine with the 32-bit compatibility layer
installed. The FreeBSD image always has the /usr/lib32 directory, so
test for the more concrete existence of crt1.o. Also enhance the tests
for freebsd to clarify what these trees look like and exercise the new
code.

Thanks to all the FreeBSD folks for helping me understand what caused
the failure and how we might fix it. =] That helps a lot. Also, yay
build bots.

llvm-svn: 148981
2012-01-25 21:32:31 +00:00
Chandler Carruth cf705b21e2 Restore a tiny bit of functionality that I completely overlooked in the
Linux toolchain selection -- sorry folks. =] This should fix the Hexagon
toolchain.

However, I would point out that I see why my testing didn't catch this
-- we have no tests for Hexagon. ;]

llvm-svn: 148977
2012-01-25 21:03:58 +00:00
Chandler Carruth f7bf3db070 The Linux pattern of adding all the search paths that exist doesn't seem
to suit the FreeBSD folks. Take them back to something closer to the old
behavior. We test whether the /usr/lib32 directory exists (within the
SysRoot), and use it if so, otherwise use /usr/lib.

FreeBSD folks, let me know if this causes any problems, or if you have
further tweaks.

llvm-svn: 148953
2012-01-25 11:24:24 +00:00
Chandler Carruth 1ccbed88fc Remove the 'ToolTriple' concept from the NetBSD toolchain along with my
gross hack to provide it from my previous patch removing HostInfo. This
was enshrining (and hiding from my searches) the concept of storing and
diff-ing the host and target triples. We don't have the host triple
reliably available, so we need to merely inspect the target system. I've
changed the logic in selecting library search paths for NetBSD to match
what I provided for FreeBSD -- we include both search paths, but put the
32-bit-on-64-bit-host path first so it trumps.

NetBSD maintainers, you may want to tweak this, or feel free to ask me
to tweak it. I've left a FIXME here about the challeng I see in fixing
this properly.

llvm-svn: 148952
2012-01-25 11:18:20 +00:00
Chandler Carruth 2886ba2352 Delete still more remnants of the now dead HostInfo. The janitoring will
continue until cleanliness improves.

llvm-svn: 148951
2012-01-25 11:03:35 +00:00
Chandler Carruth 2ad5de1f72 Delete the driver's HostInfo class. This abstraction just never really
did anything. The two big pieces of functionality it tried to provide
was to cache the ToolChain objects for each target, and to figure out
the exact target based on the flag set coming in to an invocation.
However, it had a lot of flaws even with those goals:
 - Neither of these have anything to do with the host, or its info.
 - The HostInfo class was setup as a full blown class *hierarchy* with
   a separate implementation for each "host" OS. This required
   dispatching just to create the objects in the first place.
 - The hierarchy claimed to represent the host, when in fact it was
   based on the target OS.
 - Each leaf in the hierarchy was responsible for implementing the flag
   processing and caching, resulting in a *lot* of copy-paste code and
   quite a few bugs.
 - The caching was consistently done based on architecture alone, even
   though *any* aspect of the targeted triple might change the behavior
   of the configured toolchain.
 - Flag processing was already being done in the Driver proper,
   separating the flag handling even more than it already is.

Instead of this, we can simply have the dispatch logic in the Driver
which previously created a HostInfo object create the ToolChain objects.
Adding caching in the Driver layer is a tiny amount of code. Finally,
pulling the flag processing into the Driver puts it where it belongs and
consolidates it in one location.

The result is that two functions, and maybe 100 lines of new code
replace over 10 classes and 800 lines of code. Woot.

This also paves the way to introduce more detailed ToolChain objects for
various OSes without threading through a new HostInfo type as well, and
the accompanying boiler plate. That, of course, was the yak I started to
shave that began this entire refactoring escapade. Wheee!

llvm-svn: 148950
2012-01-25 11:01:57 +00:00
Chandler Carruth b65b111d24 Switch the ToolChain types to all store a Driver reference rather than
a HostInfo reference. Nothing about the HostInfo was used by any
toolchain except digging out the driver from it. This just makes that
a lot more direct. The change was accomplished entirely mechanically.
It's one step closer to removing the shim full of buggy copy/paste code
that is HostInfo.

llvm-svn: 148945
2012-01-25 09:12:06 +00:00
Chandler Carruth cb91619e5c Remove the TargetTriple object that I added to the Driver recently. This
helped stage the refactoring of things a bit, but really isn't the right
place for it. The driver may be responsible for compilations with many
different targets. In those cases, having a target triple in the driver
is actively misleading because for many of those compilations that is
not actually the triple being targeted.

This moves the last remaining users of the Driver's target triple to
instead use the ToolChain's target triple. The toolchain has a single,
concrete target it operates over, making this a more stable and natural
home for it.

llvm-svn: 148942
2012-01-25 08:49:21 +00:00
Chandler Carruth 25442b8e72 Have FreeBSD use even more of the same smarts as Linux is now using for
adding search paths. Add them only when they exist, and prefix the paths
with the sysroot. This will allow targeting a FreeBSD sysroot on
a non-FreeBSD host machine, and perhaps more importantly should allow
testing the FreeBSD driver's behavior similarly to the Linux tests with
a fake tree of files in the regression test suite.

I don't have FreeBSD systems handy to build up the list of files that
should be used here, but this is the basic functionality and I'm hoping
Roman or someone from the community can contribute the actual test
cases.

llvm-svn: 148940
2012-01-25 08:10:33 +00:00
Chandler Carruth f4826e28b9 Switch FreeBSD to just include both '/usr/lib32' and '/usr/lib' in the
search paths for 32-bit targets. This avoids having to detect which is
expected for the target system, and the linker should DTRT, and take the
32-bit libraries from the first one when applicable. Thanks to Roman
Divacky for sanity checking this.

llvm-svn: 148939
2012-01-25 08:04:15 +00:00
Chandler Carruth a1f1fd3b60 Switch the Linux C++ standard library header search logic over to use
the GCC installation's multiarch suffix now that it is exposed.

llvm-svn: 148938
2012-01-25 08:04:13 +00:00
Chandler Carruth 866faab4db Make a major refactoring to how the GCC installation detection works.
The fundamental shift here is to stop making *any* assumptions about the
*host* triple. Where these assumptions you ask? Why, they were in one of
the two target triples referenced of course. This was the single biggest
place where the previously named "host triple" was actually used as
such. ;] The reason we were reasoning about the host is in order to
detect the use of '-m32' or '-m64' flags to change the target. These
flags shift the default target only slightly, which typically means
a slight deviation from the host. When using these flags, the GCC
installation is under a different triple from the one actually targeted
in the compilation, and we used the host triple to find it.

Too bad that wasn't even correct. Consider an x86 Linux host which has
a PPC64 cross-compiling GCC toolchain installed. This toolchain is also
configured for multiarch compiling and can target PPC32 with eth '-m32'
flag. When targeting 'powerpc-linux-gnu' or some other PPC32 triple, we
have to look for the PPC64 variant of the triple to find the GCC
install, and that triple is neither the host nor target.

The new logic computes the multiarch's alternate triple from the target
triple, and looks under both sides. It also looks more aggressively for
the correct subdirectory of the GCC installation, and exposes the
subdirectory in a nice programmatic way. This '/32' or '/64' suffix is
something we can reuse in many other parts of the toolchain.

An important note -- while this likely fixes a large category of
cross-compile use cases, that's not my primary goal, and I've not done
testing (or added test cases) for scenarios that may now work. If
someone else wants to try more interesting PPC cross compiles, I'd love
to have reports. But my focus is on factoring away the references to the
"host" triple. The refactoring is my goal, and so I'm mostly relying on
the existing (pretty good) test coverage we have here.

Future patches will leverage this new functionality to factor out more
and more of the toolchain's triple manipulation.

llvm-svn: 148935
2012-01-25 07:21:38 +00:00
Chandler Carruth 96bae7b1fd Fix one of the (larger) FIXMEs where we were misusing the Driver's idea
of the target triple to stand in for the "host" triple.

Thanks to a great conversation with Richard Smith, I'm now much more
confident in how this is proceeding. In all of the places where we
currently reason about the "host" architecture or triple, what we really
want to reason about in the detected GCC installation architecture or
triple, and the ways in which that differs from the target. When we find
a GCC installation with a different triple from our target *but capable
of targeting our target* through an option such as '-m64', we want to
detect *that* case and change the paths within the GCC installation (and
libstdc++ installation) to reflect this difference.

This patch makes one function do this correctly. Subsequent commits will
hoist the logic used here into the GCCInstallation utility, and then
reuse it through the rest of the toolchains to fix the remaining places
where this is currently happening.

llvm-svn: 148852
2012-01-24 20:08:17 +00:00
Chandler Carruth 4d9d76839a Address one part of the FIXME I introduced my switching the triple
inside of GCCInstallation to be a proper llvm::Triple. This is still
a touch ugly because we have to use it as a string in so many places,
but I think on the whole the more structured representation is better.

Comments of course welcome if this tradeoff isn't working for folks.

llvm-svn: 148843
2012-01-24 19:28:29 +00:00
Chandler Carruth 64cee06504 At least within these classes, consistently spell 'GCC' as 'GCC'.
I can't read Java-style 'Gcc' acronyms. ;]

No functionality changed.

llvm-svn: 148840
2012-01-24 19:21:42 +00:00
Chandler Carruth 46f204fef8 Start hoisting the logic for computing the target triple into its own
function. The logic for this, and I want to emphasize that this is the
logic for computing the *target* triple, is currently scattered
throughout various different HostInfo classes ToolChain factoring
functions. Best part, it is largely *duplicated* there. The goal is to
hoist all of that up to here where we can deal with it once, and in
a consistent manner.

Unfortunately, this uncovers more fun problems: the ToolChains assume
that the *actual* target triple is the one passed into them by these
factory functions, while the *host* triple is the one in the driver.
This already was a lie, and a damn lie, when the '-target' flag was
specified. It only really worked when the difference stemmed from '-m32'
and '-m64' flags. I'll have to fix that (and remove all the FIXMEs I've
introduced here to document the problem) before I can finish hoisting
the target-calculation logic.

It's bugs all the way down today it seems...

llvm-svn: 148839
2012-01-24 19:17:46 +00:00
Chandler Carruth 7f1417f7cf Remove HostInfo::useDriverDriver(). This was only used in two places
inside the innards of the Driver implementation, and only ever
implemented to return 'true' for the Darwin OSes. Instead use a more
direct query on the target triple and a comment to document why the
target matters here.

If anyone is worried about this predicate getting wider use or improper
use, I can make it a local or private predicate in the driver.

llvm-svn: 148797
2012-01-24 10:43:44 +00:00
Chandler Carruth 4d73703ffd Hoist the targeted triple object into an actual object in the Driver.
The Driver has a fixed target, whether we like it or not, the
DefaultTargetTriple is not a default. This at least makes things more
honest. I'll eventually get rid of most (if not all) of
DefaultTargetTriple with this proper triple object. Bit of a WIP.

llvm-svn: 148796
2012-01-24 10:21:46 +00:00
Nick Lewycky 1c8c436a85 Add support for -fno-optimize-sibling-calls. Currently only implemented in the
X86 backend in LLVM.

llvm-svn: 148689
2012-01-23 08:29:12 +00:00
NAKAMURA Takumi 44193b732e [Cygwin] Abandon Cygwin-1.5 and g++-3. Use g++-4.3 and higher on Cygwin-1.7.
llvm-svn: 148636
2012-01-21 14:46:01 +00:00
Sebastian Pop 422377cfd3 rename -ccc-host-triple into -target
llvm-svn: 148582
2012-01-20 22:01:23 +00:00
Ted Kremenek b9ff6b2302 Reenable DeadStoresChecker under --analyze, and move the IdempotentOperationsChecker to the 'experimental' category. Fixes <rdar://problem/10146347>.
llvm-svn: 148533
2012-01-20 06:00:17 +00:00
Douglas Gregor 226173ae93 In the driver, -fmodules enables modules for C/Objective-C but one
also needs -fcxx-modules to enable modules for C++/Objective-C++.

llvm-svn: 148393
2012-01-18 15:19:58 +00:00
David Blaikie f47fa304a4 Remove unnecessary default cases in switches over enums.
This allows -Wswitch-enum to find switches that need updating when these enums are modified.

llvm-svn: 148281
2012-01-17 02:30:50 +00:00
Eli Friedman 5ceb74a7d0 Make the auto-detection hack for the iOS simulator set the target triple correctly. Getting the target triple wrong mostly appears to work, but messes up in subtle cases; for example, we incorrectly conclude that fwrite is actually named fwrite$UNIX2003. Also shuffles around the auto-detection code a bit to try and make it a bit more reliable. Fixes <rdar://problem/10664848>.
llvm-svn: 148249
2012-01-16 18:50:54 +00:00
Chad Rosier 1b9c5f1188 Fix 80-column violation.
llvm-svn: 148162
2012-01-14 00:30:11 +00:00
Eli Friedman d749c6bf2e Revert r148138; it's causing test failures.
llvm-svn: 148141
2012-01-13 21:33:06 +00:00
Sebastian Pop 86500280c6 remove assertions in the Hexagon backend specific clang driver
Patch from Jyotsna Verma:

I have made the changes to remove assertions in the Hexagon backend
specific clang driver. Instead of asserting on invalid arch name, it has
been modified to use the default value.

I have changed the implementation of the CPU flag validation for the
Hexagon backend. Earlier, the clang driver performed the check and
asserted on invalid inputs. In the new implementation, the driver passes
the last CPU flag (or sets to "v4" if not specified) to the compiler (and
also to the assembler and linker which perform their own check) instead of
asserting on incorrect values. This patch changes the setCPU function for
the Hexagon backend in clang/lib/Basic/Targets.cpp which causes the
compiler to error out on incorrect CPU flag values.

llvm-svn: 148139
2012-01-13 20:37:10 +00:00
Sebastian Pop 9a8d528ddf rename -ccc-host-triple into -target
llvm-svn: 148138
2012-01-13 20:37:02 +00:00
Sebastian Pop 9d66d9e4b2 rename DefaultHostTriple into DefaultTargetTriple
llvm-svn: 148137
2012-01-13 20:36:46 +00:00
Evgeniy Stepanov 2ca1aa5a44 Remove --hash-style from link command on Android.
Gnu hash is not supported by the Android loader.

llvm-svn: 148113
2012-01-13 09:30:38 +00:00
Ted Kremenek 52acee87f4 Adjust set of default checkers.
llvm-svn: 148055
2012-01-12 22:41:10 +00:00
Evgeniy Stepanov 48af2a9e66 Fix -mfpu parsing on ARM.
- Support gcc-compatible vfpv3 name in addition to vfp3.
- Support vfpv3-d16.
- Disable neon feature for -mfpu=vfp* (yes, we were emitting Neon instructions
  for those!).

llvm-svn: 147943
2012-01-11 11:21:31 +00:00
Eli Friedman 027e9c3ebc Revert changes to lib/Driver in r147917; I didn't mean to commit this.
llvm-svn: 147920
2012-01-11 02:41:15 +00:00
Eli Friedman 20139d3809 Start refactoring code for capturing variables and 'this' so that it is shared between lambda expressions and block literals.
llvm-svn: 147917
2012-01-11 02:36:31 +00:00
Chandler Carruth c89aa9d964 Add support for the androideabi environment to our triple support, and
for the arm-linux-androideabi triple in particular.

Also use this to do a better job of selecting soft FP settings.

Patch by Evgeniy Stepanov.

llvm-svn: 147872
2012-01-10 19:47:42 +00:00
Eric Christopher fc3ee566eb Add -g to the cc1as flags only if we're dealing with an original
source file. Otherwise -g -save-temps will error out on the compile
of any .c file.

Fixes about 4000 of the errors in the clang-tests gdb test suite.

llvm-svn: 147819
2012-01-10 00:38:01 +00:00
Eric Christopher fe2603a78a Remove extraneous braces.
llvm-svn: 147818
2012-01-10 00:37:56 +00:00
Eli Friedman 48fd89ad14 Revert r147664; it's breaking clang regression tests.
llvm-svn: 147681
2012-01-06 20:42:20 +00:00
Jakub Staszak a78c20d734 Silence GCC warnings.
llvm-svn: 147664
2012-01-06 17:44:30 +00:00
Daniel Dunbar ecb41cbcd6 Driver/Darwin: Remove a hack that avoided passing -demangle to iOS linkers.
llvm-svn: 147552
2012-01-04 21:45:27 +00:00
Chad Rosier 1ad2433690 Fixed by Chandler in r147434.
llvm-svn: 147489
2012-01-03 22:51:32 +00:00
Douglas Gregor 787869b929 Add -fno-modules to the driver, to turn off modules (although they're off by default anyway).
llvm-svn: 147449
2012-01-03 17:13:05 +00:00
Douglas Gregor 2f197adeeb Rename the command-line option for mapping #include/#import over to
module imports from -fauto-module-import to -fmodules. The new name
will eventually be used to enable modules, and the #include/#import
mapping is a crucial part of the feature.

llvm-svn: 147447
2012-01-03 15:21:29 +00:00
Chandler Carruth 306bd2c6aa Fix PR11685 by implementing -ffast-math and its various friends in the
Clang driver. This involves a bunch of silly option parsing code to try
to carefully emulate GCC's options. Currently, this takes a conservative
approach, and unless all of the unsafe optimizations are enabled, none
of them are. The fine grained control doesn't seem particularly useful.
If it ever becomes useful, we can add that to LLVM first, and then
expose it here.

This also fixes a few tiny bugs in the flag management around
-fhonor-infinities and -fhonor-nans; the flags now form proper sets both
for enabling and disabling, with the last flag winning.

I've also implemented a moderately terrifying GCC feature where
a language change is also provided by the '-ffast-math' flag by defining
the __FAST_MATH__ preprocessor macro. This feature is tracked and
serialized in the frontend but it isn't used yet. A subsequent patch
will add the preprocessor macro and tests for it.

I've manually tested that codegen appears to respect this, but I've not
dug in enough to see if there is an easy way to test codegen options w/o
relying on the particulars of LLVM's optimizations.

llvm-svn: 147434
2012-01-02 14:19:45 +00:00
Rafael Espindola 1510c8589e Handle a /etc/debian_version with a version number instead of a codename.
Patch by Sylvestre Ledru. Fixes PR11673.

llvm-svn: 147313
2011-12-28 18:17:14 +00:00
Benjamin Kramer eed4f2a6c5 Fix potential use after free.
llvm-svn: 147277
2011-12-26 14:18:37 +00:00
Anton Yartsev 9b6b2e5535 fix for PR11634
llvm-svn: 147224
2011-12-23 20:23:19 +00:00
Kevin Enderby 292dc080e0 Last part of support for generating dwarf for assembly source files. This gets
the clang driver to enable this when assembling a .s file.  rdar://9275556

llvm-svn: 147167
2011-12-22 19:31:58 +00:00
David Blaikie 68e081d606 Unweaken vtables as per http://llvm.org/docs/CodingStandards.html#ll_virtual_anch
llvm-svn: 146959
2011-12-20 02:48:34 +00:00
Chandler Carruth 1fc603e516 Split the Windows toolchain definition into its own file. This is
especially nice as the Windows toolchain needs the windows header files,
and has lots of platform specific hooks in it.

To facilitate the split, hoist a bunch of file-level static helpers into
class-level static helpers. Spiff up their doxygen comments while there
as they're now more likely to be looked up via docs.

Hopefully, this will be followed by further breaking apart of the
toolchain definitions. Most of the large and complex ones should likely
live on their own. I'm looking at you Darwin. ;]

llvm-svn: 146840
2011-12-17 23:10:01 +00:00
Chandler Carruth 45661653df Fix an abiguous-else warning from GCC. I have no idea why Clang doesn't
have this warning.

llvm-svn: 146839
2011-12-17 22:32:42 +00:00
Richard Smith f6f003af6a C++11 constexpr: Add note stacks containing backtraces if constant evaluation
fails within a call to a constexpr function. Add -fconstexpr-backtrace-limit
argument to driver and frontend, to control the maximum number of notes so
produced (default 10). Fix APValue printing to be able to pretty-print all
APValue types, and move the testing for this functionality from a unittest to
a -verify test now that it's visible in clang's output.

llvm-svn: 146749
2011-12-16 19:06:07 +00:00
Eli Friedman 3715d1f435 gcov-style profiling support for OpenBSD. Patch by Jonathan Gray.
llvm-svn: 146631
2011-12-15 02:15:56 +00:00
Rafael Espindola 00b29189b7 Fix typos.
llvm-svn: 146595
2011-12-14 21:50:24 +00:00
Rafael Espindola 224dd63fff Don't use the frame pointer on linux x86 and x86_64 if optimizing. This
matches gcc's behavior.

Fixes PR8186.

llvm-svn: 146586
2011-12-14 21:02:23 +00:00
Bob Wilson 721d4b858d Enable stack protectors by default for iOS. <rdar://problem/8836680>
llvm-svn: 146552
2011-12-14 06:08:25 +00:00
Nick Lewycky 12eae8085c Fix "control may reach end of non-void function" warning.
llvm-svn: 146448
2011-12-12 23:36:07 +00:00
Tony Linthicum 76329bf83f Hexagon backend support
llvm-svn: 146413
2011-12-12 21:14:55 +00:00
Daniel Dunbar 19939cc380 Driver: Handle -f{no-}honor-infinities, -f{no-}honor-nans, and
-ffinite-math-only.
 - No test case yet, I don't know how to construct a situation where this
   matters.

llvm-svn: 146297
2011-12-09 23:41:18 +00:00
Chandler Carruth 0b84291222 Fix the --hash-style option when the target is MIPS as it is
incompatible with the MIPS ABI.

Patch by Simon Atanasyan.

llvm-svn: 146243
2011-12-09 04:45:18 +00:00
Eli Friedman 83de51301a Misc Minix-specific changes to clang:
. move compiler-rt to a separate directory so the -L argument only includes compiler-rt (thanks joerg)
. build all clang subdirs
. switches the Minix platform to ELF
. normalizes toolchain invocation

Patch by Ben Gras.

llvm-svn: 146206
2011-12-08 23:54:21 +00:00
Hal Finkel 221e11e864 Allow clang to find gcc libs on suse ppc64
llvm-svn: 146142
2011-12-08 05:50:03 +00:00
Bob Wilson 8c9052bd31 Minor cleanup. Avoid redundant getTriple() calls.
llvm-svn: 146122
2011-12-08 01:10:19 +00:00
Daniel Dunbar 3ca41d4758 Driver/Linux: Fix the ASAN library path to match current compiler-rt
integration.

llvm-svn: 146098
2011-12-07 23:22:17 +00:00
Daniel Dunbar f4916cde76 Driver: Add a --rtlib={compiler-rt,libgcc} argument which I plan to use to allow
dual support for compiler-rt on Linux, during bringup.

llvm-svn: 146094
2011-12-07 23:03:15 +00:00
Eli Friedman 1f1e35e034 Fix multilib library paths on ppc64 Linux. Patch by Michael Kostylev. PR11472.
llvm-svn: 146016
2011-12-07 04:00:53 +00:00
Kostya Serebryany 0b692ce7ca [asan] Mac: do not link dynamic libs with the asan-rt, use -undefined dynamic_lookup for dynamic libs. Style fixes. Patch by glider@google.com
llvm-svn: 145955
2011-12-06 19:18:44 +00:00
Nick Lewycky f4d3f7a0b9 Stack realignment is a tristate. Add -mno-stackrealign to turn off all stack
realignment, even with locals with alignment exceeding the ABI guarantee.

llvm-svn: 145909
2011-12-06 03:33:03 +00:00
Joerg Sonnenberger db66ed0e4c Add -mstack-alignment=X and fix -mstackrealign handling now that the
backend options are gone.

llvm-svn: 145868
2011-12-05 23:05:23 +00:00
Kostya Serebryany 4dd9e4765d [asan] don't require libstdc++ for asan on linux. Mac fix will go separately
llvm-svn: 145823
2011-12-05 18:32:37 +00:00
Daniel Dunbar 1d6469fcb1 Driver/Darwin: Add ASAN runtime library link support.
llvm-svn: 145651
2011-12-01 23:40:18 +00:00
Akira Hatanaka 5e9dde3782 Get the -march argument based on the target MIPS architecture or cpu and pass
it to GNU assembler. In addition, change function getMipsArchFromCPU() so that
it can be reused in ConstructJob(). 

Patch by Simon Atanasyan.

llvm-svn: 145509
2011-11-30 19:31:38 +00:00
Kostya Serebryany 7bca6c24ec when -faddress-sanitizer is present, add required flags to the linker command (linux-only)
llvm-svn: 145467
2011-11-30 01:39:16 +00:00
Akira Hatanaka a21f5dab3c Change processor names. Patch by Simon Atanasyan.
llvm-svn: 145453
2011-11-29 23:09:24 +00:00
NAKAMURA Takumi 64404a3b2c [Win32] Catch exceptions (eg. segfault) on waiting for invoked clang from the driver.
clang/lib/Driver/Driver.cpp: Don't pass through negative exit status, or parent would be confused.

llvm::sys::Program::Wait(): Suppose 0x8000XXXX and 0xC000XXXX as abnormal exit code and pass it as negative value.

Win32 Exception Handler: Exit with ExceptionCode on an unhandle exception.

llvm-svn: 145389
2011-11-29 07:47:04 +00:00
Eli Friedman 4a4932c29b A couple driver fixes for PPC Linux. Patches by Michael Kostylev. PR11444/PR11445.
llvm-svn: 145321
2011-11-28 23:46:52 +00:00
Richard Smith 9a56882e53 Add driver arguments -ftemplate-depth=N and -fconstexpr-depth=N, with the same
semantics and defaults as the corresponding g++ arguments. The historical g++
argument -ftemplate-depth-N is kept for compatibility, but modern g++ versions
no longer document that option.

Add -cc1 argument -fconstexpr-depth N to implement the corresponding
functionality.

The -ftemplate-depth=N part of this fixes PR9890.

llvm-svn: 145045
2011-11-21 19:36:32 +00:00
Roman Divacky d150ad3f07 Change the linker emulation name for FreeBSD/PPC32.
Submitted by Andreas Tobler!

llvm-svn: 145041
2011-11-21 16:50:32 +00:00
Peter Collingbourne 119cfaa595 Teach the driver about failure result files, which are compilation
output files that are valid regardless of whether the compilation
succeeded or failed (but not if we crash).  Add depfiles to the
failure result file list.

llvm-svn: 145018
2011-11-21 00:01:05 +00:00
Benjamin Kramer 7824360017 Driver: Remove the signal number from the "command failed" diagnostic.
- With the current implementation of sys::Program this always printed "2".
- The command execution code will output the right number anyway (including the signal name).

llvm-svn: 144993
2011-11-19 10:24:49 +00:00
Daniel Dunbar 4f41440cf9 clang/Darwin: Use the compiler-rt provided profile library.
llvm-svn: 144869
2011-11-17 00:36:57 +00:00
Kostya Serebryany 8855ff61cb Add -f[no-]address-sanitizer flag
llvm-svn: 144800
2011-11-16 17:34:26 +00:00
Matt Beaumont-Gay 8e9aae5999 Don't track depfiles as result files which need to be cleaned up on failure.
This is a partial revert of r143846. While cleaning up after a crash is
probably a good idea, we were also deleting .d files if the compilation failed
due to invalid input, which is not the desired behavior. The test is XFAIL'd
until the cleanup code can be reworked to do the right thing.

llvm-svn: 144590
2011-11-14 23:24:52 +00:00
Bob Wilson 1a9ad0fbee Search for libstdc++.dylib in llvm-gcc's files on darwin10. rdar://10419079
llvm-svn: 144381
2011-11-11 07:47:04 +00:00
Eli Friedman 7771c835cd Add Linux multiarch include directories for mips/mipsel. Patch from Simon Atanasyan.
llvm-svn: 144358
2011-11-11 03:05:19 +00:00
Ted Kremenek e73d9ed1a2 Add top-level driver option '--serialize-diagnostics' for serialize compiler diagnostics to a file.
llvm-svn: 144339
2011-11-11 00:07:43 +00:00
Chandler Carruth 6e46ca2c10 Fix an issue that Duncan discovered on a specific (no longer current)
version of Ubuntu. It has a very broken multiarch configuration, and so
we need special logic to handle it correctly. Fixing and testing this
uncovered a few other trivial issues with the logic that are fixed as
well.

I added tests to cover this as it is hard to notice if you install
recent versions of the OS.

llvm-svn: 144165
2011-11-09 03:46:20 +00:00
Eli Friedman 27b8c4f3fb Misc fixes for clang driver on Mips Linux. Patch by Simon Atanasyan.
llvm-svn: 144108
2011-11-08 19:43:37 +00:00
Chandler Carruth 475ab6ad7b Add a default system include of '/include'. This isn't particularly
useful when using Clang as a system-compiler, but its harmless. When
using Clang as a cross-compiler, this can be very handy as quite a few
toolchains ship their libc headers here rather than under
'/usr/include'.

For reference, this is the beginning of my work to also make the Clang
driver more suitable as a cross-compiler.

llvm-svn: 144089
2011-11-08 17:19:47 +00:00
Chad Rosier 8fe3b115cd Whitespace.
llvm-svn: 144002
2011-11-07 19:52:29 +00:00
Chad Rosier 1746e37cb8 Tablegenify -g options.
llvm-svn: 144001
2011-11-07 19:51:54 +00:00
Benjamin Kramer f5fbe436bc Fix an unsafe use of Twine.
llvm-svn: 143962
2011-11-07 16:02:25 +00:00
Chandler Carruth a62ba81682 Rip out one of the features I added for the driver-include-management.
We don't actually need a separate flag for non-sysrooted paths as the
driver has to manage the sysroot anyways. The driver is not infrequently
adding paths to the header search based on their existence on the
filesystem. For that, it has to add the sysroot anyways, we should pass
it on down to CC1 already joined. More importantly, the driver cannot in
all cases distinguish between sysrooted paths and paths that are
relative to the Clang binary's installation directory. Essentially, we
always need to ignore the system root for these internal header search
options. It turns out in most of the places we were already providing
the system root in the driver, and then another one in CC1 so this fixes
several bugs.

llvm-svn: 143917
2011-11-07 09:17:31 +00:00
Chandler Carruth f470173e46 Fix Linux libc++ usage. Somehow this slipped through during the port.
Test cases for this and all the rest of the port are still in the works,
but will wait for a fixed computer and post 3.0 merging...

llvm-svn: 143916
2011-11-07 09:01:17 +00:00
Chandler Carruth efad16ad6b Begin lifting some of the one-off checking logic into generic helper
routines on the base toolchain class.

llvm-svn: 143900
2011-11-06 23:39:37 +00:00
Chandler Carruth 4c90fba23e Move the GCC installation detection logic down into the Generic_GCC
toolchain. The logic is mostly generic already, and where possible
should be made more generic. Also, it has no impact other than to expose
a set of methods which each toolchain can then query to setup their
desired configuration. These should be available to toolchains beyond
just Linux.

llvm-svn: 143899
2011-11-06 23:39:34 +00:00
Chandler Carruth 0c0981ee47 Remove an old OpenSUSE hack that is no longer needed -- it is exactly
the same as a directory added further down in the new logic.

llvm-svn: 143897
2011-11-06 23:10:49 +00:00
Chandler Carruth d0b93d6daf Remove the HasMultilib check. It was essentially useless. The driver now
looks for evidence of a multilib installation, and adds the appropriate
bits to the search paths.

llvm-svn: 143896
2011-11-06 23:09:05 +00:00
Chandler Carruth 0ad080e720 The version objects need to actually store the version strings; they
aren't guaranteed to live long enough otherwise.

llvm-svn: 143875
2011-11-06 10:51:30 +00:00
Chandler Carruth f5d4df9e44 Throw the switch and move all Linux header search over to the GCC
detection system that is providing the library paths and crt object
files.

This, modulo any bugs that need to be shaken out, resolves numerous bugs
with how we handle header paths. Here are a few that I know of:
- We no longer need to enumerate all GCC versions searched.
- OpenSUSE searched GCC versions in the wrong order.
- There were typos when selecting various patterns, etc.
- We aren't stating quite some many directories now.
- SysRoot didn't always work in a reasonable way.

I'm working on tests for this, but the tests are making me and Lit sad.
The real testing for this type of driver change is to try it out on
various distributions. I'll hit the common ones right away, and start
more thorough testing tomorrow after some sleep.

llvm-svn: 143874
2011-11-06 10:31:01 +00:00
Chandler Carruth 7e62da2845 Add a missing triple spotted by inspecting and testing of the include
path triples. Also order the 32-bit triples a bit more reasonably.

llvm-svn: 143873
2011-11-06 10:30:58 +00:00
Chandler Carruth d95843aa8a Lift the GCCVersion type into the header file and start persisting it in
the detected GCC installation. This allows us to expose another aspect
of what we detected: the GCC version. This will be used shortly.

llvm-svn: 143871
2011-11-06 09:39:46 +00:00
Chandler Carruth 4be70dd963 Switch some of these interfaces from std::string to StringRef and Twine.
This will facilitate further use and recombinations of them.

llvm-svn: 143869
2011-11-06 09:21:54 +00:00
Chandler Carruth 5b77c6c618 Take a better approach to detecting and selecting multiarch include
directories. This way we stop at the first multiarch directory found on
the system. This achieves the real intended result of pruning
non-existent directories.

llvm-svn: 143866
2011-11-06 08:21:07 +00:00
Chandler Carruth 5da43e83d2 Revert r143864, as the problem I was actually looking at can be solved
a better way. The more I think about it the more worried I am that this
hammer is simply too large. We should only be reaching out to the
filesystem when doing interesting "detection" things, not gratuitously.

Original commit message:
Start pruning down the set of flags passed to CC1 for header search.
This cleans up the CC1 invocations, and reduces the overhead there.
We're still hammering the filesystem looking for the C++ standard
libraries though.

The only reservation I have about this policy is the case of virtualized
files inside of CC1, but it's not clear what the best way to solve that
is. The Driver consistently queries the actual filesystem to make its
decisions. Changing that would be a very large undertaking. It might be
worthwhile, but it's not an immediate goal.

llvm-svn: 143865
2011-11-06 08:21:04 +00:00
Chandler Carruth 28e39d4b17 Start pruning down the set of flags passed to CC1 for header search.
This cleans up the CC1 invocations, and reduces the overhead there.
We're still hammering the filesystem looking for the C++ standard
libraries though.

The only reservation I have about this policy is the case of virtualized
files inside of CC1, but it's not clear what the best way to solve that
is. The Driver consistently queries the actual filesystem to make its
decisions. Changing that would be a very large undertaking. It might be
worthwhile, but it's not an immediate goal.

llvm-svn: 143864
2011-11-06 07:31:36 +00:00
David Blaikie a54e9643ef Fixing -g break caused by a dead reference to a temporary introduced in r143732.
llvm-svn: 143856
2011-11-06 01:53:39 +00:00
Peter Collingbourne 9b515cb0ec Add the depfile as a result file so that it is deleted if we crash,
and prevent the diagnostic preprocessor run from writing a depfile.

llvm-svn: 143846
2011-11-06 00:40:05 +00:00
Chandler Carruth bff1e8d53d Enhance the GCC version parsing and comparison logic to handle some more
edge cases and have better behavior. Specifically, we should actually
prefer the general '4.6' version string over the '4.6.1' string, as
'4.6.2' should be able to replace it without breaking rpaths or any
other place that these paths have been embedded. Debian-based
distributions are already using a path structure with symlinks to
achieve in-place upgrades for patch versions. Now our parsing reflects
this and we select the shorter paths instead of the longer paths.

A separate issue was that we would not parse a leading patch version
number even in the presence of a suffix. The above change makes this
more problematic as it would cause a suffix being added to make us treat
the entire thing as patch-version-agnostic, which it isn't. This changes
the logic to distinguish between '4.4.x' and 4.4.1-x', and retain that
the latter has *some* patch number information. Currently, we always
bias toward the shorter and more canonical version strings. If it
becomes important we can add more Debian like rules to produce sequences
such as '4.4.1b' > '4.4.1' > '4.4.1-rc3' > '4.4.1-rc2' > '4.4.1-pre5',
but I'm very doubtful this will ever matter or be desirable.

I've made the tests for this logic a bit more interesting, and added
some specific tests for logic that is now different.

llvm-svn: 143841
2011-11-05 23:24:30 +00:00
Chandler Carruth 4dfcf4ccf4 Remove a pointless member. I have no idea why I made this not a local
variable to begin with... As I'm planning to add include root
information to this object, this would have caused confusion. It didn't
even *actually* hold the include root by the time we were done with it.

llvm-svn: 143840
2011-11-05 22:23:14 +00:00
Chandler Carruth 2a750a0801 Remove a no-longer needed helper function. Thanks for implementing this
Michael!

llvm-svn: 143839
2011-11-05 22:23:11 +00:00
Chandler Carruth 14dd5ffcbf Move the GCC installation detection helper a member of the Linux
toolchain instead of merely using it in the constructor. This will allow
us to query it when building include paths as well as the file search
paths built in the constructor. I've lifted as little of it as I could
into the header file.

Eventually this will likely sink down into some of the Generic
toolchains and be used on more platforms, but I'm starting on Linux so
I can work out all the APIs needed there, where it is easiest to test
and we have the most pressing need.

llvm-svn: 143838
2011-11-05 22:07:51 +00:00
Chandler Carruth a95f344b3e Remove support for Gentoo subversion-ebuild installed llvm-gcc libstdc++
headers. As llvm-gcc is dead, and I have no idea if this ever really
worked, I think it's time for it to go. More importantly, it makes it
harder to generalize the include search logic. If someone really wants
these to work, they can set the CPLUS_INCLUDE_PATH environment variable.

llvm-svn: 143836
2011-11-05 21:26:18 +00:00
Chandler Carruth a796f53821 Move the Linux header searching from the Frontend to the Driver. This is
the first (and diff-noisiest) step to making Linux header searching
tremendously more principled and less brittle. Note that this step
should have essentially no functional impact. We still search the exact
same set of paths in the exact same order. The only change here is where
the code implementing such a search lives.

This has one obvious negative impact -- we now pass a ludicrous number
of flags to the CC1 layer. That should go away as I re-base this logic
on the logic to detect a GCC installation. I want to do this in two
phases so the bots can tell me if this step alone breaks something, and
so that the diffs of the refactoring make more sense.

llvm-svn: 143822
2011-11-05 20:17:13 +00:00
Benjamin Kramer 6ff181ef3c Try to reduce the nastiness that creeps in through Windows.h a bit.
llvm-svn: 143816
2011-11-05 17:43:55 +00:00
Chad Rosier cda5732e52 [driver] If we're only linking, don't warn about unused arguments which are
obviously only used during compilation.
rdar://10386708

llvm-svn: 143813
2011-11-05 15:56:33 +00:00
Chandler Carruth d9e10ecb68 Fix a significant oversight in my move of MSVC includes to the driver:
actually manage the builtin header file includes as well as the system
ones.

This one is actually debatable whether it belongs in the driver or not,
as the builtin includes are really an internal bit of implementation
goop for Clang. However, they must be included at *exactly* the right
point in the sequence of header files, which makes it essentially
impossible to have this be managed by the Frontend and the rest by the
Driver. I have terrible ideas that would "work", but I think they're
worse than putting this in the driver and making the Frontend library
even more ignorant of the environment and system on which it is being
run.

Also fix the fact that we weren't properly respecting the flags which
suppress standard system include directories.

Note that this still leaves all of the Clang tests which run CC1
directly and include builtin header files broken on Windows. I'm working
on a followup patch to address that.

llvm-svn: 143801
2011-11-05 09:24:44 +00:00
Chandler Carruth 611cb64453 Add two flags to the CC1 layer that I was hoping to avoid. We need to
encode the *exact* semantics which the header search paths internally
built by the Frontend layer have had, which is both non-user-provided,
and at times adding the implicit extern "C" bit to the directory entry.

There are lots of CC1 options that are very close, but none do quite
this, and they are all already overloaded for other purposes. In some
senses this makes the command lines more clean as it clearly indicates
which flags are exclusively used to implement internal detection of
"standard" header search paths.

Lots of the implementation of this is really crufty, due to the
surrounding cruft. It doesn't seem worth investing lots of time cleaning
this up as it isn't new, and hopefully *lots* of this code will melt
away as header search inside of the frontend becomes increasingly
trivial.

llvm-svn: 143798
2011-11-05 08:30:29 +00:00
Peter Collingbourne 4a089ad86d On Linux, enable the gold plugin if we are using LTO.
llvm-svn: 143778
2011-11-05 03:47:53 +00:00
Michael J. Spencer 85da676885 Fix MSVC build.
llvm-svn: 143770
2011-11-05 00:46:46 +00:00
Chandler Carruth df52783e32 Begin the migration of header search logic to the driver, starting with
Windows. There are still FIXMEs and lots of problems with this code.
Some of them will be addressed shortly by my follow-up patches, but most
are going to wait until we isolate this code and can fix it properly.
This version should be no worse than what we had before.

llvm-svn: 143752
2011-11-04 23:49:05 +00:00
Chandler Carruth 814db37f7d Switch the C++ include interface in the ToolChain to use the same naming
as the system include interface before I start adding implementations of
it to individual ToolChain implementations.

llvm-svn: 143751
2011-11-04 23:49:01 +00:00
Devang Patel 384dfa4f10 Enable -flimit-debug-info by default. Now, clang lazily emits debug info for structs. Original behavior can be restored using -fno-limit-debug-info.
llvm-svn: 143733
2011-11-04 20:05:58 +00:00
Chad Rosier c2bf338d35 [driver] Don't blindly accept all -g options.
rdar://10383444

llvm-svn: 143732
2011-11-04 19:28:44 +00:00
Chandler Carruth 4c81dfacbb Sink the strange '-stdlib=...' flag handling into the C++ include
handling logic of the generic ToolChain. This flag, despite its name,
has *nothing* to do with the GCC flag '-nostdlib' that relates
(exclusively) to the linking behavior. It is a most unfortunate name in
that regard...

It is used to tell InitHeaderSearch.cpp *which* set of C++ standard
library header search paths to use -- those for libstdc++ from GCC's
installation, or those from a libc++ installation. As this logic is
hoisted out of the Frontend, and into the Driver as part of this
ToolChain, the generic method will be overridden for the platform, where
it can implement this logic directly. As such, hiding the CC1 option
passing in the generic space is a natural fit despite the odd naming.

Also, expand on the comments to clarify whats going on, and tidy up the
Tools.cpp code now that its simpler.

llvm-svn: 143687
2011-11-04 07:43:33 +00:00
Chandler Carruth 491db32444 Sink the handling of -fobjc-arc-cxxlib to live with the other -fobjc-arc
implementation in the driver. This cleans up the signature and semantics
of the include flag adding component of the toolchain. Another step to
ready it for holding all the InitHeaderSearch logic.

llvm-svn: 143686
2011-11-04 07:34:47 +00:00
Chandler Carruth 9802c1406f Add a FIXME to cleanup the CPATH handling. It's currently burried with
the rest of the mess in InitHeaderSearch.cpp. We could hoist it into the
driver profitably, removing more noise from the driver -> frontend
communication.

llvm-svn: 143685
2011-11-04 07:12:58 +00:00
Chandler Carruth 6bfd84f25d Add a system include management interface to the toolchain, and call it
and the C++ include management routine from the proper place when
forming preprocessor options in the driver. This is the first step to
teaching the driver to manage all of the header search paths. Currently,
these methods remain just stubs in the abstract toolchain. Subsequent
patches will flesh them out with implementations for various toolchains
based on the current code in InitHeaderSearch.cpp.

llvm-svn: 143684
2011-11-04 07:12:53 +00:00
Chad Rosier cdb008d117 In addition to dumping preprocessed source, dump a script with the command line
arguments that caused clang to crash.
rdar://8314451

llvm-svn: 143573
2011-11-02 21:29:05 +00:00
Bob Wilson 126c491319 Invoke the Darwin assembler with -g instead of --gdwarf2.
The -g and --gdwarf2 options are currently synonyms to the Darwin assembler.
But clang itself does not recognize --gdwarf2, so if we want to experiment
with using clang, with its integrated assembler, to replace the default
assembler, it is necessary to use -g.  <rdar://problem/10349486>

llvm-svn: 143533
2011-11-02 05:10:45 +00:00
Eli Friedman 055c970839 Add an option to emulate the strange Apple gcc behavior of #pragma pack.
<rdar://problem/10374763>

llvm-svn: 143527
2011-11-02 01:53:16 +00:00
Chandler Carruth 4c042fe667 Simplify the set of directories we look for on multiarch systems.
I don't have any Debian system with one of these currently, and it seems
unlikely for one to show up suddenly. We can add more patterns here if
they become necessary.

llvm-svn: 143346
2011-10-31 09:06:40 +00:00
Chandler Carruth fb7fa24e5c Fix part of PR11223 and probably a few dups as well. This teaches the
library search logic to "properly" handle multiarch installations. I've
tested this on both Debian unstable and the latest Ubuntu which both use
this setup, and this appears to work largely the same way as GCC does.
It isn't exactly the same, but it is close enough and more principled in
its behavior where it differs. This should resolve any failures to find
'crt1.o' etc on Debian-based Linux distributions. If folks find more
cases where we fail, please file bugs and CC me.

Test cases for all of the debian silliness are waiting both to simplify
the process of merging these down into the 3.0 release, and because
they're so crazy I haven't yet been able to really produce a fake tree
that represents what we need to test for. I'll eventually add them
though.

llvm-svn: 143344
2011-10-31 08:42:24 +00:00
Bob Wilson d32fba2379 Stop disabling integrated assembler with -static. <rdar://problem/10175391>
The integrated assembler seems to be working pretty well for -static code
now, so remove the hacks to disable it.

llvm-svn: 143304
2011-10-30 00:20:28 +00:00
Eric Christopher 8605082dac Allow the -fno-operator-names option to be passed down to the rest
of the compiler.

Fixes PR10198
Patch by Brian Foley!

llvm-svn: 142913
2011-10-25 07:13:06 +00:00
Dan Gohman 53bb0ff685 Remove the SystemZ backend.
llvm-svn: 142879
2011-10-24 23:48:52 +00:00
Douglas Gregor 2b4907e73a Have -fms-no-extensions turn off -fms-compatibility
llvm-svn: 142798
2011-10-24 15:49:38 +00:00
Benjamin Kramer e889bb14f3 Pack struct better.
llvm-svn: 142725
2011-10-22 15:40:28 +00:00
NAKAMURA Takumi b5e6fa2949 lib/Driver/Tools.cpp: Use PathV2::is_absolute() to add -fdebug-compilation-dir. pwd[0] might not be '/' on Win32 hosts.
llvm-svn: 142720
2011-10-22 10:25:25 +00:00
Nick Lewycky ba743b75cb Take DW_AT_comp_dir from $PWD when it's present and starts with a '/'. This is
closer to what GCC does, except that GCC also checks that the inodes for $PWD
and '.' match.

llvm-svn: 142633
2011-10-21 02:32:14 +00:00
Daniel Dunbar b274318bba Frontend: Support -iframework.
llvm-svn: 142418
2011-10-18 20:40:38 +00:00
Argyrios Kyrtzidis 058b451d87 [driver] Make the driver to link the simulator arclite lib when passing -mios-simulator-version-min.
rdar://10218700

llvm-svn: 142372
2011-10-18 17:40:15 +00:00
Argyrios Kyrtzidis 697729a7de Revert r142311, -mios-simulator-version-min does not work correctly.
llvm-svn: 142322
2011-10-18 00:22:49 +00:00
Argyrios Kyrtzidis 7e16493c9b Remove the hack where we sniff the __IPHONE_OS_VERSION_MIN_REQUIRED define.
We can use -mios-simulator-version-min now. rdar://10218700

llvm-svn: 142311
2011-10-17 23:41:26 +00:00
Nick Lewycky 1d617acef9 Wire up support for the controlling the extended dwarf .file directive. With
r142300 but not this patch, clang -S may emit .s files that assemblers other
than llvm-mc can't parse.

llvm-svn: 142301
2011-10-17 23:05:52 +00:00
Rafael Espindola 70b8d76e64 Implement -static-libstdc++ for linux.
llvm-svn: 142290
2011-10-17 22:14:51 +00:00
Rafael Espindola cc35432550 Implement -static-libgcc on linux and refactor the code responsible for adding
libgcc to the link line into a helper function.

llvm-svn: 142269
2011-10-17 21:39:04 +00:00
Chandler Carruth 5f9a44f3e9 Fix a silly bug introduced in r142133.
llvm-svn: 142134
2011-10-16 11:05:04 +00:00
Chandler Carruth a7b4414ac2 Clean up some cruft in the library path searching logic by making
'libdir' mean the actual library directory, not the GCC subdirectory of
the library directory. That was just a confusing pattern. Instead,
supply proper GCC subdirectories when scanning for various triple-based
subdirectories with a GCC installation in them. This also makes it much
more obvious how multiarch installations, which have a triple-based
prefix as well as suffix work.

Also clean up our handling of these triple-prefixed trees by using them
in both a multiarch pattern and a non-multiarch pattern whenever they
exist.

Note that this *does not* match what GCC does on Debian, the only truly
multiarch installation I've been able to get installed and test on. GCC
appears to have a bug, and ends up searching paths like
'/lib/../../lib32' which makes no sense what-so-ever. Instead, I've
tried to encode the rational logic that seems clearly intended by GCC's
pattern. GCC ends up with patterns like:

  /lib/../../lib32
  /usr/lib/../../lib32
  /usr/lib/x86_64-linux-gnu/../..lib32

Only the last one makes any sense having a '/../..' in it, so in Clang,
that's the only one which gets a '/../..' in it.

I *think* this will fix Debian multiarch links. I'm committing without
baking this logic into our test suite so I can test on a few different
systems. If all goes well (and no one screams) I'll check in some more
comprehensive tests for multiarch behavior tomorrow.

llvm-svn: 142133
2011-10-16 10:54:30 +00:00
Rafael Espindola c0b9791b63 Fix the CXX_INCLUDE_ROOT case that was out of date with ScanLibDirForGCCTriple.
llvm-svn: 141980
2011-10-14 19:50:08 +00:00
Bob Wilson 6524dd33be Use Triple.isOSDarwin() instead of comparing against Triple::Darwin.
There are now separate Triple::MacOSX and Triple::IOS values for the OS
so comparing against Triple::Darwin will fail to match those.  Note that
I changed the expected output for the Driver/rewrite-objc.m test, which had
previously not been passing Darwin-specific options with the macosx triple.

llvm-svn: 141944
2011-10-14 05:03:44 +00:00
Richard Smith 31ce793a0b Rename -Wc++0x-compat, -Wc++0x-extensions and -Wc++0x-narrowing from c++0x to
c++11. The old names are kept for backwards-compatibility. Patch by Ahmed
Charles! Names for backwards-compatible DiagGroups removed by me.

llvm-svn: 141913
2011-10-13 23:32:09 +00:00
Benjamin Kramer 74a1f91ff7 Add triple for RHEL 5 to the libpath collecting logic.
llvm-svn: 141887
2011-10-13 20:45:37 +00:00
Douglas Gregor 3d68aa838b The Objective-C rewriter uses the fragile ABI, always.
llvm-svn: 141795
2011-10-12 18:28:53 +00:00
Daniel Dunbar 0f41eee2a0 Driver: Add support for a new -nostdlibinc option.
- This disables the system include directories, but not the compiler builtin
   directories. Useful for projects that want to use things like the intrinsic
   headers, but are otherwise freestanding.

 - I'm willing to reconsider the option naming, I also considered providing an
   explicit -builtinc (which would match -nobuiltininc), but this is more
   consistent with existing options.

llvm-svn: 141692
2011-10-11 18:20:16 +00:00
Daniel Dunbar b25bfde52d Frontend: Replace -nostdinc by -nostdsysteminc (which is just system include
paths). The -nostdinc behavior is now -nostdsysteminc + -nobuiltininc.

llvm-svn: 141691
2011-10-11 18:20:10 +00:00
Roman Divacky 3403a3b28f Link in Scrt1.o instead of crt1.o when -pie is specified.
llvm-svn: 141573
2011-10-10 19:47:45 +00:00
Bob Wilson 391214aa3a Partially revert r141374: allow use of libc++ prior to Mac OS X 10.7.
Apple only supports libc++ on OS X 10.7 and later but for the open-source
compiler that restriction doesn't make sense.

llvm-svn: 141566
2011-10-10 18:46:10 +00:00
Peter Collingbourne 1deb5b61f4 OpenCL: add driver/frontend support for precompiled headers
llvm-svn: 141516
2011-10-09 22:03:19 +00:00
NAKAMURA Takumi 93eafc6ce1 Fix "Uninitialized" warnings.
llvm-svn: 141487
2011-10-08 11:31:53 +00:00
NAKAMURA Takumi 82a351197f Whitespace
llvm-svn: 141486
2011-10-08 11:31:46 +00:00
Argyrios Kyrtzidis 741fab1358 [arcmt] Ignore linking errors when doing ARC migration, rdar://10247606
llvm-svn: 141434
2011-10-07 22:58:08 +00:00
Bob Wilson 102be44843 Clang driver changes for iOS 5.0 and OS X Lion support.
Check whether the libc++ library is available when using -stdlib=libc++,
and also adjust the check for whether to link with -lgcc_s.1.
Patch by Ted Kremenek and Daniel Dunbar.

llvm-svn: 141374
2011-10-07 17:54:41 +00:00
Chad Rosier 9ac845149b More cleanup using StringSwitch.
llvm-svn: 141373
2011-10-07 17:48:56 +00:00
Bob Wilson 997a97f0f5 Use StringSwitch. Thanks for Chandler for the suggestion.
llvm-svn: 141344
2011-10-07 00:37:57 +00:00
Benjamin Kramer 8c26d440da Use strpbrk(3) instead of open coding it.
llvm-svn: 141328
2011-10-06 22:53:35 +00:00
Bob Wilson bc9f7087b2 Remove DISABLE_ARM_DARWIN_USE_MOVT ifdefs. Radar 9456730.
llvm-svn: 141320
2011-10-06 21:52:27 +00:00
Bob Wilson bd9d0e6d91 Rearrange for readability. No functional change.
llvm-svn: 141309
2011-10-06 20:27:40 +00:00
Bob Wilson d4d0237339 Add a missing check for cortex-a9.
llvm-svn: 141308
2011-10-06 20:27:38 +00:00
Ivan Krasin 31f7411bfc Add -Wlanguage-extension-token option for ext_token_used warning.
llvm-svn: 141268
2011-10-06 02:46:34 +00:00
Daniel Dunbar 096ed290a1 Driver & AST: Implement support for -fpack-struct and -fpack-struct= command
line options.
 - <rdar://problem/10120602>, PR9631

llvm-svn: 141211
2011-10-05 21:04:55 +00:00
Chad Rosier 10746f5ebb [driver] For consistency, handle all shell special characters handled by the
quoting code.

llvm-svn: 141205
2011-10-05 20:09:11 +00:00
Chad Rosier 9b1311df26 [driver] The -v option doesn't quoted the command line arguments for historical
reasons.  However, it does seems practical to quote strings that need it.
rdar://10221951

llvm-svn: 141202
2011-10-05 19:51:41 +00:00
Chandler Carruth e276b3662b Use the InstalledDir correctly, and test it correctly as well. =/ Should
have noticed this previously, sorry.

llvm-svn: 141167
2011-10-05 06:38:03 +00:00
Chandler Carruth cf59bc5939 Teach Clang to cope with GCC installations that have unusual patch
"versions". Currently, these are just dropped on the floor, A concrete
version number will always win out.

llvm-svn: 141159
2011-10-05 03:09:51 +00:00
Chandler Carruth f7e0ecb65d Implement the feature I was originally driving toward when I started
this saga. Teach the driver to detect a GCC installed along side Clang
using the existing InstalledDir support in the Clang driver. This makes
a lot of Clang's behavior more automatic when it is installed along side
GCC.

Also include the first test cases (more to come, honest) which test both
the install directory behavior, and the version sorting behavior to show
that we're actually searching for the best candidate GCC installation
now.

llvm-svn: 141145
2011-10-05 01:01:57 +00:00
Chandler Carruth 486ed05105 Hoist the other messy part out of an inner loop and into a helper
function, cleaning up along the way.

llvm-svn: 141134
2011-10-04 23:17:12 +00:00
Chandler Carruth 59f4407d5b Hoist the first chunk of this into a helper function. No functionality
change.

llvm-svn: 141131
2011-10-04 22:58:04 +00:00
Chad Rosier 6c98dfd0f4 [driver] Improve r141053 by only emitting the warning if the original input
was assembly.  Otherwise, something like -save-temps causes the integrated
assembler to warn.

llvm-svn: 141127
2011-10-04 22:35:48 +00:00
Chandler Carruth 7dc477ef77 Fix Windows+MinGW which introduces noise into path separators.
There should be a better solution to this; Michael and I are continuing
to discuss exactly what it should be. The one solution I'm very
uncomfortable with is making the FileCheck tests use a regex for each
path separator.

llvm-svn: 141126
2011-10-04 22:22:13 +00:00
Chandler Carruth e683a18970 Now that multiple prefixes are much cheaper to search for GCC
installations, support them when installed directly under the system
root ('/lib/gcc/...' essentially).

With this, Clang can correctly detect and use a cross-compiling GCC
installation within a system root and use it.

Again, test cases will be coming in later commits, as I'm going to write
a few test cases that exercise nearly all of this logic.

llvm-svn: 141121
2011-10-04 21:22:42 +00:00
Chandler Carruth 531f1ff78c Rework the search for a GCC installation still further. This combines
two fundamental changes, as they ended up being interrelated.

The first is to walk from the root down through the filesystem so that
we prune subtrees which do not exist early. This greatly reduces the
filesystem traffic of this routine. We store the "best" GCC version we
encounter, and look at all of the GCC installations available.

Also, we look through GCC versions by scanning the directory rather than
using a hard-coded list of versions. This has several benefits. It makes
it much more efficient to locate a GCC installation even in the presence
of a large number of different options by simply reading the directory
once. It also future-proofs us as new GCC versions are released and
installed. We no longer have a hard coded list of version numbers, and
won't need to manually updated it. We can still filter out known-bad
versions as needed. Currently I've left in filtering for all GCC
installations prior to 4.1.1, as that was the first one supported
previously.

llvm-svn: 141120
2011-10-04 21:22:33 +00:00
Chandler Carruth 1a98ab4fc3 Add a comment explaining that I have a better plan for implementing the
GCC installation search that requires fewer filesystem operations.
Planning to implement that next as the current approcah while thorough
(and so far looks correct) does a very unfortunate number of filesystem
operations.

I'm motivated to fix this in no small part because I would like to
support a much larger space of triples and GCC versions, which would
explode the current algorithm.

llvm-svn: 141073
2011-10-04 09:58:21 +00:00
Chandler Carruth 1d6073abad Invert the loop for detecting installed GCC trees. This make the loop
find the newest GCC available, among other goodness. It makes the entire
system much less prone to error from prefixes and/or system roots
pruning early the set of triples and GCC versions available.

Also, improve some comments and simplify the forms of some of the loops.

This causes the driver to stat directories more often than is strictly
necessary, but the alternatives which I looked at that still
accomplished this goal needed quite a bit more code and were likely not
much faster.

Test cases for this, now that our behavior here is significantly more
principled and predictable, should come tomorrow as I walk back through
VMs looking for edge cases that are missed after this.

llvm-svn: 141072
2011-10-04 09:47:17 +00:00
Chandler Carruth 621fed5f5a Fuse the two halves of the GCC installation detection. This is
significantly cleaner (IMO) and more principled. We now walk down each
layer of the directory hierarchy searching for the GCC install. This
change does in fact introduce a significant behavior change in theory,
although in practice I don't know of any distro that will be impacted by
it negatively, and Debian may (untested) get slightly better through it.

Specifically, the logic now looks exhaustively for patterns such as:

  /usr/lib/<triple>/gcc/<triple>

Previously, this would only be selected if there was *also*
a '/usr/lib/gcc/<triple>' directory, or if '<triple>' were the excat
DefaultHostTriple in the driver.

There is a 4-deep nested loop here, but it doesn't do terribly many
filesystem operations, as we skip at each layer of that layer's
directory doesn't exist.

There remains a significant FIXME in this logic: it would be much better
to first build up a set of candidate components for each of the four
layers with a bottom-up pruning such as this, but then select the final
installation using a top-down algorithm in order to find the newest GCC
installation available, regardless of which particular path leads to it.

llvm-svn: 141071
2011-10-04 08:32:14 +00:00
Bob Wilson 05de0298d2 Rip out flags for controlling C++ "production mode" separately.
This is old leftover cruft from the days when C++ was not yet ready
for prime time.

llvm-svn: 141063
2011-10-04 05:34:14 +00:00
Chandler Carruth 7e6d8cc46c Factor the data apart from the logic of locating various GCC
installations. This first selects a set of prefixes and a set of
compatible triples for the current architecture. Once selected, we drive
the search with a single piece of code.

This code isn't particularly efficient as it stands, but its only
executed once. I'm hoping as I clean up the users of this information,
it will also slowly become both cleaner and more efficient.

This also changes the behavior slightly. Previously, we had an ad-hoc
list of prefixes and triples, and we only looked for some triples
beneath specific prefixes and vice versa. This has led to lots of
one-off patches to support triple X, or support lib dir Y. Even without
going to a fully universal driver, we can do better here. This patch
makes us always look first in either 'lib32' or 'lib64' on 32- or 64-bit
hosts (resp.). However, we *always* look in 'lib'.

Currently I have one lingering problem with this strategy. We might find
a newer or better GCC version under a different (but equally compatible)
triple. Fundamentally, this loop needs to be fused with the one below.
That's my next patch.

llvm-svn: 141056
2011-10-04 02:28:41 +00:00
Chad Rosier 83200fdc65 [driver] Improve r141053 by only emitting the warning if the original input
was assembly.  Otherwise, something like -save-temps causes the integrated
assembler to warn.

llvm-svn: 141055
2011-10-04 01:53:36 +00:00
Chad Rosier 672831dec7 [driver] Emit a warning if the user has requested debug information and we're
using the integrated assembler.
rdar://10216353

llvm-svn: 141053
2011-10-04 01:01:30 +00:00
Chandler Carruth 3f0c8f79e0 Refactor the detection of a GCC installation into a helper class. This
is designed to allow the detection to record more rich information about
the installation than just a single path.

Mostly, the functionality remains the same. This is primarily
a factoring change. However, the new factoring immediately fixes one
issue where on ubuntu we didn't walk up enough layers to reach the
parent lib path. I'll have a test tree for that once I finish making the
Ubuntu tree work reasonably.

llvm-svn: 141011
2011-10-03 18:16:54 +00:00
Chandler Carruth 2356b2c307 Enable generic multilib support on 32bit hosts. Previously this was only
enabled for debian hosts, which is quite odd. I think all restriction on
when Clang attempts to use a multilib installation should go away. Clang
is fundamentally a cross compiler. It behaves more like GCC when built
as a cross compiler, and so it should just use multilib installs when
they are present on the system. However, there is a very specific
exemption for Exherbo, which I can't test on, so I'm leaving that in
place.

With this, check in a generic test tree for multilib on a 32-bit host.
This stubs out many directories that most distributions don't use but
that uptsream GCC supports. This is intended to be an agnostic test that
the driver behaves properly compared with the GCC driver it aims for
compatibility with.

Also, fix a bug in the driver that this testing exposed (see!) where it
was incorrectly testing the target architecture rather than the host
architecture.

If anyone is having trouble with the tree-structure stubs I'm creating
to test this, let me know and I can revisit the design. I chose this
over (for example) a tar-ball in order to make tests run faster at the
small, hopefully amortized VCS cost.

llvm-svn: 140999
2011-10-03 09:00:50 +00:00
Chandler Carruth 5fdc7cba2a Teach the logic for locating an installed GCC about the system root.
This requires fixing a latent bug -- if we used the default host triple
instead of an autodetected triple to locate GCC's installation, we
didn't go back and fix the GCC triple. Correct that with a pile of
hacks. This entire routine needs a major refactoring which I'm saving
for a subsequent commit. Essentially, the detection of the GCC triple
should be hoisted into the same routine as we locate the GCC
installation: the first is intrinsically tied to the latter. Then the
routine will just return the triple and base directory.

Also start to bring the rest of the library search path logic under
test, including locating crtbegin.o. Still need to test the multilib and
other behaviors, but there are also bugs in the way of that.

llvm-svn: 140995
2011-10-03 08:02:58 +00:00
Chandler Carruth 2a649c7a42 Add initial support for applying the sysroot to library search paths.
This is still very much a WIP, but sysroot was completely broken before
this so we are moving closer to correctness.

The crux of this is that 'ld' (on Linux, the only place I'm touching
here) doesn't apply the sysroot to any flags given to it. Instead, the
driver must translate all the paths it adds to the link step with the
system root. This is easily observed by building a GCC that supports
sysroot, and checking its driver output.

This patch just fixes the non-multilib library search paths. We should
also use this in many other places, but first things first.

This also allows us to make the Linux 'ld' test independent of the host
system. This in turn will allow me to check in test tree configurations
based on various different distro's configuration. Again, WIP.

llvm-svn: 140990
2011-10-03 06:41:08 +00:00
Chandler Carruth 413e5ac2a5 Rework the selection of builtin library search paths on Linux to
precisely match the pattern and logic used by the GCC driver on Linux as
of a recent SVN checkout.

This happens to follow a *much* more principled approach. There is
a strict hierarchy of paths examined, first with multilib-suffixing,
second without such suffixing. Any and all of these directories which
exist will be added to the library search path when using GCC.

There were many places where Clang followed different paths, omitted
critical entries, and worst of all (in terms of challenges to debugging)
got the entries in a subtly wrong order.

If this breaks Clang on a distro you use, please let me know, and I'll
work with you to figure out what is needed to work on that distro. I've
checked the behavior of the latest release of Ubuntu, OpenSUSE, Fedora,
and Gentoo. I'll be testing it on those as well as Debian stable and
unstable and ArchLinux. I may even dig out a Slackware install.

No real regression tests yet, those will follow once I add enough
support for sysroot to simulate various distro layouts in the testsuite.

llvm-svn: 140981
2011-10-03 05:28:29 +00:00
Chandler Carruth a884013eaa Simplify this through the power of the ternary operator.
llvm-svn: 140965
2011-10-02 07:28:34 +00:00
Chandler Carruth b8d1be837c Consolidate the currently bizarre 32/64 multilib selection logic a bit.
llvm-svn: 140964
2011-10-02 07:06:48 +00:00
John McCall 9b0a7cea0f Make -fobjc-nonfragile-abi the -cc1 default, since it's the
increasingly prevailing case to the point that new features
like ARC don't even support the fragile ABI anymore.

This required a little bit of reshuffling with exceptions
because a check was assuming that ObjCNonFragileABI was
only being set in ObjC mode, and that's actually a bit
obnoxious to do.

Most, though, it involved a perl script to translate a ton
of test cases.

Mostly no functionality change for driver users, although
there are corner cases with disabling language-specific
exceptions that we should handle more correctly now.

llvm-svn: 140957
2011-10-02 01:16:38 +00:00
Chandler Carruth 6d913a1884 Revert r140604: "Let -B work for ld paths on Linux."
This patch may do what it describes, it may not. It's hard to tell as
its completely unclear what this is supposed to do. There are also no
test cases. More importantly, this seems to have broken lots of linker
invocations on multilib Linux systems.

The manual pages for 'ld' on Linux mention translating a '=' at the
beginning of the path into a *configure time* sysroot prefix (this is,
I believe, distinct from the --sysroot flag which 'ld' also can
support). I tested this with a normal binutils 'ld', a binutils 'ld'
with the sysroot flag enabled, and gold with the sysroot flag enabled,
and all of them try to open the path '=/lib/../lib32', No translation
occurs.

I think at the very least inserting an '=' needs to be conditioned on
some indication that it is supported and desired. I'm also curious to
see what toolchain and whan environment cause it to actually make
a difference.

I'm going to add a test case for basic sanity of Linux 'ld' invocations
from Clang in a follow-up commit that would have caught this.

llvm-svn: 140908
2011-10-01 00:37:35 +00:00
Daniel Dunbar 920844c36e Revert my --working-directory option, which wasn't well thought through.
llvm-svn: 140889
2011-09-30 21:33:09 +00:00
David Chisnall 3154e68bef Remove the conditional that avoided passing the Objective-C runtime specification flags to cc1. This fixes PR10369 (__builtin_NSStringMakeConstantString() selecting the wrong runtime in C / C++ code and crashing, although it doesn't fix the problem that instantiating the Mac runtime for non-Darwin targets was crashing.)
llvm-svn: 140853
2011-09-30 13:32:35 +00:00
Peter Collingbourne 3e7644af27 Driver: use correct search paths for multilib
llvm-svn: 140782
2011-09-29 13:42:24 +00:00
Benjamin Kramer fcfb53d5a5 Driver: Fix two bad typos that were breaking the buildbots.
llvm-svn: 140682
2011-09-28 05:33:02 +00:00
Chad Rosier fe6fd36b6c [driver] If no OSX or iOS target has been specified and we're compiling for
armv7, go ahead as assume we're targeting iOS.
rdar://10147774

llvm-svn: 140668
2011-09-28 00:46:32 +00:00
David Chisnall ddbd68fbd2 Check for GCC paths that have the target triple in them. This is required for a lot of cross-compile toolchains. Also add some slightly better support for -B.
llvm-svn: 140645
2011-09-27 22:03:18 +00:00
David Chisnall 3c9029b06c Let -B work for ld paths on Linux.
llvm-svn: 140604
2011-09-27 13:31:58 +00:00
Akira Hatanaka 37fd9e97d1 Make necessary changes in AddMIPSTargetArgs for targeting Mips64. Enable use of
-mcpu.
 

llvm-svn: 140562
2011-09-26 21:07:52 +00:00
David Blaikie 9c902b5502 Rename Diagnostic to DiagnosticsEngine as per issue 5397
llvm-svn: 140478
2011-09-25 23:23:43 +00:00
Daniel Dunbar eb5348ac31 Driver: Use sys::Process::SetWorkingDirectory, for consistency.
llvm-svn: 140434
2011-09-23 23:32:02 +00:00
Benjamin Kramer 333198cbd7 Driver: Explicitly include <unistd.h>, libstdc++'s <map> pulls it in, libc++ doesn't.
Also, on windows, chdir seems to live in <direct.h>.

llvm-svn: 140414
2011-09-23 21:03:19 +00:00
Daniel Dunbar 10d398f894 Driver: Add a --working-directory option which can be used to cause the compiler
to operate "as if" in a certain working directory.
 - For now, we just implement this by changing the actual working directory, but
   eventually we would want to handle this transparently. This is useful to
   avoid an extra exec() pair in some situations, and will be something we would
   want to support for more flexibility in using the Clang libraries.

llvm-svn: 140409
2011-09-23 20:33:41 +00:00
David Blaikie aa347f9392 Removing a bunch of dead returns/breaks after llvm_unreachables.
llvm-svn: 140407
2011-09-23 20:26:49 +00:00
David Blaikie 7900020616 More missing header inclusions from llvm_unreachable migration.
llvm-svn: 140369
2011-09-23 05:57:42 +00:00
David Blaikie 83d382b1ca Switch assert(0/false) llvm_unreachable.
llvm-svn: 140367
2011-09-23 05:06:16 +00:00
Benjamin Kramer 8404eb0bad Add support for CPATH and friends.
This moves the existing code for CPATH into the driver and adds the environment lookup and path splitting there.
The paths are then passed down to cc1 with -I options (CPATH), added after the normal user-specified include dirs.
Language specific paths are passed via -LANG-isystem and the actual filtering is performed in the frontend.

I tried to match GCC's behavior as close as possible

Fixes PR8971.

llvm-svn: 140341
2011-09-22 21:41:16 +00:00
Akira Hatanaka 94ab554749 Add case labels for Mips64 architectures.
llvm-svn: 140226
2011-09-21 02:13:07 +00:00
Bob Wilson 3e42bc55db For i386 kext fallback to llvm-gcc, search paths for several Darwin versions.
This replaces the hack to read UNAME_RELEASE from the environment when
identifying the OS version on Darwin, and it's more flexible.  It's also
horribly ugly, but at least this consolidates the ugliness to touch less of
the code so that it will be easier to rip out later.

llvm-svn: 140187
2011-09-20 22:00:38 +00:00
Chad Rosier d3a0f954a3 [driver] Default to arm mode when using the integrated assembler.
rdar://10125227

llvm-svn: 140179
2011-09-20 20:44:06 +00:00
Francois Pichet 1b4f1637fb As per discussion with Doug Gregor on the IRC channel, introduce a new compiler switch: -fms-compatility.
Microsoft specific tweaking will now fall into 2 categories:

    - fms-extension: Microsoft specific extensions that should never change the meaning of an otherwise well formed code. Currently map to LangOptions::Microsoft. (To be clearer, I am planning to change the name to LangOptions::MicrosoftExt).

    - fms-compatibility: Really a MSVC emulation mode. Map to LangOptions::MicrosoftMode. Can change the meaning of an otherwise standard conformant program.

llvm-svn: 139978
2011-09-17 04:32:15 +00:00
Douglas Gregor c6b316acd9 Pass -fmodule-cache-path along to -cc1 properly
llvm-svn: 139977
2011-09-17 02:20:28 +00:00
Eli Friedman 0ee0b9fdaf Fix search paths for Ubuntu 11.04 x86. Patch by Stepan Dyatkovskiy.
llvm-svn: 139941
2011-09-16 21:04:38 +00:00
Douglas Gregor 97eec24b0b Add an experimental flag -fauto-module-import that automatically turns
#include or #import direcctives of framework headers into module
imports of the corresponding framework module.

llvm-svn: 139860
2011-09-15 22:00:41 +00:00
Douglas Gregor f936f782f5 Teach the driver to always pass down a module cache path. If none is
supplied, use something derived from the system's temporary
directory. Depends on LLVM r139725.

llvm-svn: 139726
2011-09-14 20:28:46 +00:00
Chad Rosier 8230116066 [driver] Add support for the COMPILER_PATH environment variable, which adds the
specified path(s) to the list of prefix directories.
rdar://10097714

llvm-svn: 139677
2011-09-14 00:47:55 +00:00
John McCall 7959fee258 Treat the weak export of block runtime symbols as a deployment-target
feature akin to the ARC runtime checks.  Removes a terrible hack where
IR gen needed to find the declarations of those symbols in the translation
unit.

llvm-svn: 139404
2011-09-09 20:41:01 +00:00
Chad Rosier c31e48d7e4 [driver] i386 kext preprocessor jobs also need their unsupported options
filtered.  This happenis when -save-temps is specified. 
<rdar://problem/10088387>

llvm-svn: 139269
2011-09-08 00:38:00 +00:00
Chad Rosier e75ef40843 [driver] When clang crashes, don't try to generate diagnostics (i.e.,
preprocessor output) with multiple -arch options.

llvm-svn: 139207
2011-09-06 23:52:36 +00:00