summaryrefslogtreecommitdiffstats
path: root/clang/lib/Driver/Driver.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* Remove extraneous qualifiers due to "using namespace". NFCDouglas Katzman2015-06-041-1/+1
| | | | llvm-svn: 239038
* Replace push_back(Constructor(foo)) with emplace_back(foo) for non-trivial typesBenjamin Kramer2015-05-291-2/+2
| | | | | | | | | | | | | | | | | | | | If the type isn't trivially moveable emplace can skip a potentially expensive move. It also saves a couple of characters. Call sites were found with the ASTMatcher + some semi-automated cleanup. memberCallExpr( argumentCountIs(1), callee(methodDecl(hasName("push_back"))), on(hasType(recordDecl(has(namedDecl(hasName("emplace_back")))))), hasArgument(0, bindTemporaryExpr( hasType(recordDecl(hasNonTrivialDestructor())), has(constructExpr()))), unless(isInTemplateInstantiation())) No functional change intended. llvm-svn: 238601
* Change final case of Driver::getToolChain to "if/else/else/else..."Douglas Katzman2015-05-261-20/+11
| | | | | | Differential Revision: http://reviews.llvm.org/D9939 llvm-svn: 238225
* clang-cl: Don't look up absolute paths in %LIB%.Nico Weber2015-04-241-1/+2
| | | | | | | | | Before this patch, passing a non-existent absolute path to clang-cl would cause stat'ing of impossible paths. For example, `clang-cl -c d:\adsfasdf.txt` would cause a stat of C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\LIBd:\asdfadsf.cc llvm-svn: 235787
* Report an error when -m<os>-version-min= does not specify a version.Bob Wilson2015-04-071-1/+1
| | | | | | | | | Currently if you use -mmacosx-version-min or -mios-version-min without specifying a version number, clang silently sets the minimum version to "0.0.0". This is almost certainly not what was intended, so it is better to report it as an error. rdar://problem/20433945 llvm-svn: 234270
* Add driver support for Native Client SDKDerek Schuff2015-03-301-0/+3
| | | | | | | | | | | | | | Add Tool and ToolChain support for clang to target the NaCl OS using the NaCl SDK for x86-32, x86-64 and ARM. Includes nacltools::Assemble and Link which are derived from gnutools. They are similar to Linux but different enought that they warrant their own class. Also includes a NaCl_TC in ToolChains derived from Generic_ELF with library and include paths suitable for an SDK and independent of the system tools. Differential Revision: http://reviews.llvm.org/D8590 llvm-svn: 233594
* Let Clang invoke CloudABI's linker.Ed Schouten2015-03-261-0/+3
| | | | | | | | | | | | | | | | | | | | | | Now that CloudABI's target information and header search logic for Clang has been submitted, the only thing that remains to be done is adding support for CloudABI's linker. CloudABI uses Binutils ld, although there is some work to use lld instead. This means that this code is largely based on what we use on FreeBSD. There are some exceptions, however: - Only static linking is performed. CloudABI does not support any dynamically linked executables. - CloudABI uses compiler-rt, libc++ and libc++abi unconditionally. Link in these libraries instead of using libgcc_s, libstdc++, etc. - We must ensure that the .eh_frame_hdr is present to make C++ exceptions work properly. Differential Revision: http://reviews.llvm.org/D8250 llvm-svn: 233269
* Remove many superfluous SmallString::str() calls.Yaron Keren2015-03-181-2/+2
| | | | | | | | | | | | | | | Now that SmallString is a first-class citizen, most SmallString::str() calls are not required. This patch removes a whole bunch of them, yet there are lots more. There are two use cases where str() is really needed: 1) To use one of StringRef member functions which is not available in SmallString. 2) To convert to std::string, as StringRef implicitly converts while SmallString do not. We may wish to change this, but it may introduce ambiguity. llvm-svn: 232622
* Driver: Print the clang version and original command in crash scriptsJustin Bogner2015-03-121-0/+3
| | | | | | | | | | When a crash report script doesn't work for a reproduction on your machine for one reason or another, it can be really tricky to figure out why not. The compiler version that crashed and the original command line before stripping flags are very helpful when this comes up. llvm-svn: 231989
* Fix program name in "clang -help"Sumanth Gundapaneni2015-03-031-1/+1
| | | | | | | | | | | | | | | | | With out this patch, "clang -help" prints "USAGE: clang-3 [options] <inputs>". It should either print USAGE: clang [options] <inputs> or USAGE: clang-3.7 [options] <inputs> With this patch, on Linux, it prints USAGE: clang-3.7 [options] <inputs> On Windows, it prints USAGE: clang.exe [options] <inputs> llvm-svn: 231124
* Implement Control Flow Integrity for virtual calls.Peter Collingbourne2015-02-201-4/+9
| | | | | | | | | | | | | | | This patch introduces the -fsanitize=cfi-vptr flag, which enables a control flow integrity scheme that checks that virtual calls take place using a vptr of the correct dynamic type. More details in the new docs/ControlFlowIntegrity.rst file. It also introduces the -fsanitize=cfi flag, which is currently a synonym for -fsanitize=cfi-vptr, but will eventually cover all CFI checks implemented in Clang. Differential Revision: http://reviews.llvm.org/D7424 llvm-svn: 230055
* PR 17421: Implemented -save-temps={obj|cwd} optionReid Kleckner2015-02-021-25/+38
| | | | | | | | | | | | | | | | | -save-temps=cwd is equivalent to -save-temps -save-temps=obj saves temporary file in the same directory as output This helps to avoid clobbering of temp files in case of parallel compilation with -save-temps of the files that have the same name but located in different directories. Patch by Artem Belevich Reviewed By: rnk Differential Revision: http://reviews.llvm.org/D7304 llvm-svn: 227886
* Driver: include rewrite maps in the diagnosticsSaleem Abdulrasool2015-01-121-0/+5
| | | | | | | | The rewrite map files are not copied, and so cannot be tracked as temporary files. Add them explicitly to the list of files that we request from the user to be attached to bug reports. llvm-svn: 225614
* Driver: tweak the code for determining default image nameHans Wennborg2015-01-091-6/+8
| | | | | | | | It seemed odd to have to make DefaultImageName be a mutable member of Driver. We don't need to the full result of computeTargetTriple() to determine the image name; just base it on DefaultTargetTriple. llvm-svn: 225530
* Fix default image name to 'a.exe' on Windows, instead 'a.out'.Yaron Keren2015-01-041-0/+2
| | | | | | This applies to mingw as clang-cl already has its own logic for the filename. llvm-svn: 225134
* Driver: convert a couple more instances to range based loopsSaleem Abdulrasool2014-12-291-6/+4
| | | | | | | More conversion to range based for loops rather than direct iterators with dereferencing. NFC. llvm-svn: 224954
* Driver: convert a number of loops to range basedSaleem Abdulrasool2014-12-291-33/+10
| | | | | | | Iterate over the arguments via range based for loops rather than iterators and explicitly dereferencing them. NFC. llvm-svn: 224944
* [multilib] Teach Clang's code about multilib by threadingChandler Carruth2014-12-291-3/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | a CLANG_LIBDIR_SUFFIX down from the build system and using that as part of the default resource dir computation. Without this, essentially nothing that uses the clang driver works when building clang with a libdir suffix. This is probably the single biggest missing piece of support for multilib as without this people could hack clang to end up installed in the correct location, but it would then fail to find its own basic resources. I know of at least one distro that has some variation on this patch to hack around this; hopefully they'll be able to use the libdir suffix functionality directly as the rest of these bits land. This required fixing a copy of the code to compute Clang's resource directory that is buried inside of the frontend (!!!). It had bitrotted significantly relative to the driver code. I've made it essentially a clone of the driver code in order to keep tests (which use cc1 heavily) passing. This copy should probably just be removed and the frontend taught to always rely on an explicit resource directory from the driver, but that is a much more invasive change for another day. I've also updated one test which actually encoded the resource directory in its checked output to tolerate multilib suffixes. Note that this relies on a prior LLVM commit to add a stub to the autoconf build system for this variable. llvm-svn: 224924
* Reapply "Change -save-temps to emit unoptimized bitcode files."Bob Wilson2014-12-211-11/+48
| | | | | | | | | | | | | | | | | | | | | | | | This reapplies r224503 along with a fix for compiling Fortran by having the clang driver invoke gcc (see r224546, where it was reverted). I have added a testcase for that as well. Original commit message: It is often convenient to use -save-temps to collect the intermediate results of a compilation, e.g., when triaging a bug report. Besides the temporary files for preprocessed source and assembly code, this adds the unoptimized bitcode files as well. This adds a new BackendJobAction, which is mostly mechanical, to run after the CompileJobAction. When not using -save-temps, the BackendJobAction is combined into one job with the CompileJobAction, similar to the way the integrated assembler is handled. I've implemented this entirely as a driver change, so under the hood, it is just using -disable-llvm-optzns to get the unoptimized bitcode. Based in part on a patch by Steven Wu. rdar://problem/18909437 llvm-svn: 224688
* Revert "Change -save-temps to emit unoptimized bitcode files."Reid Kleckner2014-12-181-33/+10
| | | | | | | | | | This reverts commit r224503. It broke compilation of fortran through the Clang driver. Previously `clang -c t.f` would invoke `gcc t.f` and `clang -cc1as`, but now it tries to call `clang -cc1 t.f` which fails for obvious reasons. llvm-svn: 224546
* Change -save-temps to emit unoptimized bitcode files.Bob Wilson2014-12-181-10/+33
| | | | | | | | | | | | | | | | | | | It is often convenient to use -save-temps to collect the intermediate results of a compilation, e.g., when triaging a bug report. Besides the temporary files for preprocessed source and assembly code, this adds the unoptimized bitcode files as well. This adds a new BackendJobAction, which is mostly mechanical, to run after the CompileJobAction. When not using -save-temps, the BackendJobAction is combined into one job with the CompileJobAction, similar to the way the integrated assembler is handled. I've implemented this entirely as a driver change, so under the hood, it is just using -disable-llvm-optzns to get the unoptimized bitcode. Based in part on a patch by Steven Wu. rdar://problem/18909437 llvm-svn: 224503
* Use isOSBinFormatMachO() instead of comparing the object formatEric Christopher2014-12-051-1/+1
| | | | | | against an enum. llvm-svn: 223422
* Update for LLVM API changeDavid Blaikie2014-11-191-1/+1
| | | | llvm-svn: 222303
* clang-cl: Allow /Fo without an argument (PR21589)Hans Wennborg2014-11-171-15/+4
| | | | | | | | | | When it's used without an argument, the default file name is used. The same goes for /Fe. Also, allow using /Fo, /Fa and /Fe with multiple inputs if they don't have an argument. llvm-svn: 222164
* Fix style.Michael J. Spencer2014-11-071-4/+3
| | | | llvm-svn: 221546
* Make helper function static. NFC.Benjamin Kramer2014-11-041-1/+2
| | | | llvm-svn: 221290
* [llvm-api-change] Use findProgramByName.Michael J. Spencer2014-11-041-3/+3
| | | | llvm-svn: 221222
* Driver: reduce search logic duplicationSaleem Abdulrasool2014-10-251-21/+28
| | | | | | | Refactor the path search into a helper function to avoid duplicating the path handling for the search. NFC. llvm-svn: 220628
* Driver: add CrossWindowsToolChainSaleem Abdulrasool2014-10-241-0/+3
| | | | | | | | | | | | | | | | | | | | This is a very basic toolchain. It supports cross-compiling Windows (primarily inspired by the WoA target). It is meant to use clang with the LLVM IAS and a binutils ld-compatible interface for the linker (eventually to be lld). It does not perform any "standard" GCC lookup, nor does it perform any special adjustments given that it is expected to be used in an environment where the user is using MSVCRT (and as such Visual Studio headers) and the Windows SDK. The primary runtime library is expected to be compiler-rt and the C++ implementation to be libc++. It also expects that a sysroot has been setup given the usual Unix semantics (standard C headers in /usr/include, all the import libraries available in /usr/lib). It also expects that an entry point stub is present in /usr/lib (crtbegin.obj for executables, crtbeginS.obj for shared libraries). The entry point stub is responsible for running any GNU constructors. llvm-svn: 220546
* Driver: rename Windows to MSVCToolChainSaleem Abdulrasool2014-10-221-1/+1
| | | | | | | | This renames the Windows toolchain to MSVCToolChain. This is a preparatory step for adding a CrossWindowsToolChain which uses clang/libc++/(ld/lld) without the standard GCC toolchain lookup. NFC. llvm-svn: 220362
* Driver: Quote the command in crash reproduction scripts.Justin Bogner2014-10-211-1/+1
| | | | | | | | This fixes crash report generation when filenames have spaces. It also removes an awkward workaround that quoted *some* arguments when generating crash reports. llvm-svn: 220307
* Driver: Move crash report command mangling into Command::PrintJustin Bogner2014-10-211-27/+4
| | | | | | | | | | This pushes the logic for generating a crash reproduction script entirely into Command::Print, instead of Command doing half of the work and then relying on textual substitution for the rest. This makes this logic much easier to read and will simplify fixing a couple of issues in this area. llvm-svn: 220305
* Driver: Consolidate the logic for naming the module crashdump cacheJustin Bogner2014-10-201-15/+10
| | | | | | | | List the module cache we use for crashdumps as a tempfile. This simplifies how we pick up this directory when generating the actual crash diagnostic and removes some duplicate logic. llvm-svn: 220241
* Driver: Name crashdump scripts after the first temp fileJustin Bogner2014-10-201-42/+54
| | | | | | | | | | | | | | | | In practice there's only ever one temporary output file when generating a crashdump, but even if there were many iterating over each and creating a duplicate run script for each one wouldn't make very much sense. This updates the behaviour to only generate the script once, based on the first filename. This should make it more reasonable to generate extra output files to include in the crashdump going forward, so I've also added a FIXME to look into doing just that with the extra module crashdump files. llvm-svn: 220238
* Driver: Use an early return instead of a long if condition (NFC)Justin Bogner2014-10-201-56/+55
| | | | | | | This just flattens an if block by returning early on the "else" condition. llvm-svn: 220235
* Driver: Make FailingCommand mandatory for generateCompilationDiagnosticsJustin Bogner2014-10-201-9/+4
| | | | | | | | | | | | | We currently use a null FailingCommand when generating crash reports as an indication that the cause is FORCE_CLANG_DIAGNOSTICS_CRASH, the environment variable that exists to test crash dumps. This means that our tests don't actually cover real crashes at all, and adds a more complicated code path that's only used in the tests. Instead, we can have the driver synthesize that every command failed and just call generateCompilationDiagnostics normally. llvm-svn: 220234
* CFE Knob for: Add a thread-model knob for lowering atomics on baremetal & ↵Jonathan Roelofs2014-10-031-3/+7
| | | | | | | | single threaded systems http://reviews.llvm.org/D4985 llvm-svn: 219027
* Driver: Use pointee_iterator rather than iterating over unique_ptrsJustin Bogner2014-10-031-2/+2
| | | | | | | | There's probably never a good reason to iterate over unique_ptrs. This lets us use range-for and say Job.foo instead of (*it)->foo in a few places. llvm-svn: 218938
* Driver: use range based for loopSaleem Abdulrasool2014-09-161-8/+6
| | | | | | Use a couple more range based for loops. NFC. llvm-svn: 217857
* Teach Clang how to use response files when calling other toolsReid Kleckner2014-09-151-2/+28
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Patch by Rafael Auler! This patch addresses PR15171 and teaches Clang how to call other tools with response files, when the command line exceeds system limits. This is a problem for Windows systems, whose maximum command-line length is 32kb. I introduce the concept of "response file support" for each Tool object. A given Tool may have full support for response files (e.g. MSVC's link.exe) or only support file names inside response files, but no flags (e.g. Apple's ld64, as commented in PR15171), or no support at all (the default case). Therefore, if you implement a toolchain in the clang driver and you want clang to be able to use response files in your tools, you must override a method (getReponseFileSupport()) to tell so. I designed it to support different kinds of tools and internationalisation needs: - VS response files ( UTF-16 ) - GNU tools ( uses system's current code page, windows' legacy intl. support, with escaped backslashes. On unix, fallback to UTF-8 ) - Clang itself ( UTF-16 on windows, UTF-8 on unix ) - ld64 response files ( only a limited file list, UTF-8 on unix ) With this design, I was able to test input file names with spaces and international characters for Windows. When the linker input is large enough, it creates a response file with the correct encoding. On a Mac, to test ld64, I temporarily changed Clang's behavior to always use response files regardless of the command size limit (avoiding using huge command line inputs). I tested clang with the LLVM test suite (compiling benchmarks) and it did fine. Test Plan: A LIT test that tests proper response files support. This is tricky, since, for Unix systems, we need a 2MB response file, otherwise Clang will simply use regular arguments instead of a response file. To do this, my LIT test generate the file on the fly by cloning many -DTEST parameters until we have a 2MB file. I found out that processing 2MB of arguments is pretty slow, it takes 1 minute using my notebook in a debug build, or 10s in a Release build. Therefore, I also added "REQUIRES: long_tests", so it will only run when the user wants to run long tests. In the full discussion in http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20130408/171463.html, Rafael Espindola discusses a proper way to test llvm::sys::argumentsFitWithinSystemLimits(), and, there, Chandler suggests to use 10 times the current system limit (20MB resp file), so we guarantee that the system will always use response file, even if a new linux comes up that can handle a few more bytes of arguments. However, by testing with a 20MB resp file, the test takes long 8 minutes just to perform a silly check to see if the driver will use a response file. I found it to be unreasonable. Thus, I discarded this approach and uses a 2MB response file, which should be enough. Reviewers: asl, rafael, silvas Reviewed By: silvas Subscribers: silvas, rnk, thakis, cfe-commits Differential Revision: http://reviews.llvm.org/D4897 llvm-svn: 217792
* clang-cl: Warn when a /TC or /TP argument is unusedEhsan Akhgari2014-09-121-2/+2
| | | | | | | | | | | | Test Plan: The patch includes a test case. Reviewers: hansw Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D5338 llvm-svn: 217710
* clang-cl: Don't treat linker input files differently when /TP or /TC is ↵Ehsan Akhgari2014-09-121-2/+11
| | | | | | | | | | | | | | | | specified. Summary: This fixes http://llvm.org/PR20923. Test Plan: This patch includes an automated test. Reviewers: hansw Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D5334 llvm-svn: 217699
* clang-cl: Add support for the /o option for object files, executables, and ↵Ehsan Akhgari2014-09-111-7/+19
| | | | | | | | | | | | | | | | | | | | | | | | | preprocessor output Summary: cl.exe recognizes /o as a deprecated and undocumented option similar to /Fe. This patch adds support for this option to clang-cl for /Fe, /Fo and /Fi. It also ensures that the last option among /o and /F* wins, if both specified. This is required at least for building autoconf based software, since autoconf uses -o to specify the executable output. This fixes http://llvm.org/PR20894. Test Plan: The patch includes automated tests. Reviewers: rnk Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D5308 llvm-svn: 217615
* Avoid some unnecessary SmallVector copies.Benjamin Kramer2014-09-111-1/+1
| | | | | | No functionality change. llvm-svn: 217586
* Only override the target architecture on -m32 and friends if it isJoerg Sonnenberger2014-09-101-1/+1
| | | | | | | | actually different. Fixes a surprising link error with nodejs on rpi, where armv6-netbsd-eabihf turned into armv5e-netbsd-eabihf, which doesn't lacks the necessary VFP support. llvm-svn: 217546
* unique_ptrify Driver Action handlingDavid Blaikie2014-08-291-31/+43
| | | | | | | | | | | | It hits a limit when we reach ActionList, which is used for dynamic conditional ownership, so we lose type safety there. This did expose at least one caller "lying" about ownership (passing ownership to an Action, then updating the Action to specify that it doesn't actually own the thing that was passed) - changing this to unique_ptr just makes that oddity more obvious. llvm-svn: 216713
* Update for llvm api change.Rafael Espindola2014-08-251-4/+4
| | | | llvm-svn: 216397
* Fix PR17239 by changing the semantics of the RemainingArgsClass Option kindReid Kleckner2014-08-221-2/+5
| | | | | | | | | | | | | | | | | | | | | | | This patch aims at fixing PR17239. This bug happens because the /link (clang-cl.exe argument) is marked as "consume all remaining arguments". However, when inside a response file, /link should only consume all remaining arguments inside the response file where it is located, not the entire command line after expansion. The LLVM side of the patch will change the semantics of the RemainingArgsClass kind to always consume only until the end of the response file when the option originally came from a response file. There are only two options in this class: dash dash (--) and /link. This is the Clang side of the patch in http://reviews.llvm.org/D4899 Reviewered By: rafael, rnk Differential Revision: http://reviews.llvm.org/D4900 Patch by Rafael Auler! llvm-svn: 216281
* [x32] Handle -m64/-m32 switches by Driver in x32 modePavel Chupin2014-08-181-4/+8
| | | | | | | | | | | | | | | | | Summary: Adding remaining 2 cases handling: * from x32 to 32 via -m32 * from x32 to 64 via -m64 Test Plan: linux-ld test updated Reviewers: chandlerc, atanasyan Subscribers: cfe-commits, zinovy.nis Differential Revision: http://reviews.llvm.org/D4930 llvm-svn: 215899
* Delete support for AuroraUX.Rafael Espindola2014-08-141-6/+1
| | | | | | auroraux.org is not resolving. llvm-svn: 215644
OpenPOWER on IntegriCloud