Commit Graph

40 Commits

Author SHA1 Message Date
Jake Hillion
8831269523 build and test LLVM version 16
Add LLVM-16 to the Nix builds and CI matrix. Also add the option to explicitly
select an LLVM version so the CircleCI build can still work as before.

We should support at least LLVM-17 currently, but there appears to be a
significant performance regression in compiling the generated code for large
variants that I'm going to debug separately. The long term goal is to support
and test all versions 15 and up.

Test plan:
- CI
2024-08-21 16:46:29 +01:00
Jake Hillion
fe9b4b232a nix: add building oid to the flake
OI's build is challenging and has often been a problem for the Open Source
community. It requires an extremely specific set of dependencies that are very
hard to achieve on most systems. There are frequent breakages, like when
updating to CentOS Stream 9, or when trying to update the CI's clang from
clang-12 to clang-15 - OI requires the clang libraries to be version 15 but
can't be compiled with it on the CI!

This changes provides a mostly working build environment with `nix`. This
environment is pinned to a specific nixpkgs revision using `flake.lock`, and
only updates when we explicitly tell it to.

Summary of changes:
- Update CMakeLists.txt required version to 3.24. This allows specifying
  `FIND_PACKAGE_ARGS` in `FetchContent`, meaning we can use system packages.
  This is available on most up to date distros (3.30.2 is current).
- Extends `flake.nix` to be able to build OI. Adds instructions for building
  and developing OI using `nix`.
- Partially runs the tests in GitHub Actions. A huge amount must be excluded
  because of incompatibilites between the clangStdenv compiler and drgn. We
  have similar, though fewer, issues when building with the clang-12/libstdcxx
  mix on the Ubuntu 22.04 CircleCI, though this is at least reproducible.
- Updates CircleCI to build CMake from source as we don't have a newer image
  available. Also add some newly found dependencies (not sure how it was
  working without them before).

Test plan:

This change requires less testing than previous build related changes because
it deprecates most of the build types.

- The internal BUCK build is unaffected. No special testing.
- The semi-internal CMake build is gone. Use Nix.
- The Nix build for clang-15 and some tests are continuously tested in GitHub
  actions.
- Tested the set of Nix commands in the README. All work except the one that
  points to GitHub as this must be merged first.
- The existing CircleCI runs on Ubuntu 20.04 are maintained.
- Unable to test the new `test-report.yml` as it must be merged due to the
  permissions it needs. Will follow up with testing after this is merged. See:
  https://github.com/dorny/test-reporter?tab=readme-ov-file#recommended-setup-for-public-repositories

The list of exclusions for GitHub Actions/nix testing is currently very long, I
think 29% of the tests. This should be stable and reproducible though, and
likely needs deep changes to OI to fix. That's why fixes are excluded from this
PR. It's all to do with the forked drgn not being able to parse clang's newer
DWARF output, and can't be fixed by rolling back as we required a relatively
new libcxx.
2024-08-16 12:29:31 +01:00
Jake Hillion
8306c37508 build: remove dependency on modified folly repository
Currently we pull a modified folly repository to be able to use it header only.
The only difference in this repository is adding the `folly-config.h` file.
Pull this patch into this repo instead and use upstream folly.

Bump folly to latest main as well.

