summaryrefslogtreecommitdiffstats
path: root/clang/lib/Driver/ToolChains/Gnu.cpp
Commit message (Collapse)AuthorAgeFilesLines
* [Clang] Fix Hurd toolchain test on a two-stage build with ThinLTOAlexandre Ganea2020-04-291-9/+11
| | | | | | | | | | A two-stage ThinLTO build previously failed the clang/test/Driver/hurd.c test because of a static_cast in "tools::gnutools::Linker::ConstructJob()" which wrongly converted an instance of "clang::driver::toolchains::Hurd" into that of "clang::driver::toolchains::Linux". ThinLTO would later devirtualize the "ToolChain.getDynamicLinker(Args)" call and use "Linux::getDynamicLinker()" instead, causing the test to generate a wrong "-dynamic-linker" linker flag (/lib/ld-linux.so.2 instead of /lib/ld.so) Fixes PR45061. Differential Revision: https://reviews.llvm.org/D75373 (cherry picked from commit 7e77cf473ac9d8f8b65db017d660892f1c8f4b75)
* [PowerPC] Default ppc64 linux-gnu/freebsd to -fno-PICFangrui Song2020-01-071-3/+0
| | | | | | | | | | | | | | | | | According to D53384, the default was switched from -fno-PIC to -fPIC to work around a -fsanitize=leak bug on big-endian. This gratuitous difference between little-endian and big-endian is undesired, and not acceptable on powerpc64-unknown-freebsd. If -fsanitize=leak still has the problem, we should consider defaulting to -fPIC/-fPIE only when -fsanitize=leak is specified (see SanitizerArgs::requiresPIE()) powerpc64-ibm-aix is unaffected: it still defaults to -fPIC. powerpc64-linux-musl is unaffected (-fPIE since D39588): it still defaults to -fPIE. Reviewed By: #powerpc, jhibbits Differential Revision: https://reviews.llvm.org/D72363
* [Gnu toolchain] Look at standard GCC paths for libstdcxx by defaultKristina Brooks2020-01-051-10/+94
| | | | | | | | | | | Linux' current addLibCxxIncludePaths and addLibStdCxxIncludePaths are actually almost non-Linux-specific at all, and can be reused almost as such for all gcc toolchains. Only keep Android/Freescale/Cray hacks in Linux's version. Patch by sthibaul (Samuel Thibault) Differential Revision: https://reviews.llvm.org/D69758
* [clang][SystemZ] Add support for -march=nativeUlrich Weigand2019-12-161-1/+1
| | | | | | Handle -march=native in systemz::getSystemZTargetCPU, similar to how this is done on other platforms. Also change the return type to std::string instead of const char *.
* [Driver] Use .init_array for all gcc installations and simplify Generic_ELF ↵Fangrui Song2019-12-131-17/+1
| | | | | | | | | | | | | | | | | -fno-use-init-array rules D39317 made clang use .init_array when no gcc installations is found. This change changes all gcc installations to use .init_array . GCC 4.7 by default stopped providing .ctors/.dtors compatible crt files, and stopped emitting .ctors for __attribute__((constructor)). .init_array should always work. FreeBSD rules are moved to FreeBSD.cpp to make Generic_ELF rules clean. Reviewed By: rnk Differential Revision: https://reviews.llvm.org/D71434
* Default to -fuse-init-arrayFangrui Song2019-12-121-3/+3
| | | | | | | | | | | | | | | | | | | Very few ELF platforms still use .ctors/.dtors now. Linux (glibc: 1999-07), DragonFlyBSD, FreeBSD (2012-03) and Solaris have supported .init_array for many years. Some architectures like AArch64/RISC-V default to .init_array . GNU ld and gold can even convert .ctors to .init_array . It makes more sense to flip the CC1 default, and only uses -fno-use-init-array on platforms that don't support .init_array . For example, OpenBSD did not support DT_INIT_ARRAY before Aug 2016 (https://github.com/openbsd/src/commit/86fa57a2792c6374b0849dd7b818a11e676e60ba) I may miss some ELF platforms that still use .ctors, but their maintainers can easily diagnose such problems. Reviewed By: rnk Differential Revision: https://reviews.llvm.org/D71393
* Initial implementation of -fmacro-prefix-map and -ffile-prefix-mapDan McGregor2019-11-261-0/+13
| | | | | | | | | GCC 8 implements -fmacro-prefix-map. Like -fdebug-prefix-map, it replaces a string prefix for the __FILE__ macro. -ffile-prefix-map is the union of -fdebug-prefix-map and -fmacro-prefix-map Reviewed By: rnk, Lekensteyn, maskray Differential Revision: https://reviews.llvm.org/D49466
* [Driver] Fix incorrect GNU triplet for PowerPC on SUSE LinuxAaron Puchert2019-11-231-1/+3
| | | | | | | | | | | | | | | Summary: On SUSE distributions for 32-bit PowerPC, gcc is configured as a 64-bit compiler using the GNU triplet "powerpc64-suse-linux", but invoked with "-m32" by default. Thus, the correct GNU triplet for 32-bit PowerPC SUSE distributions is "powerpc64-suse-linux" and not "powerpc-suse-linux". Reviewers: jrtc27, nemanjai, glaubitz Reviewed By: nemanjai Differential Revision: https://reviews.llvm.org/D55326
* [RISCV] Support mutilib in baremetal environmentZakk Chen2019-11-211-0/+56
| | | | | | | | | | | | 1. Currently only support the set of multilibs same to riscv-gnu-toolchain. 2. Fix testcase typo causes fail on Windows. 3. Fix testcases to set empty sysroot. Reviewers: espindola, asb, kito-cheng, lenary Reviewed By: lenary Differential Revision: https://reviews.llvm.org/D67508
* Revert "[RISCV] Support mutilib in baremetal environment"Zakk Chen2019-11-211-56/+0
| | | | | This reverts commit df876a026981b7a125b31bbb85ba4b1144edb0f9. Clang::riscv32-toolchain.c Clang::riscv64-toolchain.c fails on Windows.
* [RISCV] Support mutilib in baremetal environmentZakk Chen2019-11-211-0/+56
| | | | | | | | | | | 1. Currently only support the set of multilibs same to riscv-gnu-toolchain. 2. Fix testcase typo causes fail on Windows Reviewers: espindola, asb, kito-cheng, lenary Reviewed By: lenary Differential Revision: https://reviews.llvm.org/D67508
* Revert "[RISCV] Support mutilib in baremetal environment"Nico Weber2019-11-191-56/+0
| | | | | This reverts commit b6d7bbfa004310777cd41448ffc377aea082fc8c. Driver/riscv64-toolchain.c fails on Windows.
* [RISCV] Support mutilib in baremetal environmentZakk Chen2019-11-191-0/+56
| | | | | | | | | | Currently only support the set of multilibs same to riscv-gnu-toolchain. Reviewers: espindola, asb, kito-cheng, lenary Reviewed By: lenary Differential Revision: https://reviews.llvm.org/D67508
* [RISCV] Match GCC `-march`/`-mabi` driver defaultsSam Elliott2019-11-151-5/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: Clang/LLVM is a cross-compiler, and so we don't have to make a choice about `-march`/`-mabi` at build-time, but we may have to compute a default `-march`/`-mabi` when compiling a program. Until now, each place that has needed a default `-march` has calculated one itself. This patch adds a single place where a default `-march` is calculated, in order to avoid calculating different defaults in different places. This patch adds a new function `riscv::getRISCVArch` which encapsulates this logic based on GCC's for computing a default `-march` value when none is provided. This patch also updates the logic in `riscv::getRISCVABI` to match the logic in GCC's build system for computing a default `-mabi`. This patch also updates anywhere that `-march` is used to now use the new function which can compute a default. In particular, we now explicitly pass a `-march` value down to the gnu assembler. GCC has convoluted logic in its build system to choose a default `-march`/`-mabi` based on build options, which would be good to match. This patch is based on the logic in GCC 9.2.0. This commit's logic is different to GCC's only for baremetal targets, where we default to rv32imac/ilp32 or rv64imac/lp64 depending on the target triple. Tests have been updated to match the new logic. Reviewers: asb, luismarques, rogfer01, kito-cheng, khchen Reviewed By: asb, luismarques Subscribers: sameer.abuasal, rbar, johnrusso, simoncook, apazos, sabuasal, niosHD, shiva0217, jrtc27, MaskRay, zzheng, edward-jones, MartinMosbeck, brucehoult, the_o, rkruppe, PkmX, jocewei, psnobl, benna, Jim, s.egerton, pzheng, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D69383
* [mips] Add `octeon+` to the list of CPUs accepted by the driverSimon Atanasyan2019-11-071-1/+2
|
* [Clang][OpenMP Offload] Add new tool for wrapping offload device binariesSergey Dmitriev2019-10-091-4/+1
| | | | | | | | | | This patch removes the remaining part of the OpenMP offload linker scripts which was used for inserting device binaries into the output linked binary. Device binaries are now inserted into the host binary with a help of the wrapper bit-code file which contains device binaries as data. Wrapper bit-code file is dynamically created by the clang driver with a help of new tool clang-offload-wrapper which takes device binaries as input and produces bit-code file with required contents. Wrapper bit-code is then compiled to an object and resulting object is appended to the host linking by the clang driver. This is the second part of the patch for eliminating OpenMP linker script (please see https://reviews.llvm.org/D64943). Differential Revision: https://reviews.llvm.org/D68166 llvm-svn: 374219
* [mips] Set default float ABI to "soft" on FreeBSDSimon Atanasyan2019-10-091-1/+2
| | | | | | | | Initial patch by Kyle Evans. Fix PR43596 llvm-svn: 374154
* [Driver] Add -static-openmp driver optionPirama Arumuga Nainar2019-09-091-1/+5
| | | | | | | | | | | | | | | | | | | | | | Summary: For Gnu, FreeBSD and NetBSD, this option forces linking with the static OpenMP host runtime (similar to -static-libgcc and -static-libstdcxx). Android's NDK will start the shared OpenMP runtime in addition to the static libomp. In this scenario, the linker will prefer to use the shared library by default. Add this option to enable linking with the static libomp. Reviewers: Hahnfeld, danalbert, srhines, joerg, jdoerfert Subscribers: guansong, cfe-commits Tags: #clang Fixes https://github.com/android-ndk/ndk/issues/1028 Differential Revision: https://reviews.llvm.org/D67200 llvm-svn: 371437
* [Clang] Migrate llvm::make_unique to std::make_uniqueJonas Devlieghere2019-08-141-3/+3
| | | | | | | | | | Now that we've moved to C++14, we no longer need the llvm::make_unique implementation from STLExtras.h. This patch is a mechanical replacement of (hopefully) all the llvm::make_unique instances across the monorepo. Differential revision: https://reviews.llvm.org/D66259 llvm-svn: 368942
* Add support for openSUSE RISC-V tripleSam Elliott2019-08-011-1/+2
| | | | | | | | | | | | | | | | Reviewers: asb Reviewed By: asb Subscribers: lenary, rbar, johnrusso, simoncook, apazos, sabuasal, niosHD, jrtc27, zzheng, edward-jones, MartinMosbeck, brucehoult, the_o, PkmX, jocewei, lebedev.ri, kito-cheng, shiva0217, rogfer01, dexonsmith, rkruppe, cfe-commits, llvm-commits Tags: #clang, #llvm Differential Revision: https://reviews.llvm.org/D63497 Patch by Andreas Schwab (schwab) llvm-svn: 367565
* [RISCV][NFC] Make use of Triple::isRISCVAlex Bradbury2019-07-081-5/+1
| | | | | | Use new helper introduced in rL365327. llvm-svn: 365329
* [Driver] -static-pie: add -z textFangrui Song2019-05-301-0/+2
| | | | | | | | | | | | | | | | | | | | | | | This matches gcc -static-pie. The intention is to prevent dynamic relocations in read-only segments. In ld.bfd and gold, -z notext is the default. If text relocations are needed: * -z notext: allow and emit DF_TEXTREL. DF_TEXTREL is not emitted if there is no text relocation. * -z text: error In lld, -z text is the default (this change is a no-op). * -z text: error on text relocations * -z notext: allow text relocations, and emit DF_TEXTREL no matter whether text relocations exist. Reviewed By: sivachandra Differential Revision: https://reviews.llvm.org/D62606 llvm-svn: 362050
* Let -static-pie win if it is specified along with -pie or -static.Siva Chandra2019-05-211-7/+28
| | | | | | | | Also, disallow specifying -no-pie/-nopie along with -static-pie. Differential Revision: https://reviews.llvm.org/D59841 llvm-svn: 361312
* [AVR] Automatically link CRT and libgcc from the system avr-gccDylan McKay2019-05-191-0/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: This patch modifies the AVR toolchain so that if avr-gcc and avr-libc are detected during compilation, the CRT, libgcc, libm, and libc anre linked. This matches avr-gcc's default behaviour, and the expected behaviour of all C compilers - including the C runtime. avr-gcc also needs a -mmcu specified in order to link runtime libraries. The difference betwen this patch and avr-gcc is that this patch will warn users whenever they compile without a runtime, as opposed to GCC, which silently trims the runtime libs from the linker arguments when no -mmcu is specified. Reviewers: aaron.ballman, kparzysz, asb, hfinkel, brucehoult, TimNN Subscribers: cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D54334 llvm-svn: 361116
* [cc1as] Change -compress-debug-sections= to use --Fangrui Song2019-05-111-5/+3
| | | | | | The double dash form is documented by GNU as, used by gcc, and accepted by llvm-mc. llvm-svn: 360495
* [Driver] Support compiler-rt crtbegin.o/crtend.o for LinuxPetr Hosek2019-04-301-24/+45
| | | | | | | | | | When compiler-rt is selected as the runtime library for Linux targets use its crtbegin.o/crtend.o implemenetation rather than platform one if available. Differential Revision: https://reviews.llvm.org/D59264 llvm-svn: 359603
* [Fuchsia] Support multilib for -fsanitize=address and -fno-exceptionsPetr Hosek2019-04-271-10/+2
| | | | | | | | | | | | | | | This introduces a support for multilibs to Fuchsia driver. Unlike the existing multilibs that are used primarily for handling different architecture variants, we use multilibs to handle different variants of Clang runtime libraries: -fsanitize=address and -fno-exceptions are the two we support initially. This replaces the existing support for sanitized runtimes libraries that was only used by Fuchsia driver and it also refactors some of the logic to allow sharing between GNU and Fuchsia drivers. Differential Revision: https://reviews.llvm.org/D61040 llvm-svn: 359360
* Add support for detection of devtoolset-8Tom Stellard2019-04-091-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: The current llvm/clang et al. project can be built with the latest developer toolset (devtoolset-8) on RHEL, which provides GCC 8.2.1. However, the result compiler will not identify this toolset itself when compiling programs, which is of course not desirable. After the patch - which simply adds the name of the developer toolset to the existing list - it gets identified and selected, as shown below: [bamboo@bamboo llvm-project]$ clang -v clang version 9.0.0 (https://github.com/llvm/llvm-project.git e5ac385fb1ffa4bd3875ea6a4d24efdbd7814572) Target: x86_64-unknown-linux-gnu Thread model: posix InstalledDir: /home/bamboo/llvm/bin Found candidate GCC installation: /opt/rh/devtoolset-4/root/usr/lib/gcc/x86_64-redhat-linux/5.2.1 Found candidate GCC installation: /opt/rh/devtoolset-7/root/usr/lib/gcc/x86_64-redhat-linux/7 Found candidate GCC installation: /opt/rh/devtoolset-8/root/usr/lib/gcc/x86_64-redhat-linux/8 Found candidate GCC installation: /usr/lib/gcc/x86_64-redhat-linux/4.8.2 Found candidate GCC installation: /usr/lib/gcc/x86_64-redhat-linux/4.8.5 Selected GCC installation: /opt/rh/devtoolset-8/root/usr/lib/gcc/x86_64-redhat-linux/8 Candidate multilib: .;@m64 Candidate multilib: 32;@m32 Selected multilib: .;@m64 Patch By: Radu-Adrian Popescu Reviewers: tstellar, fedor.sergeev Reviewed By: tstellar Subscribers: jdoerfert, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D59987 llvm-svn: 358002
* Enable IAS for FreeBSD SPARC64.Brad Smith2019-04-071-1/+2
| | | | llvm-svn: 357878
* [RISCV] Collect library directories and triples for riscv64 triple tooAlex Bradbury2019-04-041-6/+16
| | | | | | | | | | | | When setting up library and tools paths when detecting an accompanying GCC installation only riscv32 was handled. As a consequence when targetting riscv64 neither the linker nor libraries would be found. This adds handling and tests for riscv64. Differential Revision: https://reviews.llvm.org/D53392 Patch by Edward Jones. llvm-svn: 357699
* [driver] clang-format. Fix indentation, split long lines. NFCSimon Atanasyan2019-04-021-3/+5
| | | | llvm-svn: 357505
* [Driver] Use --warn-shared-textrel for Android.Dan Albert2019-03-291-0/+5
| | | | | | | | | | | | | | | Android does not allow shared text relocations. Enable the linker warning to detect them by default. Reviewers: srhines, pirama Reviewed By: srhines Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D53344 llvm-svn: 357296
* [Driver] Default Android toolchains to noexecstack.Dan Albert2019-03-281-0/+9
| | | | | | | | | | | | | | Android does not support executable stacks. Reviewers: srhines, pirama Reviewed By: pirama Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D53343 llvm-svn: 357197
* Revert the r348352 "[clang] - Simplify tools::SplitDebugName."George Rimar2019-03-271-1/+1
| | | | | | | | | This partially reverts the r348352 (https://reviews.llvm.org/D55006) because of https://bugs.llvm.org/show_bug.cgi?id=41161. I did not revert the test case file because it passes fine now. llvm-svn: 357061
* [Clang Driver] Add support for "-static-pie" argument to the Clang driver.Siva Chandra2019-02-201-6/+15
| | | | | | | | | | | | Summary: This change mimics GCC's support for the "-static-pie" argument. Subscribers: cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D58307 llvm-svn: 354502
* [Driver][Gnu] Support -nolibc flagPetr Hosek2019-02-171-1/+2
| | | | | | | | | This can be used to disable libc linking. This flag is supported by GCC since version 9 as well as some Clang target toolchains. Differential Revision: https://reviews.llvm.org/D58326 llvm-svn: 354210
* Update the file headers across all of the LLVM projects in the monorepoChandler Carruth2019-01-191-4/+3
| | | | | | | | | | | | | | | | | to reflect the new license. We understand that people may be surprised that we're moving the header entirely to discuss the new license. We checked this carefully with the Foundation's lawyer and we believe this is the correct approach. Essentially, all code in the project is now made available by the LLVM project under our new license, so you will see that the license headers include that license only. Some of our contributors have contributed code under our old license, and accordingly, we have retained a copy of our old license notice in the top-level files in each project and repository. llvm-svn: 351636
* Enable IAS for OpenBSD SPARC.Brad Smith2019-01-151-1/+1
| | | | llvm-svn: 351245
* [MSP430] Provide a toolchain descriptionAnton Korobeynikov2019-01-151-0/+34
| | | | | | | | | | | | | | | This is an initial implementation for msp430 toolchain including -mmcu option support -mhwmult options support -integrated-as by default The toolchain uses msp430-elf-as as a linker and supports msp430-gcc toolchain tree. Patch by Kristina Bessonova! Differential Revision: https://reviews.llvm.org/D56658 llvm-svn: 351228
* [Solaris] Move enabling IAS for SPARC from the Solaris toolchain to Generic_GCC.Brad Smith2019-01-151-0/+6
| | | | llvm-svn: 351217
* Replace getOS() == llvm::Triple::*BSD with isOS*BSD() [NFCI]Michal Gorny2018-12-201-1/+1
| | | | | | | | | | | | Replace multiple comparisons of getOS() value with FreeBSD, NetBSD, OpenBSD and DragonFly with matching isOS*BSD() methods. This should improve the consistency of coding style without changing the behavior. Direct getOS() comparisons were left whenever used in switch or switch- like context. Differential Revision: https://reviews.llvm.org/D55916 llvm-svn: 349752
* [PowerPC] Make no-PIC default to match GCC - CLANGStefan Pintilie2018-12-181-1/+1
| | | | | | | | Make -fno-PIC default on PowerPC for Little Endian Linux. Differential Revision: https://reviews.llvm.org/D53384 llvm-svn: 349489
* [mips] Enable using of integrated assembler in all cases.Simon Atanasyan2018-12-121-10/+1
| | | | llvm-svn: 348935
* Revert "[PowerPC] Make no-PIC default to match GCC - CLANG"Stefan Pintilie2018-12-111-1/+1
| | | | | | This reverts commit rL348299. llvm-svn: 348858
* [clang] - Simplify tools::SplitDebugName.George Rimar2018-12-051-1/+1
| | | | | | | | | | | | | | | | | | This is an updated version of the D54576, which was reverted. Problem was that SplitDebugName calls the InputInfo::getFilename which asserts if InputInfo given is not of type Filename: const char *getFilename() const { assert(isFilename() && "Invalid accessor."); return Data.Filename; } At the same time at that point, it can be of type Nothing and we need to use getBaseInput(), like original code did. Differential revision: https://reviews.llvm.org/D55006 llvm-svn: 348352
* [PowerPC] Make no-PIC default to match GCC - CLANGStefan Pintilie2018-12-041-1/+1
| | | | | | | | Make -fno-PIC default on PowerPC LE. Differential Revision: https://reviews.llvm.org/D53384 llvm-svn: 348299
* Add Hurd target to Clang driver (2/2)Kristina Brooks2018-11-291-1/+5
| | | | | | | | | | | | | | | This adds Hurd toolchain support to Clang's driver in addition to handling translating the triple from Hurd-compatible form to the actual triple registered in LLVM. (Phabricator was stripping the empty files from the patch so I manually created them) Patch by sthibaul (Samuel Thibault) Differential Revision: https://reviews.llvm.org/D54379 llvm-svn: 347833
* Revert "[clang] - Simplify tools::SplitDebugName."Jonas Toth2018-11-271-1/+1
| | | | | | | | This reverts commit r347035 as it introduced assertion failures under certain conditions. More information can be found here: https://reviews.llvm.org/rL347035 llvm-svn: 347676
* Revert "[PowerPC] Make no-PIC default to match GCC - CLANG"Stefan Pintilie2018-11-161-0/+3
| | | | | | This reverts commit r347070 llvm-svn: 347075
* [PowerPC] Make no-PIC default to match GCC - CLANGStefan Pintilie2018-11-161-3/+0
| | | | | | | | Make the default -fno-PIC on Power PC. Differential Revision: https://reviews.llvm.org/D53384 llvm-svn: 347070
OpenPOWER on IntegriCloud