Skip to content

Commit 0d37f1f

Browse files
d4l3kfacebook-github-bot
authored andcommitted
multipy: fix unity_demo (#155)
Summary: Pull Request resolved: #155 This fixes the unity_demo which requires `intepreter_all` variant internally due to the custom loading. * adds back sharedfuncptr code to target * added more complexity to `__deploy_register_code` to avoid it getting optimized out * switched remove_dt_needed to only use read since some build systems limit files to read only Reviewed By: PaliC Differential Revision: D39193272 fbshipit-source-id: a427de7bf070afc0eb6955ef3a759b7b8cbf066d
1 parent 97b3467 commit 0d37f1f

File tree

3 files changed

+6
-1
lines changed

3 files changed

+6
-1
lines changed

multipy/runtime/interpreter/import_find_sharedfuncptr.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ extern "C" dl_funcptr _PyImport_FindSharedFuncptr(
5353
// that itself gets unloaded.
5454
loaded_files_.emplace_back(CustomLibrary::create(pathname, 1, args));
5555
CustomLibrary& lib = *loaded_files_.back();
56+
assert(deploy_self);
5657
lib.add_search_library(SystemLibrary::create(deploy_self));
5758
lib.add_search_library(SystemLibrary::create());
5859
for (auto f : search_files_) {

multipy/runtime/loader.cpp

+4
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,10 @@ static void* local__tls_get_addr(TLSIndex* idx);
267267
__attribute__((noinline)) void __deploy_register_code() {
268268
std::cout << ""; // otherwise the breakpoint doesn't get hit, not sure if
269269
// there is a more stable way of doing this.
270+
unsigned i;
271+
for (i = 0; i < 10; i++) {
272+
__asm__ volatile("" : "+g"(i) : :);
273+
}
270274
};
271275

272276
struct DeployModuleInfo {

multipy/runtime/remove_dt_needed.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ int main(int argc, const char** argv) {
3333
return 1;
3434
}
3535
const char* filename = argv[1];
36-
int fd_ = open(filename, O_RDWR);
36+
int fd_ = open(filename, O_RDONLY);
3737
CHECK(fd_ != -1, "failed to open {}: {}", filename, strerror(errno));
3838
struct stat s = {0};
3939
if (-1 == fstat(fd_, &s)) {

0 commit comments

Comments
 (0)