summaryrefslogtreecommitdiff
path: root/clang/test/Driver/linux-header-search.cpp
AgeCommit message (Collapse)Author
2024-04-02[Driver,test] Remove --gcc-toolchain=""Fangrui Song
This option was added so that changing CMake GCC_INSTALL_PREFIX would not cause test failures or due to cargo culting. Setting GCC_INSTALL_PREFIX leads to an error now and we should stop making our tests ugly.
2023-09-18[driver] Conditionally include installed libc++ headers for AndroidShoaib Meenai
https://reviews.llvm.org/D71154 prevented Clang from search for libc++ headers installed alongside the driver when targeting Android. The motivation was the NDK's use of a different libc++ inline namespace (`__ndk1` instead of the standard `__1`), which made regular libc++ headers incompatible with the NDK's libc++ library. Since then, libc++ has gained the ability to install its `__config_site` header (which controls the inline namespace, among other things) to a per-target include directory, which enables per-target customizations. If this directory is present, the user has expressly built libc++ for Android, and we should use those headers. The motivation is that, with the current setup, if a user builds their own libc++ for Android, they'll use the library they built themselves but the NDK's headers instead of their own, which is surprising at best and can cause all sorts of problems (e.g. if you built your own libc++ with a different ABI configuration). It's important to match the headers and libraries in that scenario, and checking for an Android per-target include directory lets us do so without regressing the original scenario which https://reviews.llvm.org/D71154 was addressing. While I'm here, switch to using sys::path::append instead of slashes directly, to get system path separators on Windows, which is consistent with how library paths are constructed (and that consistency will be important in a follow-up, where we use a common search function for the include and library path construction). (As an aside, one of the motivations for https://reviews.llvm.org/D71154 was to support targeting both Android and Apple platforms, which expected libc++ headers to be provided by the toolcain at the time. Apple has since switched to including libc++ headers in the platform SDK instead of in the toolchain, so that specific motivation no longer applies either.) Reviewed By: phosek Differential Revision: https://reviews.llvm.org/D159292
2023-04-24[Clang][Driver] Handle LoongArch multiarch tuplesWANG Xuerui
This follows v1.00 of the [[ https://loongson.github.io/LoongArch-Documentation/LoongArch-toolchain-conventions-EN.html | LoongArch Toolchain Conventions ]], but notably with [[ https://github.com/loongson/LoongArch-Documentation/pull/80 | this patch ]] applied (a proper version bump to v2.00 was not done, so it is indistinguishable from the "original" but now incompatible v1.00 otherwise). Only `loongarch64` is implemented in `Linux::getMultiarchTriple` because support for LA32 and ILP32* ABIs are incomplete right now. The Debian sysroot layout is based on Han Gao's recent porting effort, specifically the ghcr.io/rabenda/beige:loong64-v23-preview-20230330 container image. Reviewed By: SixWeining Differential Revision: https://reviews.llvm.org/D142688
2022-06-24Revert "[Driver][test] Replace ^//$ with empty string"Fangrui Song
This reverts commit 4817b7729a1846b709ec02b98bfe11b0125f8e8f. It caused some `^/\n` and had some objection about its readability improvement.
2022-06-24[Driver][test] Replace ^//$ with empty stringFangrui Song
The convention does not add //\n. Having all RUN/CHECK lines separated by //\n makes editor movement difficult (e.g. { } in Vim).
2022-05-27[Clang][Driver] Fix include paths for `--sysroot /` on LinuxEgor Zhdan
Currently if `--sysroot /` is passed to the Clang driver, the include paths generated by the Clang driver will start with a double slash: `//usr/include/...`. If VFS is used to inject files into the include paths (for example, the Swift compiler does this), VFS will get confused and the injected files won't be visible. This change makes sure that the include paths start with a single slash. Fixes #28283. Differential Revision: https://reviews.llvm.org/D126289
2022-05-01[Driver][test] Remove unneeded -no-canonical-prefixes and use preferred ↵Fangrui Song
--target= Similar to D119309
2021-04-28[libc++] Support per-target __config_site in per-target runtime buildPetr Hosek
When using the per-target runtime build, it may be desirable to have different __config_site headers for each target where all targets cannot share a single configuration. The layout used for libc++ headers after this change is: ``` include/ c++/ v1/ <libc++ headers except for __config_site> <target1>/ c++/ v1/ __config_site <target2>/ c++/ v1/ __config_site <other targets> ``` This is the most optimal layout since it avoids duplication, the only headers that's per-target is __config_site, all other headers are shared across targets. This also means that we no need two -isystem flags: one for the target-agnostic headers and one for the target specific headers. Differential Revision: https://reviews.llvm.org/D89013
2021-03-28[Driver] Linux.cpp: move resource directory before /usr/local/include for ↵Fangrui Song
non-musl This follows GCC and simplifies code. /usr/local/include and TOOL_INCLUDE_DIR should not conflict with the resource directory include so users should not observe any difference.
2021-03-21[test] Delete obsoleted debian_multiarch_tree and ubuntu_13.04_multiarch_treeFangrui Song
They are quite outdated. Delete them to avoid unnecessary test churn.
2021-03-21[Driver] Linux.cpp: add -internal-isystem lib/../$triple/includeFangrui Song
With this change, for `#include <ar.h>`, `clang --target=aarch64-linux-gnu` will read `/usr/lib/gcc/aarch64-linux-gnu/10/../../../../aarch64-linux-gnu/include/ar.h` (on Debian gcc->gcc-cross) instead of `/usr/include/ar.h`. Some glibc headers (e.g. gnu/stubs.h) are different across architectures.
2021-03-20Revert "Revert "[Driver] Drop obsoleted Ubuntu 11.04 gcc detection""Fangrui Song
This reverts commit 243333ef3ec6c1e3910eb442177c2e2e927e6a87.
2021-03-20Revert "[Driver] Drop obsoleted Ubuntu 11.04 gcc detection"David Zarzycki
This reverts commit bdf39e6b0ed4b41a1842ac0193f30a726f8d9f63. The change is failing on Fedora 33 (x86-64).
2021-03-19[Driver] Drop obsoleted Ubuntu 11.04 gcc detectionFangrui Song
It has a very broken gcc installation path (usr/lib/i386-linux-gnu/gcc/i686-linux-gnu).
2021-01-02[PowerPC] Support powerpcle target in Clang [3/5]Brandon Bergren
Add powerpcle support to clang. For FreeBSD, assume a freestanding environment for now, as we only need it in the first place to build loader, which runs in the OpenFirmware environment instead of the FreeBSD environment. For Linux, recognize glibc and musl environments to match current usage in Void Linux PPC. Adjust driver to match current binutils behavior regarding machine naming. Adjust and expand tests. Reviewed By: MaskRay Differential Revision: https://reviews.llvm.org/D93919
2020-11-23[Driver] Enable getOSLibDir() lib32 workaround for SPARC on LinuxJohn Paul Adrian Glaubitz
This fixes the Builtins-sparc-linux testsuite failures on Linux SPARC which occur because clang cannot find the 32-bit runtime libraries when -m32 is passed on the command line. The same workaround is already being used on X86 and PPC. Also, switch the CHECK-DEBIAN-SPARC tests to use debian_multiarch_tree as both sparc and sparc64 are using the MultiArch mechanism on modern Debian systems the same way as x86_64, powerpc64el and others. Thus, switch the CHECK-DEBIAN-SPARC32 and CHECK-DEBIAN-SPARC64 tests to use the files from the debian_multiarch_tree directory for the header and linker path tests. Finally, rename CHECK-DEBIAN-SPARC32 to CHECK-DEBIAN-SPARC to match the naming scheme of the Debian MultiArch checks for the other Debian architectures. Reviewed By: MaskRay, phosek Differential Revision: https://reviews.llvm.org/D90524
2018-11-13[Driver] Support g++ headers in include/g++David Greene
ray's gcc installation puts C++ headers in PREFIX/include/g++ without indicating a gcc version at all. Typically this is because the version is encoded somewhere in PREFIX. Differential Revision: https://reviews.llvm.org/D53770 llvm-svn: 346802
2018-08-07Fix clash of gcc toolchains in driver regression testsKarl-Johan Karlsson
For some regression tests the path to the right toolchain is specified using the -sysroot switch. However, if clang was configured with a custom gcc toolchain (either by using GCC_INSTALL_PREFIX in cmake or the equivalent configure command), the path to the custom gcc toolchain path takes precedence to the one specified by sysroot. This causes several regression tests to fail as they will be using an unexpected path. This patch fixes this issue by adding --gcc-toolchain='' to all tests that rely on that. The empty string causes the driver to pick the path from sysroot instead. This patch contain the same kind of fixes as done in rC225182 llvm-svn: 339112
2018-07-31Fix linux-header-search.cpp with CLANG_DEFAULT_CXX_STDLIBJonas Hahnfeld
This configuration was broken after r338294 because Clang might be configured to always use libc++. llvm-svn: 338360
2018-07-30[OpenEmbedded] Fix lib paths for OpenEmbedded targetsMandeep Singh Grang
Summary: The lib paths are not correctly picked up for OpenEmbedded sysroots (like arm-oe-linux-gnueabi) for 2 reasons: 1. OpenEmbedded sysroots are of the form <sysroot>/usr/lib/<triple>/x.y.z. This form is handled in clang but only for Freescale vendor. 2. 64-bit OpenEmbedded sysroots may not have a /usr/lib dir. So they cannot find /usr/lib64 as it is referenced as /usr/lib/../lib64 in clang. This is a follow-up to the llvm patch: D48861 Reviewers: dlj, rengolin, fedor.sergeev, javed.absar, hfinkel, rsmith Reviewed By: rsmith Subscribers: rsmith, kristof.beyls, cfe-commits Differential Revision: https://reviews.llvm.org/D48862 llvm-svn: 338294
2018-06-28Support for multiarch runtimes layoutPetr Hosek
This change adds a support for multiarch style runtimes layout, so in addition to the existing layout where runtimes get installed to: lib/clang/$version/lib/$os Clang now allows runtimes to be installed to: lib/clang/$version/$target/lib This also includes libc++, libc++abi and libunwind; today those are assumed to be in Clang library directory built for host, with the new layout it is possible to install libc++, libc++abi and libunwind into the runtime directory built for different targets. The use of new layout is enabled by setting the LLVM_ENABLE_RUNTIME_TARGET_DIR CMake variable and is supported by both projects and runtimes layouts. The runtimes CMake build has been further modified to use the new layout when building runtimes for multiple targets. Differential Revision: https://reviews.llvm.org/D45604 llvm-svn: 335809
2018-04-07[Driver] Update GCC libraries detection logic for Gentoo.Manoj Gupta
Summary: 1. Find GCC's LDPATH from the actual GCC config file. 2. Avoid picking libraries from a similar named tuple if the exact tuple is installed. Reviewers: mgorny, chandlerc, thakis, rnk Reviewed By: mgorny, rnk Subscribers: cfe-commits, mgorny Differential Revision: https://reviews.llvm.org/D45233 llvm-svn: 329512
2016-12-12[Driver] Fix finding multilib gcc install on Gentoo (with gcc-config)Michal Gorny
Fix the gcc-config code to support multilib gcc installs properly. This solves two problems: -mx32 using the 64-bit gcc directory (due to matching installation triple), and -m32 not respecting gcc-config at all (due to mismatched installation triple). In order to fix the former issue, split the multilib scan out of Generic_GCC::GCCInstallationDetector::ScanLibDirForGCCTriple() (the code is otherwise unchanged), and call it for each installation found via gcc-config. In order to fix the latter issue, split the gcc-config processing out of Generic_GCC::GCCInstallationDetector::init() and repeat it for all triples, including extra and biarch triples. The only change in the gcc-config code itself is adding the call to multilib scan. Convert the gentoo_linux_gcc_multi_version_tree test input to multilib x86_64+32+x32 install, and add appropriate tests to linux-header-search and linux-ld. Differential Revision: https://reviews.llvm.org/D26887 llvm-svn: 289436
2016-10-25[Driver] Support obtaining active toolchain from gcc-config on GentooMichal Gorny
Support using gcc-config to determine the correct GCC toolchain location on Gentoo. In order to do that, attempt to read gcc-config configuration form [[sysroot]]/etc/env.d/gcc, if no custom toolchain location is provided. Differential Revision: https://reviews.llvm.org/D25661 llvm-svn: 285074
2016-05-08Teach header search about GCC 4.9 header search paths in Gentoo, theyChandler Carruth
now use the full GCC version in their weird suffix. llvm-svn: 268874
2016-02-12tests: Add explicit -stdlib=libstdc++ to tests that require itJonas Hahnfeld
This will be needed for the next commit that allows to switch the default C++ library which would otherwise make these tests fail. llvm-svn: 260661
2015-11-09Extend linux header search to find libc++ headers in c++/vN for any N.Evgeniy Stepanov
llvm-svn: 252514
2015-06-05[SPARC] Add multiarch include paths.James Y Knight
Adds tests verifying the proper dirs are found in the Debian 8/GCC4.9 layout for sparc (32bit), sparc (32bit) with lib64 multilib, and sparc64. The test cases added here also cover r239047, which fixed the linker paths. llvm-svn: 239154
2015-01-28Avoid testing for a particular choice of resource dir.Sean Silva
Without this patch, this test was accidentally testing that CLANG_RESOURCE_DIR, CLANG_LIBDIR_SUFFIX, and CLANG_VERSION_STRING were set to a particular set of values. The test was also getting pretty hairy since it was attempting to craft a regular expression that covered "all" possible combinations of settings for these configure-time constants. Clean it up by directly capturing the resource directory in a FileCheck variable. llvm-svn: 227310
2015-01-05Fix clash of gcc toolchains in driver regression tests.Samuel Antao
For some regression tests the path to the right toolchain is specified using the -sysroot switch. However, if clang was configured with a custom gcc toolchain (either by using GCC_INSTALL_PREFIX in cmake or the equivalent configure command), the path to the custom gcc toolchain path takes precedence to the one specified by sysroot. This causes several regression tests to fail as they will be using an unexpected path. This patch fixes this issue by adding --gcc-toolchain='' to all tests that rely on that. The empty string causes the driver to pick the path from sysroot instead. llvm-svn: 225182
2014-08-27Significantly fix Clang's header search for Ubuntu (and possibly otherChandler Carruth
modern Debian-based distributions) due to on-going multiarch madness. It appears that when the multiarch heeader search support went into the clang driver, it went in in a quite bad state. The order of includes completely failed to match the order exhibited by GCC, and in a specific case -- when the GCC triple and the multiarch triple don't match as with i686-linux-gnu and i386-linux-gnu -- we would absolutely fail to find the libstdc++ target-specific header files. I assume that folks who have been using Clang on Ubuntu 32-bit systems have been applying weird patches to hack around this. I can't imagine how else it could have worked. This was originally reported by a 64-bit operating system user who had a 32-bit crosscompiler installed. We tried to use that rather than the bi-arch support of the 64-bit compiler, but failed due to the triple differences. I've corrected all the wrong orderings in the existing tests and added a specific test for the multiarch triple strings that are different in a significant way. This should significantly improve the usability of Clang when checked out vanilla from upstream onto Ubuntu machines with an i686 GCC installation for whatever reason. llvm-svn: 216531
2014-07-10[x32] Adding X32 target support to driver, including ↵Zinovy Nis
TargetInfo,DescriptionString, flags, paths lookup, etc. Cover changes with new tests. The author of the patch is Pavel Chupin (@pavel.v.chupin). The changes enable "hello world" on x32 target (x86_64-*-linux-gnux32). s/isX32/IsX32/ also fixed. Differential Revision: http://reviews.llvm.org/D4180 llvm-svn: 212725
2014-06-24[Driver][Mips] Support mips64-linux-gnuabi64 / mips64el-linux-gnuabi64 ↵Simon Atanasyan
target triples. The patch fixes the bug #19869. http://llvm.org/bugs/show_bug.cgi?id=19869 llvm-svn: 211619
2014-06-20[PowerPC] Add MultiarchIncludeDirs for powerpc64leUlrich Weigand
There was already partial support for multi-arch on powerpc64le, but the MultiarchIncludeDirs setting was missing. This patch adds the appropriate definition, and also extends the linux-header-search.cpp test case to verify an Ubuntu 14.04 powerpc64le tree. llvm-svn: 211359
2014-05-12[Driver] Do not lose already detected set of toolchain's multilibs whileSimon Atanasyan
iterating over different library path suffixes and different library versions. To find the most appropriate library for the given command line flags we iterate over a set of disk paths. Before probe each path the already detected set of multilibs are cleared. If the set of paths contains existing paths which do not satisfy command line flags or do not contain necessary libraries and object files at all we might lose found multilibs. The patch updates variables which hold detected multilibs if we really find a new multilib matches command line flags. The patch reviewed by Jon Roelofs. llvm-svn: 208523
2014-03-03Update tests for addition of patch level to LLVM versionTom Stellard
llvm-svn: 202721
2014-01-20Make the Linux support for finding libc++ somewhat less braindead.Chandler Carruth
Now instead of just looking in the system root for it, we also look relative to the clang binary's directory. This should "just work" in almost all cases. I've added test cases accordingly. This is probably *very* worthwhile to backport to the 3.4 branch so that folks can check it out, build it, and use that as their host compiler going forward. llvm-svn: 199632
2013-08-26Teach the Linux toolchain about more modern Gentoo installations of GCCChandler Carruth
which add another wrinkle to the installation of the libstdc++ headers. Add at least some basic testing of the weirdnesses of Gentoo's layout. llvm-svn: 189212
2013-07-26Rework r187192, to tweak expressions to be tolerant of DOSish paths. XFAILs ↵NAKAMURA Takumi
can be removed. llvm-svn: 187194
2013-07-26clang/test/Driver/linux-header-search.cpp: Add XFAILs, for now. I'll fix ↵NAKAMURA Takumi
them later. llvm-svn: 187192
2013-07-26Fix gcc search for cross-compiler on Ubuntu 13.04.Eli Friedman
Just more craziness to find crtbegin.o etc. Patch by Stephen Kelly. llvm-svn: 187175
2013-06-26Remove PathV1.h usage from ToolChains.cpp.Rafael Espindola
llvm-svn: 184902
2013-03-06Driver: add support for new style multiarch in Ubuntu 13.04Dmitri Gribenko
Patch by Sanne Wouda. llvm-svn: 176557
2012-10-09The clang driver has a fairly fancy support for executing gcc instead ofRafael Espindola
clang itself. This dates back to clang's early days and while it looks like some of it is still used (for kext for example), other parts are probably dead. Remove the -ccc-clang-archs option and associated code. I don't think there is any remaining setup where clang doesn't support an architecture but it can expect an working gcc cross compiler to be available. A nice side effect is that tests no longer need to differentiate architectures that are included in production builds of clang and those that are not. llvm-svn: 165545
2012-04-09Author: Daniel Dunbar <daniel@zuster.org>Daniel Dunbar
--- log message follows this test --- [tests] Fixup some tests to work in "CLANG_IS_PRODUCTION" mode. llvm-svn: 154342
2012-02-26Okay, makes sense to change all the occurences to match clang.EXE.Benjamin Kramer
llvm-svn: 151491
2012-02-26Allow any file extension for the clang binary in the linux-header-search test.Benjamin Kramer
Turns out this can be .exe or .EXE, depending on the build system. llvm-svn: 151490
2012-02-26A follow-up to r151482 which added support for powerpc and powerpc64Chandler Carruth
Debian multiarch libraries, this should in theory add support for those platform's header search rules. I don't have a system to check this with, so review appreciated. I've added the corresponding tests referring to the debian multiarch tree. We are starting to have a relatively completely tested Linux platform for header search and library search, with several interesting peculiarities. We should point people at the debian_multiarch_tree when suggesting new tests. Folks with Debian systems that can check this for correctness, it would be much appreciated. The missing chunks I know of are testing bi-arch peudo-cross-compiling toolchains betwen 32-bit and 64-bit variants of platforms, and the MIPS and ARM Debian toolchains. llvm-svn: 151484
2012-01-20rename -ccc-host-triple into -targetSebastian Pop
llvm-svn: 148582
2012-01-13Revert r148138; it's causing test failures.Eli Friedman
llvm-svn: 148141