Commit Graph

37 Commits

Author SHA1 Message Date
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