Test plan:
- CI build. I have local build issues at the moment.
2024-08-12 14:30:09 +01:00
Jon Haslam
7e71dc6192
bump python version to 3.9 (#492) 2024-04-16 12:06:47 +01:00
Jake Hillion
55989a9156 oilgen: migrate to source parsing (#421)
Summary:
oilgen: migrate to source parsing

Using debug information generated from partial source (that is, not the final
binary) has been insufficient to generally generate OIL code.

A particular example is pointers to templates:
```cpp
#include <oi/oi.h>
template <typename T>
struct Foo {
  T t;
};
template <typename T>
struct Bar {
  Foo<T>& f;
};
void foo(const Bar<int>& b) {
  oi::introspect(b);
}
```

The pointer/reference to `Foo<int>` appears in DWARF with
`DW_AT_declaration(true)` because it could be specialised before its usage.
However, with OIL, we are creating an implicit usage site in the
`oi::introspect` call that the compiler is unable to see.

This change reworks OILGen to work from a Clang command line rather than debug
information. We setup and run a compiler on the source, giving us access to an
AST and Semantic Analyser. We then:
- Find the `oi::introspect` template.
- Iterate through each of its callsites for their type.
- Run `ClangTypeParser::parse` on each type.
- Run codegen.
- Compile into an object file.

Having access to the semantic analyser allows us to forcefully complete a type,
as it would be if it was used in the initial code.


Test Plan:
hope

`buck2 run fbcode//mode/opt fbcode//object-introspection/oil/examples/compile-time:compile-time`

Reviewed By: tyroguru

Differential Revision: D51854477

Pulled By: JakeHillion
2023-12-19 13:26:25 -08:00
Jake Hillion
25426127bb add range-v3 library
Adds the range-v3 library which supports features that otherwise wouldn't be
available until C++23 or C++26. I caught a couple of uses that suit it but this
will allow us to use more in future.

Test Plan:
- CI
2023-11-13 18:42:04 +00:00
Jake Hillion
cc6c7bf21f compiler: update to c++20 2023-10-25 15:55:18 +01:00
Jake Hillion
67739840fe add portability.h (#386)
Summary:

Spin around our open/closed source checks. Previously we defined `OSS_ENABLE` in open source builds. This change defines `OI_META_INTERNAL` instead. This is nicer, as external users don't have to do anything special to get a working build.

Use this new macro to define a boolean constant in a new header `Portability.h`. This is inspired by Folly, and makes the internal build easier - definitions in Buck2 have to propagate up from a dependency instead of down from one. Annoyingly we can't use `if constexpr` for a lot of the previous `#ifdef` blocks as we conditionally include the headers. Longer term we could fix this by exposing a header interface but no source, allowing these to build but not be compiled in. For now I did something weird: I defined a function style macro in `Portability.h` based on the compile time macro. This forces you to have included `Portability.h` before using it to ensure the definition is everywhere. Open to feedback as I haven't seen anyone else do this.

Reviewed By: tyroguru

Differential Revision: D50000454
2023-10-24 03:03:16 -07:00
Jake Hillion
37991140da support 0 to many config files (#371)
Summary:
Previously OID/OIL required exactly one configuration file. This change makes it so you can supply 0 or more configuration files. 0 is useful if you have pre-generated the cache or use some sort of remote generation system. 1 is useful for the common case, where you have a configuration file that describes your entire source and use just that. More are useful if you have supplemental bits of config you wish to apply/override - see the changes to the integration test framework where we do exactly this.


Test Plan:
This isn't super well tested. It works for the test cases which add features via the config or enable `codegen.ignore`.

- CI

Reviewed By: ajor

Differential Revision: D49758032

Pulled By: JakeHillion
2023-10-02 14:06:39 -06:00
Milian Wolff
256ca1202f Minor: fix indentation for FetchContent calls 2023-09-22 10:59:23 +01:00
Milian Wolff
1317aa3cf6 Show progress information for FetchContent
Github is currently extremely slow to load for me for some reason.
Due to that, I first thought that `cmake` is hung up, but tracing
that I realized it's waiting for minutes to download the sources
for tomlplusplus via FetchContent.

This patch enables progress reporting for FetchContent to make it
more obvious what's going on here.
2023-09-22 10:59:23 +01:00
Jake Hillion
53cac53f25 rocksdb: update to v8.5.3 2023-09-22 10:34:57 +01:00
Jake Hillion
a6d74a20a6 Update to clang/llvm 15 (#342)
Summary:

Update to clang-15 compiler and libraries as clang-12 is ancient.

The changes to oilgen are necessary because the new internal toolchain is being more picky about linking PIC to PIC. In certain modes we build with PIC, but try to link a non-PIC oilgen artifact. Add the ability to build the oilgen artifacts with PIC which sorts this.

Reviewed By: ttreyer

Differential Revision: D46220858
2023-09-14 06:02:32 -07:00
Jake Hillion
5071519e45 oil v2 2023-08-23 15:59:53 +01:00
Jake Hillion
323daed329 googletest: change to FetchContent 2023-07-21 17:18:06 +01:00
Jake Hillion
bd948152b7 add exporters::TypeCheckingWalker 2023-07-13 16:05:24 +01:00
Jake Hillion
032c28c0ea type checking: add description of data segment type 2023-07-13 16:05:24 +01:00
Jake Hillion
6aead62652 static types: place in own header for testing 2023-06-30 12:54:02 +01:00
Thierry Treyer
32152bf5cf Introduce OIRP to dump RocksDB 2023-06-19 19:13:16 +02:00
Jake Hillion
91dc954d40 CMake: add elfutils to rpath for dynamic builds 2023-06-02 17:52:53 +02:00
Alastair Robertson
60e87735c8 Disable PCH 2023-05-23 10:36:42 +01:00
Alastair Robertson
febef742d5 Disable warnings for generated Flex & Bison code 2023-05-23 10:36:42 +01:00
Alastair Robertson
956f828303 Disable warnings for external projects 2023-05-23 10:36:42 +01:00
Alastair Robertson
2b3f3966a9 Clean up CMakeLists.txt 2023-05-23 10:36:42 +01:00
Alastair Robertson
24e108a81b Enable compiler warnings globally
With the previous method of enabling them on a target-by-target basis,
it was very easy to accidentally miss a target. This had happened in a
number of instances, e.g. "codegen" and "symbol_service".
2023-05-23 10:36:42 +01:00
Jake Hillion
b32f723844 resources: manage headers properly
Previously we had an `R"(` string in `OITraceCode.cpp` which allowed us
to include the file as a string. Instead, keep `OITraceCode.cpp` a fully
formed C++ file and utilise the build system to turn it into a string.
This will be used for more header files that are needed both as valid
headers and as strings for JIT compilation in the Typed TreeBuilder
work.
2023-05-18 16:04:13 +02:00
Jon Haslam
d4891e98d4
move src directory to oi (#134) 2023-04-26 16:20:53 +01:00
Alastair Robertson
daa3cb06ec Build with tests by default 2023-04-05 15:53:15 +01:00
Jake Hillion
675211aff5 tests: build integration.py targets with cmake 2023-03-27 16:15:37 +01:00
Jake Hillion
00b52fca6f folly: create explicit folly_headers library target 2023-03-20 13:25:15 +00:00
Jake Hillion
f10e8a7173 folly: switch to FetchContent 2023-03-20 13:25:15 +00:00
Jake Hillion
a429733474 rocksdb: switch to FetchContent 2023-03-20 13:25:15 +00:00
Alastair Robertson
ccc90c3068 Split codegen into separate build targets
To help with the transition to type-graph based CodeGen, we need to
reduce dependencies on legacy CodeGen from other parts of OI.

Pieces of CodeGen referenced by other files, but which only return
drgn data have been moved into a new "drgn_utils" target, allowing
us to remove CodeGen dependencies for these functions.

The new "symbol_service" build target can be used in the future by
other files only needing access to symbol information and not full
CodeGen.
2023-03-08 14:18:20 +00:00
Alastair Robertson
ab2f58b7fe Bump minimum CMake version to 3.19
We are already using CMP0109 which depends on 3.19. This change just
provides more useful error messages when using older versions.
2023-02-14 17:53:12 +00:00
Alastair Robertson
397b798235 CI: Add code coverage reporting
Add CODE_COVERAGE option to enable coverage instrumentation in builds.

Add new CI job to upload coverage reports to CodeCov.io.

Reports can be found by navigating the codecov.io UI, or by going to
the URL printed at the end of the "Code Coverage" CI job. More CodeCov
integration could be set up later once we have coverage reporting on the
main branch.
2023-02-03 12:16:56 +00:00
Alastair Robertson
425bb3fc24 Add CMake hook for defining custom build rules 2023-01-26 10:46:53 +00:00
Alastair Robertson
f1d982f0a8 Delete oi_compile
It has been replaced by oilgen and has become a burden to keep
up-to-date with CodeGen changes.
2023-01-23 14:21:46 +00:00
Jake Hillion
a0d2d46c71 stop over optimising drgn 2023-01-10 11:32:29 +00:00
Jake Hillion
0384d1c144 remove setcap 2023-01-10 11:32:10 +00:00
Jon Haslam
db90326c4b Initial commit 2022-12-19 06:37:51 -08:00