-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Dylib Derivation & Scanning #77
Changes from all commits
6f89bea
b4b03b5
f6d9f5e
d60d48b
3de9c00
cf3dd79
6d0fbad
0e8dee7
5ccc0a2
c516b87
4b6a52f
9d3aa33
f365a0c
7ca396b
d050908
2978d1c
c6a1114
5907afb
e6ae50f
e60946b
041b105
e4dd201
5841535
a4987e7
2c1d210
654d789
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// Copyright 2024 Adobe | ||
// All Rights Reserved. | ||
// | ||
// NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms | ||
// of the Adobe license agreement accompanying it. | ||
|
||
#pragma once | ||
|
||
#include <functional> | ||
|
||
//====================================================================================================================== | ||
|
||
namespace orc { | ||
|
||
//====================================================================================================================== | ||
|
||
// Enqueue a task for (possibly asynchronous) execution. If the `parallel_processing` setting in the | ||
// ORC config file is true, the task will be enqueued for processing on a background thread pool. | ||
// Otherwise, the task will be executed immediately in the current thread. | ||
void do_work(std::function<void()>); | ||
|
||
// blocks the calling thread until all enqueued work items have completed. If the | ||
// `parallel_processing` setting in the ORC config file is `false`, this will return immediately. | ||
void block_on_work(); | ||
|
||
//====================================================================================================================== | ||
|
||
} // namespace orc | ||
|
||
//====================================================================================================================== |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -55,7 +55,13 @@ bool emit_report(const odrv_report& report); | |
|
||
/**************************************************************************************************/ | ||
|
||
std::vector<odrv_report> orc_process(const std::vector<std::filesystem::path>&); | ||
std::vector<odrv_report> orc_process(std::vector<std::filesystem::path>&&); | ||
|
||
namespace orc { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I've started putting ORC calls into an |
||
|
||
void register_dies(dies die_vector); | ||
|
||
} // namespace orc | ||
|
||
void orc_reset(); | ||
|
||
|
@@ -93,3 +99,5 @@ template <class F> | |
void cerr_safe(F&& f) { | ||
ostream_safe(std::cerr, std::forward<F>(f)); | ||
} | ||
|
||
/**************************************************************************************************/ |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -226,19 +226,25 @@ constexpr std::decay_t<T> copy(T&& value) noexcept(noexcept(std::decay_t<T>{ | |
|
||
/**************************************************************************************************/ | ||
|
||
using register_dies_callback = std::function<void(dies)>; | ||
using do_work_callback = std::function<void(std::function<void()>)>; | ||
using empool_callback = std::function<pool_string(std::string_view)>; | ||
enum class macho_reader_mode { | ||
invalid, | ||
register_dies, | ||
derive_dylibs, | ||
odrv_reporting, | ||
}; | ||
|
||
struct macho_params { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
At any rate, the added genericity resulted in passing around the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I like the idea of windows support, but at this point, I think that would be more about abstracting out the ORC core from the parser. ORC would begin to look more like a multi-platform app, where you have the "core" parts and the "platform/compiler" parts. At that point, we would need to abstract the macho params. But it's all very theoretical - especially w/o a MSVC implementation, so I think the approach of streamlining what we actually have is the correct one. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Agreed. |
||
using register_dependencies_callback = std::function<void(std::vector<std::filesystem::path>&&)>; | ||
|
||
struct callbacks { | ||
register_dies_callback _register_die; | ||
do_work_callback _do_work; | ||
macho_reader_mode _mode{macho_reader_mode::invalid}; | ||
std::filesystem::path _executable_path; // only required if mode == derive_dylibs | ||
register_dependencies_callback _register_dependencies; // only required if mode == derive_dylibs | ||
}; | ||
|
||
void parse_file(std::string_view object_name, | ||
const object_ancestry& ancestry, | ||
freader& s, | ||
std::istream::pos_type end_pos, | ||
callbacks callbacks); | ||
macho_params params); | ||
|
||
/**************************************************************************************************/ |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# For documentation on `just`, see https://github.com/casey/just | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I just (ha!) discovered the |
||
# and the online manual https://just.systems/man/en/ | ||
# This set of recipes have only been tested on macOS. | ||
|
||
set shell := ["bash", "-uc"] | ||
|
||
# Self-help | ||
[private] # Don't print `default` as one of the recipes | ||
default: | ||
@just --list --justfile {{justfile()}} --list-heading $'Usage: `just recipe` where `recipe` is one of:\n' | ||
|
||
# Make `build/` if it does not exist | ||
mkdir: | ||
#!/usr/bin/env bash | ||
set -euxo pipefail | ||
if [ ! -d build ]; then | ||
mkdir build | ||
fi | ||
|
||
# Generate the cmake project (Tracy disabled) | ||
gen: mkdir | ||
cd build && cmake .. -GXcode -DTRACY_ENABLE=OFF | ||
|
||
# Erase and rebuild `build/` folder | ||
[confirm("Are you sure you want to delete `build/`? (y/N)")] | ||
nuke: && mkdir gen | ||
rm -rf build/ | ||
|
||
# Generate the cmake project (Tracy enabled) | ||
tracy: mkdir | ||
cd build && cmake .. -GXcode -DTRACY_ENABLE=ON |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We were passing
do_work
all over the code base as the scheduler for any ORC task we may want to do asynchronously. (With theparallel_processing
setting set tofalse
, the tasks are run immediately- that's how we're able to implement that switch.)Given that
do_work
is the only scheduler we were using, I have removed it as a callback (more on the death ofcallbacks
in a separate comment) and put it into its own header that the sources can reference themselves. This has made our asynchronous story much simpler, in terms of how we, you know, do work.