Port Bazel toolchain and code to macOS (x86). (#238)

This updates the Bazel toolchain logic to work on macOS. Much like on
Linux, I'm not testing this against a *released* LLVM, but against
a from-source build. You can build and install LLVM from top-of-tree
locally with CMake, or on macOS maybe use Homebrew like:
```
brew install llvm --HEAD
```

You then need to point Bazel to the installed `clang` executable if it
is not placed onto your PATH (Homebrew doesn't):
```
bazel test --repo_env=CC=$HOME/homebrew/opt/llvm/bin/clang //parser:all
```

This builds and passes tests for me at least.

The fuzzer feature may not work (yet) with this setup, but that can be
improved incrementally as we proceed.
This commit is contained in:
Chandler Carruth
2021-01-16 16:08:51 -08:00
committed by GitHub
parent 5db229afc6
commit 9da9c62225
3 changed files with 93 additions and 59 deletions
+6 -1
View File
@@ -54,7 +54,12 @@ auto SourceBuffer::CreateFromFile(llvm::StringRef filename)
}
errno = 0;
void* mapped_text = mmap(nullptr, size, PROT_READ, MAP_PRIVATE | MAP_POPULATE,
void* mapped_text = mmap(nullptr, size, PROT_READ,
#ifdef __APPLE__
MAP_PRIVATE,
#else
MAP_PRIVATE | MAP_POPULATE,
#endif
file_descriptor, /*offset=*/0);
if (mapped_text == MAP_FAILED) {
return ErrnoToError(errno);