Commit Graph

31 Commits

Author SHA1 Message Date
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
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
Jon Haslam
08311d2bf9
Make oitb actually log TB output (#415) 2023-11-20 13:24:28 +00:00
Jake Hillion
393f8aab42 clang-format: disable bin packing
Bin packing often makes code hard to read. Disable it entirely.

Test plan:
- CI
2023-11-13 18:19:53 +00:00
Jake Hillion
217f675e30 oilgen: accept multiple config files (#379)
Summary:

Extend the multiple config files system to OILGen, the piece it was originally designed for. This allows for specifying additional configs which say which keys of maps to capture.

Reviewed By: ajor

Differential Revision: D50105138
2023-10-11 16:25:13 -07:00
Jake Hillion
c6723a4381 oilgen: add missing gflags header 2023-09-20 17:59:24 +01:00
Jake Hillion
6abeb0c723 oilgen: add debug flag
Summary: Current output of OILGen is always without debug. This hides things like the printed type graph from the end user, which would be useful in the logs of a build failure. Also rename the `-d` flag which was for jumping JIT code to `-j`, as `-d` is used in all the other tools for debug output level.
2023-09-18 15:32:06 +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
Alastair Robertson
8f3d11955c OIRP: Add copyright header 2023-08-03 15:17:16 +01:00
Jake Hillion
d7cfcca30d move all internal logic to oi::detail namespace 2023-07-26 18:01:38 +01:00
Alastair Robertson
0330ef8945 Take list of pass-through types from config instead of hardcoding
As we now store ContainerInfo objects in OICodeGen::Config, we can not
copy it any more. Change all places that took copies to take const
references instead.

The copy in OICodeGen modified membersToStub, the contents of which form
part of OICache's hash. However, as OICache also previously had its own
copy, it would not have been OICodeGen's modifications.
2023-07-05 13:39:19 +01:00
Jake Hillion
3da628b852 help: improve feature descriptions 2023-07-03 16:57:43 +01:00
Jake Hillion
40c7a9afb7 features: clean up old flags 2023-06-23 11:25:43 +01:00
Thierry Treyer
3b752fde13 Formatting 2023-06-19 19:13:16 +02:00
Thierry Treyer
32152bf5cf Introduce OIRP to dump RocksDB 2023-06-19 19:13:16 +02:00
Thierry Treyer
6e691daefc OITB support for -f/-F feature flags 2023-06-19 19:13:16 +02:00
Thierry Treyer
4e730fbc95 OIP prints location expressions 2023-06-19 19:13:16 +02:00
Thierry Treyer
aea1e12004 OIP prints 'this'as an arg for methods 2023-06-19 19:13:16 +02:00
Thierry Treyer
f28bdfca48 Fix TypeHierarchy's type 2023-06-19 19:13:16 +02:00
Jake Hillion
4c331fb5a2 clean up common.h 2023-06-09 13:15:17 +02:00
Alastair Robertson
5e23f9ca75 Add missing headers to oitb 2023-05-23 10:36:42 +01:00
Jake Hillion
a9ace14466 features: switch to bitset 2023-05-19 15:59:18 +02:00
Jon Haslam
d4891e98d4
move src directory to oi (#134) 2023-04-26 16:20:53 +01:00
Jake Hillion
641a128b39 add command line feature addition/removal 2023-04-21 19:02:44 +02:00
Jake Hillion
76f525f43d codegen: carry decl and func with containerinfo 2023-04-03 16:13:30 +01:00
Jake Hillion
d2caaf22e8 formatting: force pointers/references with the type 2023-03-24 20:18:18 +00:00
Jake Hillion
53ba312f1e oilgen: change interface to support multiple calls in one cu 2023-03-07 19:48:18 +00:00
Jake Hillion
72f31639b7 oilgen: add an --exit-code option to fail on noop 2023-02-03 17:26:15 +00:00
Alastair Robertson
9e72ada131 Support dynamic polymorphic inheritance
i.e. classes which contain virtual functions and use a virtual pointer
2023-01-30 13:22:09 +00:00
Jake Hillion
33f51afa36 oilgen: set DRGN_ENABLE_TYPE_ITERATOR 2023-01-19 16:19:22 +00:00
Jon Haslam
db90326c4b Initial commit 2022-12-19 06:37:51 -08:00