Commit Graph

1364 Commits

Author SHA1 Message Date
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