Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update paths to homebrew LLVM for M1 macs #711

Merged
merged 2 commits into from Nov 28, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
19 changes: 14 additions & 5 deletions README.md
Expand Up @@ -67,7 +67,7 @@ For example, the official LLVM packages from [apt.llvm.org](https://apt.llvm.org
nix-shell
```

- **OS X:** XCode command-line tools and recent LLVM (we recommend the Homebrew version) are required.
- **macOS:** Xcode command-line tools and recent LLVM (we recommend the Homebrew version) are required.

```sh
xcode-select --install
Expand All @@ -91,11 +91,20 @@ like this, for example:
LLVM_CONFIG_PATH=llvm-config-14 cargo install c2rust
```

On OS X with Homebrew LLVM, you need to point the build system at the LLVM installation as follows:
On macOS with Homebrew LLVM, you need to point the build system at the LLVM installation. The path for the installation is architecture dependent:

```sh
LLVM_CONFIG_PATH=/usr/local/opt/llvm/bin/llvm-config cargo install c2rust
```
- **Intel Macs:**

```sh
LLVM_CONFIG_PATH=/usr/local/opt/llvm/bin/llvm-config cargo install c2rust
```


- **Arm Macs:**

```sh
LLVM_CONFIG_PATH=/opt/homebrew/opt/llvm/bin/llvm-config cargo install c2rust
```

On Linux with Linuxbrew LLVM, you need to point the build system at the LLVM installation as follows:

Expand Down
11 changes: 11 additions & 0 deletions c2rust-analyze/tests/filecheck.rs
Expand Up @@ -6,24 +6,35 @@ use std::process::{Command, Stdio};
fn detect_filecheck() -> Option<&'static str> {
let candidates = [
"FileCheck",
// Intel macOS homebrew location.
"/usr/local/opt/llvm/bin/FileCheck",
// Arm macOS homebrew location.
"/opt/homebrew/opt/llvm/bin/FileCheck",
"FileCheck-14",
"/usr/local/opt/llvm@14/bin/FileCheck",
"/opt/homebrew/opt/llvm@14/bin/FileCheck",
"FileCheck-13",
"/usr/local/opt/llvm@13/bin/FileCheck",
"/opt/homebrew/opt/llvm@13/bin/FileCheck",
"FileCheck-12",
"/usr/local/opt/llvm@12/bin/FileCheck",
"/opt/homebrew/opt/llvm@12/bin/FileCheck",
"FileCheck-11",
"/usr/local/opt/llvm@11/bin/FileCheck",
"/opt/homebrew/opt/llvm@11/bin/FileCheck",
"FileCheck-10",
"/usr/local/opt/llvm@10/bin/FileCheck",
"/opt/homebrew/opt/llvm@10/bin/FileCheck",
"FileCheck-9",
"/usr/local/opt/llvm@9/bin/FileCheck",
"/opt/homebrew/opt/llvm@9/bin/FileCheck",
"FileCheck-8",
"/usr/local/opt/llvm@8/bin/FileCheck",
"/opt/homebrew/opt/llvm@8/bin/FileCheck",
"FileCheck-7",
"FileCheck-7.0",
"/usr/local/opt/llvm@7/bin/FileCheck",
"/opt/homebrew/opt/llvm@7/bin/FileCheck",
];

for filecheck in candidates {
Expand Down
10 changes: 9 additions & 1 deletion c2rust-build-paths/src/lib.rs
Expand Up @@ -98,14 +98,22 @@ pub fn find_llvm_config() -> Option<PathBuf> {
"llvm-config-7",
"llvm-config-7.0",
"llvm-config",
// Homebrew install locations on MacOS
// Homebrew install locations on Intel macOS
"/usr/local/opt/llvm@13/bin/llvm-config",
"/usr/local/opt/llvm@12/bin/llvm-config",
"/usr/local/opt/llvm@11/bin/llvm-config",
"/usr/local/opt/llvm@10/bin/llvm-config",
"/usr/local/opt/llvm@9/bin/llvm-config",
"/usr/local/opt/llvm@8/bin/llvm-config",
"/usr/local/opt/llvm/bin/llvm-config",
// Homebrew install locations on Arm macOS
"/opt/homebrew/opt/llvm@13/bin/llvm-config",
"/opt/homebrew/opt/llvm@12/bin/llvm-config",
"/opt/homebrew/opt/llvm@11/bin/llvm-config",
"/opt/homebrew/opt/llvm@10/bin/llvm-config",
"/opt/homebrew/opt/llvm@9/bin/llvm-config",
"/opt/homebrew/opt/llvm@8/bin/llvm-config",
"/opt/homebrew/opt/llvm/bin/llvm-config",
]
.iter()
.map(Path::new)
Expand Down