summaryrefslogtreecommitdiffstats
path: root/clang/lib/Driver/Tools.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* [ARM] Implement execute-only support in CodeGenPrakhar Bahuguna2016-12-151-1/+24
| | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: This implements execute-only support for ARM code generation, which prevents the compiler from generating data accesses to code sections. The following changes are involved: * Add the CodeGen option "-arm-execute-only" to the ARM code generator. * Add the clang flag "-mexecute-only" as well as the GCC-compatible alias "-mpure-code" to enable this option. * When enabled, literal pools are replaced with MOVW/MOVT instructions, with VMOV used in addition for floating-point literals. As the MOVT instruction is required, execute-only support is only available in Thumb mode for targets supporting ARMv8-M baseline or Thumb2. * Jump tables are placed in data sections when in execute-only mode. * The execute-only text section is assigned section ID 0, and is marked as unreadable with the SHF_ARM_PURECODE flag with symbol 'y'. This also overrides selection of ELF sections for globals. Reviewers: t.p.northover, rengolin Subscribers: llvm-commits, aemerson Differential Revision: https://reviews.llvm.org/D27450 llvm-svn: 289786
* AArch64: add architecture version feature to Clang invocation.Tim Northover2016-12-141-2/+4
| | | | | | | Otherwise we don't get the correct predefines and so on in the front-end (or the right features in the backend). llvm-svn: 289692
* [Driver][Darwin] Disable default stack protector levels in freestanding mode.Bruno Cardoso Lopes2016-12-081-1/+8
| | | | | | | | | Currently -fstack-protector is on by default when using -ffreestanding. Change the default behavior to have it off when using -ffreestanding. rdar://problem/14089363 llvm-svn: 289005
* Refactor how the MSVC toolchain searches for a compatibility version.David L. Jones2016-12-071-70/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: The MSVC toolchain and Clang driver combination currently uses a fairly complex sequence of steps to determine the MS compatibility version to pass to cc1. There is some oddness in this sequence currently, with some code which inspects flags in the toolchain, and some code which inspects the triple and local environment in the driver code. This change is an attempt to consolidate most of this logic so that Win32-specific code lives in MSVCToolChain.cpp. I'm not 100% happy with the split, so any suggestions are welcome. There are a few things you might want to watch for for specifically: - On all platforms, if MSVC compatibility flags are provided (and valid), use those. - The fallback sequence should be the same as before, but is now consolidated into MSVCToolChain::getMSVCVersion: - Otherwise, try to use the Triple. - Otherwise, on Windows, check the executable. - Otherwise, on Windows or with --fms-extensions, default to 18. - Otherwise, we can't determine the version. - MSVCToolChain::ComputeEffectiveTriple no longer calls the base ToolChain::ComputeEffectiveClangTriple. The only thing it would change for Windows the architecture, which we don't care about for the compatibility version. - I'm not sure whether this is philosophically correct (but it should be easy to add back to MSVCToolChain::getMSVCVersionFromTriple if not). - Previously, Tools.cpp just called getTriple() anyhow, so it doesn't look like the effective triple was always being used previously anyhow. Reviewers: hans, compnerd, llvm-commits, rnk Subscribers: amccarth Differential Revision: https://reviews.llvm.org/D27477 llvm-svn: 288998
* Driver: Remove support for -fobjc-gc*Duncan P. N. Exon Smith2016-12-071-19/+0
| | | | | | | | | | | | As a first step toward removing Objective-C garbage collection from Clang, remove support from the driver. I'm hoping this will flush out any expected bots/configurations/whatever that might rely on it. I've left the options behind temporarily in -cc1 to keep tests passing. I'll kill them off entirely in a follow up when I've had a chance to update/delete the rest of Clang. llvm-svn: 288872
* If clang was configured for a DEFAULT_SYSROOT and no --sysroot argumentJoerg Sonnenberger2016-12-061-0/+5
| | | | | | is seen, record one with the implicit default. llvm-svn: 288822
* Allow clang to write compilation database records.Joerg Sonnenberger2016-12-061-1/+60
| | | | | | | | | | | | | | | | | | | | When integrating compilation database output into existing build systems, two approaches dominate so far. Ad-hoc implementation of the JSON output rules or using compiler wrappers. This patch adds a new option "-MJ foo.json" which gives a slightly cleaned up compilation record. The output is a fragment, i.e. you still need to add the array markers, but it allows multiple files to be easy merged. This way the only change in a build system is adding the option with potentially a per-target output file and merging the files with something like (echo '['; cat *.o.json; echo ']' > compilation_database.json or some additional filtering to remove the trailing comma for strict JSON compliance. Differential Revision: https://reviews.llvm.org/D27140 llvm-svn: 288821
* [clang] Fix D26214: Move error handling out of MC and to the callers.Mandeep Singh Grang2016-12-061-0/+18
| | | | | | | | | | | | | | Summary: Related llvm patch: https://reviews.llvm.org/D27359 Reviewers: echristo, t.p.northover, rengolin, grosbach, compnerd Subscribers: mehdi_amini, cfe-commits, llvm-commits Tags: #clang-c Differential Revision: https://reviews.llvm.org/D27360 llvm-svn: 288762
* With LTO and profile-use, enable hotness info in opt remarksAdam Nemet2016-12-021-7/+19
| | | | | | | | | | This is to match the behavior of non-LTO; when -fsave-optimization-record is passed and PGO is available we enable the generation of hotness information in the optimization records. Differential Revision: https://reviews.llvm.org/D27332 llvm-svn: 288520
* [clang] Implement support for -defsym assembler optionMandeep Singh Grang2016-12-011-0/+3
| | | | | | | | | | | | | | | | | Summary: Adds support for -Wa,-defsym,abc=1 option. Related llvm patch: https://reviews.llvm.org/D26214 Reviewers: rafael, t.p.northover, colinl, echristo, compnerd, rengolin Subscribers: mehdi_amini Tags: #clang-c Differential Revision: https://reviews.llvm.org/D26213 llvm-svn: 288397
* Fix crash with unsupported architectures in Linux/Gnu target triples.Florian Hahn2016-12-011-3/+8
| | | | | | | | | | | | Summary: This patch adds a check and an error message to gnutools::Linker::ConstructJob in case the architecture is not supported. For most other operating systems, the error message is created in lib/Basic/Targets.cpp:AllocateTarget, but when construction the linker arguments for the gnutools linker a supported architecture is required. Reviewers: rafael, joerg, echristo Subscribers: mehdi_amini, joerg, dschuff, cfe-commits Differential Revision: https://reviews.llvm.org/D27066 llvm-svn: 288327
* darwin: Unconditionally pass -lto_library, remove -Wliblto warning.Nico Weber2016-11-221-8/+8
| | | | | | | | | | | | | | | | | | | | | https://reviews.llvm.org/D25932 made it so that clang always checks if libLTO.dylib is present on disk, even if -flto is not being used. The motivation for that change was that if a dependency happens to contain bitcode, ld64 will try to load libLTO without -flto explicitly being enabled. However, the change had the undesirable side effect of warning if libLTO.dylib doesn't exist even if it isn't needed. Change things so that -lto_library is always passes, independent of if it exists or not. ld64 only looks at this flag if it uses LTO. If the dylib exists, all is well. If it doesn't, and LTO is not being used, all is well too. If ld64 does end up using LTO and the dylib does not exist, ld64 will print something like ld: could not process llvm bitcode object file, because foo/libLTO.dylib could not be loaded file 'test.o' for architecture x86_64 https://reviews.llvm.org/D26984 llvm-svn: 287685
* Rename option to -lto-pass-remarks-outputAdam Nemet2016-11-221-1/+1
| | | | | | | The new option -pass-remarks-output broke LLVM_LINK_LLVM_DYLIB because of the duplicate option name with opt. llvm-svn: 287628
* [XRay] Support AArch64 in ClangDean Michael Berris2016-11-211-7/+13
| | | | | | | | | | | | | | | | | | This patch adds XRay support in Clang for AArch64 target. This patch is one of a series: LLVM: https://reviews.llvm.org/D26412 compiler-rt: https://reviews.llvm.org/D26413 Author: rSerge Reviewers: rengolin, dberris Subscribers: aemerson, cfe-commits, iid_iunknown Differential Revision: https://reviews.llvm.org/D26415 llvm-svn: 287518
* LTO support for -fsave-optimization-record on DarwinAdam Nemet2016-11-181-0/+13
| | | | | | | | I guess this would have to be added for each linker. Differential Revision: https://reviews.llvm.org/D26833 llvm-svn: 287358
* Fix a comment for -fsave-optimization-recordAdam Nemet2016-11-181-1/+1
| | | | | | Differential Revision: https://reviews.llvm.org/D26807 llvm-svn: 287357
* [CUDA] Driver changes to support CUDA compilation on MacOS.Justin Lebar2016-11-181-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: Compiling CUDA device code requires us to know the host toolchain, because CUDA device-side compiles pull in e.g. host headers. When we only supported Linux compilation, this worked because CudaToolChain, which is responsible for device-side CUDA compilation, inherited from the Linux toolchain. But in order to support MacOS, CudaToolChain needs to take a HostToolChain pointer. Because a CUDA toolchain now requires a host TC, we no longer will create a CUDA toolchain from Driver::getToolChain -- you have to go through CreateOffloadingDeviceToolChains. I am *pretty* sure this is correct, and that previously any attempt to create a CUDA toolchain through getToolChain() would eventually have resulted in us throwing "error: unsupported use of NVPTX for host compilation". In any case hacking getToolChain to create a CUDA+host toolchain would be wrong, because a Driver can be reused for multiple compilations, potentially with different host TCs, and getToolChain will cache the result, causing us to potentially use a stale host TC. So that's the main change in this patch. In addition, we have to pull CudaInstallationDetector out of Generic_GCC and into a top-level class. It's now used by the Generic_GCC and MachO toolchains. Reviewers: tra Subscribers: rryan, hfinkel, sfantao Differential Revision: https://reviews.llvm.org/D26774 llvm-svn: 287285
* [Driver] Infer the correct option to ld64 for -fembed-bitcodeSteven Wu2016-11-161-4/+4
| | | | | | | | | | | | | | | | | | Summary: -fembed-bitcode infers -bitcode_bundle to ld64 but it is not correctly passed when using LTO. LTO is a special case of -fembed-bitcode which it doesn't require embed the bitcode in a special section in the object file but it requires linker to save that as part of the final executable. rdar://problem/29274226 Reviewers: mehdi_amini Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D26690 llvm-svn: 287084
* Revert r286735 due to test failureBrad Smith2016-11-131-4/+0
| | | | llvm-svn: 286736
* Link static PIE programs against rcrt0.o on OpenBSDBrad Smith2016-11-121-0/+4
| | | | | | Patch by Stefan Kempf. llvm-svn: 286735
* clang-cl: Pass /Zc:threadSafeInit through to MSVC with /fallback (PR30948)Hans Wennborg2016-11-091-0/+8
| | | | llvm-svn: 286324
* Rename the version of ConstructJob for multiple outputs to ↵Samuel Antao2016-11-031-5/+4
| | | | | | | | ConstructJobMultipleOutputs. It was causing trouble with the GCC bots. llvm-svn: 285925
* [asan] Use the dynamic ASan runtime if -shared-libasan is passedReid Kleckner2016-11-021-1/+2
| | | | | | | | | | -shared-libasan is likely to be used as a link flag if the user is using the GCC-style clang driver. This logic is already tested in clang-cl tests, and the new flag to exercise it will be covered by asan tests. llvm-svn: 285820
* Fix Clang-tidy readability-redundant-string-cstr warningsMalcolm Parsons2016-11-021-3/+3
| | | | | | | | | | Reviewers: aaron.ballman, mehdi_amini, dblaikie Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D26206 llvm-svn: 285799
* [Modules] Add a command line option for loading the clang builtins modulemap.Elad Cohen2016-10-311-0/+12
| | | | | | | | | -fbuiltin-module-map loads the clang builtins modulemap file. (This is equivalent to -fmodule-map-file=<resource dir>/include/module.modulemap) Differential Revision: https://reviews.llvm.org/D25767 llvm-svn: 285548
* Fix clang installed path to handle case where clang is invoked through a symlinkMehdi Amini2016-10-301-1/+1
| | | | | | | | | | | | | | | | This code path is used when generating the path to libLTO.dylib, which is passed to the linker as `-lto_library'. Without this, if clang is invoked through a symlink, libLTO is searched in a path relative to where the symlink is instead of where clang is actually installed. Fix PR30811. Patch by: Jack Howarth Differential Revision: https://reviews.llvm.org/D26116 llvm-svn: 285525
* [Driver][OpenMP] Add support to create jobs for unbundling actions.Samuel Antao2016-10-271-1/+65
| | | | | | | | | | | | | | | | | | | Summary: This patch adds the support to create jobs for the `OffloadBundlingAction` which will invoke the `clang-offload-bundler` tool to unbundle input files. Unlike other actions, unbundling actions have multiple outputs. Therefore, this patch adds the required changes to have a variant of `Tool::ConstructJob` with multiple outputs. The way the naming of the results is implemented is also slightly modified so that the same action can use a different offloading prefix for each use by the different offloading actions. With this patch, it is possible to compile a functional OpenMP binary with offloading support, even with separate compilation. Reviewers: echristo, tra, jlebar, ABataev, hfinkel Subscribers: mkuron, whchung, mehdi_amini, cfe-commits, Hahnfeld, andreybokhanko, arpith-jacob, carlo.bertolli, caomhin Differential Revision: https://reviews.llvm.org/D21857 llvm-svn: 285326
* [Driver][OpenMP] Add support to create jobs for bundling actions.Samuel Antao2016-10-271-0/+66
| | | | | | | | | | | | Summary: This patch adds the support to create a job for the `OffloadBundlingAction` which will invoke the `clang-offload-bundler` tool. Reviewers: echristo, tra, jlebar, ABataev, hfinkel Subscribers: whchung, mehdi_amini, cfe-commits, Hahnfeld, andreybokhanko, arpith-jacob, carlo.bertolli, caomhin Differential Revision: https://reviews.llvm.org/D21856 llvm-svn: 285325
* [Driver][OpenMP] Build jobs for OpenMP offloading actions for targets using ↵Samuel Antao2016-10-271-28/+200
| | | | | | | | | | | | | | | | | gcc tool chains. Summary: This patch adds logic to create jobs for OpenMP offloading actions by: - tuning the jobs result information to use the offloading prefix even for (device) linking actions. - replacing the device inputs of the host linking jobs by a linker script that embed them in the right sections. Reviewers: echristo, tra, jlebar, rsmith, ABataev, hfinkel Subscribers: mkuron, whchung, mehdi_amini, cfe-commits, Hahnfeld, andreybokhanko, arpith-jacob, carlo.bertolli, caomhin Differential Revision: https://reviews.llvm.org/D21847 llvm-svn: 285319
* [Driver][OpenMP] Create tool chains for OpenMP offloading kind.Samuel Antao2016-10-271-67/+18
| | | | | | | | | | | | Summary: This patch adds new logic to create the necessary tool chains to support offloading for OpenMP. The OpenMP related options are checked and the tool chains created accordingly. Diagnostics are emitted in case the options are illegal or express unknown targets. Reviewers: echristo, tra, jlebar, rsmith, ABataev, hfinkel Subscribers: whchung, mkuron, mehdi_amini, cfe-commits, Hahnfeld, arpith-jacob, carlo.bertolli, caomhin Differential Revision: https://reviews.llvm.org/D21843 llvm-svn: 285311
* [XRay] Check in Clang whether XRay supports the target when ↵Dean Michael Berris2016-10-271-1/+10
| | | | | | | | | | | | | | | -fxray-instrument is passed Summary: Added the code which explicitly emits an error in Clang in case `-fxray-instrument` is passed, but XRay is not supported for the selected target. Reviewers: rsmith, aaron.ballman, rnk, dberris Differential Revision: https://reviews.llvm.org/D24799 llvm-svn: 285266
* Unconditionally pass `-lto_library` to the linker on DarwinMehdi Amini2016-10-261-15/+15
| | | | | | | | | | | We're only doing it with -flto currently, however it never "hurt" to pass it, and users that are linking without -flto can get in trouble if one of the dependency (a static library for instance) contains bitcode. Differential Revision: https://reviews.llvm.org/D25932 llvm-svn: 285254
* [Myriad] Find libc++ adjacent to libstdc++Douglas Katzman2016-10-251-3/+11
| | | | llvm-svn: 285140
* Use linker flag --fix-cortex-a53-843419 on Android ARM64 compilation.Stephen Hines2016-10-251-0/+8
| | | | | | | | | | | | | | | | Summary: This is only forced on if there is no non-Cortex-A53 CPU specified as well. Android's platform and NDK builds need to assume that the code can be run on Cortex-A53 devices, so we always enable the fix unless we know specifically that the code is only running on a different kind of CPU. Reviewers: cfe-commits Subscribers: aemerson, rengolin, tberghammer, pirama, danalbert Differential Revision: https://reviews.llvm.org/D25761 llvm-svn: 285127
* Adjust for TimePoint interface change in llvm: D25730. NFCPavel Labath2016-10-241-3/+5
| | | | llvm-svn: 284964
* [Driver][Darwin] Pass -no_deduplicate to ld64Bruno Cardoso Lopes2016-10-211-0/+27
| | | | | | | | | | Recent versions of ld64 run a deduplicate pass, which is on by default. Disable the pass by using -no_deduplicate in certain condition and enhance total compile time. rdar://problem/25455336 llvm-svn: 284798
* New clang option -mpie-copy-relocations to use copy relocations for PIE builds.Sriraman Tallam2016-10-191-0/+6
| | | | | | Differential Revision: https://reviews.llvm.org/D19996 llvm-svn: 284638
* [Driver] Use stem rather than filename for executable namePetr Hosek2016-10-171-1/+1
| | | | | | | | | | When comparing the linker name in Fuchsia driver, use stem rather than filename to get the name of the linker becase on Windows, the filename will have an extension. Differential Revision: https://reviews.llvm.org/D25700 llvm-svn: 284430
* Fix a typo.Adrian Prantl2016-10-171-1/+1
| | | | llvm-svn: 284400
* Revert r284256 due to test failureEd Maste2016-10-141-4/+0
| | | | llvm-svn: 284259
* Link static PIE programs against rcrt0.o on OpenBSDEd Maste2016-10-141-0/+4
| | | | | | | | Patch by Stefan Kempf. Differential Revision: https://reviews.llvm.org/D22130 llvm-svn: 284256
* Pass -ffunction-sections/-fdata-sections along to gold-pluginTeresa Johnson2016-10-131-5/+22
| | | | | | | | | | | | | | Summary: These options need to be passed to the plugin in order to have an effect on LTO/ThinLTO compiles. Reviewers: mehdi_amini, pcc Subscribers: jfb, dschuff, mehdi_amini, cfe-commits Differential Revision: https://reviews.llvm.org/D24644 llvm-svn: 284140
* Guard flag –fdenormal-fp-math with –fno-fast-math.Sjoerd Meijer2016-10-131-3/+10
| | | | | | | | This allows disabling the FP options with just one flag (-fno-fast-math). Differential Revision: https://reviews.llvm.org/D25479 llvm-svn: 284121
* Revert - When optimizing for size, enable loop rerolling by defaultMike Edwards2016-10-111-10/+1
| | | | | | This reverts r283685 as it is causing test failures on Green Dragon. llvm-svn: 283950
* Add an option to save the backend-produced YAML optimization record to a fileHal Finkel2016-10-111-0/+33
| | | | | | | | | | | | | | | | | | | | | | | | | The backend now has the capability to save information from optimizations, the same information that can be used to generate optimization diagnostics but in machine-consumable form, into an output file. This can be enabled when using opt (see r282539), and this change enables it when using clang. The idea is that other tools will be able to consume these files, and perhaps in combination with the original source code, produce various kinds of optimization reports for users (and for compiler developers). We now have at-least two tools that can consume these files: * tools/llvm-opt-report * utils/opt-viewer Using the flag -fsave-optimization-record will cause the YAML file to be generated; the file name will be based on the output file name (if we're using -c or -S and have an output name), or the input file name. When we're using CUDA, or some other offloading mechanism, separate files are generated for each backend target. The output file name can be specified by the user using -foptimization-record-file=filename. Differential Revision: https://reviews.llvm.org/D25225 llvm-svn: 283834
* [Driver] Let -gline-tables-only win when it comes after -gmodules.Adrian Prantl2016-10-101-1/+3
| | | | | | | | | | | | The -gmodules option is all about putting debug type info into clang modules and for line tables the type information is irrelevant, so combining these two options makes no sense. This commmit fixes the behavior to match the one documented on the clang man page: the last -g... option wins. <rdar://problem/27059770> llvm-svn: 283810
* When optimizing for size, enable loop rerolling by defaultHal Finkel2016-10-091-1/+10
| | | | | | | | | | We have a loop-rerolling optimization which can be enabled by using -freroll-loops. While sometimes loops are hand-unrolled for performance reasons, when optimizing for size, we should always undo this manual optimization to produce smaller code (our optimizer's unroller will still unroll the rerolled loops if it thinks that is a good idea). llvm-svn: 283685
* Use StringReg in TargetParser APIs (NFC)Mehdi Amini2016-10-071-33/+34
| | | | llvm-svn: 283527
* [Driver] Add driver support for FuchsiaPetr Hosek2016-10-061-0/+107
| | | | | | | | | | | Provide toolchain and tool support for Fuchsia operating system. Fuchsia uses compiler-rt as the runtime library and libc++, libc++abi and libunwind as the C++ standard library. lld is used as a default linker. Differential Revision: https://reviews.llvm.org/D25117 llvm-svn: 283420
* Revert "[XRay] Check in Clang whether XRay supports the target when ↵Dean Michael Berris2016-10-041-14/+1
| | | | | | | | -fxray-instrument is passed" This reverts 283193 -- broke the build. llvm-svn: 283199
OpenPOWER on IntegriCloud