summaryrefslogtreecommitdiffstats
path: root/clang/lib/Driver/Tools.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* Don't link in sanitizer runtimes if -nostdlib/-nodefaultlibs is provided.Alexey Samsonov2014-09-261-0/+4
| | | | | | | | | | | It makes no sense to link in sanitizer runtimes in this case: the user probably doesn't want to see any system/toolchain libs in his link if he provides these flags, and the link will most likely fail anyway - as sanitizer runtimes depend on libpthread, libdl, libc etc. Also, see discussion in https://code.google.com/p/address-sanitizer/issues/detail?id=344 llvm-svn: 218541
* Fix forwarding -l to MSVC's link.exeReid Kleckner2014-09-161-6/+24
| | | | | | | | | | | Translate -lfoo to -lfoo.lib while making sure that -lfoo.lib stays as -lfoo.lib. Also, these arguments were being passed twice: once explicitly via AddAllArgs, and again implicitly as linker inputs. Now they are passed once. Fixes PR20868. llvm-svn: 217895
* Major rewrite of linking strategy for sanitizer runtimes on Linux.Alexey Samsonov2014-09-151-143/+105
| | | | | | | | | | | | | | | | | | | | | | | | | | | Change 1: we used to add static sanitizer runtimes at the very beginning of the linker invocation, even before crtbegin.o, which is gross and not correct in general. Fix this: now addSanitizerRuntimes() adds all sanitizer-related link flags to the end of the linker invocation being constructed. It means, that we should call this function in the correct place, namely, before AddLinkerInputs() to make sure sanitizer versions of library functions will be preferred. Change 2: Put system libraries sanitizer libraries depend on at the end of the linker invocation, where all the rest system libraries are located. Respect --nodefaultlibs and --nostdlib flags. This is another way to fix PR15823. Original fix landed in r215940 put "-lpthread" and friends immediately after static ASan runtime, before the user linker inputs. This caused significant slowdown in dynamic linker for large binaries linked against thousands of shared objects. Instead, to mark system libraries as DT_NEEDED we prepend them with "--no-as-needed" flag, discarding the "-Wl,--as-needed" flag that could be provided by the user. Otherwise, this change is a code cleanup. Instead of having a special method for each sanitizer, we introduce a function collectSanitizerRuntimes() that analyzes -fsanitize= flags and returns the set of static and shared libraries that needs to be linked. llvm-svn: 217817
* Teach Clang how to use response files when calling other toolsReid Kleckner2014-09-151-3/+30
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Add -fseh-exceptions for MinGW-w64Reid Kleckner2014-09-151-0/+2
| | | | | | | | | | | | | | This adds a flag called -fseh-exceptions that uses the native Windows .pdata and .xdata unwind mechanism to throw exceptions. The other EH possibilities are DWARF and SJLJ exceptions. Patch by Martell Malone! Reviewed By: asl, rnk Differential Revision: http://reviews.llvm.org/D3419 llvm-svn: 217790
* [ASan/Win] Fix PR20918 -- SEH handler doesn't work with the MD runtimeTimur Iskhodzhanov2014-09-121-0/+3
| | | | llvm-svn: 217679
* [ASan/Win] Rename asan_win_uar_thunk.lib to asan_win_dynamic_runtime_thunk.libTimur Iskhodzhanov2014-09-121-1/+2
| | | | | | | | It turned out that we have to bridge more stuff between the executable and the ASan RTL DLL than just __asan_option_detect_stack_use_after_return. See PR20918 for more details. llvm-svn: 217673
* Use the simpler version of llvm::sys::fs::exists.Rafael Espindola2014-09-111-4/+1
| | | | | | | In all these cases it looks like the intention was to handle error in a similar way to the file not existing. llvm-svn: 217614
* Avoid some unnecessary SmallVector copies.Benjamin Kramer2014-09-111-2/+2
| | | | | | No functionality change. llvm-svn: 217586
* unique_ptrify JobList::JobsDavid Blaikie2014-09-041-41/+44
| | | | llvm-svn: 217168
* ARM: Default to apcs-gnu ABI for NetBSDOliver Stannard2014-09-041-1/+6
| | | | | | | | r216662 changed the default ABI for 32-bit ARM targets to be "aapcs" when no environment is given in the triple, however NetBSD requires it to be "apcs-gnu". llvm-svn: 217141
* Fix some cases where StringRef was being passed by const reference. Remove ↵Craig Topper2014-08-301-5/+5
| | | | | | const from some other StringRefs since its implicitly const already. llvm-svn: 216825
* Call powerpc-darwin external tools with -arch ppc.Rafael Espindola2014-08-281-11/+3
| | | | | | | | | | With this patch we call external tools for powerpc-darwin with "-arch ppc" instead of "-arch powerpc", so as to be compatible with the cctools assembler and ld64 linker. Patch by Stephen Drake! llvm-svn: 216687
* [ARM] Change default ABI for AArch32 to be "aapcs" (was "apcs-gnu")Oliver Stannard2014-08-281-2/+1
| | | | | | | | | | | | | | The current default abi when no environment is given is "apcs-gnu", which is obsolete. This patch changes the default to "aapcs". "aapcs" has both hard- and soft-float variants, so the -mhard-float, -msoft-float and -mfloat-abi= options now all behave as expected when no environment is specified in the triple. While writing this I also noticed that a preprocessor test claims to be checking darwin, but is actually checking the defaults, which are different for darwin. llvm-svn: 216662
* Allow __fp16 as a function arg or return type for AArch64Oliver Stannard2014-08-271-0/+4
| | | | | | | | | | | ACLE 2.0 allows __fp16 to be used as a function argument or return type. This enables this for AArch64. This also fixes an existing bug that causes clang to not allow homogeneous floating-point aggregates with a base type of __fp16. This is valid for AAPCS64, but not for AAPCS-VFP. llvm-svn: 216558
* [asan] Restore asan-rt name on linux back to pre-r216380.Evgeniy Stepanov2014-08-271-2/+1
| | | | | | | | | | There is no reason to have different library names for shared and static cases on linux. It also breaks Android where we install the shared asan-rt library into the system and should keep the old name. This change reverts most of r216380 limiting it to win32 targets only. llvm-svn: 216533
* Convert MC command line flag for fatal assembler warnings into a properJoerg Sonnenberger2014-08-261-2/+1
| | | | | | flag. llvm-svn: 216472
* [ASan/Win] Add an extra thunk.lib to handle stack-use-after-return optionTimur Iskhodzhanov2014-08-261-1/+4
| | | | | | | With this patch, "check-asan" passes all the tests with both MT and MD ASan RTL if you set COMPILER_RT_BUILD_SHARED_ASAN to ON (PR20214) llvm-svn: 216447
* [ASan] Rename the ASan dynamic RTTimur Iskhodzhanov2014-08-251-1/+1
| | | | | | Reviewed at http://reviews.llvm.org/D5026 llvm-svn: 216380
* Handle SPARC float command line parameters for SPARCv9.Brad Smith2014-08-191-1/+2
| | | | llvm-svn: 216029
* Update link strategy for sanitizer runtime libraries on Linux:Alexey Samsonov2014-08-181-26/+33
| | | | | | | | | | | | | | | | | | | 1. Always put static sanitizer runtimes to the front of the linker invocation line. This was already done for all sanitizers except UBSan: in case user provides static libstdc++ we need to make sure that new/delete operator definitions are picked from sanitizer runtimes instead of libstdc++. We have to put UBSan runtime first for similar reasons: it depends on some libstdc++ parts (e.g. __dynamic_cast function), and has to go first in link line to ensure these functions will be picked up from libstdc++. 2. Put sanitizer libraries system dependencies (-ldl, -lpthread etc.) right after sanitizer runtimes. This will ensure these libraries participate in the link even if user provided -Wl,-as-needed flag. This should fix PR15823. 3. In case we link in several sanitizer runtimes (e.g. "ubsan", "ubsan_cxx" and "san"), add system dependencies (-ldl, -lpthread, ...) only once. llvm-svn: 215940
* Move some code into a helper function. NFC.Rafael Espindola2014-08-151-45/+48
| | | | llvm-svn: 215731
* Use the big endian emulations for NetBSD/arm in EB mode.Joerg Sonnenberger2014-08-141-2/+17
| | | | llvm-svn: 215670
* Delete support for AuroraUX.Rafael Espindola2014-08-141-108/+0
| | | | | | auroraux.org is not resolving. llvm-svn: 215644
* Revert what looks like an unintended change in r215557.Rafael Espindola2014-08-131-1/+1
| | | | | | Should fix test ulibc driver tests. llvm-svn: 215561
* Header guard canonicalization, clang part.Benjamin Kramer2014-08-131-1/+1
| | | | | | Modifications made by clang-tidy with minor tweaks. llvm-svn: 215557
* [Driver] Support -muclibc / -mglibc command line options for a coupleSimon Atanasyan2014-08-131-1/+10
| | | | | | | | | | | | | of MIPS toolchains. The uCLibc implemented for multiple architectures. A couple of MIPS toolchains contains both uCLibc and glibc implementation so these options allow to select used C library. Initially -muclibc / -mglibc (as well as -mbionic) have been implemented in gcc for various architectures so they are not MIPS specific. llvm-svn: 215552
* For NetBSD, use the same settings for PPC64 as for PPC when it comes toJoerg Sonnenberger2014-08-131-0/+12
| | | | | | | integrated assembler, libc++ and libgcc. Set emulation for ld for both platforms for correct -m32 handling. llvm-svn: 215551
* Emit diagnostic for -munaligned-access on v6m targetsOliver Stannard2014-08-131-1/+5
| | | | | | | | | | Rather than silently disabling unaligned accesses for v6m targets as in the previous patch to llvm, instead produce a warning saying that this architecture doesn't support unaligned accesses. Patch by Ben Foster llvm-svn: 215531
* GCC compatibility: Ignore -fexec-charset=UTF-8 argument. It is the default ↵Sylvestre Ledru2014-08-111-0/+8
| | | | | | | | | | | | | | | | | | in Clang. Reject other values. Summary: Just like with -finput-charset=UTF-8 in review http://reviews.llvm.org/D4347, I think we should just ignore it when UTF-8 is provided. Reviewers: rnk, rafael Reviewed By: rafael Subscribers: rafael, cfe-commits Differential Revision: http://reviews.llvm.org/D4841 llvm-svn: 215368
* NetBSD/aarch64 has no libgcc or libstdc++. Drop arm64 tests.Joerg Sonnenberger2014-08-091-0/+1
| | | | llvm-svn: 215291
* Add -link-cxx-sanitizer driver flag.Alexey Samsonov2014-08-081-5/+5
| | | | | | | | | | | | | | | | | | | | | | Summary: This flag can be used to force linking of CXX-specific parts of sanitizer runtimes into the final executable. It gives more precise control than --driver-mode=g++ and comes handy when user links several object files with sanitized C++ code into an executable, but wants to provide libstdc++ himself, instead of relying on Clang dirver's behavior. Test Plan: clang regression test suite Reviewers: chandlerc, rsmith Reviewed By: rsmith Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D4824 llvm-svn: 215252
* Partially revert r215204 - [mips] Add -mabicalls/-mno-abicalls to the driverDaniel Sanders2014-08-081-3/+0
| | | | | | | | It wasn't actually a bug that -mabicalls/-mno-abicalls wasn't being passed to GAS. The only reason we pass it to the integrated assembler is because it shares the same framework with CodeGen. llvm-svn: 215236
* [mips] Invert the abicalls feature bit to be noabicalls so that it's ↵Daniel Sanders2014-08-081-8/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | possible for -mno-abicalls to take effect. Also added the testcase that should have been in r215194. This behaviour has surprised me a few times now. The problem is that the generated MipsSubtarget::ParseSubtargetFeatures() contains code like this: if ((Bits & Mips::FeatureABICalls) != 0) IsABICalls = true; so '-abicalls' means 'leave it at the default' and '+abicalls' means 'set it to true'. In this case, (and the similar -modd-spreg case) I'd like the code to be IsABICalls = (Bits & Mips::FeatureABICalls) != 0; or possibly: if ((Bits & Mips::FeatureABICalls) != 0) IsABICalls = true; else IsABICalls = false; and preferably arrange for 'Bits & Mips::FeatureABICalls' to be true by default (on some triples). llvm-svn: 215211
* [mips] Add -mabicalls/-mno-abicalls to the driverDaniel Sanders2014-08-081-0/+12
| | | | | | | Based on a patch by Matheus Almeida. I've added testcases and fixed a bug where the options weren't passed on to GAS. llvm-svn: 215204
* Driver: Add -fno-profile-arcs to go with -fprofile-arcsJustin Bogner2014-08-071-2/+4
| | | | | | This is a trivial gcc-compatible change. llvm-svn: 215051
* Use -Rblah, not -Wblah, to control remark diagnostics. This was always theRichard Smith2014-08-071-9/+1
| | | | | | | | | | | | | | | | | | | | | | intent when we added remark support, but was never implemented in the general case, because the first -R flags didn't need it. (-Rpass= had special handling to accomodate its argument.) -Rno-foo, -Reverything, and -Rno-everything can be used to turn off a remark, or to turn on or off all remarks. Per discussion on cfe-commits, -Weverything does not affect remarks, and -Reverything does not affect warnings or errors. The only "real" -R flag we have right now is -Rmodule-build; that flag is effectively renamed from -Wmodule-build to -Rmodule-build by this change. -Wpass and -Wno-pass (and their friends) are also renamed to -Rpass and -Rno-pass by this change; it's not completely clear whether we intended to have a -Rpass (with no =pattern), but that is unchanged by this commit, other than the flag name. The default pattern is effectively one which matches no passes. In future, we may want to make the default pattern be .*, so that -Reverything works for -Rpass properly. llvm-svn: 215046
* Introduce f[no-]max-unknown-pointer-align=[number] optionFariborz Jahanian2014-08-051-0/+15
| | | | | | | | | to instruct the code generator to not enforce a higher alignment than the given number (of bytes) when accessing memory via an opaque pointer or reference. Patch reviewed by John McCall (with post-commit review pending). rdar://16254558 llvm-svn: 214911
* Add coverage mapping generation.Alex Lorenz2014-08-041-0/+8
| | | | | | | | | | This patch adds the '-fcoverage-mapping' option which allows clang to generate the coverage mapping information that can be used to provide code coverage analysis using the execution counts obtained from the instrumentation based profiling (-fprofile-instr-generate). llvm-svn: 214752
* [Driver][Mips] Construct dynamic linker path by string concatination.Simon Atanasyan2014-08-041-12/+17
| | | | | | | | | That reduces a number of `if` operators and prevent a combinatorics explosion if/when more dynamic linker path variants added. No functional changes. llvm-svn: 214712
* Tools.cpp: Avoid std::to_string() on -fbuild-session-timestamp to appease ↵NAKAMURA Takumi2014-08-031-3/+4
| | | | | | mingw32 builder. llvm-svn: 214656
* Add -fbuild-session-file as an alternative to -fbuild-session-timestampBen Langmuir2014-08-011-1/+15
| | | | | | | | Build systems tend to traffic in files and modification times, so having them touch a file at the beginning of the build can be easier than having them update the compile command they use every time they build. llvm-svn: 214577
* Fix up handling of ARM options for controlling strict alignment.Bob Wilson2014-07-291-23/+18
| | | | | | | | | | | | | | | | | | | | | | The -mstrict-align option was originally added in r167619 as a target- independent option. It was then changed in r167623 to be implemented with an ARM-specific backend option, even though the code remained in the target-independent Clang::ConstructJob function. This means that if you used the -mstrict-align option with a non-ARM target, you would still get the -arm-strict-align option getting passed to the backend, which was harmless but gross. The driver option was then replaced by the GCC-compatible -m[no-]unaligned-access option (r189175) and modified to work with AArch64 (r208075). However, in the process, the help text for -mstrict-align was incorrectly changed to show it as only being supported for AArch64. Even worse, the logic for handling these options together with -mkernel was wrong for AArch64, where -mkernel does not currently imply strict alignment. This patch fixes up all of those things. Besides the obvious change to the option help text, it moves the logic into the ARM and AArch64-specific parts of the driver, so that the option will be correctly ignored for non-ARM targets. <rdar://problem/17823697> llvm-svn: 214148
* [PowerPC] Support ELFv1/ELFv2 ABI selection via -mabi= optionUlrich Weigand2014-07-281-3/+43
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | While Clang now supports both ELFv1 and ELFv2 ABIs, their use is currently hard-coded via the target triple: powerpc64-linux is always ELFv1, while powerpc64le-linux is always ELFv2. These are of course the most common scenarios, but in principle it is possible to support the ELFv2 ABI on big-endian or the ELFv1 ABI on little-endian systems (and GCC does support that), and there are some special use cases for that (e.g. certain Linux kernel versions could only be built using ELFv1 on LE). This patch implements the Clang side of supporting this, based on the LLVM commit 214072. The command line options -mabi=elfv1 or -mabi=elfv2 select the desired ABI if present. (If not, Clang uses the same default rules as now.) Specifically, the patch implements the following changes based on the presence of the -mabi= option: In the driver: - Pass the appropiate -target-abi flag to the back-end - Select the correct dynamic loader version (/lib64/ld64.so.[12]) In the preprocessor: - Define _CALL_ELF to the appropriate value (1 or 2) In the compiler back-end: - Select the correct ABI in TargetInfo.cpp - Select the desired ABI for LLVM via feature (elfv1/elfv2) llvm-svn: 214074
* Now that PIC generation on PPC32 is supported, hook up linking supportJoerg Sonnenberger2014-07-251-1/+2
| | | | | | for NetBSD. llvm-svn: 213972
* AArch64: update Clang for merged arm64/aarch64 triples.Tim Northover2014-07-231-25/+7
| | | | | | | | | | | | | | The main subtlety here is that the Darwin tools still need to be given "-arch arm64" rather than "-arch aarch64". Fortunately this already goes via a custom function to handle weird edge-cases in other architectures, and it tested. I removed a few arm64_be tests because that really isn't an interesting thing to worry about. No-one using big-endian is also referring to the target as arm64 (at least as far as toolchains go). Mostly they date from when arm64 was a separate target and we *did* need a parallel name simply to test it at all. Now aarch64_be is sufficient. llvm-svn: 213744
* [mips] -mno-shared should only be given to the assembler when ↵Daniel Sanders2014-07-231-2/+16
| | | | | | | | -fPIC/-fpic/-fPIE/-fpie is not in effect. This fixes compiler recursion on MIPS32r2. llvm-svn: 213741
* [Driver][Mips] Restore FIXME comment was removed accidentally.Simon Atanasyan2014-07-231-0/+2
| | | | llvm-svn: 213734
* clang-cl: ignore /showIncludes when combined with /E (PR20336)Hans Wennborg2014-07-211-2/+5
| | | | | | | | Both /showIncludes and /E write to stdout. Allowing both results in interleaved output and an error when double-closing the file descriptor, intended to catch issues like this. llvm-svn: 213589
* [mips] Use Triple::getVendor() instead of Triple::getVendorName() to ↵Daniel Sanders2014-07-181-1/+1
| | | | | | identify 'mti' vendor triples. llvm-svn: 213383
OpenPOWER on IntegriCloud