[clang] [Clang][Driver] Support relative paths for CLANG_CONFIG_FILE_SYSTEM_DIR (PR #110962)
carlocab wrote: I authored my commit using a working email address. See the [header](https://github.com/llvm/llvm-project/commit/e31545f666eb4ca32030956a38dbc4078a64068c.patch) of the patch: ``` >From e31545f666eb4ca32030956a38dbc4078a64068c Mon Sep 17 00:00:00 2001 From: Carlo Cabrera Date: Thu, 3 Oct 2024 14:15:07 +0800 Subject: [PATCH] [Clang][Driver] Support relative paths for CLANG_CONFIG_FILE_SYSTEM_DIR ``` Is that insufficient? https://github.com/llvm/llvm-project/pull/110962 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang][Driver] Support relative paths for CLANG_CONFIG_FILE_SYSTEM_DIR (PR #110962)
carlocab wrote: That's annoying. Thanks GitHub. I've updating my settings now. https://github.com/llvm/llvm-project/pull/110962 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang][Driver] Improve config file handling on Darwin (PR #111306)
https://github.com/carlocab created https://github.com/llvm/llvm-project/pull/111306 On Darwin, the default target triple contains the version of the kernel: ❯ clang --print-target-triple arm64-apple-darwin24.0.0 ❯ uname -r 24.0.0 This makes writing config files for the target triple rather cumbersome, because they require including the full version of the kernel in the filename when one generally cares only about the major version if at all. Let's improve this by also checking for major-versioned and unversioned `.cfg` files if we weren't able to find a `.cfg` file for the full triple when targetting Darwin. >From 7ab9f9ebb858618f6eb92bb058afca0cb0f56269 Mon Sep 17 00:00:00 2001 From: Carlo Cabrera <30379873+carlo...@users.noreply.github.com> Date: Mon, 7 Oct 2024 01:53:37 +0800 Subject: [PATCH] [Clang][Driver] Improve config file handling on Darwin MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit On Darwin, the default target triple contains the version of the kernel: ❯ clang --print-target-triple arm64-apple-darwin24.0.0 ❯ uname -r 24.0.0 This makes writing config files for the target triple rather cumbersome, because they require including the full version of the kernel in the filename when one generally cares only about the major version if at all. Let's improve this by also checking for major-versioned and unversioned `.cfg` files if we weren't able to find a `.cfg` file for the full triple when targetting Darwin. --- clang/lib/Driver/Driver.cpp| 19 +++ clang/test/Driver/config-file-darwin.c | 24 2 files changed, 43 insertions(+) create mode 100644 clang/test/Driver/config-file-darwin.c diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp index 2aaa52072b03d2..e9f241228d4aab 100644 --- a/clang/lib/Driver/Driver.cpp +++ b/clang/lib/Driver/Driver.cpp @@ -95,6 +95,7 @@ #include "llvm/TargetParser/Host.h" #include "llvm/TargetParser/RISCVISAInfo.h" #include // ::getenv +#include #include #include #include @@ -1222,6 +1223,24 @@ bool Driver::loadDefaultConfigFiles(llvm::cl::ExpansionContext &ExpCtx) { if (ExpCtx.findConfigFile(CfgFileName, CfgFilePath)) return readConfigFile(CfgFilePath, ExpCtx); + // On Darwin, try a major-versioned triple then an unversioned triple. + auto pos = Triple.find("-apple-darwin"); + auto kernelVersionStart = pos + std::strlen("-apple-darwin"); + if (pos != Triple.npos && Triple.length() > kernelVersionStart) { +// First, find the major-versioned triple (e.g. arm64-apple-darwin24). +auto T = Triple.substr(0, Triple.find(".", kernelVersionStart)); +CfgFileName = T + ".cfg"; +if (ExpCtx.findConfigFile(CfgFileName, CfgFilePath)) + return readConfigFile(CfgFilePath, ExpCtx); + +// If that is not available, try an unversioned triple +// (e.g. arm64-apple-darwin). +T = Triple.substr(0, kernelVersionStart); +CfgFileName = T + ".cfg"; +if (ExpCtx.findConfigFile(CfgFileName, CfgFilePath)) + return readConfigFile(CfgFilePath, ExpCtx); + } + // If we were unable to find a config file deduced from executable name, // that is not an error. return false; diff --git a/clang/test/Driver/config-file-darwin.c b/clang/test/Driver/config-file-darwin.c new file mode 100644 index 00..c24eb7ad19fe67 --- /dev/null +++ b/clang/test/Driver/config-file-darwin.c @@ -0,0 +1,24 @@ +// REQUIRES: shell + +// RUN: unset CLANG_NO_DEFAULT_CONFIG +// RUN: rm -rf %t && mkdir %t + +//--- Major-versioned config files are used when targetting *-apple-darwin* +// +// RUN: mkdir -p %t/testbin +// RUN: ln -s %clang %t/testbin/x86_64-apple-darwin24.0.0-clang +// RUN: echo "-Werror" > %t/testbin/x86_64-apple-darwin24.cfg +// RUN: %t/testbin/x86_64-apple-darwin24.0.0-clang --config-system-dir= --config-user-dir= -c -no-canonical-prefixes -### %s 2>&1 | FileCheck %s -check-prefix CHECK-MAJOR-VERSIONED +// +// CHECK-MAJOR-VERSIONED: Configuration file: {{.*}}/testbin/x86_64-apple-darwin24.cfg +// CHECK-MAJOR-VERSIONED: -Werror + +//--- Unversioned config files are used when targetting *-apple-darwin* +// +// RUN: mkdir -p %t/testbin +// RUN: ln -s %clang %t/testbin/arm64-apple-darwin23.1.2-clang +// RUN: echo "-Werror" > %t/testbin/arm64-apple-darwin.cfg +// RUN: %t/testbin/arm64-apple-darwin23.1.2-clang --config-system-dir= --config-user-dir= -c -no-canonical-prefixes -### %s 2>&1 | FileCheck %s -check-prefix CHECK-UNVERSIONED +// +// CHECK-UNVERSIONED: Configuration file: {{.*}}/testbin/arm64-apple-darwin.cfg +// CHECK-UNVERSIONED: -Werror ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang][Driver] Improve config file handling on Darwin (PR #111306)
https://github.com/carlocab updated https://github.com/llvm/llvm-project/pull/111306 >From 80b4301ba4a043fe426f206a4ae3a7b46ad8396c Mon Sep 17 00:00:00 2001 From: Carlo Cabrera Date: Mon, 7 Oct 2024 01:53:37 +0800 Subject: [PATCH] [Clang][Driver] Improve config file handling on Darwin MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit On Darwin, the default target triple contains the version of the kernel: ❯ clang --print-target-triple arm64-apple-darwin24.0.0 ❯ uname -r 24.0.0 This makes writing config files for the target triple rather cumbersome, because they require including the full version of the kernel in the filename when one generally cares only about the major version if at all. Let's improve this by also checking for major-versioned and unversioned `.cfg` files if we weren't able to find a `.cfg` file for the full triple when targetting Darwin. --- clang/lib/Driver/Driver.cpp| 19 +++ clang/test/Driver/config-file-darwin.c | 24 2 files changed, 43 insertions(+) create mode 100644 clang/test/Driver/config-file-darwin.c diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp index 2aaa52072b03d2..e9f241228d4aab 100644 --- a/clang/lib/Driver/Driver.cpp +++ b/clang/lib/Driver/Driver.cpp @@ -95,6 +95,7 @@ #include "llvm/TargetParser/Host.h" #include "llvm/TargetParser/RISCVISAInfo.h" #include // ::getenv +#include #include #include #include @@ -1222,6 +1223,24 @@ bool Driver::loadDefaultConfigFiles(llvm::cl::ExpansionContext &ExpCtx) { if (ExpCtx.findConfigFile(CfgFileName, CfgFilePath)) return readConfigFile(CfgFilePath, ExpCtx); + // On Darwin, try a major-versioned triple then an unversioned triple. + auto pos = Triple.find("-apple-darwin"); + auto kernelVersionStart = pos + std::strlen("-apple-darwin"); + if (pos != Triple.npos && Triple.length() > kernelVersionStart) { +// First, find the major-versioned triple (e.g. arm64-apple-darwin24). +auto T = Triple.substr(0, Triple.find(".", kernelVersionStart)); +CfgFileName = T + ".cfg"; +if (ExpCtx.findConfigFile(CfgFileName, CfgFilePath)) + return readConfigFile(CfgFilePath, ExpCtx); + +// If that is not available, try an unversioned triple +// (e.g. arm64-apple-darwin). +T = Triple.substr(0, kernelVersionStart); +CfgFileName = T + ".cfg"; +if (ExpCtx.findConfigFile(CfgFileName, CfgFilePath)) + return readConfigFile(CfgFilePath, ExpCtx); + } + // If we were unable to find a config file deduced from executable name, // that is not an error. return false; diff --git a/clang/test/Driver/config-file-darwin.c b/clang/test/Driver/config-file-darwin.c new file mode 100644 index 00..c24eb7ad19fe67 --- /dev/null +++ b/clang/test/Driver/config-file-darwin.c @@ -0,0 +1,24 @@ +// REQUIRES: shell + +// RUN: unset CLANG_NO_DEFAULT_CONFIG +// RUN: rm -rf %t && mkdir %t + +//--- Major-versioned config files are used when targetting *-apple-darwin* +// +// RUN: mkdir -p %t/testbin +// RUN: ln -s %clang %t/testbin/x86_64-apple-darwin24.0.0-clang +// RUN: echo "-Werror" > %t/testbin/x86_64-apple-darwin24.cfg +// RUN: %t/testbin/x86_64-apple-darwin24.0.0-clang --config-system-dir= --config-user-dir= -c -no-canonical-prefixes -### %s 2>&1 | FileCheck %s -check-prefix CHECK-MAJOR-VERSIONED +// +// CHECK-MAJOR-VERSIONED: Configuration file: {{.*}}/testbin/x86_64-apple-darwin24.cfg +// CHECK-MAJOR-VERSIONED: -Werror + +//--- Unversioned config files are used when targetting *-apple-darwin* +// +// RUN: mkdir -p %t/testbin +// RUN: ln -s %clang %t/testbin/arm64-apple-darwin23.1.2-clang +// RUN: echo "-Werror" > %t/testbin/arm64-apple-darwin.cfg +// RUN: %t/testbin/arm64-apple-darwin23.1.2-clang --config-system-dir= --config-user-dir= -c -no-canonical-prefixes -### %s 2>&1 | FileCheck %s -check-prefix CHECK-UNVERSIONED +// +// CHECK-UNVERSIONED: Configuration file: {{.*}}/testbin/arm64-apple-darwin.cfg +// CHECK-UNVERSIONED: -Werror ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang][Driver] Improve config file handling on Darwin (PR #111306)
carlocab wrote: > ⚠️ We detected that you are using a GitHub private e-mail address to > contribute to the repo. Please turn off [Keep my email addresses > private](https://github.com/settings/emails) setting in your account. See > [LLVM > Discourse](https://discourse.llvm.org/t/hidden-emails-on-github-should-we-do-something-about-it) > for more information. This seems to be based on the commit author rather than my actual GitHub configuration. See also https://github.com/llvm/llvm-project/pull/110962#issuecomment-2392834897 https://github.com/llvm/llvm-project/pull/111306 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang][Driver] Improve config file handling on Darwin (PR #111306)
carlocab wrote: #111387 is a better approach to this. https://github.com/llvm/llvm-project/pull/111306 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang][Driver] Improve config file handling on Darwin (PR #111306)
https://github.com/carlocab closed https://github.com/llvm/llvm-project/pull/111306 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Darwin][Driver][clang] Prioritise `-isysroot` over `--sysroot` consistently (PR #115993)
https://github.com/carlocab created https://github.com/llvm/llvm-project/pull/115993 On Darwin, `clang` currently prioritises `-isysroot` over `--sysroot` when selecting headers, but does the reverse when setting `-syslibroot` for the linker, which determines library selection. This is wrong, because it leads to using headers that are of different versions from the libraries being linked. We can see this from: ❯ bin/clang -v -xc - -o /dev/null \ -isysroot /Applications/Xcode-14.3.1.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.sdk \ --sysroot=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.sdk <<<'int main(){}' clang version 20.0.0git (https://github.com/llvm/llvm-project.git 3de5dbb1110887d5127e815f3ca247a9d839ee85) Target: arm64-apple-darwin24.1.0 [snip] #include "..." search starts here: #include <...> search starts here: /Users/carlocab/github/llvm-project/build-clang-config/lib/clang/20/include /Applications/Xcode-14.3.1.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.sdk/usr/include /Applications/Xcode-14.3.1.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.sdk/System/Library/Frameworks (framework directory) End of search list. "/usr/bin/ld" -demangle -lto_library /Users/carlocab/github/llvm-project/build-clang-config/lib/libLTO.dylib -no_deduplicate -dynamic -arch arm64 -platform_version macos 13.3.0 13.3 -syslibroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.sdk -mllvm -enable-linkonceodr-outlining -o /dev/null /var/folders/nj/9vfk4f0n377605jhxxmngd8hgn/T/--b914c6.o -lSystem We can fix this by reversing the order in which the `-syslibroot` flag is determined. Downstream bug report: https://github.com/Homebrew/homebrew-core/issues/197277 Co-authored-by: Bo Anderson >From d35918e23eaf15f4068e32f8c9b971bd556eb37a Mon Sep 17 00:00:00 2001 From: Carlo Cabrera Date: Wed, 13 Nov 2024 13:09:59 +0800 Subject: [PATCH] [Darwin][Driver][clang] Prioritise `-isysroot` over `--sysroot` consistently MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit On Darwin, `clang` currently prioritises `-isysroot` over `--sysroot` when selecting headers, but does the reverse when setting `-syslibroot` for the linker, which determines library selection. This is wrong, because it leads to using headers that are of different versions from the libraries being linked. We can see this from: ❯ bin/clang -v -xc - -o /dev/null \ -isysroot /Applications/Xcode-14.3.1.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.sdk \ --sysroot=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.sdk <<<'int main(){}' clang version 20.0.0git (https://github.com/llvm/llvm-project.git 3de5dbb1110887d5127e815f3ca247a9d839ee85) Target: arm64-apple-darwin24.1.0 [snip] #include "..." search starts here: #include <...> search starts here: /Users/carlocab/github/llvm-project/build-clang-config/lib/clang/20/include /Applications/Xcode-14.3.1.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.sdk/usr/include /Applications/Xcode-14.3.1.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.sdk/System/Library/Frameworks (framework directory) End of search list. "/usr/bin/ld" -demangle -lto_library /Users/carlocab/github/llvm-project/build-clang-config/lib/libLTO.dylib -no_deduplicate -dynamic -arch arm64 -platform_version macos 13.3.0 13.3 -syslibroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.sdk -mllvm -enable-linkonceodr-outlining -o /dev/null /var/folders/nj/9vfk4f0n377605jhxxmngd8hgn/T/--b914c6.o -lSystem We can fix this by reversing the order in which the `-syslibroot` flag is determined. Downstream bug report: https://github.com/Homebrew/homebrew-core/issues/197277 Co-authored-by: Bo Anderson --- clang/lib/Driver/ToolChains/Darwin.cpp | 13 ++--- clang/test/Driver/sysroot.c| 4 ++-- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/clang/lib/Driver/ToolChains/Darwin.cpp b/clang/lib/Driver/ToolChains/Darwin.cpp index 87380869f6fdab..8bb239d8d3f9df 100644 --- a/clang/lib/Driver/ToolChains/Darwin.cpp +++ b/clang/lib/Driver/ToolChains/Darwin.cpp @@ -428,15 +428,14 @@ void darwin::Linker::AddLinkArgs(Compilation &C, const ArgList &Args, Args.AddAllArgs(CmdArgs, options::OPT_sub__library); Args.AddAllArgs(CmdArgs, options::OPT_sub__umbrella); - // Give --sysroot= preference, over the Apple specific behavior to also use - // --isysroot as the syslibroot. - StringRef sysroot = C.getSysRoot(); - if (sysroot != "") { -CmdArgs.push_back("-syslibroot"); -CmdArgs.push_back(
[clang] [Clang][Driver] Support relative paths for CLANG_CONFIG_FILE_SYSTEM_DIR (PR #110962)
https://github.com/carlocab created https://github.com/llvm/llvm-project/pull/110962 Shipping a system configuration file for Clang is useful, but it limits the relocatability of the toolchain because it bakes in a reference to an absolute path on the file system. Let's fix that by allowing for `CLANG_CONFIG_FILE_SYSTEM_DIR` to be set to a relative path, and then interpreting that relative to the location of the driver if applicable. This would be useful for the LLVM package we ship at Homebrew. We currently have to bake in a `DEFAULT_SYSROOT` in order to ship a toolchain that works out of the box on macOS. If `CLANG_CONFIG_FILE_SYSTEM_DIR` supported relative paths, we could replace that with a configuration file which would be easier to update when the compiled-in `DEFAULT_SYSROOT` becomes stale (e.g. on macOS version upgrades). We could, of course, set `CLANG_CONFIG_FILE_SYSTEM_DIR` to an absolute path to begin with. However, we do have users who install Homebrew into a prefix that is different from the one used on our buildbots, so doing this would result in a broken toolchain for those users. >From 775a54f42b673ab9d3e6e86f73848dec75795d4b Mon Sep 17 00:00:00 2001 From: Carlo Cabrera Date: Thu, 3 Oct 2024 14:15:07 +0800 Subject: [PATCH] [Clang][Driver] Support relative paths for CLANG_CONFIG_FILE_SYSTEM_DIR Shipping a system configuration file for Clang is useful, but it limits the relocatability of the toolchain because it bakes in a reference to an absolute path on the file system. Let's fix that by allowing for `CLANG_CONFIG_FILE_SYSTEM_DIR` to be set to a relative path, and then interpreting that relative to the location of the driver if applicable. This would be useful for the LLVM package we ship at Homebrew. We currently have to bake in a `DEFAULT_SYSROOT` in order to ship a toolchain that works out of the box on macOS. If `CLANG_CONFIG_FILE_SYSTEM_DIR` supported relative paths, we could replace that with a configuration file which would be easier to update when the compiled-in `DEFAULT_SYSROOT` becomes stale (e.g. on macOS version upgrades). We could, of course, set `CLANG_CONFIG_FILE_SYSTEM_DIR` to an absolute path to begin with. However, we do have users who install Homebrew into a prefix that is different from the one used on our buildbots, so doing this would result in a broken toolchain for those users. --- clang/lib/Driver/Driver.cpp | 11 ++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp index 10d72be2c3d658..aaedfbc31579b7 100644 --- a/clang/lib/Driver/Driver.cpp +++ b/clang/lib/Driver/Driver.cpp @@ -229,7 +229,16 @@ Driver::Driver(StringRef ClangExecutable, StringRef TargetTriple, } #if defined(CLANG_CONFIG_FILE_SYSTEM_DIR) - SystemConfigDir = CLANG_CONFIG_FILE_SYSTEM_DIR; + { +if (llvm::sys::path::is_absolute(CLANG_CONFIG_FILE_SYSTEM_DIR)) { + SystemConfigDir = CLANG_CONFIG_FILE_SYSTEM_DIR; +} else { + SmallString<128> configFileDir(Dir); + llvm::sys::path::append(configFileDir, CLANG_CONFIG_FILE_SYSTEM_DIR); + llvm::sys::path::remove_dots(configFileDir, true); + SystemConfigDir = static_cast(configFileDir); +} + } #endif #if defined(CLANG_CONFIG_FILE_USER_DIR) { ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang][Driver] Support relative paths for CLANG_CONFIG_FILE_SYSTEM_DIR (PR #110962)
carlocab wrote: Thanks, done! I thought that was preferred given the handling of `CLANG_CONFIG_FILE_USER_DIR` below it. https://github.com/llvm/llvm-project/pull/110962 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang][Driver] Support relative paths for CLANG_CONFIG_FILE_SYSTEM_DIR (PR #110962)
https://github.com/carlocab updated https://github.com/llvm/llvm-project/pull/110962 >From e31545f666eb4ca32030956a38dbc4078a64068c Mon Sep 17 00:00:00 2001 From: Carlo Cabrera Date: Thu, 3 Oct 2024 14:15:07 +0800 Subject: [PATCH] [Clang][Driver] Support relative paths for CLANG_CONFIG_FILE_SYSTEM_DIR Shipping a system configuration file for Clang is useful, but it limits the relocatability of the toolchain because it bakes in a reference to an absolute path on the file system. Let's fix that by allowing for `CLANG_CONFIG_FILE_SYSTEM_DIR` to be set to a relative path, and then interpreting that relative to the location of the driver if applicable. This would be useful for the LLVM package we ship at Homebrew. We currently have to bake in a `DEFAULT_SYSROOT` in order to ship a toolchain that works out of the box on macOS. If `CLANG_CONFIG_FILE_SYSTEM_DIR` supported relative paths, we could replace that with a configuration file which would be easier to update when the compiled-in `DEFAULT_SYSROOT` becomes stale (e.g. on macOS version upgrades). We could, of course, set `CLANG_CONFIG_FILE_SYSTEM_DIR` to an absolute path to begin with. However, we do have users who install Homebrew into a prefix that is different from the one used on our buildbots, so doing this would result in a broken toolchain for those users. --- clang/lib/Driver/Driver.cpp | 9 - 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp index 10d72be2c3d658..e9bf60d5e2ee46 100644 --- a/clang/lib/Driver/Driver.cpp +++ b/clang/lib/Driver/Driver.cpp @@ -229,7 +229,14 @@ Driver::Driver(StringRef ClangExecutable, StringRef TargetTriple, } #if defined(CLANG_CONFIG_FILE_SYSTEM_DIR) - SystemConfigDir = CLANG_CONFIG_FILE_SYSTEM_DIR; + if (llvm::sys::path::is_absolute(CLANG_CONFIG_FILE_SYSTEM_DIR)) { +SystemConfigDir = CLANG_CONFIG_FILE_SYSTEM_DIR; + } else { +SmallString<128> configFileDir(Dir); +llvm::sys::path::append(configFileDir, CLANG_CONFIG_FILE_SYSTEM_DIR); +llvm::sys::path::remove_dots(configFileDir, true); +SystemConfigDir = static_cast(configFileDir); + } #endif #if defined(CLANG_CONFIG_FILE_USER_DIR) { ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Darwin][Driver][clang] Prioritise `-isysroot` over `--sysroot` consistently (PR #115993)
carlocab wrote: > However, notably, even on Darwin, if you pass _both_ flags, you still get the > intended behavior of `-isysroot` affecting headers, and `--sysroot` affecting > libraries. Your change would break that. What's the use-case for this? Because for most users, you almost certainly don't want to mix headers and libraries of different versions, and keeping the existing behavior is essentially a big footgun when trying to build a useful toolchain on Darwin. At Homebrew, we used to configure the toolchain with `DEFAULT_SYSROOT` but have recently switched that to setting the `--sysroot` flag in a Clang `.cfg` file.[^1] In either case, if you set `SDKROOT` in your environment or try to run our `clang` using Apple's `xcrun`, this becomes equivalent to setting `-isysroot` and you most likely will end up with headers that mismatch the libraries you try to link to. It seems to me that getting rid of a footgun that can impact many users (our toolchain is installed [a few hundred thousand times a year](https://formulae.brew.sh/formula/llvm#default), see also the [downstream bug report](https://github.com/Homebrew/homebrew-core/issues/197277) I initially linked) might be worth breaking what currently seems to be a niche use-case of using headers and libraries of different versions. If you really wanted to do this, you can set `-Wl,-syslibroot`. Of course, I'm open to alternatives that don't involve breaking anyone. [^1]: We do this so that the toolchain can find the sysroot out of the box, when it wouldn't be able to otherwise. https://github.com/llvm/llvm-project/pull/115993 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Darwin][Driver][clang] Prioritise `-isysroot` over `--sysroot` consistently (PR #115993)
carlocab wrote: Ping? https://github.com/llvm/llvm-project/pull/115993 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Darwin][Driver][clang] Prioritise command line args over `DEFAULT_SYSROOT` (PR #115993)
https://github.com/carlocab edited https://github.com/llvm/llvm-project/pull/115993 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Darwin][Driver][clang] Prioritise `-isysroot` over `--sysroot` consistently (PR #115993)
https://github.com/carlocab updated https://github.com/llvm/llvm-project/pull/115993 >From e257a7924d15e3f19fe483ea81d792feb4644874 Mon Sep 17 00:00:00 2001 From: Carlo Cabrera Date: Wed, 13 Nov 2024 13:09:59 +0800 Subject: [PATCH] [Darwin][Driver][clang] Prioritise command line flags over `DEFAULT_SYSROOT` If a toolchain is configured with `DEFAULT_SYSROOT`, then this could result in an unintended value for `-syslibroot` being passed to the linker if the user manually sets `-isysroot` or `SDKROOT`. Let's fix this by prioritising command line flags when determining `-syslibroot` before checking `getSysRoot`. Downstream bug report: https://github.com/Homebrew/homebrew-core/issues/197277 Co-authored-by: Bo Anderson --- clang/lib/Driver/ToolChains/Darwin.cpp | 10 +++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/clang/lib/Driver/ToolChains/Darwin.cpp b/clang/lib/Driver/ToolChains/Darwin.cpp index 87380869f6fdab..cdb6d21a0148b6 100644 --- a/clang/lib/Driver/ToolChains/Darwin.cpp +++ b/clang/lib/Driver/ToolChains/Darwin.cpp @@ -430,13 +430,17 @@ void darwin::Linker::AddLinkArgs(Compilation &C, const ArgList &Args, // Give --sysroot= preference, over the Apple specific behavior to also use // --isysroot as the syslibroot. - StringRef sysroot = C.getSysRoot(); - if (sysroot != "") { + // We check `OPT__sysroot_EQ` directly instead of `getSysRoot` to make sure we + // prioritise command line arguments over configuration of `DEFAULT_SYSROOT`. + if (const Arg *A = Args.getLastArg(options::OPT__sysroot_EQ)) { CmdArgs.push_back("-syslibroot"); -CmdArgs.push_back(C.getArgs().MakeArgString(sysroot)); +CmdArgs.push_back(A->getValue()); } else if (const Arg *A = Args.getLastArg(options::OPT_isysroot)) { CmdArgs.push_back("-syslibroot"); CmdArgs.push_back(A->getValue()); + } else if (StringRef sysroot = C.getSysRoot(); sysroot != "") { +CmdArgs.push_back("-syslibroot"); +CmdArgs.push_back(C.getArgs().MakeArgString(sysroot)); } Args.AddLastArg(CmdArgs, options::OPT_twolevel__namespace); ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Darwin][Driver][clang] Prioritise command line args over `DEFAULT_SYSROOT` (PR #115993)
carlocab wrote: > Maybe instead, the logic in the patch should be setting `-syslibroot` for > linker in following order: > > * `--sysroot` > * `-isysroot` > * `C.getSysRoot()`, which is basically DEFAULT_SYSROOT as other cases is > handled in `--sysroot` Thanks, pushed a change that I think should implement this. Haven't gotten around to testing it yet, I will this afternoon. https://github.com/llvm/llvm-project/pull/115993 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] Make the `CHECK` lines here resistent to `chandlerc` (PR #118736)
https://github.com/carlocab approved this pull request. https://github.com/llvm/llvm-project/pull/118736 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [flang] [clang][driver] Special care for linker flags in config files (PR #117573)
https://github.com/carlocab edited https://github.com/llvm/llvm-project/pull/117573 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [flang] [clang][driver] Special care for linker flags in config files (PR #117573)
@@ -82,3 +82,29 @@ // CHECK-TWO-CONFIGS: -isysroot // CHECK-TWO-CONFIGS-SAME: /opt/data // CHECK-TWO-CONFIGS-SAME: -Wall + +//--- The linker input flags should be moved to the end of input list and appear only when linking. +// RUN: %clang --target=aarch64-unknown-linux-gnu --config %S/Inputs/config-l.cfg %s -lmylib -Wl,foo.a -### 2>&1 | FileCheck %s -check-prefix CHECK-LINKING +// RUN: %clang --target=aarch64-unknown-linux-gnu --config %S/Inputs/config-l.cfg -fopenmp %s -lmylib -Wl,foo.a -### 2>&1 | FileCheck %s -check-prefix CHECK-LINKING-LIBOMP-GOES-LAST +// RUN: %clang --target=aarch64-unknown-linux-gnu --config %S/Inputs/config-l.cfg -S %s -### 2>&1 | FileCheck %s -check-prefix CHECK-NOLINKING +// RUN: %clang --target=aarch64-unknown-linux-gnu --config %S/Inputs/config-l.cfg -fopenmp -S %s -### 2>&1 | FileCheck %s -check-prefix CHECK-NOLINKING-OPENMP +// RUN: %clang --target=x86_64-pc-windows-msvc--config %S/Inputs/config-l.cfg %s -lmylib -Wl,foo.lib -### 2>&1 | FileCheck %s -check-prefix CHECK-LINKING-MSVC +// RUN: %clang --target=x86_64-pc-windows-msvc--config %S/Inputs/config-l.cfg -S %s -### 2>&1 | FileCheck %s -check-prefix CHECK-NOLINKING-MSVC +// CHECK-LINKING: Configuration file: {{.*}}Inputs{{.}}config-l.cfg +// CHECK-LINKING: "-Wall" +// CHECK-LINKING: "--as-needed" "{{.*}}-{{.*}}.o" "-lmylib" "foo.a" "-lm" "-Bstatic" "-lhappy" "-Bdynamic" +// CHECK-LINKING-LIBOMP-GOES-LAST: Configuration file: {{.*}}Inputs{{.}}config-l.cfg +// CHECK-LINKING-LIBOMP-GOES-LAST: "-Wall" {{.*}}"-fopenmp" carlocab wrote: Don't need an anchor (i.e. something like `{{$}}`) to ensure that `-fopenmp` actually does come last? Or have I misunderstood the intent of this assertion? https://github.com/llvm/llvm-project/pull/117573 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [flang] [clang][driver] Special care for linker flags in config files (PR #117573)
https://github.com/carlocab edited https://github.com/llvm/llvm-project/pull/117573 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][docs] fix rendering of `$`-prefixed options (PR #119249)
carlocab wrote: No worries, I missed it too. For future reference, it might be useful to check the rich diff too: https://github.com/user-attachments/assets/003082f8-1135-4be2-996a-2cde6691f61a";> https://github.com/llvm/llvm-project/pull/119249 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][docs] fix rendering of `$`-prefixed options (PR #119249)
https://github.com/carlocab closed https://github.com/llvm/llvm-project/pull/119249 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Darwin][Driver][clang] Prioritise command line args over `DEFAULT_SYSROOT` (PR #115993)
https://github.com/carlocab updated https://github.com/llvm/llvm-project/pull/115993 >From b072008a5b1a3bd697e3f9efc091bcddfbcc3547 Mon Sep 17 00:00:00 2001 From: Carlo Cabrera Date: Wed, 13 Nov 2024 13:09:59 +0800 Subject: [PATCH] [Darwin][Driver][clang] Prioritise command line flags over `DEFAULT_SYSROOT` If a toolchain is configured with `DEFAULT_SYSROOT`, then this could result in an unintended value for `-syslibroot` being passed to the linker if the user manually sets `-isysroot` or `SDKROOT`. Let's fix this by prioritising command line flags when determining `-syslibroot` before checking `getSysRoot`. Downstream bug report: https://github.com/Homebrew/homebrew-core/issues/197277 Co-authored-by: Bo Anderson --- clang/lib/Driver/ToolChains/Darwin.cpp | 10 +++--- clang/test/Driver/sysroot.c| 3 +-- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/clang/lib/Driver/ToolChains/Darwin.cpp b/clang/lib/Driver/ToolChains/Darwin.cpp index 87380869f6fdab..cdb6d21a0148b6 100644 --- a/clang/lib/Driver/ToolChains/Darwin.cpp +++ b/clang/lib/Driver/ToolChains/Darwin.cpp @@ -430,13 +430,17 @@ void darwin::Linker::AddLinkArgs(Compilation &C, const ArgList &Args, // Give --sysroot= preference, over the Apple specific behavior to also use // --isysroot as the syslibroot. - StringRef sysroot = C.getSysRoot(); - if (sysroot != "") { + // We check `OPT__sysroot_EQ` directly instead of `getSysRoot` to make sure we + // prioritise command line arguments over configuration of `DEFAULT_SYSROOT`. + if (const Arg *A = Args.getLastArg(options::OPT__sysroot_EQ)) { CmdArgs.push_back("-syslibroot"); -CmdArgs.push_back(C.getArgs().MakeArgString(sysroot)); +CmdArgs.push_back(A->getValue()); } else if (const Arg *A = Args.getLastArg(options::OPT_isysroot)) { CmdArgs.push_back("-syslibroot"); CmdArgs.push_back(A->getValue()); + } else if (StringRef sysroot = C.getSysRoot(); sysroot != "") { +CmdArgs.push_back("-syslibroot"); +CmdArgs.push_back(C.getArgs().MakeArgString(sysroot)); } Args.AddLastArg(CmdArgs, options::OPT_twolevel__namespace); diff --git a/clang/test/Driver/sysroot.c b/clang/test/Driver/sysroot.c index 85da2499090af1..3080f76e031686 100644 --- a/clang/test/Driver/sysroot.c +++ b/clang/test/Driver/sysroot.c @@ -4,10 +4,9 @@ // CHECK-SYSROOTEQ: "-cc1"{{.*}} "-isysroot" "{{[^"]*}}/FOO" // Apple Darwin uses -isysroot as the syslib root, too. -// We pass --sysroot="" to defeat any -DDEFAULT_SYSROOT parameter. // RUN: touch %t2.o // RUN: %clang -target i386-apple-darwin10 \ -// RUN: -isysroot /FOO --sysroot="" -### %t2.o 2> %t2 +// RUN: -isysroot /FOO -### %t2.o 2> %t2 // RUN: FileCheck --check-prefix=CHECK-APPLE-ISYSROOT < %t2 %s // CHECK-APPLE-ISYSROOT: "-arch" "i386"{{.*}} "-syslibroot" "{{[^"]*}}/FOO" ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Darwin][Driver][clang] Prioritise command line args over `DEFAULT_SYSROOT` (PR #115993)
carlocab wrote: Dropped the `--sysroot=""` flag from the test. > Changing the test itself (to e.g. locally set that env var) is a good > regression test that should be added for this pr anyway. Sorry, which env var are you referring to? https://github.com/llvm/llvm-project/pull/115993 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][docs] fix rendering of `$`-prefixed options (PR #119249)
https://github.com/carlocab created https://github.com/llvm/llvm-project/pull/119249 This was added in #117573 but the options were not being rendered correctly due to the missing newline after `::`. >From ed70bf358357a5b54599db4a89e61588fd96aca7 Mon Sep 17 00:00:00 2001 From: Carlo Cabrera Date: Tue, 10 Dec 2024 03:09:11 +0800 Subject: [PATCH] [clang][docs] fix rendering of `$`-prefixed options This was added in #117573 but the options were not being rendered correctly due to the missing newline after `::`. --- clang/docs/UsersManual.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/clang/docs/UsersManual.rst b/clang/docs/UsersManual.rst index 5b7a293a4ecc27..8af9f5be644a02 100644 --- a/clang/docs/UsersManual.rst +++ b/clang/docs/UsersManual.rst @@ -1066,6 +1066,7 @@ is being invoked, and added after all of the command-line specified linker inputs. Here is some example of ``$``-prefixed options: :: + $-Wl,-Bstatic $-lm $-Wl,-Bshared ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] Add -fuse-lipo option (PR #121231)
https://github.com/carlocab edited https://github.com/llvm/llvm-project/pull/121231 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] Add -fuse-lipo option (PR #121231)
https://github.com/carlocab commented: Thanks for the PR! This change needs new tests to be added. https://github.com/llvm/llvm-project/pull/121231 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] Add -fuse-lipo option (PR #121231)
@@ -910,7 +910,10 @@ void darwin::Lipo::ConstructJob(Compilation &C, const JobAction &JA, CmdArgs.push_back(II.getFilename()); } - const char *Exec = Args.MakeArgString(getToolChain().GetProgramPath("lipo")); + std::string LipoName = + std::string(Args.getLastArgValue(options::OPT_fuse_lipo_EQ, "lipo")); + const char *Exec = + Args.MakeArgString(getToolChain().GetProgramPath(LipoName.c_str())); carlocab wrote: Seems a bit much to create a throwaway `std::string` here. Something like this should work: ```suggestion StringRef LipoName = Args.getLastArgValue(options::OPT_fuse_lipo_EQ, "lipo"); const char *Exec = Args.MakeArgString(getToolChain().GetProgramPath(LipoName.data())); ``` https://github.com/llvm/llvm-project/pull/121231 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] add llvm abi support (PR #121123)
carlocab wrote: > Introducing a target triple has large ecosystem implication and should not be > taken lightly. To be fair this patch doesn't introduce a target triple, it only makes it more easily usable in Clang. That said, I tend to agree with the review at https://github.com/llvm/llvm-project/pull/121123#discussion_r1900548165 that this doesn't seem like the right approach. https://github.com/llvm/llvm-project/pull/121123 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [Darwin][Driver][clang] apple-none-macho orders the resource directory after internal-externc-isystem when nostdlibinc is used (PR #122035)
carlocab wrote: > LLVM Buildbot has detected a new failure on builder `fuchsia-x86_64-linux` > running on `fuchsia-debian-64-us-central1-a-1` while building `clang,llvm` at > step 4 "annotate". > > Full details are available at: > https://lab.llvm.org/buildbot/#/builders/11/builds/10651 > > > Here is the relevant piece of the build log for the > reference > > ``` > Step 4 (annotate) failure: 'python > ../llvm-zorg/zorg/buildbot/builders/annotated/fuchsia-linux.py ...' (failure) > ... > [1015/1367] Linking CXX executable > unittests/DebugInfo/DWARF/DebugInfoDWARFTests > [1016/1367] Running the Clang regression tests > llvm-lit: > /var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/llvm/utils/lit/lit/llvm/config.py:506: > note: using clang: > /var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-it8eyuar/bin/clang > llvm-lit: > /var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/llvm/utils/lit/lit/llvm/subst.py:126: > note: Did not find clang-repl in > /var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-it8eyuar/bin:/var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-it8eyuar/bin > llvm-lit: > /var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/llvm/utils/lit/lit/llvm/config.py:506: > note: using ld.lld: > /var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-it8eyuar/bin/ld.lld > llvm-lit: > /var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/llvm/utils/lit/lit/llvm/config.py:506: > note: using lld-link: > /var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-it8eyuar/bin/lld-link > llvm-lit: > /var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/llvm/utils/lit/lit/llvm/config.py:506: > note: using ld64.lld: > /var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-it8eyuar/bin/ld64.lld > llvm-lit: > /var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/llvm/utils/lit/lit/llvm/config.py:506: > note: using wasm-ld: > /var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-it8eyuar/bin/wasm-ld > -- Testing: 21766 tests, 60 workers -- > Testing: 0.. 10.. 20.. 30.. 40.. > FAIL: Clang :: Driver/darwin-embedded-search-paths.c (10801 of 21766) > TEST 'Clang :: Driver/darwin-embedded-search-paths.c' > FAILED > Exit Code: 1 > > Command Output (stderr): > -- > RUN: at line 6: > /var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-it8eyuar/bin/clang -x > c -target arm64-apple-none-macho -isysroot > /var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/clang/test/Driver/Inputs/MacOSX15.1.sdk > -### -c > /var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/clang/test/Driver/darwin-embedded-search-paths.c > 2>&1 | > /var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-it8eyuar/bin/FileCheck > --check-prefixes=CC1,NO-CXX,ULI,CI,UI,NO-FW > -DSDKROOT=/var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/clang/test/Driver/Inputs/MacOSX15.1.sdk > > /var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/clang/test/Driver/darwin-embedded-search-paths.c > + > /var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-it8eyuar/bin/FileCheck > --check-prefixes=CC1,NO-CXX,ULI,CI,UI,NO-FW > -DSDKROOT=/var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/clang/test/Driver/Inputs/MacOSX15.1.sdk > > /var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/clang/test/Driver/darwin-embedded-search-paths.c > + /var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-it8eyuar/bin/clang > -x c -target arm64-apple-none-macho -isysroot > /var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/clang/test/Driver/Inputs/MacOSX15.1.sdk > -### -c > /var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/clang/test/Driver/darwin-embedded-search-paths.c > RUN: at line 10: > /var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-it8eyuar/bin/clang -x > c++ -target arm64-apple-none-macho -isysroot > /var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/clang/test/Driver/Inputs/MacOSX15.1.sdk > -### -c > /var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/clang/test/Driver/darwin-embedded-search-paths.c > 2>&1 | > /var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-it8eyuar/bin/FileCheck > --check-prefixes=CC1,NO-CXX,ULI,CI,UI,NO-FW > -DSDKROOT=/var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/clang/test/Driver/Inputs/MacOSX15.1.sdk > > /var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/clang/test/Driver/darwin-embedded-search-paths.c > + > /var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-it8eyuar/bin/FileCheck > --check-prefixes=CC1,NO-CXX,ULI,CI,UI,NO-FW > -DSDKROOT=/var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/clang/test/Driver/Inputs/MacOSX15.1.sdk > > /var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/clang/test/Driver/darwin-embedded-search-paths.c > + /var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-it8eyuar/bin/clang > -x c++ -target arm64-apple-none-macho -isysroot > /var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/clang/test/Driver/Inputs/MacOSX15.1.sdk > -### -c > /var/lib/buildbot/fuchsia-x86_64-linux/llvm
[clang] Reapply "[nfc][Driver] Remove {{(.exe)?}} from sanitizer test (#121160)" (PR #121162)
carlocab wrote: I don't really understand why this is needed either. Should we revert? https://github.com/llvm/llvm-project/pull/121162 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] add llvm abi support (PR #121123)
https://github.com/carlocab commented: Needs tests. https://github.com/llvm/llvm-project/pull/121123 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [nfc][Driver] Remove {{(.exe)?}} from sanitizer test (PR #121160)
@@ -8,7 +8,7 @@ // RUN: --sysroot=%S/Inputs/basic_linux_tree \ // RUN: | %{filecheck} --check-prefix=CHECK-ASAN-LINUX // -// CHECK-ASAN-LINUX: "{{(.*[^-.0-9A-Z_a-z])?}}ld{{(.exe)?}}" +// CHECK-ASAN-LINUX: "{{(.*[^-.0-9A-Z_a-z])?}}ld" carlocab wrote: Is this not needed if you are running this test on Windows? https://github.com/llvm/llvm-project/pull/121160 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Darwin][Driver][clang] Prioritise command line args over `DEFAULT_SYSROOT` (PR #115993)
carlocab wrote: > > Sorry, which env var are you referring to? > > I'm suggesting an explicit test case that checks that `DEFAULT_SYSROOT` is > set and behaves as expected. It's ignored if sysroot or isysroot is passed, > it's used when they're missing. `DEFAULT_SYSROOT` is not an environment variable. It is a CMake variable/macro that must be set at configure-time: https://github.com/llvm/llvm-project/blob/aac000a01ba8c0ed15fec3c198fce9f13fc83725/clang/CMakeLists.txt#L208-L209 https://github.com/llvm/llvm-project/blob/aac000a01ba8c0ed15fec3c198fce9f13fc83725/clang/include/clang/Config/config.h.cmake#L48-L49 I don't think `lit` knows how to tell whether `DEFAULT_SYSROOT` is set. We could maybe teach it to, but given that that intent of #94284 is to deprecate it (and I think all usage of it in existing builders has been removed), that seems like the wrong direction. https://github.com/llvm/llvm-project/pull/115993 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Darwin][Driver][clang] Prioritise command line args over `DEFAULT_SYSROOT` (PR #115993)
https://github.com/carlocab edited https://github.com/llvm/llvm-project/pull/115993 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Darwin][Driver][clang] Prioritise command line args over `DEFAULT_SYSROOT` (PR #115993)
carlocab wrote: > The PR description (first comment), which will be used as the default commit > message, should be fixed. Thanks for the reminder, fixed. I plan to do a few more local tests with `DEFAULT_SYSROOT` enabled before merging (since this isn't tested in CI). https://github.com/llvm/llvm-project/pull/115993 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Darwin][Driver][clang] Prioritise command line args over `DEFAULT_SYSROOT` (PR #115993)
carlocab wrote: Tested locally; seems to be working as intended. https://github.com/llvm/llvm-project/pull/115993 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Darwin][Driver][clang] Prioritise command line args over `DEFAULT_SYSROOT` (PR #115993)
https://github.com/carlocab closed https://github.com/llvm/llvm-project/pull/115993 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][Driver][Darwin] Optionally use xcselect to find macOS SDK (PR #119670)
https://github.com/carlocab created https://github.com/llvm/llvm-project/pull/119670 This is a scaled down version of https://reviews.llvm.org/D136315. The intent is largely the same as before[^1], but I've scaled down the scope to try to avoid the issues that the previous patch caused: - the changes are now opt-in based on enabling `CLANG_USE_XCSELECT` - this only works when targeting macOS on a macOS host (this is the only case supported by `libxcselect`[^2]) We also introduce an environment variable `CLANG_NO_XCSELECT` that disables this behaviour if Clang is configured with `CLANG_USE_XCSELECT=ON`. This is needed to avoid breaking tests. Another reason to leave this as opt-in for now is that there are some bugs in libxcselect that need fixing before it is safe to use by default for all users. This has been reported to Apple as FB16081077. [^1]: See also https://reviews.llvm.org/D109460 and #45225. [^2]: https://developer.apple.com/documentation/xcselect?language=objc >From 9db768ec1be84d6bf647b85f052776720822f64f Mon Sep 17 00:00:00 2001 From: Carlo Cabrera Date: Tue, 10 Dec 2024 01:45:22 +0800 Subject: [PATCH] [clang][Driver][Darwin] Optionally use xcselect to find macOS SDK This is a scaled down version of https://reviews.llvm.org/D136315. The intent is largely the same as before[^1], but I've scaled down the scope to try to avoid the issues that the previous patch caused: - the changes are now opt-in based on enabling `CLANG_USE_XCSELECT` - this only works when targeting macOS on a macOS host (this is the only case supported by `libxcselect`[^2]) We also introduce an environment variable `CLANG_NO_XCSELECT` that disables this behaviour if Clang is configured with `CLANG_USE_XCSELECT=ON`. This is needed to avoid breaking tests. Another reason to leave this as opt-in for now is that there are some bugs in libxcselect that need fixing before it is safe to use by default for all users. This has been reported to Apple as FB16081077. [^1]: See also https://reviews.llvm.org/D109460 and #45225. [^2]: https://developer.apple.com/documentation/xcselect?language=objc --- clang/CMakeLists.txt | 33 +++ clang/include/clang/Config/config.h.cmake | 6 + clang/lib/Driver/CMakeLists.txt | 4 +++ clang/lib/Driver/ToolChains/Darwin.cpp| 31 ++--- clang/test/lit.cfg.py | 4 +++ 5 files changed, 69 insertions(+), 9 deletions(-) diff --git a/clang/CMakeLists.txt b/clang/CMakeLists.txt index 27e8095534a65c..3c7096a27c509b 100644 --- a/clang/CMakeLists.txt +++ b/clang/CMakeLists.txt @@ -214,6 +214,39 @@ if(GCC_INSTALL_PREFIX AND NOT USE_DEPRECATED_GCC_INSTALL_PREFIX) "See https://github.com/llvm/llvm-project/pull/77537 for detail.") endif() +if(APPLE) + check_include_file(xcselect.h CLANG_HAVE_XCSELECT_H) + if(CLANG_HAVE_XCSELECT_H) +include(CheckSymbolExists) +list(APPEND CMAKE_REQUIRED_LIBRARIES xcselect) +check_symbol_exists(xcselect_host_sdk_path xcselect.h CLANG_HAVE_XCSELECT_HOST_SDK_PATH) +list(REMOVE_ITEM CMAKE_REQUIRED_LIBRARIES xcselect) + endif() +endif() + +cmake_dependent_option(CLANG_USE_XCSELECT "Use libxcselect to find the macOS SDK." OFF + "APPLE;CLANG_HAVE_XCSELECT_HOST_SDK_PATH" OFF) + +if(DEFAULT_SYSROOT AND CLANG_USE_XCSELECT) + message(FATAL_ERROR "Setting DEFAULT_SYSROOT is incompatible with CLANG_USE_XCSELECT.") +endif() + +if(CLANG_USE_XCSELECT) + set(XCSELECT_VALID_POLICIES LATEST MATCHING_ONLY MATCHING_PREFERRED) + set(CLANG_XCSELECT_HOST_SDK_POLICY "LATEST" CACHE STRING +"Policy to use for xcselect. One of: ${XCSELECT_VALID_POLICIES}") + set_property(CACHE CLANG_XCSELECT_HOST_SDK_POLICY PROPERTY STRINGS ${XCSELECT_VALID_POLICIES}) + string(TOUPPER ${CLANG_XCSELECT_HOST_SDK_POLICY} CLANG_XCSELECT_HOST_SDK_POLICY) + list(JOIN XCSELECT_VALID_POLICIES "|" XCSELECT_POLICY_REGEX) + if(NOT CLANG_XCSELECT_HOST_SDK_POLICY MATCHES "^XCSELECT_HOST_SDK_POLICY_(${XCSELECT_POLICY_REGEX})$") +if(NOT CLANG_XCSELECT_HOST_SDK_POLICY IN_LIST XCSELECT_VALID_POLICIES) + message(FATAL_ERROR +"CLANG_XCSELECT_HOST_SDK_POLICY (${CLANG_XCSELECT_HOST_SDK_POLICY}) must be one of: ${XCSELECT_VALID_POLICIES}") +endif() +set(CLANG_XCSELECT_HOST_SDK_POLICY "XCSELECT_HOST_SDK_POLICY_${CLANG_XCSELECT_HOST_SDK_POLICY}") + endif() +endif() + set(ENABLE_LINKER_BUILD_ID OFF CACHE BOOL "pass --build-id to ld") set(ENABLE_X86_RELAX_RELOCATIONS ON CACHE BOOL diff --git a/clang/include/clang/Config/config.h.cmake b/clang/include/clang/Config/config.h.cmake index 27ed69e21562bf..9ae0c6a4b9e11d 100644 --- a/clang/include/clang/Config/config.h.cmake +++ b/clang/include/clang/Config/config.h.cmake @@ -86,4 +86,10 @@ /* Whether CIR is built into Clang */ #cmakedefine01 CLANG_ENABLE_CIR +/* Whether to use xcselect to find the macOS SDK */ +#cmakedefine CLANG_USE_XCSELECT + +/* Policy to use for xcselect */ +#cmakedefine CLANG_XCSELECT_HOST_
[clang] [clang][Driver][Darwin] Optionally use xcselect to find macOS SDK (PR #119670)
carlocab wrote: > We also introduce an environment variable `CLANG_NO_XCSELECT` that disables > this behaviour if Clang is configured with `CLANG_USE_XCSELECT=ON`. This is > needed to avoid breaking tests. It might also be nicer to set this only for the tests that break instead of globally. https://github.com/llvm/llvm-project/pull/119670 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][Driver] Fix triple config loading for clang-cl (PR #111397)
https://github.com/carlocab approved this pull request. Needs conflict resolution, but otherwise LGTM https://github.com/llvm/llvm-project/pull/111397 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][Driver] Support simplified triple versions for config files (PR #111387)
carlocab wrote: Merging this to land the improvement. Happy to work on suggested improvements for the tests if any are still outstanding from the discussion in https://github.com/llvm/llvm-project/pull/111387#discussion_r1873784293 (since it's not clear to me which comments still apply). CC @MaskRay https://github.com/llvm/llvm-project/pull/111387 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][Driver] Support simplified triple versions for config files (PR #111387)
https://github.com/carlocab closed https://github.com/llvm/llvm-project/pull/111387 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][Driver] Fix triple config loading for clang-cl (PR #111397)
carlocab wrote: > I didn't even realize people are using config files with clang-cl (since IIRC > it doesn't support the config file command-line options). You don't need to use config files with `clang-cl` to need this patch -- you need it if you use triple-based config files and also use `clang-cl`. The issue is that if you have, for example, a `x86_64-unknown-linux-gnu.cfg` in a location that `clang` loads by default, then this breaks `clang-cl` because running `clang-cl` also loads `x86_64-unknown-linux-gnu.cfg` (which will generically contain incompatible flags). https://github.com/llvm/llvm-project/pull/111397 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][Darwin] Remove legacy framework search path logic in the frontend (PR #120149)
@@ -0,0 +1,26 @@ +// UNSUPPORTED: system-windows +// Windows is unsupported because we use the Unix path separator `/` in the test. + +// Add default directories before running clang to check default +// search paths. +// RUN: rm -rf %t && mkdir -p %t +// RUN: cp -R %S/Inputs/MacOSX15.1.sdk %t/ +// RUN: mkdir -p %t/MacOSX15.1.sdk/System/Library/Frameworks +// RUN: mkdir -p %t/MacOSX15.1.sdk/System/Library/SubFrameworks +// RUN: mkdir -p %t/MacOSX15.1.sdk/usr/include + +// RUN: %clang -xc %s -target arm64-apple-darwin13.0 -isysroot %t/MacOSX15.1.sdk -E -v 2>&1 | FileCheck --check-prefix=CHECK-C %s carlocab wrote: Yea, this should probably be `arm64-apple-macosx15.1` (or, alternatively, `arm64-apple-macos15.1` or `arm64-apple-darwin24.2`) https://github.com/llvm/llvm-project/pull/120149 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][Driver][Darwin] Optionally use xcselect to find macOS SDK (PR #119670)
https://github.com/carlocab updated https://github.com/llvm/llvm-project/pull/119670 >From 9db768ec1be84d6bf647b85f052776720822f64f Mon Sep 17 00:00:00 2001 From: Carlo Cabrera Date: Tue, 10 Dec 2024 01:45:22 +0800 Subject: [PATCH 1/3] [clang][Driver][Darwin] Optionally use xcselect to find macOS SDK This is a scaled down version of https://reviews.llvm.org/D136315. The intent is largely the same as before[^1], but I've scaled down the scope to try to avoid the issues that the previous patch caused: - the changes are now opt-in based on enabling `CLANG_USE_XCSELECT` - this only works when targeting macOS on a macOS host (this is the only case supported by `libxcselect`[^2]) We also introduce an environment variable `CLANG_NO_XCSELECT` that disables this behaviour if Clang is configured with `CLANG_USE_XCSELECT=ON`. This is needed to avoid breaking tests. Another reason to leave this as opt-in for now is that there are some bugs in libxcselect that need fixing before it is safe to use by default for all users. This has been reported to Apple as FB16081077. [^1]: See also https://reviews.llvm.org/D109460 and #45225. [^2]: https://developer.apple.com/documentation/xcselect?language=objc --- clang/CMakeLists.txt | 33 +++ clang/include/clang/Config/config.h.cmake | 6 + clang/lib/Driver/CMakeLists.txt | 4 +++ clang/lib/Driver/ToolChains/Darwin.cpp| 31 ++--- clang/test/lit.cfg.py | 4 +++ 5 files changed, 69 insertions(+), 9 deletions(-) diff --git a/clang/CMakeLists.txt b/clang/CMakeLists.txt index 27e8095534a65c..3c7096a27c509b 100644 --- a/clang/CMakeLists.txt +++ b/clang/CMakeLists.txt @@ -214,6 +214,39 @@ if(GCC_INSTALL_PREFIX AND NOT USE_DEPRECATED_GCC_INSTALL_PREFIX) "See https://github.com/llvm/llvm-project/pull/77537 for detail.") endif() +if(APPLE) + check_include_file(xcselect.h CLANG_HAVE_XCSELECT_H) + if(CLANG_HAVE_XCSELECT_H) +include(CheckSymbolExists) +list(APPEND CMAKE_REQUIRED_LIBRARIES xcselect) +check_symbol_exists(xcselect_host_sdk_path xcselect.h CLANG_HAVE_XCSELECT_HOST_SDK_PATH) +list(REMOVE_ITEM CMAKE_REQUIRED_LIBRARIES xcselect) + endif() +endif() + +cmake_dependent_option(CLANG_USE_XCSELECT "Use libxcselect to find the macOS SDK." OFF + "APPLE;CLANG_HAVE_XCSELECT_HOST_SDK_PATH" OFF) + +if(DEFAULT_SYSROOT AND CLANG_USE_XCSELECT) + message(FATAL_ERROR "Setting DEFAULT_SYSROOT is incompatible with CLANG_USE_XCSELECT.") +endif() + +if(CLANG_USE_XCSELECT) + set(XCSELECT_VALID_POLICIES LATEST MATCHING_ONLY MATCHING_PREFERRED) + set(CLANG_XCSELECT_HOST_SDK_POLICY "LATEST" CACHE STRING +"Policy to use for xcselect. One of: ${XCSELECT_VALID_POLICIES}") + set_property(CACHE CLANG_XCSELECT_HOST_SDK_POLICY PROPERTY STRINGS ${XCSELECT_VALID_POLICIES}) + string(TOUPPER ${CLANG_XCSELECT_HOST_SDK_POLICY} CLANG_XCSELECT_HOST_SDK_POLICY) + list(JOIN XCSELECT_VALID_POLICIES "|" XCSELECT_POLICY_REGEX) + if(NOT CLANG_XCSELECT_HOST_SDK_POLICY MATCHES "^XCSELECT_HOST_SDK_POLICY_(${XCSELECT_POLICY_REGEX})$") +if(NOT CLANG_XCSELECT_HOST_SDK_POLICY IN_LIST XCSELECT_VALID_POLICIES) + message(FATAL_ERROR +"CLANG_XCSELECT_HOST_SDK_POLICY (${CLANG_XCSELECT_HOST_SDK_POLICY}) must be one of: ${XCSELECT_VALID_POLICIES}") +endif() +set(CLANG_XCSELECT_HOST_SDK_POLICY "XCSELECT_HOST_SDK_POLICY_${CLANG_XCSELECT_HOST_SDK_POLICY}") + endif() +endif() + set(ENABLE_LINKER_BUILD_ID OFF CACHE BOOL "pass --build-id to ld") set(ENABLE_X86_RELAX_RELOCATIONS ON CACHE BOOL diff --git a/clang/include/clang/Config/config.h.cmake b/clang/include/clang/Config/config.h.cmake index 27ed69e21562bf..9ae0c6a4b9e11d 100644 --- a/clang/include/clang/Config/config.h.cmake +++ b/clang/include/clang/Config/config.h.cmake @@ -86,4 +86,10 @@ /* Whether CIR is built into Clang */ #cmakedefine01 CLANG_ENABLE_CIR +/* Whether to use xcselect to find the macOS SDK */ +#cmakedefine CLANG_USE_XCSELECT + +/* Policy to use for xcselect */ +#cmakedefine CLANG_XCSELECT_HOST_SDK_POLICY ${CLANG_XCSELECT_HOST_SDK_POLICY} + #endif diff --git a/clang/lib/Driver/CMakeLists.txt b/clang/lib/Driver/CMakeLists.txt index 4fd10bf671512f..299de2ef30470c 100644 --- a/clang/lib/Driver/CMakeLists.txt +++ b/clang/lib/Driver/CMakeLists.txt @@ -14,6 +14,10 @@ if(WIN32) set(system_libs version) endif() +if(CLANG_USE_XCSELECT) + set(system_libs xcselect) +endif() + add_clang_library(clangDriver Action.cpp Compilation.cpp diff --git a/clang/lib/Driver/ToolChains/Darwin.cpp b/clang/lib/Driver/ToolChains/Darwin.cpp index 87380869f6fdab..8d3e0130a5a432 100644 --- a/clang/lib/Driver/ToolChains/Darwin.cpp +++ b/clang/lib/Driver/ToolChains/Darwin.cpp @@ -29,6 +29,10 @@ #include "llvm/TargetParser/Triple.h" #include // ::getenv +#ifdef CLANG_USE_XCSELECT +#include // ::xcselect_host_sdk_path +#endif + using namespace clang::driver; using namespace clang::driver::tools;
[clang] [clang][Driver][Darwin] Optionally use xcselect to find macOS SDK (PR #119670)
https://github.com/carlocab edited https://github.com/llvm/llvm-project/pull/119670 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][Driver][Darwin] Optionally use xcselect to find macOS SDK (PR #119670)
carlocab wrote: After excluding the `-darwin*` spelling from using `xcselect`, most of the failures go away, but one remains. I'll investigate it tomorrow. I've left it as `XFAIL` for now, since it seems to be the least bad option (compared to `CLANG_NO_XCSELECT` or `UNSUPPORTED`), given: > > I'm wondering if it's worth reviving the CLANG_NO_XCSELECT environment > > variable and then just setting them in these tests (and slowly getting rid > > of instances of CLANG_NO_XCSELECT as we find better fixes). > > The downside here is that when investigating running each command, it might > be confusing that the error is not reproducing unless an env is set. > > Alternative is just `UNSUPPORTED:` but that will reduce the coverage when > XCSELECT is configured. https://github.com/llvm/llvm-project/pull/119670 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][Driver][Darwin] Optionally use xcselect to find macOS SDK (PR #119670)
carlocab wrote: For reference, the failure from dropping `XFAIL` from `darwin-ld-platform-version-macos.c`: Failure Log ``` + /Users/carlocab/github/llvm-project/build-xcselect/bin/FileCheck --check-prefix=NOSDK /Users/carlocab/github/llvm-project/clang/test/Driver/darwin-ld-platform-version-macos.c /Users/carlocab/github/llvm-project/clang/test/Driver/darwin-ld-platform-version-macos.c:50:11: error: NOSDK: expected string not found in input // NOSDK: "-platform_version" "macos" "10.13.0" "10.13.0" ^ :1:1: note: scanning from here clang version 20.0.0git (https://github.com/carlocab/llvm-project.git dc195bd7668c09b7ec94abf771b618170cfd4b78) ^ :6:141: note: possible intended match here "/usr/bin/ld" "-demangle" "-lto_library" "/Users/carlocab/github/llvm-project/build-xcselect/lib/libLTO.dylib" "-dynamic" "-arch" "x86_64" "-platform_version" "macos" "10.13.0" "15.2" "-syslibroot" "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.2.sdk" "-mllvm" "-enable-linkonceodr-outlining" "-o" "a.out" "/Users/carlocab/github/llvm-project/build-xcselect/tools/clang/test/Driver/Output/darwin-ld-platform-version-macos.c.tmp.o" "-lSystem" "/Users/carlocab/github/llvm-project/build-xcselect/lib/clang/20/lib/darwin/libclang_rt.osx.a" ^ Input file: Check file: /Users/carlocab/github/llvm-project/clang/test/Driver/darwin-ld-platform-version-macos.c -dump-input=help explains the following input dump. Input was: << 1: clang version 20.0.0git (https://github.com/carlocab/llvm-project.git dc195bd7668c09b7ec94abf771b618170cfd4b78) check:50'0 X~~~ error: no match found 2: Target: x86_64-apple-macos10.13 check:50'0 3: Thread model: posix check:50'0 4: InstalledDir: /Users/carlocab/github/llvm-project/build-xcselect/bin check:50'0 ~ 5: Build config: +assertions check:50'0 ~~ 6: "/usr/bin/ld" "-demangle" "-lto_library" "/Users/carlocab/github/llvm-project/build-xcselect/lib/libLTO.dylib" "-dynamic" "-arch" "x86_64" "-platform_version" "macos" "10.13.0" "15.2" "-syslibroot" "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.2.sdk" "-mllvm" "-enable-linkonceodr-outlining" "-o" "a.out" "/Users/carlocab/github/llvm-project/build-xcselect/tools/clang/test/Driver/Output/darwin-ld-platform-version-macos.c.tmp.o" "-lSystem" "/Users/carlocab/github/llvm-project/build-xcselect/lib/clang/20/lib/darwin/libclang_rt.osx.a" check:50'0 ~ check:50'1 ? possible intended match >> ``` https://github.com/llvm/llvm-project/pull/119670 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][Driver][Darwin] Optionally use xcselect to find macOS SDK (PR #119670)
@@ -2257,17 +2261,25 @@ void Darwin::AddDeploymentTarget(DerivedArgList &Args) const { // Warn if the path does not exist. if (!getVFS().exists(A->getValue())) getDriver().Diag(clang::diag::warn_missing_sysroot) << A->getValue(); - } else { -if (char *env = ::getenv("SDKROOT")) { - // We only use this value as the default if it is an absolute path, - // exists, and it is not the root path. - if (llvm::sys::path::is_absolute(env) && getVFS().exists(env) && - StringRef(env) != "/") { -Args.append(Args.MakeSeparateArg( -nullptr, Opts.getOption(options::OPT_isysroot), env)); - } + } else if (const char *env = ::getenv("SDKROOT")) { +// We only use this value as the default if it is an absolute path, +// exists, and it is not the root path. +if (llvm::sys::path::is_absolute(env) && getVFS().exists(env) && +StringRef(env) != "/") { + Args.append(Args.MakeSeparateArg( + nullptr, Opts.getOption(options::OPT_isysroot), env)); } } +#ifdef CLANG_USE_XCSELECT + else if (getTriple().isMacOSX()) { carlocab wrote: Yes, thanks, applied in c51df70d1380c3c7476f5314b0d34605e6fa8ac6 https://github.com/llvm/llvm-project/pull/119670 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][Driver][Darwin] Optionally use xcselect to find macOS SDK (PR #119670)
https://github.com/carlocab updated https://github.com/llvm/llvm-project/pull/119670 >From 9db768ec1be84d6bf647b85f052776720822f64f Mon Sep 17 00:00:00 2001 From: Carlo Cabrera Date: Tue, 10 Dec 2024 01:45:22 +0800 Subject: [PATCH 1/7] [clang][Driver][Darwin] Optionally use xcselect to find macOS SDK This is a scaled down version of https://reviews.llvm.org/D136315. The intent is largely the same as before[^1], but I've scaled down the scope to try to avoid the issues that the previous patch caused: - the changes are now opt-in based on enabling `CLANG_USE_XCSELECT` - this only works when targeting macOS on a macOS host (this is the only case supported by `libxcselect`[^2]) We also introduce an environment variable `CLANG_NO_XCSELECT` that disables this behaviour if Clang is configured with `CLANG_USE_XCSELECT=ON`. This is needed to avoid breaking tests. Another reason to leave this as opt-in for now is that there are some bugs in libxcselect that need fixing before it is safe to use by default for all users. This has been reported to Apple as FB16081077. [^1]: See also https://reviews.llvm.org/D109460 and #45225. [^2]: https://developer.apple.com/documentation/xcselect?language=objc --- clang/CMakeLists.txt | 33 +++ clang/include/clang/Config/config.h.cmake | 6 + clang/lib/Driver/CMakeLists.txt | 4 +++ clang/lib/Driver/ToolChains/Darwin.cpp| 31 ++--- clang/test/lit.cfg.py | 4 +++ 5 files changed, 69 insertions(+), 9 deletions(-) diff --git a/clang/CMakeLists.txt b/clang/CMakeLists.txt index 27e8095534a65c..3c7096a27c509b 100644 --- a/clang/CMakeLists.txt +++ b/clang/CMakeLists.txt @@ -214,6 +214,39 @@ if(GCC_INSTALL_PREFIX AND NOT USE_DEPRECATED_GCC_INSTALL_PREFIX) "See https://github.com/llvm/llvm-project/pull/77537 for detail.") endif() +if(APPLE) + check_include_file(xcselect.h CLANG_HAVE_XCSELECT_H) + if(CLANG_HAVE_XCSELECT_H) +include(CheckSymbolExists) +list(APPEND CMAKE_REQUIRED_LIBRARIES xcselect) +check_symbol_exists(xcselect_host_sdk_path xcselect.h CLANG_HAVE_XCSELECT_HOST_SDK_PATH) +list(REMOVE_ITEM CMAKE_REQUIRED_LIBRARIES xcselect) + endif() +endif() + +cmake_dependent_option(CLANG_USE_XCSELECT "Use libxcselect to find the macOS SDK." OFF + "APPLE;CLANG_HAVE_XCSELECT_HOST_SDK_PATH" OFF) + +if(DEFAULT_SYSROOT AND CLANG_USE_XCSELECT) + message(FATAL_ERROR "Setting DEFAULT_SYSROOT is incompatible with CLANG_USE_XCSELECT.") +endif() + +if(CLANG_USE_XCSELECT) + set(XCSELECT_VALID_POLICIES LATEST MATCHING_ONLY MATCHING_PREFERRED) + set(CLANG_XCSELECT_HOST_SDK_POLICY "LATEST" CACHE STRING +"Policy to use for xcselect. One of: ${XCSELECT_VALID_POLICIES}") + set_property(CACHE CLANG_XCSELECT_HOST_SDK_POLICY PROPERTY STRINGS ${XCSELECT_VALID_POLICIES}) + string(TOUPPER ${CLANG_XCSELECT_HOST_SDK_POLICY} CLANG_XCSELECT_HOST_SDK_POLICY) + list(JOIN XCSELECT_VALID_POLICIES "|" XCSELECT_POLICY_REGEX) + if(NOT CLANG_XCSELECT_HOST_SDK_POLICY MATCHES "^XCSELECT_HOST_SDK_POLICY_(${XCSELECT_POLICY_REGEX})$") +if(NOT CLANG_XCSELECT_HOST_SDK_POLICY IN_LIST XCSELECT_VALID_POLICIES) + message(FATAL_ERROR +"CLANG_XCSELECT_HOST_SDK_POLICY (${CLANG_XCSELECT_HOST_SDK_POLICY}) must be one of: ${XCSELECT_VALID_POLICIES}") +endif() +set(CLANG_XCSELECT_HOST_SDK_POLICY "XCSELECT_HOST_SDK_POLICY_${CLANG_XCSELECT_HOST_SDK_POLICY}") + endif() +endif() + set(ENABLE_LINKER_BUILD_ID OFF CACHE BOOL "pass --build-id to ld") set(ENABLE_X86_RELAX_RELOCATIONS ON CACHE BOOL diff --git a/clang/include/clang/Config/config.h.cmake b/clang/include/clang/Config/config.h.cmake index 27ed69e21562bf..9ae0c6a4b9e11d 100644 --- a/clang/include/clang/Config/config.h.cmake +++ b/clang/include/clang/Config/config.h.cmake @@ -86,4 +86,10 @@ /* Whether CIR is built into Clang */ #cmakedefine01 CLANG_ENABLE_CIR +/* Whether to use xcselect to find the macOS SDK */ +#cmakedefine CLANG_USE_XCSELECT + +/* Policy to use for xcselect */ +#cmakedefine CLANG_XCSELECT_HOST_SDK_POLICY ${CLANG_XCSELECT_HOST_SDK_POLICY} + #endif diff --git a/clang/lib/Driver/CMakeLists.txt b/clang/lib/Driver/CMakeLists.txt index 4fd10bf671512f..299de2ef30470c 100644 --- a/clang/lib/Driver/CMakeLists.txt +++ b/clang/lib/Driver/CMakeLists.txt @@ -14,6 +14,10 @@ if(WIN32) set(system_libs version) endif() +if(CLANG_USE_XCSELECT) + set(system_libs xcselect) +endif() + add_clang_library(clangDriver Action.cpp Compilation.cpp diff --git a/clang/lib/Driver/ToolChains/Darwin.cpp b/clang/lib/Driver/ToolChains/Darwin.cpp index 87380869f6fdab..8d3e0130a5a432 100644 --- a/clang/lib/Driver/ToolChains/Darwin.cpp +++ b/clang/lib/Driver/ToolChains/Darwin.cpp @@ -29,6 +29,10 @@ #include "llvm/TargetParser/Triple.h" #include // ::getenv +#ifdef CLANG_USE_XCSELECT +#include // ::xcselect_host_sdk_path +#endif + using namespace clang::driver; using namespace clang::driver::tools;
[clang] [clang][Driver][Darwin] Optionally use xcselect to find macOS SDK (PR #119670)
carlocab wrote: Thanks, done. https://github.com/llvm/llvm-project/pull/119670 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][Driver][Darwin] Optionally use xcselect to find macOS SDK (PR #119670)
@@ -43,8 +43,8 @@ // RUN: %clang -target x86_64-apple-macos10.13 -mlinker-version=520 \ // RUN: -### %t.o 2>&1 \ -// RUN: | FileCheck --check-prefix=NOSDK %s +// RUN: | FileCheck --check-prefix=INFERRED-SDK %s carlocab wrote: I think they'll pass since I've just relaxed the text to match against. But I'll double check locally for both enabling and disabling `CLANG_USE_XCSELECT` and delete them if it fails. https://github.com/llvm/llvm-project/pull/119670 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][Driver][Darwin] Optionally use xcselect to find macOS SDK (PR #119670)
https://github.com/carlocab updated https://github.com/llvm/llvm-project/pull/119670 >From 9db768ec1be84d6bf647b85f052776720822f64f Mon Sep 17 00:00:00 2001 From: Carlo Cabrera Date: Tue, 10 Dec 2024 01:45:22 +0800 Subject: [PATCH 1/6] [clang][Driver][Darwin] Optionally use xcselect to find macOS SDK This is a scaled down version of https://reviews.llvm.org/D136315. The intent is largely the same as before[^1], but I've scaled down the scope to try to avoid the issues that the previous patch caused: - the changes are now opt-in based on enabling `CLANG_USE_XCSELECT` - this only works when targeting macOS on a macOS host (this is the only case supported by `libxcselect`[^2]) We also introduce an environment variable `CLANG_NO_XCSELECT` that disables this behaviour if Clang is configured with `CLANG_USE_XCSELECT=ON`. This is needed to avoid breaking tests. Another reason to leave this as opt-in for now is that there are some bugs in libxcselect that need fixing before it is safe to use by default for all users. This has been reported to Apple as FB16081077. [^1]: See also https://reviews.llvm.org/D109460 and #45225. [^2]: https://developer.apple.com/documentation/xcselect?language=objc --- clang/CMakeLists.txt | 33 +++ clang/include/clang/Config/config.h.cmake | 6 + clang/lib/Driver/CMakeLists.txt | 4 +++ clang/lib/Driver/ToolChains/Darwin.cpp| 31 ++--- clang/test/lit.cfg.py | 4 +++ 5 files changed, 69 insertions(+), 9 deletions(-) diff --git a/clang/CMakeLists.txt b/clang/CMakeLists.txt index 27e8095534a65c..3c7096a27c509b 100644 --- a/clang/CMakeLists.txt +++ b/clang/CMakeLists.txt @@ -214,6 +214,39 @@ if(GCC_INSTALL_PREFIX AND NOT USE_DEPRECATED_GCC_INSTALL_PREFIX) "See https://github.com/llvm/llvm-project/pull/77537 for detail.") endif() +if(APPLE) + check_include_file(xcselect.h CLANG_HAVE_XCSELECT_H) + if(CLANG_HAVE_XCSELECT_H) +include(CheckSymbolExists) +list(APPEND CMAKE_REQUIRED_LIBRARIES xcselect) +check_symbol_exists(xcselect_host_sdk_path xcselect.h CLANG_HAVE_XCSELECT_HOST_SDK_PATH) +list(REMOVE_ITEM CMAKE_REQUIRED_LIBRARIES xcselect) + endif() +endif() + +cmake_dependent_option(CLANG_USE_XCSELECT "Use libxcselect to find the macOS SDK." OFF + "APPLE;CLANG_HAVE_XCSELECT_HOST_SDK_PATH" OFF) + +if(DEFAULT_SYSROOT AND CLANG_USE_XCSELECT) + message(FATAL_ERROR "Setting DEFAULT_SYSROOT is incompatible with CLANG_USE_XCSELECT.") +endif() + +if(CLANG_USE_XCSELECT) + set(XCSELECT_VALID_POLICIES LATEST MATCHING_ONLY MATCHING_PREFERRED) + set(CLANG_XCSELECT_HOST_SDK_POLICY "LATEST" CACHE STRING +"Policy to use for xcselect. One of: ${XCSELECT_VALID_POLICIES}") + set_property(CACHE CLANG_XCSELECT_HOST_SDK_POLICY PROPERTY STRINGS ${XCSELECT_VALID_POLICIES}) + string(TOUPPER ${CLANG_XCSELECT_HOST_SDK_POLICY} CLANG_XCSELECT_HOST_SDK_POLICY) + list(JOIN XCSELECT_VALID_POLICIES "|" XCSELECT_POLICY_REGEX) + if(NOT CLANG_XCSELECT_HOST_SDK_POLICY MATCHES "^XCSELECT_HOST_SDK_POLICY_(${XCSELECT_POLICY_REGEX})$") +if(NOT CLANG_XCSELECT_HOST_SDK_POLICY IN_LIST XCSELECT_VALID_POLICIES) + message(FATAL_ERROR +"CLANG_XCSELECT_HOST_SDK_POLICY (${CLANG_XCSELECT_HOST_SDK_POLICY}) must be one of: ${XCSELECT_VALID_POLICIES}") +endif() +set(CLANG_XCSELECT_HOST_SDK_POLICY "XCSELECT_HOST_SDK_POLICY_${CLANG_XCSELECT_HOST_SDK_POLICY}") + endif() +endif() + set(ENABLE_LINKER_BUILD_ID OFF CACHE BOOL "pass --build-id to ld") set(ENABLE_X86_RELAX_RELOCATIONS ON CACHE BOOL diff --git a/clang/include/clang/Config/config.h.cmake b/clang/include/clang/Config/config.h.cmake index 27ed69e21562bf..9ae0c6a4b9e11d 100644 --- a/clang/include/clang/Config/config.h.cmake +++ b/clang/include/clang/Config/config.h.cmake @@ -86,4 +86,10 @@ /* Whether CIR is built into Clang */ #cmakedefine01 CLANG_ENABLE_CIR +/* Whether to use xcselect to find the macOS SDK */ +#cmakedefine CLANG_USE_XCSELECT + +/* Policy to use for xcselect */ +#cmakedefine CLANG_XCSELECT_HOST_SDK_POLICY ${CLANG_XCSELECT_HOST_SDK_POLICY} + #endif diff --git a/clang/lib/Driver/CMakeLists.txt b/clang/lib/Driver/CMakeLists.txt index 4fd10bf671512f..299de2ef30470c 100644 --- a/clang/lib/Driver/CMakeLists.txt +++ b/clang/lib/Driver/CMakeLists.txt @@ -14,6 +14,10 @@ if(WIN32) set(system_libs version) endif() +if(CLANG_USE_XCSELECT) + set(system_libs xcselect) +endif() + add_clang_library(clangDriver Action.cpp Compilation.cpp diff --git a/clang/lib/Driver/ToolChains/Darwin.cpp b/clang/lib/Driver/ToolChains/Darwin.cpp index 87380869f6fdab..8d3e0130a5a432 100644 --- a/clang/lib/Driver/ToolChains/Darwin.cpp +++ b/clang/lib/Driver/ToolChains/Darwin.cpp @@ -29,6 +29,10 @@ #include "llvm/TargetParser/Triple.h" #include // ::getenv +#ifdef CLANG_USE_XCSELECT +#include // ::xcselect_host_sdk_path +#endif + using namespace clang::driver; using namespace clang::driver::tools;
[clang] [clang][Driver][Darwin] Optionally use xcselect to find macOS SDK (PR #119670)
https://github.com/carlocab edited https://github.com/llvm/llvm-project/pull/119670 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][Driver][Darwin] Optionally use xcselect to find macOS SDK (PR #119670)
https://github.com/carlocab updated https://github.com/llvm/llvm-project/pull/119670 >From 9db768ec1be84d6bf647b85f052776720822f64f Mon Sep 17 00:00:00 2001 From: Carlo Cabrera Date: Tue, 10 Dec 2024 01:45:22 +0800 Subject: [PATCH 1/6] [clang][Driver][Darwin] Optionally use xcselect to find macOS SDK This is a scaled down version of https://reviews.llvm.org/D136315. The intent is largely the same as before[^1], but I've scaled down the scope to try to avoid the issues that the previous patch caused: - the changes are now opt-in based on enabling `CLANG_USE_XCSELECT` - this only works when targeting macOS on a macOS host (this is the only case supported by `libxcselect`[^2]) We also introduce an environment variable `CLANG_NO_XCSELECT` that disables this behaviour if Clang is configured with `CLANG_USE_XCSELECT=ON`. This is needed to avoid breaking tests. Another reason to leave this as opt-in for now is that there are some bugs in libxcselect that need fixing before it is safe to use by default for all users. This has been reported to Apple as FB16081077. [^1]: See also https://reviews.llvm.org/D109460 and #45225. [^2]: https://developer.apple.com/documentation/xcselect?language=objc --- clang/CMakeLists.txt | 33 +++ clang/include/clang/Config/config.h.cmake | 6 + clang/lib/Driver/CMakeLists.txt | 4 +++ clang/lib/Driver/ToolChains/Darwin.cpp| 31 ++--- clang/test/lit.cfg.py | 4 +++ 5 files changed, 69 insertions(+), 9 deletions(-) diff --git a/clang/CMakeLists.txt b/clang/CMakeLists.txt index 27e8095534a65c..3c7096a27c509b 100644 --- a/clang/CMakeLists.txt +++ b/clang/CMakeLists.txt @@ -214,6 +214,39 @@ if(GCC_INSTALL_PREFIX AND NOT USE_DEPRECATED_GCC_INSTALL_PREFIX) "See https://github.com/llvm/llvm-project/pull/77537 for detail.") endif() +if(APPLE) + check_include_file(xcselect.h CLANG_HAVE_XCSELECT_H) + if(CLANG_HAVE_XCSELECT_H) +include(CheckSymbolExists) +list(APPEND CMAKE_REQUIRED_LIBRARIES xcselect) +check_symbol_exists(xcselect_host_sdk_path xcselect.h CLANG_HAVE_XCSELECT_HOST_SDK_PATH) +list(REMOVE_ITEM CMAKE_REQUIRED_LIBRARIES xcselect) + endif() +endif() + +cmake_dependent_option(CLANG_USE_XCSELECT "Use libxcselect to find the macOS SDK." OFF + "APPLE;CLANG_HAVE_XCSELECT_HOST_SDK_PATH" OFF) + +if(DEFAULT_SYSROOT AND CLANG_USE_XCSELECT) + message(FATAL_ERROR "Setting DEFAULT_SYSROOT is incompatible with CLANG_USE_XCSELECT.") +endif() + +if(CLANG_USE_XCSELECT) + set(XCSELECT_VALID_POLICIES LATEST MATCHING_ONLY MATCHING_PREFERRED) + set(CLANG_XCSELECT_HOST_SDK_POLICY "LATEST" CACHE STRING +"Policy to use for xcselect. One of: ${XCSELECT_VALID_POLICIES}") + set_property(CACHE CLANG_XCSELECT_HOST_SDK_POLICY PROPERTY STRINGS ${XCSELECT_VALID_POLICIES}) + string(TOUPPER ${CLANG_XCSELECT_HOST_SDK_POLICY} CLANG_XCSELECT_HOST_SDK_POLICY) + list(JOIN XCSELECT_VALID_POLICIES "|" XCSELECT_POLICY_REGEX) + if(NOT CLANG_XCSELECT_HOST_SDK_POLICY MATCHES "^XCSELECT_HOST_SDK_POLICY_(${XCSELECT_POLICY_REGEX})$") +if(NOT CLANG_XCSELECT_HOST_SDK_POLICY IN_LIST XCSELECT_VALID_POLICIES) + message(FATAL_ERROR +"CLANG_XCSELECT_HOST_SDK_POLICY (${CLANG_XCSELECT_HOST_SDK_POLICY}) must be one of: ${XCSELECT_VALID_POLICIES}") +endif() +set(CLANG_XCSELECT_HOST_SDK_POLICY "XCSELECT_HOST_SDK_POLICY_${CLANG_XCSELECT_HOST_SDK_POLICY}") + endif() +endif() + set(ENABLE_LINKER_BUILD_ID OFF CACHE BOOL "pass --build-id to ld") set(ENABLE_X86_RELAX_RELOCATIONS ON CACHE BOOL diff --git a/clang/include/clang/Config/config.h.cmake b/clang/include/clang/Config/config.h.cmake index 27ed69e21562bf..9ae0c6a4b9e11d 100644 --- a/clang/include/clang/Config/config.h.cmake +++ b/clang/include/clang/Config/config.h.cmake @@ -86,4 +86,10 @@ /* Whether CIR is built into Clang */ #cmakedefine01 CLANG_ENABLE_CIR +/* Whether to use xcselect to find the macOS SDK */ +#cmakedefine CLANG_USE_XCSELECT + +/* Policy to use for xcselect */ +#cmakedefine CLANG_XCSELECT_HOST_SDK_POLICY ${CLANG_XCSELECT_HOST_SDK_POLICY} + #endif diff --git a/clang/lib/Driver/CMakeLists.txt b/clang/lib/Driver/CMakeLists.txt index 4fd10bf671512f..299de2ef30470c 100644 --- a/clang/lib/Driver/CMakeLists.txt +++ b/clang/lib/Driver/CMakeLists.txt @@ -14,6 +14,10 @@ if(WIN32) set(system_libs version) endif() +if(CLANG_USE_XCSELECT) + set(system_libs xcselect) +endif() + add_clang_library(clangDriver Action.cpp Compilation.cpp diff --git a/clang/lib/Driver/ToolChains/Darwin.cpp b/clang/lib/Driver/ToolChains/Darwin.cpp index 87380869f6fdab..8d3e0130a5a432 100644 --- a/clang/lib/Driver/ToolChains/Darwin.cpp +++ b/clang/lib/Driver/ToolChains/Darwin.cpp @@ -29,6 +29,10 @@ #include "llvm/TargetParser/Triple.h" #include // ::getenv +#ifdef CLANG_USE_XCSELECT +#include // ::xcselect_host_sdk_path +#endif + using namespace clang::driver; using namespace clang::driver::tools;
[clang] [clang][Driver][Darwin] Optionally use xcselect to find macOS SDK (PR #119670)
@@ -1,3 +1,6 @@ +// XFAIL: xcselect carlocab wrote: In theory, yes. In practice, it looks to me like all these failing test cases[^1] have deployment targets that pre-date macOS 10.14, so it seems very likely that anyone who can enable `CLANG_USE_XCSELECT` will probably see these tests fail as soon as they do. But, point taken. Do you have an alternative approach in mind? I'm wondering if it's worth reviving the `CLANG_NO_XCSELECT` environment variable and then just setting them in these tests (and slowly getting rid of instances of `CLANG_NO_XCSELECT` as we find better fixes). [^1]: I haven't checked each individually, so I'm not sure yet. https://github.com/llvm/llvm-project/pull/119670 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][Driver][Darwin] Optionally use xcselect to find macOS SDK (PR #119670)
carlocab wrote: > Maybe it is because the `darwin` legacy OS in the triple? This is a good guess, it seems to help: ```diff diff --git a/clang/test/Driver/arc.c b/clang/test/Driver/arc.c index 7f6ac81aad17..70cd66899dff 100644 --- a/clang/test/Driver/arc.c +++ b/clang/test/Driver/arc.c @@ -1,11 +1,8 @@ -// XFAIL: xcselect -// FIXME: There's no reason why this should fail with CLANG_USE_XCSELECT. - -// RUN: not %clang -ObjC -target i386-apple-darwin10 -stdlib=libstdc++ -m32 -fobjc-arc %s -fsyntax-only 2>&1 | FileCheck %s -// RUN: not %clang -x objective-c -target i386-apple-darwin10 -stdlib=libstdc++ -m32 -fobjc-arc %s -fsyntax-only 2>&1 | FileCheck %s -// RUN: not %clang -x objective-c++ -target i386-apple-darwin10 -stdlib=libstdc++ -m32 -fobjc-arc %s -fsyntax-only 2>&1 | FileCheck %s -// RUN: not %clang -x c -target i386-apple-darwin10 -stdlib=libstdc++ -m32 -fobjc-arc %s -fsyntax-only 2>&1 | FileCheck -check-prefix NOTOBJC %s -// RUN: not %clang -x c++ -target i386-apple-darwin10 -stdlib=libstdc++ -m32 -fobjc-arc %s -fsyntax-only 2>&1 | FileCheck -check-prefix NOTOBJC %s +// RUN: not %clang -ObjC -target i386-apple-macosx10.6 -stdlib=libstdc++ -m32 -fobjc-arc %s -fsyntax-only 2>&1 | FileCheck %s +// RUN: not %clang -x objective-c -target i386-apple-macosx10.6 -stdlib=libstdc++ -m32 -fobjc-arc %s -fsyntax-only 2>&1 | FileCheck %s +// RUN: not %clang -x objective-c++ -target i386-apple-macosx10.6 -stdlib=libstdc++ -m32 -fobjc-arc %s -fsyntax-only 2>&1 | FileCheck %s +// RUN: not %clang -x c -target i386-apple-macosx10.6 -stdlib=libstdc++ -m32 -fobjc-arc %s -fsyntax-only 2>&1 | FileCheck -check-prefix NOTOBJC %s +// RUN: not %clang -x c++ -target i386-apple-macosx10.6 -stdlib=libstdc++ -m32 -fobjc-arc %s -fsyntax-only 2>&1 | FileCheck -check-prefix NOTOBJC %s // RUN: not %clang -x objective-c -target x86_64-apple-darwin11 -mmacos-version-min=10.5 -fobjc-arc %s -fsyntax-only 2>&1 | FileCheck -check-prefix NOTSUPPORTED %s // Just to test clang is working. ``` This change makes `arc.c` succeed. > Maybe don't use `xcselect` when it is darwin since the modern spelling should > `macOS` family? This is an option, but not the ideal one since the default target triple still uses the `-darwin` spelling. Though I suppose one can just change this at configure time. Is there any reason why default builds don't just use the macOS spelling, at least for modern versions of macOS? https://github.com/llvm/llvm-project/pull/119670 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][Driver][Darwin] Optionally use xcselect to find macOS SDK (PR #119670)
https://github.com/carlocab updated https://github.com/llvm/llvm-project/pull/119670 >From 9db768ec1be84d6bf647b85f052776720822f64f Mon Sep 17 00:00:00 2001 From: Carlo Cabrera Date: Tue, 10 Dec 2024 01:45:22 +0800 Subject: [PATCH 1/5] [clang][Driver][Darwin] Optionally use xcselect to find macOS SDK This is a scaled down version of https://reviews.llvm.org/D136315. The intent is largely the same as before[^1], but I've scaled down the scope to try to avoid the issues that the previous patch caused: - the changes are now opt-in based on enabling `CLANG_USE_XCSELECT` - this only works when targeting macOS on a macOS host (this is the only case supported by `libxcselect`[^2]) We also introduce an environment variable `CLANG_NO_XCSELECT` that disables this behaviour if Clang is configured with `CLANG_USE_XCSELECT=ON`. This is needed to avoid breaking tests. Another reason to leave this as opt-in for now is that there are some bugs in libxcselect that need fixing before it is safe to use by default for all users. This has been reported to Apple as FB16081077. [^1]: See also https://reviews.llvm.org/D109460 and #45225. [^2]: https://developer.apple.com/documentation/xcselect?language=objc --- clang/CMakeLists.txt | 33 +++ clang/include/clang/Config/config.h.cmake | 6 + clang/lib/Driver/CMakeLists.txt | 4 +++ clang/lib/Driver/ToolChains/Darwin.cpp| 31 ++--- clang/test/lit.cfg.py | 4 +++ 5 files changed, 69 insertions(+), 9 deletions(-) diff --git a/clang/CMakeLists.txt b/clang/CMakeLists.txt index 27e8095534a65c..3c7096a27c509b 100644 --- a/clang/CMakeLists.txt +++ b/clang/CMakeLists.txt @@ -214,6 +214,39 @@ if(GCC_INSTALL_PREFIX AND NOT USE_DEPRECATED_GCC_INSTALL_PREFIX) "See https://github.com/llvm/llvm-project/pull/77537 for detail.") endif() +if(APPLE) + check_include_file(xcselect.h CLANG_HAVE_XCSELECT_H) + if(CLANG_HAVE_XCSELECT_H) +include(CheckSymbolExists) +list(APPEND CMAKE_REQUIRED_LIBRARIES xcselect) +check_symbol_exists(xcselect_host_sdk_path xcselect.h CLANG_HAVE_XCSELECT_HOST_SDK_PATH) +list(REMOVE_ITEM CMAKE_REQUIRED_LIBRARIES xcselect) + endif() +endif() + +cmake_dependent_option(CLANG_USE_XCSELECT "Use libxcselect to find the macOS SDK." OFF + "APPLE;CLANG_HAVE_XCSELECT_HOST_SDK_PATH" OFF) + +if(DEFAULT_SYSROOT AND CLANG_USE_XCSELECT) + message(FATAL_ERROR "Setting DEFAULT_SYSROOT is incompatible with CLANG_USE_XCSELECT.") +endif() + +if(CLANG_USE_XCSELECT) + set(XCSELECT_VALID_POLICIES LATEST MATCHING_ONLY MATCHING_PREFERRED) + set(CLANG_XCSELECT_HOST_SDK_POLICY "LATEST" CACHE STRING +"Policy to use for xcselect. One of: ${XCSELECT_VALID_POLICIES}") + set_property(CACHE CLANG_XCSELECT_HOST_SDK_POLICY PROPERTY STRINGS ${XCSELECT_VALID_POLICIES}) + string(TOUPPER ${CLANG_XCSELECT_HOST_SDK_POLICY} CLANG_XCSELECT_HOST_SDK_POLICY) + list(JOIN XCSELECT_VALID_POLICIES "|" XCSELECT_POLICY_REGEX) + if(NOT CLANG_XCSELECT_HOST_SDK_POLICY MATCHES "^XCSELECT_HOST_SDK_POLICY_(${XCSELECT_POLICY_REGEX})$") +if(NOT CLANG_XCSELECT_HOST_SDK_POLICY IN_LIST XCSELECT_VALID_POLICIES) + message(FATAL_ERROR +"CLANG_XCSELECT_HOST_SDK_POLICY (${CLANG_XCSELECT_HOST_SDK_POLICY}) must be one of: ${XCSELECT_VALID_POLICIES}") +endif() +set(CLANG_XCSELECT_HOST_SDK_POLICY "XCSELECT_HOST_SDK_POLICY_${CLANG_XCSELECT_HOST_SDK_POLICY}") + endif() +endif() + set(ENABLE_LINKER_BUILD_ID OFF CACHE BOOL "pass --build-id to ld") set(ENABLE_X86_RELAX_RELOCATIONS ON CACHE BOOL diff --git a/clang/include/clang/Config/config.h.cmake b/clang/include/clang/Config/config.h.cmake index 27ed69e21562bf..9ae0c6a4b9e11d 100644 --- a/clang/include/clang/Config/config.h.cmake +++ b/clang/include/clang/Config/config.h.cmake @@ -86,4 +86,10 @@ /* Whether CIR is built into Clang */ #cmakedefine01 CLANG_ENABLE_CIR +/* Whether to use xcselect to find the macOS SDK */ +#cmakedefine CLANG_USE_XCSELECT + +/* Policy to use for xcselect */ +#cmakedefine CLANG_XCSELECT_HOST_SDK_POLICY ${CLANG_XCSELECT_HOST_SDK_POLICY} + #endif diff --git a/clang/lib/Driver/CMakeLists.txt b/clang/lib/Driver/CMakeLists.txt index 4fd10bf671512f..299de2ef30470c 100644 --- a/clang/lib/Driver/CMakeLists.txt +++ b/clang/lib/Driver/CMakeLists.txt @@ -14,6 +14,10 @@ if(WIN32) set(system_libs version) endif() +if(CLANG_USE_XCSELECT) + set(system_libs xcselect) +endif() + add_clang_library(clangDriver Action.cpp Compilation.cpp diff --git a/clang/lib/Driver/ToolChains/Darwin.cpp b/clang/lib/Driver/ToolChains/Darwin.cpp index 87380869f6fdab..8d3e0130a5a432 100644 --- a/clang/lib/Driver/ToolChains/Darwin.cpp +++ b/clang/lib/Driver/ToolChains/Darwin.cpp @@ -29,6 +29,10 @@ #include "llvm/TargetParser/Triple.h" #include // ::getenv +#ifdef CLANG_USE_XCSELECT +#include // ::xcselect_host_sdk_path +#endif + using namespace clang::driver; using namespace clang::driver::tools;
[clang] [clang][Driver][Darwin] Optionally use xcselect to find macOS SDK (PR #119670)
carlocab wrote: > Need to add test. You should add `CLANG_USE_XCSELECT` as a requirement and > label all the tests properly (including those will break). Maybe you can also > remove the hack for `CLANG_NO_XCSELECT` but I am neutral on that. All done, thanks. I don't quite understand why the failing tests are caused to fail when `CLANG_USE_XCSELECT` is enabled. I'll have to put more time into investigating them -- I consider this another blocker for enabling this feature more widely. https://github.com/llvm/llvm-project/pull/119670 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][Driver][Darwin] Optionally use xcselect to find macOS SDK (PR #119670)
carlocab wrote: > I don't quite understand why the failing tests are caused to fail when > `CLANG_USE_XCSELECT` is enabled. I'll have to put more time into > investigating them -- I consider this another blocker for enabling this > feature more widely. I think the issue is that the implicit `-isysroot` flag from `libxcselect` changes the deployment target, which then also changes the behaviour of `clang` in these tests. But I'll need to verify this locally to make sure. https://github.com/llvm/llvm-project/pull/119670 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][Driver][Darwin] Optionally use xcselect to find macOS SDK (PR #119670)
carlocab wrote: > > I don't quite understand why the failing tests are caused to fail when > > `CLANG_USE_XCSELECT` is enabled. I'll have to put more time into > > investigating them -- I consider this another blocker for enabling this > > feature more widely. > > I think the issue is that the implicit `-isysroot` flag from `libxcselect` > changes the deployment target, which then also changes the behaviour of > `clang` in these tests. But I'll need to verify this locally to make sure. Yea, this seems right. Adding appropriate `-mmacosx-version-min=` flags to the failing tests seems to make them succeed again. Not sure if that's the right move, though. https://github.com/llvm/llvm-project/pull/119670 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][Driver] Fix triple config loading for clang-cl (PR #111397)
carlocab wrote: > Maybe the fix is to always _ignore_ config files in clang-cl mode I'd be fine with doing this too -- I just wasn't aware that clang-cl did not support config files (since this fact doesn't seem to be documented anywhere, unless I missed it). https://github.com/llvm/llvm-project/pull/111397 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][Driver][Darwin] Optionally use xcselect to find macOS SDK (PR #119670)
@@ -43,8 +43,8 @@ // RUN: %clang -target x86_64-apple-macos10.13 -mlinker-version=520 \ // RUN: -### %t.o 2>&1 \ -// RUN: | FileCheck --check-prefix=NOSDK %s +// RUN: | FileCheck --check-prefix=INFERRED-SDK %s carlocab wrote: I think it does provide some value, particularly for builds with `CLANG_USE_XCSELECT=ON` (since there is a stricter test that was separated out for builds where it is disabled). That is, we check that the first two arguments to `-platform_version`, "macos" and "10.13.0", are correctly inferred from `-target`, and that the last argument looks like a version scheme, even when no `-isysroot` flag is provided. That still seems valuable to me, even if it's not the same as the original test. However, if you're still not convinced, I can remove it. https://github.com/llvm/llvm-project/pull/119670 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] Temporarily disable test `clang/Interpreter/crash.cpp` (PR #119978)
carlocab wrote: Obsoleted by 61ab36a3e226df32855286dd31a2c3859800475d https://github.com/llvm/llvm-project/pull/119978 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] Temporarily disable test `clang/Interpreter/crash.cpp` (PR #119978)
carlocab wrote: > > Obsoleted by > > [61ab36a](https://github.com/llvm/llvm-project/commit/61ab36a3e226df32855286dd31a2c3859800475d) > > > > That was the right fix, not the revert... I'm inclined to agree. Could revert the revert then apply this. https://github.com/llvm/llvm-project/pull/119978 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Darwin][Driver][clang] apple-none-macho orders the resource directory after internal-externc-isystem when nostdlibinc is used (PR #120507)
@@ -1018,13 +1018,19 @@ bool Darwin::hasBlocksRuntime() const { } } -void Darwin::AddCudaIncludeArgs(const ArgList &DriverArgs, -ArgStringList &CC1Args) const { +void MachO::AddCudaIncludeArgs(const ArgList &DriverArgs, + ArgStringList &CC1Args) const { + if (!isTargetAppleBased()) +return ToolChain::AddCudaIncludeArgs(DriverArgs, CC1Args); carlocab wrote: > But that's a good point, it would probably be cleaner to make an AppleMachO > toolchain in between the existing MachO and Darwin ones This does seem cleaner to me, but I can see how someone else might prefer the opposite -- feel free to leave the `isTargetAppleBased` checks in if someone else pushes back on an `AppleMachO` toolchain. https://github.com/llvm/llvm-project/pull/120507 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Darwin][Driver][clang] apple-none-macho orders the resource directory after internal-externc-isystem when nostdlibinc is used (PR #120507)
@@ -312,7 +312,8 @@ bool InitHeaderSearch::ShouldAddDefaultIncludePaths( break; case llvm::Triple::UnknownOS: -if (triple.isWasm()) +if (triple.isWasm() || ((triple.getVendor() == llvm::Triple::Apple) && +triple.isOSBinFormatMachO())) carlocab wrote: Maybe a bit much for only one call site, but `triple.isAppleMacho()` seems much nicer to me here. (For reference, `isTargetMachineMac` also has only one caller AFAICT) https://github.com/llvm/llvm-project/pull/120507 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Darwin][Driver][clang] apple-none-macho orders the resource directory after internal-externc-isystem when nostdlibinc is used (PR #120507)
https://github.com/carlocab edited https://github.com/llvm/llvm-project/pull/120507 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Darwin][Driver][clang] apple-none-macho orders the resource directory after internal-externc-isystem when nostdlibinc is used (PR #120507)
https://github.com/carlocab approved this pull request. LGTM once @jroelofs is happy with the test. https://github.com/llvm/llvm-project/pull/120507 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Darwin][Driver][clang] apple-none-macho orders the resource directory after internal-externc-isystem when nostdlibinc is used (PR #120507)
https://github.com/carlocab edited https://github.com/llvm/llvm-project/pull/120507 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Darwin][Driver][clang] Prioritise command line args over `DEFAULT_SYSROOT` (PR #115993)
carlocab wrote: > It's unclear to me how homebrew gets into a situation where there are > conflicting sdks passed for `sysroot` and `isysroot` when you effectively > want to ignore whatever is passed to `sysroot`. Maybe this has already been answered, but just in case. You get conflicting SDKs when: - You build a toolchain that is configured with `DEFAULT_SYSROOT` (or, you use a Clang configuration file that uses `--sysroot=`, which mostly mirrors the effects of setting `DEFAULT_SYSROOT`) - Your user uses your toolchain and passes `-isysroot` to a different SDK (or, equivalently, sets `SDKROOT` pointing to a different SDK) In each of the four possible scenarios above (two possibilities in each bullet point), you end up with `clang` using one SDK for headers (coming from `-isysroot`/`SDKROOT`) and a different one for libraries (coming from `DEFAULT_SYSROOT`/`--sysroot`). > Hm, I had a thought which might meet the needs here, and not add additional > confusion: we could have the Darwin SDKROOT environment variable override > both `-isysroot` and `--sysroot`. Would that help the original issue? This would help too, actually. I'll look into this. Thanks. > I think the correct solution for Homebrew is to never use `--sysroot` and > switch to `-isysroot` since the former is almost never used on Darwin > platforms. I'm looking at this in https://github.com/Homebrew/homebrew-core/pull/200047. However, based on [this comment](https://github.com/Homebrew/homebrew-core/pull/200047#issuecomment-2517969578), it doesn't quite solve the downstream bug report entirely. But that's something I'll have to look into. Us switching to using `-isysroot` instead doesn't solve the problem of (other) users who configure a toolchain with `DEFAULT_SYSROOT`, but maybe the changes I've made here that you suggested at https://github.com/llvm/llvm-project/pull/115993#issuecomment-2518537500 will be enough for that. https://github.com/llvm/llvm-project/pull/115993 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] Factor common code for quoting a builtin name (PR #120835)
https://github.com/carlocab approved this pull request. https://github.com/llvm/llvm-project/pull/120835 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Driver] Warn when using msan on Android (PR #122540)
https://github.com/carlocab approved this pull request. https://github.com/llvm/llvm-project/pull/122540 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Driver] Warn when using msan on Android (PR #122540)
https://github.com/carlocab closed https://github.com/llvm/llvm-project/pull/122540 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [InstrProf] Add frontend temporal profiling flag (PR #122385)
@@ -3035,6 +3035,38 @@ indexed format, regardeless whether it is produced by frontend or the IR pass. overhead. ``prefer-atomic`` will be transformed to ``atomic`` when supported by the target, or ``single`` otherwise. +.. option:: -fprofile-generate-temporal carlocab wrote: That's fair. Maybe `-fprofile-temporal-generate`? Putting `temporal` closer to `profile` seems like an improvement. But I'm fine with leaving things as-is if others feel strongly about it. https://github.com/llvm/llvm-project/pull/122385 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [InstrProf] Add frontend temporal profiling flag (PR #122385)
@@ -3035,6 +3035,38 @@ indexed format, regardeless whether it is produced by frontend or the IR pass. overhead. ``prefer-atomic`` will be transformed to ``atomic`` when supported by the target, or ``single`` otherwise. +.. option:: -fprofile-generate-temporal carlocab wrote: Mild suggestion: `-fgenerate-temporal-profile` or `-ftemporal-profile-generate` seems less awkward to me. https://github.com/llvm/llvm-project/pull/122385 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Driver] Warn when using msan on Android (PR #122540)
carlocab wrote: There is already handling of unsupported sanitisers just above: https://github.com/llvm/llvm-project/blob/77ef5a601ad3827316e412788f609e9141b51e83/clang/lib/Driver/SanitizerArgs.cpp#L523-L530 Is it not possible to incorporate the lack of support for msan on Android there? https://github.com/llvm/llvm-project/pull/122540 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang] Add -fwrapv-pointer flag (PR #122486)
carlocab wrote: > Matching gcc's behavior for -f flags both compilers have also makes sense, > IMHO. Agree with this, FWIW. https://github.com/llvm/llvm-project/pull/122486 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][Driver] Fix triple config loading for clang-cl (PR #111397)
carlocab wrote: LLVM 20 is branching soon -- would be good to try to get this in before then. https://github.com/llvm/llvm-project/pull/111397 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Driver] -fno-plt: warn for unsupported targets (PR #124081)
https://github.com/carlocab approved this pull request. https://github.com/llvm/llvm-project/pull/124081 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [PGO] Add a clang option -fprofile-continuous that enables PGO continuous mode (PR #124353)
@@ -1886,6 +1886,11 @@ def fprofile_update_EQ : Joined<["-"], "fprofile-update=">, Values<"atomic,prefer-atomic,single">, MetaVarName<"">, HelpText<"Set update method of profile counters">, MarshallingInfoFlag>; +def fprofile_continuous : Flag<["-"], "fprofile-continuous">, carlocab wrote: Mild suggestion: `-fprofile-continuously` reads a little better. But happy with the existing flag if you feel strongly about it. https://github.com/llvm/llvm-project/pull/124353 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][Driver] Fix triple config loading for clang-cl (PR #111397)
carlocab wrote: Yep, was just trying to ping @Bo98 for an update here. https://github.com/llvm/llvm-project/pull/111397 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [flang] [Flang][Driver] Add a flag to control zero initialization of global v… (PR #122144)
@@ -3494,6 +3494,12 @@ def fno_struct_path_tbaa : Flag<["-"], "fno-struct-path-tbaa">, Group; def fno_strict_enums : Flag<["-"], "fno-strict-enums">, Group; def fno_strict_overflow : Flag<["-"], "fno-strict-overflow">, Group, Visibility<[ClangOption, FlangOption]>; +defm init_global_zero : BoolFOption<"init-global-zero", carlocab wrote: `-fzero-init-globals`, maybe? Feel free to ignore if you disagree, though. https://github.com/llvm/llvm-project/pull/122144 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [flang] [Flang][Driver] Add a flag to control zero initialization of global v… (PR #122144)
https://github.com/carlocab approved this pull request. https://github.com/llvm/llvm-project/pull/122144 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [flang] [Flang][Driver] Add a flag to control zero initialization of global v… (PR #122144)
https://github.com/carlocab edited https://github.com/llvm/llvm-project/pull/122144 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [flang] [Flang][Driver] Add a flag to control zero initialization of global v… (PR #122144)
@@ -3494,6 +3494,9 @@ def fno_struct_path_tbaa : Flag<["-"], "fno-struct-path-tbaa">, Group; def fno_strict_enums : Flag<["-"], "fno-strict-enums">, Group; def fno_strict_overflow : Flag<["-"], "fno-strict-overflow">, Group, Visibility<[ClangOption, FlangOption]>; +def fno_zero_init_global_without_init : Flag<["-"], "fno-zero-init-global-without-init">, Group, carlocab wrote: Following https://github.com/llvm/llvm-project/pull/121619#discussion_r1906391568, I suggest considering `-fskip-zero-init-globals` or similar. https://github.com/llvm/llvm-project/pull/122144 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [flang] [Flang][Driver] Add a flag to control zero initialization of global v… (PR #122144)
https://github.com/carlocab edited https://github.com/llvm/llvm-project/pull/122144 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [Darwin][Driver][clang] apple-none-macho orders the resource directory after internal-externc-isystem when nostdlibinc is used (PR #122035)
https://github.com/carlocab approved this pull request. https://github.com/llvm/llvm-project/pull/122035 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] ohos: fix ohos.c test case error with LLVM_ENABLE_PER_TARGET_RUNTIME_… (PR #121484)
carlocab wrote: > And one question: will llvm deprecate the old layout? There was some desire to, but it seems to have fizzled out: https://discourse.llvm.org/t/rfc-time-to-drop-legacy-runtime-paths/64628 I imagine it'll happen eventually, but it will probably take a while. > should we consider adding the old layout support for ohos? I don't know enough about OHOS and its users to be able to say. If you're not sure: I suggest leaving out support for now, and someone who needs it can contribute support for it. But if we do leave support out: good error messages for users who happen to try to use/build it in the wrong configuration are probably essential. https://github.com/llvm/llvm-project/pull/121484 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] ohos: fix ohos.c test case error with LLVM_ENABLE_PER_TARGET_RUNTIME_… (PR #121484)
carlocab wrote: > Note: OHOS driver doesn't support the old layout, compiler-rt for > ${arch}-linux-unknown-ohos targets have to be built with > LLVM_ENABLE_PER_TARGET_RUNTIME_DIR=ON Can we make `cmake` error out if you try to build for `*-linux-unknown-ohos` with `LLVM_ENABLE_PER_TARGET_RUNTIME_DIR=OFF`? https://github.com/llvm/llvm-project/pull/121484 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [FatLTO] Allow -fno-fat-lto-objects to override -ffat-lto-objects (PR #128157)
https://github.com/carlocab approved this pull request. https://github.com/llvm/llvm-project/pull/128157 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [WebAssembly] Make WASI -threads environment behave as -pthread (PR #129164)
https://github.com/carlocab approved this pull request. Thanks! https://github.com/llvm/llvm-project/pull/129164 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Driver] Avoid repeated hash lookups (NFC) (PR #130888)
https://github.com/carlocab approved this pull request. https://github.com/llvm/llvm-project/pull/130888 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][driver][NFC] Remove else after return (PR #131182)
https://github.com/carlocab approved this pull request. https://github.com/llvm/llvm-project/pull/131182 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] Split out and disable tests that break relative rpaths (PR #137411)
https://github.com/carlocab approved this pull request. Thanks; this has bugged me for a while now. https://github.com/llvm/llvm-project/pull/137411 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits