Commit Graph
51 Commits
Author SHA1 Message Date
Jon Ross-Perkins 1da299977e Routine LLVM update (#3130)
Just updating the LLVM version:
https://github.com/llvm/llvm-project/commit/0e17372b380467ac8339afdec992fbf887a11feb

I was mainly looking at this for `llvm::seq(size)` which I think is a
new addition.
2023-08-22 21:42:23 +00:00
maan2003 7c891fdacd Language Server (#3112)
Add a language server for carbon as part of GSoC.

This currently does code outline using toolchain parser.

See development steps in utils/vscode/README.md for running and using
language server.
2023-08-21 18:39:31 +00:00
Jon Ross-Perkins 1dd5caf847 Update re2, absl, and googletest (#3042)
re2 has migrated from StringPiece to absl::string_view since we last
updated. There are also some changes to how string_view is packaged by
absl. As I do test work, I'm noticing these gaps and think an update
would help.
2023-08-01 16:16:49 +00:00
mx42andjosh11b 1cab6920f2 Treesitter parser (#2902)
A push towards better editor support.
See utils/treesitter/README.md

---------

Co-authored-by: josh11b <josh11b@users.noreply.github.com>
2023-07-13 18:28:28 +00:00
Jon Ross-Perkins c27f41c94b Update the LLVM version in use. (#2895)
The prior terminfo and zlib calls are obsolete. I'm adding the zstd library myself as a quick fix, although I want to investigate if we can make better use of [LLVM's workspace](https://github.com/llvm/llvm-project/blob/main/utils/bazel/WORKSPACE) (where the zstd dep comes from).

```
ERROR: .../external/llvm-project/llvm/BUILD.bazel:184:11: no such package '@llvm_zstd//': The repository '@llvm_zstd' could not be resolved: Repository '@llvm_zstd' is not defined and referenced by '@llvm-project//llvm:Support'
```

The particular commit in use fixes a macos build error. https://github.com/llvm/llvm-project/commit/c5f6a287499a816cba5585708999e2c8b134290f
2023-06-15 16:58:12 -07:00
psh 2722397f51 Update rules_flex to 0.2.1 and rules_bison to 0.2.2 (#2877)
Updates the dependencies flex and bison to latest. @jonmeow suggested in the Discord the patched versions should hopefully go away now, and so those are removed as well.
2023-06-13 22:03:40 -07:00
Chandler Carruth 6d5c6ada59 Modernize the LLVM lit build rule. (#2673)
This resolves an issue I was seeing where none of the `lit` based test
executions could import the `lit` module. The `imports` attribute this
adds seems like the essential part, but I added both while there.

I'm not sure if this is the right fix though as no one else seems to
have been having trouble and worried this is actually something weird
with my setup that is broken. Ideas or suggestions welcome!
2023-03-13 08:46:09 -07:00
Jon Ross-Perkins 5fa6f04d83 Update the LLVM library version in use. (#2633)
This also fixes a couple issues with the newer version; makeArrayRef is deprecated, and ErrorHandling is now needed for llvm_unreachable.
2023-02-24 13:24:31 -08:00
Jon Ross-Perkins 61c34c7a10 Rollback WORKSPACE sha changes (#2570)
This should undo #2566 and #2568

GitHub's trying to rollback the change:

- https://github.com/bazel-contrib/SIG-rules-authors/issues/11#issuecomment-1409438954
- https://github.blog/changelog/2023-01-30-git-archive-checksums-may-change/

At some point this PR should start working, and then we should merge it.
2023-01-30 23:03:22 -08:00
Jon Ross-Perkins a7916c57fe Update a couple more WORKSPACE shas (#2568)
See #2566, I believe this is the same underlying issue. These packages weren't affected earlier.
2023-01-30 16:46:44 -08:00
Jon Ross-Perkins bb647cc228 Update WORKSPACE checksums for everything (#2566)
I'm running a `bazel build //...` now and things look fine, so I'm guessing this is now correct. But it seems like GH changed something about their /archive/ downloads that just changed the checksums. Releases appear to be unaffected. I don't have any reference for what changed though.

https://github.com/bazelbuild/bazel/issues/15128 says to use /refs/tags, but I think we can't do that when we're trying to get a specific commit.
2023-01-30 11:23:17 -08:00
Chandler Carruth dd26ea6a15 Update Bazel & protobufs, then narrow warnings to Carbon. (#2500)
Protobufs code hits a warning with the latest system headers on macOS.
I figured this may have been fixed so I updated protobufs and Bazel to
the latest releases. This generally cleaned things up.

However, it actually added *more* warnings. This clearly isn't a really
well tested path. In fact, we already have a disabled warning that we'd
like for Carbon code because LLVM isn't clean for that warning.

So I've switched our warning strategy to a more durable approach of
suppressing all warnings for external repository headers and source
files. This lets us re-enable the missing warning and should fix the
protobuf warning that started me down this twisty path.

Sadly, we *have* to update to Bazel 6 in order to have the necessary
flag to use this approach to suppressing warnings, so I couldn't do this
as two PRs cleanly. =/ That's why I've bundled both the Bazel (and
protobuf) updates with the warning strategy change.

Last but not least, I've fixed several unused parameters in Carbon's
code that our warnings now catch.
2022-12-28 16:58:01 -08:00
micttyl 63487da665 Support building on FreeBSD (#2463)
It is less care-taking since GitHub Workflow is not configured
2022-12-15 10:14:19 -08:00
Jon Ross-Perkins 4fc120f935 Restructure the patches dir in expectation of non-llvm patches. (#2469)
Per #2463 we're looking at adding more patches, this updates .pre-commit-config.yaml and sets up the directory structure to be more accommodating to more patches.
2022-12-14 14:28:14 -08:00
Chandler Carruth 814ae3d419 Fix some broken regexes for files in pre-commit configs. (#2438)
The result was we weren't actually running buildifier on files for
example, so this also runs it on a bunch of files to clean things up.
2022-12-05 08:16:06 -08:00
Chandler CarruthandJon Ross-Perkins 94cf343b05 Update LLVM and switch to std::optional. (#2424)
LLVM's bazel build has changed a bit, so this updates the tree for that.

LLVM is also moving `llvm::Optional` to match the standard API, but it seemed simpler to just switch to `std::optional`.

Co-authored-by: Jon Ross-Perkins <jperkins@google.com>
2022-12-01 09:22:43 -08:00
Jon Ross-Perkins f9979e3cb1 Switch WORKSPACE from %s to .format (#2433)
Per discussion on #2424
2022-11-30 16:42:06 -08:00
Jon Ross-Perkins 6293610cb0 Replace dashes with underscores in llvm-patches (#2211)
Dashes in bazel package names in particular can cause problems (which renaming `llvm-patches` to `llvm_patches` will fix for me). But we've generally named files with underscores, so there's also consistency.
2022-09-22 12:37:24 -07:00
Jon Ross-Perkins c25a2b23d2 Switch gtest to re2, adjust related tests (#2183)
See https://github.com/google/googletest/blob/main/docs/advanced.md#regular-expression-syntax for gtest regex notes.

Add framework suffix handling for includes because of a dep being triggered on macos.
2022-09-15 08:19:52 -07:00
Jon Ross-Perkins a62e2dc21c Update things for clang-15 support. (#2174)
libprotobuf_mutator and abseil have warnings that are already fixed in newer versions.

bison outputs code that hits new warnings; there I'm just silencing it because testing a newer bison version is more difficult.

Fixes #1650

Fixes #1660
2022-09-13 15:18:55 -07:00
micttyl e2f4205ca3 Enable Local Patches (#2168)
Configure `WORKSPACE` so to use patches that we have in
the current repository
2022-09-12 10:31:07 -07:00
Metarsit 76a262c0e9 Format Bazel files and add argument to run buildifier on pre-commit (#1919) 2022-08-05 10:09:13 -07:00
pk19604014 9f90fa3633 Added a patch with a fuzzer Bazel BUILD file and updated fuzz_test rule to use the new @llvm-project//compiler-rt:FuzzerMain
Fixes #1208 (_LIBCPP_DEBUG crash)

Fully bazel-ifying compiler-rt is more complex than I originally thought, due to dependencies on other llvm projects like libcxx which currently also don't have bazel build support -- https://github.com/carbon-language/carbon-lang/issues/1208#issuecomment-1171555971
2022-07-15 09:14:30 -04:00
Chandler Carruth b8ebea81ef Update LLVM. (#1353)
This gets us into 2022-06-29 commits.

Originally @JonMeow was doing this, and we paired to resolve a bug in
our Bazel configs that landed in #1350 so now we can pull it.

Sending this out now so that CI can do the slow run and start caching
build artifacts.
2022-06-30 08:58:42 -07:00
df345b5ec7 Remove LLVM from the repo, and clean up history. (#1344)
This proposal establishes a plan for moving away from the embedded copy
of LLVM and instead downloading it with Bazel.

The goal is that after this lands, we will do a history-rewrite to
cleanup the repository. There are instructions on how folks can move any
in-flight work over to the newly tidied repo.

Co-authored-by: Richard Smith <richard@metafoo.co.uk>
Co-authored-by: Jon Ross-Perkins <jperkins@google.com>
Co-authored-by: josh11b <josh11b@users.noreply.github.com>
2022-06-28 13:49:38 -07:00
Jon Meow b27aa21a88 Update tools (#1252) 2022-05-11 17:23:01 -07:00
Jon Meow 107848e30f Switch mypy approach to pre-commit (#1234)
I'm treating my PR to mypy bazel integration as dead in the water. Abandoning that approach, this seems to work reasonably well as a replacement. It's actually a slightly newer version of mypy too -- the bazel integration was stuck on an old version.

Note I don't think we're losing much: we shouldn't be writing too much python.
2022-05-09 09:54:12 -07:00
pk19604014andJon Meow 22462a0d7f Carbon fuzzing 3/3: added actual fuzzer implementation and a fuzzverter utility for investigating crashing protos (#1156)
* finished fuzzer and added fuzzverter util

* fixed typo

* renamed cmd line params

* fixed libproto_mutator download path

* small fixes

* small fixes

* small fixes

* renamed sample corpus proto

* small fixes

* try building on github with LIBCPP_DEBUG enabled

* temporarily marked proto fuzzer as a manual test

* code review

* use a dedicated proto-fuzzer feature to work around LIBCPP_DEBUG=1 crash in proto code

* code review comments, added README.md

* minor fixes to the text

* Update bazel/cc_toolchains/clang_cc_toolchain_config.bzl

Co-authored-by: Jon Meow <jperkins@google.com>

* use Carbon source representation for "empty Main()" instead of text format proto representation

* fixed typo

* made FuzzerUtil produce the full carbon source (proto converted + Main if needed) to decrease code duplication a bit

* typo

* switched to text proto format per code review

* Update executable_semantics/prelude.h

Co-authored-by: Jon Meow <jperkins@google.com>

* Update executable_semantics/fuzzing/README.md

Co-authored-by: Jon Meow <jperkins@google.com>

* Update executable_semantics/fuzzing/README.md

Co-authored-by: Jon Meow <jperkins@google.com>

* Update executable_semantics/fuzzing/README.md

Co-authored-by: Jon Meow <jperkins@google.com>

* Update executable_semantics/fuzzing/README.md

Co-authored-by: Jon Meow <jperkins@google.com>

* Update executable_semantics/fuzzing/README.md

Co-authored-by: Jon Meow <jperkins@google.com>

* review comments

* removed unnecessary file mode variables

* Update executable_semantics/fuzzing/fuzzverter.cpp

Co-authored-by: Jon Meow <jperkins@google.com>

* Update executable_semantics/fuzzing/README.md

Co-authored-by: Jon Meow <jperkins@google.com>

* Update executable_semantics/fuzzing/README.md

Co-authored-by: Jon Meow <jperkins@google.com>

* code review comments

* Update executable_semantics/syntax/BUILD

Co-authored-by: Jon Meow <jperkins@google.com>

* buildifier

Co-authored-by: Jon Meow <jperkins@google.com>
2022-04-11 16:47:03 -04:00
pk19604014andJon Meow 5ae6d22415 Carbon fuzzing 1/3: added a proto for representing Carbon AST + ast_to_proto library (#1128)
* initial fuzzer proto

* visibility change

* use newer protocol buffer version which has the defs.bzl bug fixed

* Adjusted fix_cc_deps to work with protobuf external repo

* explicitly load rules_cc to avoid a frozenset bug in the version loaded by protobuf

* use explit deps, use llvm's zlib

* restored cxx settings

* deps change

* Cleaned up WORKSPACE and changed the test to read carbon sources from testdata

* updated comment

* adapted to new ErrorOr return value

* proto buffer 3.19.2 -> 3.19.4

* changed comment

* Apply suggestions from code review

Co-authored-by: Jon Meow <jperkins@google.com>

* Apply suggestions from code review

Co-authored-by: Jon Meow <jperkins@google.com>

* Update executable_semantics/fuzzing/BUILD

Co-authored-by: Jon Meow <jperkins@google.com>

* addressed review comments

* updated Unimplemented error message

* Addressed review comments

* more review comments

* switched to loading protobuf via rules_proto()

* Ignore protobuf headers in fix_cc_deps.py until the script supports alias rules

* renamed repeated proto fields to be plural

* added @zlib to check_non_test_cc_deps

* Update common/fuzzing/BUILD

Co-authored-by: Jon Meow <jperkins@google.com>

* review comments

* set is_omitted_expression for return value

Co-authored-by: Jon Meow <jperkins@google.com>
2022-03-25 15:29:31 -04:00
Jon Meow cba02e1b47 Update WORKSPACE deps (#1003) 2022-01-05 09:45:59 -08:00
Jon Meow e727eb8fe6 Update gtest to pull in clang-tidy workarounds (#972) 2021-12-07 16:58:42 -08:00
Chandler Carruth e476373d28 Cleanup the new dependencies and our tooling setup. (#943)
I didn't fully configure the new dependencies correctly or fully get
them working with our tooling rigging for compilation databases.

- I needed to fix the sha256 of the benchmark. I pasted the wrong
  one, but didn't test it effectively.

- Didn't successfully enable the use of Abseil from GoogleTest
  (including nice things like its symbolization, etc). Doing this is
  a bit awkward as it needs to go into our `.bazelrc`, but it works.

- Didn't add libraries other that GoogleTest to the compile flags.

- Didn't teach the compilation database creation step to cause these
  external repositories to be linked in and populated nicely.

All of these are fixed. As I was making changes to the Python script
here, I've added a test to at least type check it and fixed the type
errors reported.
2021-11-04 19:27:39 -07:00
Chandler Carruth 5f67029479 Use upstream GoogleTest and add related test utils. (#876)
This moves over to the vanilla upstream GoogleTest pulled in the more
expected manner with Bazel. It also adds Abseil and Google Benchmark
libraries in the same fashion (there are cross dependencies here).

As part of this, also introduce a dependency check test that can enforce
basic layering of dependencies. For example, this lets us ensure that
non-test Carbon code only depends on LLVM and Clang despite having other
libraries available. There remains some cleanup to improve the way these
dependency tests work, but this at least ensures we don't regress.

I've also provided workarounds to allow both Carbon code and LLVM code
to freely be used with GoogleTest (and other `std::ostream` based
output code). This is done by extending the code in
`//common/ostream.h`. One downside is that it requires opening the
`llvm` namespace and adding an ADL_found overload there. I think on
balance this is still a win and doesn't make me too nervous.

The new version of GoogleTest requires printing more often from matchers
and so I've also added several printing routines to types that
previously didn't require them. Otherwise, most of the updates are just
using the more conventional upstream style of including the headers and
adding `ostream.h` where it is needed.

I did consider moving code over to use `std::ostream` instead of LLVM's
`raw_ostream`, but the advantages of not doing virtual dispatch still
seem significant, and it also seems good to retain access to LLVM's
formatting utilities built around `raw_ostream` given that we can't pull
arbitrary dependencies into Carbon code outside of test code.

All of this was slightly motivated by requests for newer features in
GoogleTest, but much more-so by my desire to have access to Google
Benchmark and Abseil when writing benchmarks. For example, using
Abseil's random number generator seems extremely helpful when generating
inputs for benchmarks. The growing dependencies between these packages
further motivated me to just pull them all in and ensure they worked
well.
2021-11-02 20:14:12 -07:00
Chandler Carruth fbb0aa729b Update LLVM and switch to upstreamed Bazel BUILD. (#838)
Also removes the legacy llvm-bazel submodule that is no longer needed.
2021-09-20 13:15:08 -07:00
Jon Meow 3351443c8f Switch to a mypy fork that handles imports (#823)
I'm seeing if I can upstream thundergolfer/bazel-mypy-integration#43, but we can also point at my fork for the time being.

This should resolve conflicts with mypy treating imports as non-hermetic, creating inconsistent behavior if packages are/aren't installed locally.
2021-09-13 13:08:54 -07:00
Jon Meow 4cbf5c6ab9 Add typing hints to github_tools with mypy enforcement (#771) 2021-08-25 09:29:17 -07:00
Jon Meow 952d2c0aed Update versions of archives in WORKSPACE (#775)
The m4/flex/bison commits are in, unreleased, but we can still go back to the canonical repo. Also updates the python version.

This pulls out the version statement mainly because it's typically repeated, not due to the m4/flex/bison verbosity. Pulling it out makes it more obvious and easier to change.
2021-08-24 09:20:47 -07:00
Chandler CarruthandJon Meow 05261b7fe7 Remove the LLVM bootstrap and use Hombrew installed LLVM-12. (#551)
Now that LLVM 12 has been released we no longer have any need to
bootstrap LLVM to get the desired featureset. LLVM 12 is available
widely, including in Homebrew across multiple platforms and in the
GitHub action runners.

Sadly, the Linux distribution builds of LLVM-12 are largely broken and
not as useful for us. The Homebrew Linux install was also broken
originally, but I've worked extensively with the Homebrew folks to get
the Linux install into a really good shape. It should now work reliably.

There are two primary bugs in Linux LLVM packages that need to be fixed
before we can just use them:

- https://bugs.llvm.org/show_bug.cgi?id=43604
- https://bugs.llvm.org/show_bug.cgi?id=46321

Once those are addressed and point releases with the fixes widely
available we can further simplify things.

Even with the need to use Homebrew installs, using the released LLVM has
the extra advantage of making it easy to properly support Darwin ARM and
I've added that configuration so that I can test things there.

Last but not least, this will significantly shrink our build outputs
which should allow building much more in continuous integration on
GitHub actions without exceeding the action cache size limits. I've even
added several tweaks and adjustments to the compile and build flags to
improve the build performance and reduce the build output size.

Once this is landed and stable, we can consider adding the refactoring
tooling back to our CI.

One of the biggest downsides of this path is that our CI has to download
and install the LLVM toolchain from Homebrew on each run. This is pretty
slow (takes a couple of minutes). But it is a fixed overhead -- it won't
get worse over time. Eventually, we can either look at a much fancier
action configuration to avoid this or hopefully the Debian packages will
get updated and we can move back to those.

The bootstrapping has served us long enough at this point. We can
resurrect it if we ever find a compelling reason for breaking off of the
latest LLVM release as our host toolchain.

Co-authored-by: Jon Meow <46229924+jonmeow@users.noreply.github.com>
2021-06-09 10:00:46 -07:00
Chandler Carruth 4034fa223d Update LLVM (and llvm-bazel). (#550)
This picks up a newer version of LLVM and the LLVM Bazel integration.
The big change here is that we can configure the LLVM targets that are
built, which allows us to dramatically reduce the build costs by
focusing on a couple of CPUs for the time being.

There are a few API updates needed as well.

This also rotates the cache version so we start with a clean Bazel cache
from here. Otherwise we'd potentially pay the cost of carrying around
stale bits of LLVM endlessly.
2021-05-25 15:21:57 -07:00
Jon MeowandMatthew Riley 88a9d244b7 Initial migration framework (#525)
What this does:

- Sets up a `migrate_cpp` tool which currently only runs `clang-tidy`.
  - This is intended to have more transformations in the future.
- Sets up a `migrate_cpp.sh` script.
  - This copies the original woff2 code into a `carbon` directory and runs the `migrate_cpp` tool on it there.
- Adds the initial `carbon` directory of woff2
  - To be clear, this is currently only updated via `clang-tidy`.
  - More transformations should be expected in the future.
- Minor related edits. For example:
  - Adjust pre-commit to skip the `carbon` directory, because it's third-party code and shouldn't be edited in the same way.
  - Adds `@brotli_carbon` as a local repository so that we can "build" outputs.
  - Makes clang-tidy from the bootstrap toolchain accessible for BUILD dependencies, as it's then used for `migrate_cpp`.

What this does not do:

- Any actual transformation of C++ code to Carbon

Co-authored-by: Matthew Riley <mdriley@gmail.com>
2021-05-11 10:13:47 -07:00
Jon Meow acd10c01ef Add submodule entries for brotli and woff2 (#453)
This is to support converting the code to Carbon. My theory with the setup is:

- Have the code available to build in C++ under `third_party/<project>/original`.
- Created a `third_party/<project>/carbon` for the converted version.

Having the existing code building should, I think, make it easier to run analysis on said code. Using a submodule means we should be aiming to keep it pristine, for easy comparison / updates.
2021-04-19 16:49:09 -07:00
Jon Meow 7716ac6784 Update pre-commit (#439) 2021-04-08 09:01:35 -07:00
Jon Meow b4593f5133 Add pip_install to the build. (#435)
Updates corresponding tool instructions.
2021-04-07 09:08:02 -07:00
Chandler Carruth bbb38a3728 Format WORKSPACE with buildifier. (#403)
This wasn't being caught by our `pre-commit` setup, I've sent the fix
here: https://github.com/jlebar/pre-commit-hooks/pull/9
2021-03-19 01:17:05 -07:00
Chandler Carruth 8f1f9b9fc2 Remove unused bits from our WORKSPACE. (#402)
Originally, I experimented with special rules for C++ builds of LLVM but
we ended up with a native build of it instead. Loading and using this
was completely unnecessary now and would have needed an update. Just
remove it.

Fixes #400
2021-03-19 01:00:26 -07:00
Chandler Carruth 39aea3c45d Add Bazel repositories for Flex and Bison. (#279)
This makes executable semantics build and pass tests for me without
installing either Bison or Flex. We just use the primitive toolchain
with the existing genrule as the packaged rules don't quite fit how
we're building and organizing the code.

Currently, this points at forks of the upstream rule repositories while
PRs I have sent there are going through, but this should be functional
for now and there doesn't seem to be any reason to wait for those PRs to
go through.
2021-02-25 19:03:38 -08:00
Jon Meow d16e042950 Quick fix for master->main branch rename (#268)
Done in https://github.com/bazelbuild/rules_foreign_cc/issues/472, this is probably de facto the new state.
2021-02-12 15:13:48 -08:00
Jon MeowandChandler Carruth f58e5da827 Modify clang detection to build clang (#261)
Per chandlerc's comment:

First, this builds inside the Bazel tree rather than in the source
repository. This ensures we start in a clean directory each time the
repository rule is run again. We don't need to detect an existing build
with this, and it will only be rebuilt when the workspace file or the
repository rule implementation is changed. This can be forced by using:
```
bazel sync --configure
```

Second, we use an implicit dependency on the `WORKSPACE` file to locate
the workspace directory automatically, and the `HEAD` file from the
`llvm-project` submodule to trigger a rebuild if the submodule is
updated.

Third, teach the CMake script to try to use a system-installed `clang`
if installed and not overridden by the `CC` environment variable. This
is very different from the prior logic -- this is only used with the
CMake build, and so should work with any system C++ compiler that can
build Clang and LLVM.

Lastly, this tweaks the CMake options to tune this build given that we
now fully control it and it will only be used in this context. This
still results in a 1.5gb build for me. =/ But its as small as I can make
it really. It's a frustrating long list, but I couldn't find a more
brief way of representing this.

Co-authored-by: Chandler Carruth <chandlerc@gmail.com>
2021-02-08 17:17:58 -08:00
Jon Meow efef7cae16 Detect if there's a built version of clang within the workspace (#260) 2021-02-05 15:15:51 -08:00
Jon Meow d76f8a1eff Bazel-ify most of the Python scripts. (#229) 2020-12-28 16:37:55 -08:00